akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

typedef struct _tree_t {
	int id;
	struct _tree_t *p, *l, *r;
} tree_t;

tree_t* tree_insert(tree_t* root, int id){
	tree_t *y = NULL;
	tree_t *x = root;
	tree_t *z = (tree_t*)malloc(sizeof(tree_t));
	z->id = id;
	z->l = z->r = z->p = NULL;

	while(x != NULL) {
	    y = x;
	    if(z->id < x->id) {
	        x = x->l;
	    } else { 
	        x = x->r;
	    }
	}
	z->p = y;
	if(y == NULL) {
    	root = z;
	} else if(z->id < y->id) {
	    y->l = z;
	} else { 
	    y->r = z;
	}
	
	return root;
}
void print_find(tree_t *tree, int id) {
	if(tree==NULL) {
		printf("no\n");
		return;
	}
	
	if(id == tree->id) {
		printf("yes\n");
		return;
	} else if(id < tree->id) {
		print_find(tree->l, id);
	} else {
		print_find(tree->r, id);
	}
}

void print_preorder(tree_t *tree) {
    printf(" %d", tree->id);
    if(tree->l != NULL) print_preorder(tree->l);
    if(tree->r != NULL) print_preorder(tree->r);
}

void print_inorder(tree_t *tree) {
    if(tree->r == NULL && tree->l == NULL) {
        printf(" %d", tree->id);
    } else if(tree->r == NULL) {
        print_inorder(tree->l);
        printf(" %d", tree->id);
    } else if(tree->l == NULL) {
        printf(" %d", tree->id);
        print_inorder(tree->r);
    } else {
        print_inorder(tree->l);
        printf(" %d", tree->id);
        print_inorder(tree->r);
    }
}
int main(void) {
	int i, n, id;
	char buff[100];
	tree_t *root = NULL;
	scanf("%d\n", &n);
	for(i=0;i<n;i++) {
		scanf("%s %d\n", buff, &id);
		if(buff[0] == 'i') {
			root = tree_insert(root, id);
		} else if(buff[0] == 'f') {
			print_find(root, id);
		} else if(buff[0] == 'p') {
			print_inorder(root);
			printf("\n");
			print_preorder(root);
			printf("\n");
		}
	}
	
	return 0;
}



Measured memory_bytes: 20524
/*
QUESTION    :

RULE        :

INPUT       :

OUTPUT      :
*/
/*
    int     :10^9
long long   :10^19
*/
//kotatsugameさん解答
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<(n);++i)
#define repeq(i,a,n) for(int i=a;i<=(n);++i)
using namespace std;
using ll = long long int;
using P = pair<int,int>;
const long double PI =(acos(-1));

int cnt[10001];
int main(){
    int n;
    cin >> n;
    for(int i=1;i<=100;++i){
        for(int j=1;j<=100;++j){
            for(int k=1;k<=100;++k){
                int t=i*i+j*j+k*k+i*j+j*k+k*i;
                if(t<=n) cnt[t]++;
            }
        }
    }
    for(int i=1;i<=n;++i){
        cout << cnt[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
def func1(x, y, z, a):
  if x == y:
    z.append(a)
    return 1 
  return 0

def func2(x, y):
  if x==y:
    return 1
  return 0

def func3(x, y, z, a):
  l = 0
  for i in x:
    for j in y:
      k = 2 * j - i
      if k <= N-1 and i < j:
        l += func2(z[k], a)
  return l

  
N = int(input())
S = input()
r, g, b, rgb, equal = 0, 0, 0, 0, 0
r0, g0, b0 = [], [], []

for i in range(N):
  r += func1(S[i], 'R', r0, i)
  g += func1(S[i], 'G', g0, i)
  b += func1(S[i], 'B', b0, i)

rgb = r * g * b

# R<G<B
equal += func3(r0, g0, S, 'B')
# R<B<G
equal += func3(r0, b0, S, 'G')
# G<R<B
equal += func3(g0, r0, S, 'B')
# G<B<R
equal += func3(g0, b0, S, 'R')
# B<R<G
equal += func3(b0, r0, S, 'G')
# B<G<R
equal += func3(b0, g0, S, 'R')

print(rgb - equal)

Measured memory_bytes: 9296
N, M = map(int, input().split())
paths = []

for i in range(M) :
    paths.append(list(map(int, input().split())))
    
INF = -10**20
cost = [INF for x in range(N)]
cost[0] = 0
inf_flg = False 

for i in range(N * 2) :
    break_flg = True 
    for p in paths :
        f, t, c = p[0] - 1, p[1] - 1, p[2]
        
        if cost[t] < cost[f] + c and not(cost[t] == cost[f] == INF):
            break_flg = False 
            cost[t] = cost[f] + c
            
            if i >= N and t == N - 1:
                inf_flg = True 
                break
        
    if break_flg == True :
            break
    
if inf_flg == True :
    print("inf")
else :
    for c in cost :
        if c == INF :
            print("")
    print(cost[N - 1])

Measured memory_bytes: 3572
#include <stdio.h>
#include <string.h>

void strrev(char* src, char* dest)
{
	int i = 0;
	int len = strlen(src);
	
	for (i = 0; i < len; i++){
		dest[i] = src[len - 1 - i];
	}
	dest[len] = 0;

}

int main(void)
{
	char s[100];
	char r[100];
	int cnt = 0;
	
	while (scanf("%s", s) != EOF){
		strrev(s, r);
		if (strcmp(s, r) == 0){
			cnt++;
		}
	}
	
	printf("%d\n", cnt);
	
	return (0);
}

Measured memory_bytes: 556
#include<cstdio>
#include<vector>
#include<algorithm>

#define	pb	push_back

using namespace std;

int main(){
	unsigned int cub[1111];
	for(int i=1;i<1111;i++)	cub[i]=i*i*i;
	vector<unsigned int> candi;
	for(int i=1;i<1111;i++)for(int j=i;j<1111;j++)	candi.pb(cub[i]+cub[j]);
	sort(candi.begin(),candi.end());

	for(unsigned int z;scanf("%u",&z),z;){
		unsigned int z3=z*z*z;
		unsigned int x3py3=*(upper_bound(candi.begin(),candi.end(),z3)-1);
		printf("%u\n",z3-x3py3);
	}

	return 0;
}

Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

int main() {
  string s;
  cin >> s;

  bool ans = true;
  rep (i, s.size()) {
    if (i % 2 == 0 && s[i] == 'L') {
      ans = false;
      break;
    } 
    if (i % 2 == 1 && s[i] == 'R') {
      ans = false;
      break;
    } 
  }

  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    int amari = n % 10;
    if (amari == 2 || amari == 4 || amari == 5 || amari == 7 || amari == 9){
        cout << "hon" << endl;
    } else if (amari == 0 || amari == 1 || amari == 6 || amari == 8)
    {
        cout << "pon" << endl;
    } else
    {
        cout << "bon" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, k, cnt = 0, basho=0, ans;
	cin >> n >> k;
	vector<lli> a(n+1);
	map<lli, int> memo;
	loop(i, 1, n+1) cin >> a[i];

	int flag = 0;
	memo[1]++;
	lli old = 1;
	vector<lli> q(1,1);//初期設定

	rep(i,n+1){
		memo[a[old]]++;
		if(memo[a[old]] > 1){
			flag = 1;
			for(const auto& x : q){
				if(x == a[old]) break;
				basho++;
			}
		}
		if(flag == 1) break;
		q.push_back(a[old]);
		old = a[old];
	}//ループし始める要素の先頭になったら
	//その要素の過去に出た場所を特定する

	if(k < basho) ans = q[k];
	else if(basho == 0){
		if(k <= q.size()-1) ans = q[k];
		else{
			k -= (q.size());
			k %= q.size();
			ans = q[k];
		}
	}else{
		k -= (basho);
		lli youso = q.size()-basho;
		k %= youso;
		ans = q[basho+k];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 18632
#include <bits/stdc++.h>
using namespace std;

#define ub        upper_bound            // first element >  val(itr)
#define lb        lower_bound            // first element >= val(itr)

#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define mem(a,b) memset( a, b, sizeof(a) )

#define bitcount(a) __builtin_popcount(a)   // count set bits
#define lzcount(x) __builtin_clz(x)        // count leading zeros in binary representation of number
#define tzcount(x) __builtin_ctz(x)        // count trailing zeros in binary representation of number

#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

typedef long long int ll;
const ll MOD = 1e9+7;

template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
/*
inline ll mod(ll x,ll n) {if (x < n) return x; if (x >= n) return x - n;}
string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M,only if M is prime
ll add(ll a,ll b,ll M)  { return mod(( mod(a,M ) + mod(b,M )),M);     }
ll sub(ll a, ll b,ll M) { return mod((mod(a,M ) + M - mod(b,M )),M);   }
ll mult(ll a,ll b,ll M) { return  mod(( mod(a,M)*mod(b,M) ),M) ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

  
               /* -------------------------------Main Code------------------------------- */		

int main(){
	FAST
	int a,b;cin>>a>>b;
	int cnt = 0;
	int t= 1;
	while(t<b){
		cnt++;
		t+=a;
		t--;
	}
	//cout<<t<<endl;
	cout<<cnt<<endl;
    return 0;
}	

 	




Measured memory_bytes: 256
/*
 * atcoder/dp_2nd/n.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long
#define MOD 1000000007

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX = 420;
const ll INF = 100000000000000000;
ll N;
vector<ll> A;

// [l: r) までを合体させる最小コスト
ll dp[MAX][MAX];

void input() {
  cin >> N;
  ll a;
  loop(n,0,N) {
    cin >> a;
    A.push_back(a);
  }
}

void solve() {
  for (int len=1; len<=N; len++) {
    for (int l=0; l+len<=N; l++) {
      if (len == 1) { dp[l][l+1] = 0; continue; }
      ll self = 0, child = INF;
      int r = l+len;
      for (int i=l; i<r; i++) self += A[i];
      for (int cut=l+1; cut<r; cut++) {
        chmin(child, dp[l][cut] + dp[cut][r]);
      }
      dp[l][r] = self + child;
    }
  }
  cout << dp[0][N] << endl;
}

void dump() {
  for (int len=1; len<=N; len++) {
    for (int l=0; l+len<=N; l++) {
      cout << "[" << l << ": " << (l+len-1) << "] dp = " << dp[l][l+len] << endl;
    }
  }
}

int main() {
  // cout.precision(15);
  input();
  solve();
  // dump();
  return 0;
}


Measured memory_bytes: 1536
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);

    ll n,m,sum=0;
    string str;
    cin>>m>>n;;
    vector<ll> v(n);
    vector<ll> w(n-1);
    rep(i,n)   cin >> v[i];
    sort(v.begin(),v.end());
    rep(i,n-1) w[i]=v[i+1]-v[i];
    sort(w.begin(),w.end());
    rep(i,n-m) sum+=w[i];
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう！
int main(){
    ll a,b,n;
    std::cin >> a>>b>>n;
    if(b-1>n){
        std::cout << (n*a)/b-a*(n/b) << std::endl;
    }
    else std::cout << ((b-1)*a)/b << std::endl;
}

Measured memory_bytes: 3640
import fractions
n, y = map(int,input().split())
x = list(map(int,input().split()))

x.append(y)
x.sort()
d = []
for i in range(n):
    d.append(x[i+1]-x[i])
if len(d) !=1:
    ans = fractions.gcd(d[0],d[1])
    for i in range(n-1):
        ans = fractions.gcd(ans,d[i])
    print(ans)
else:
    ans = d[0]
    print(ans)

Measured memory_bytes: 88596
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    long N; 
    string S;
    cin >> N >> S;
    long all = N*(N-1)*(N-2)/6;
    long R = 0 , G = 0, B = 0;
    REP(i, 0, N){
        if(S[i] == 'R') R++;
        if(S[i] == 'G') G++;
        if(S[i] == 'B') B++;
    }
    long same_l = 0;
    REP(i, 0, N){
        REP(j, 1, N){
            if(i + j*2 >= N) break;
            if(S[i] != S[i+j] && S[i+j] != S[i + j + j] && S[i] != S[i + j + j]){
                same_l++;
            }
        }
    }
    long Rpair = R* (R-1)/2 * (N-R);
    long Gpair = G* (G-1)/2 * (N-G);
    long Bpair = B* (B-1)/2 * (N-B);
    long Rtrio = R* (R-1) * (R-2) / 6;
    long Gtrio = G* (G-1) * (G-2) / 6;
    long Btrio = B* (B-1) * (B-2) / 6;
    long ans =  all - (Rpair + Gpair + Bpair) - (Rtrio + Gtrio + Btrio) - same_l;
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

using namespace std;

int main(void){
  int N;
  cin>>N;
  vector<int> v(N+2);

  // 入力受け取り，アドバンスゼロセット
  v[0] = 0;
  FORQ(i,1,N){
    cin>>v[i];
  }
  v[N+1] = 0;
  for(auto x: v) cerr<<x<<" "; cerr<<endl;

  // 変数宣言
  int cnt = 0, endflag = 1;
  int zero_id1 = 0, zero_id2 = 0;
  int minx = 0;
  cerr<<endl;
  // 本処理
  while(1){
    // 終了条件
    // cerr<<"endflag : ";
    FORQ(i,1,N){
      if ( v[i] != 0 ) endflag = -1;
      // cerr<<endflag<<" ";
    }
    // cerr<<endl;
    if(endflag == 1)
      break;
    endflag = 1;
    /*判定後はちゃんとフラグを戻そうね！！*/

    
    // 0 範囲チェック
    FORQ(j,0,N)
      if (v[j] == 0 && v[j+1] != 0) zero_id1 = j;
    FORQ(j,0,N)
      if (v[j] != 0 && v[j+1] == 0) zero_id2 = j+1;
      
    // minチェック
    minx = *min_element(v.begin() + zero_id1 + 1, v.begin() + zero_id2 - 1 +1);
    cnt += minx;
    cerr<<"now cnt is "<<cnt<<endl; cerr<<"now minx is "<<minx<<endl;
    FORQ(j, zero_id1 + 1, zero_id2 - 1)
      v[j] = v[j] - minx;
    for(auto x: v) cerr<<x<<" ";  cerr<<endl;
    cerr<<endl;
  }

  cout<<cnt<<endl;

  
  return 0;
}


Measured memory_bytes: 256
#pragma region Macros
/***
 * @author uesugi
 * @file AtCoder用テンプレート
 */

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

/**
 * 最大値更新
 * @param T &a 更新対象
 * @param const T &b 判定対象
 * @return 更新有無
 */
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

/**
 * 最小値更新
 * @param T &a 更新対象
 * @param const T &b 判定対象
 * @return 更新有無
 */
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

/**
 * overload
 * 入力を配列に格納
 * 配列の長さ分入力を格納
 * @param std::istream &is 入力ストリーム
 * @param std::vector<T> &vec 格納先配列
 * @return std::istream 
 */
template <typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element : vec) {
        is >> element;
    }
    return is;
}

/**
 * overload
 * コンテナの要素を出力する
 * @param std::basic_ostream<Ch, Tr> &os 出力ストリーム
 * @param Container const &x 出力対象コンテナ
 * @return std::basic_ostream<Ch, Tr> 
 */
template <class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
/**
 * デバッグ用出力メソッド
 * 変数名及び値を出力
 * -D_DEBUG オプション付きビルド時のみ有効
 * @param 可変長引数
 */
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

/**
 * 処理
 * @return void
 */
void Main() {
    int N;
    cin >> N;
    set<string> s;
    string buff;
    REP(i, N) {
        cin >> buff;
        s.insert(buff);
    }

    cout << s.size();
}

#pragma region main
/**
 * main
 * 共通処理
 * @return signed
 */
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << std::fixed;
    cout.precision(20);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 19048
#include "bits/stdc++.h"
using namespace std;

int main() {
	string a[3];
	cin >> a[0] >> a[1] >> a[2];

	int p=0;

	while(1) {
		if(a[p][0] == 'a') {
			a[p].erase(a[p].begin());
			p=0;
		}
		else if(a[p][0] == 'b') {
			a[p].erase(a[p].begin());
			p=1;
		}
		else if(a[p][0] == 'c') {
			a[p].erase(a[p].begin());
			p=2;
		}

		if((a[0].size() == 0 && p==0) || (a[1].size() == 0 && p==1) || (a[2].size() == 0 && p==2)) break;
	}

	char ans;

	if((a[0].size() == 0 && p==0)) ans = 'A';
	if((a[1].size() == 0 && p==1)) ans = 'B';
	if((a[2].size() == 0 && p==2)) ans = 'C';

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct ans {
    int y, x, toy, tox;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int H, W;
    cin >> H >> W;
    auto a = vector<vector<int>>(H, vector<int>(W));

    REP(i, H) REP(j, W) { cin >> a[i][j]; }

    auto out = vector<ans>();

    REP(y, H) {
        REP(x, W) {
            if (a[y][x] % 2 != 0 && (x != W - 1 || y != H - 1)) {
                if (x == W - 1) {
                    a[y + 1][x]++;
                    a[y][x]--;
                    out.push_back({y + 1, x + 1, y + 2, x + 1});
                } else {
                    a[y][x + 1]++;
                    a[y][x]--;
                    out.push_back({y + 1, x + 1, y + 1, x + 2});
                }
            }
        }
    }

    std::cout << out.size() << '\n';
    REP(i, out.size()) {
        std::cout << out[i].y << " " << out[i].x << " " << out[i].toy << " "
                  << out[i].tox << '\n';
    }

    return 0;
}

Measured memory_bytes: 5236
#include<iostream>
using namespace std;
int main(){
	int n,a[100],i,z=0;
	cin>>n;
	cin>>a[0];
	for(i=1;i<n;i++){
		cin>>a[i];
		if(a[i]==a[i-1]){
		    z++;
		    a[i]=0;
	    }
	}
	cout<<z;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    [rec_impl = [](auto f, string s, unsigned long k, unsigned long rem) -> void {
        if(rem == 0){
            cout << s << "\n";
            return;
        }
        for(unsigned long i{1}; i <= k; ++i)f(f, s + static_cast<char>('`' + i), k + (i == k), rem - 1);
    }, &N]{rec_impl(rec_impl, "", 1, N);}();
    cout << flush;
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll num_of_cycle(vector<ll> &A){
	ll N = A.size();
	vector<pll> X(N);
	REP(i, N){
		X[i].first = A[i];
		X[i].second = i;
	}
	sort(X.begin(), X.end());

	/*
	REP(i, N){
		cout << X[i].second << " ";
	}
	cout << endl;
	*/

	vector<bool> visited(N, false);
	ll cnt = 0;
	REP(i, N){
		if(visited[i]) continue;
		ll start = i;
		ll now = start;
		while(1){
			visited[now] = true;
			now = X[now].second;
			if(now == start) break;
		}
		cnt++;
	}
	return cnt;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;
    vector<pll> Z(N);
    REP(i, N) cin >> Z[i].second;
    REP(i, N) cin >> Z[i].first;
    sort(Z.begin(), Z.end());
    vector<ll> A(N), B(N);
    REP(i, N) A[i] = Z[i].second;
    REP(i, N) B[i] = Z[i].first;

    //cout << A << endl;
    //cout << B << endl;
    
    vector<ll> C(N), D(N);
    REP(i, N) C[i] = A[i];
    REP(i, N) D[i] = B[i];
    sort(C.begin(), C.end());
    sort(D.begin(), D.end());

    bool ok1 = true;
    REP(i, N) if(D[i]<C[i]) ok1 = false;

    //cout << C << endl;
    //cout << D << endl;

    if(ok1){
    	ll nc = num_of_cycle(A);
    	//dump(nc)
    	if(nc == 1){
    		bool ok2 = false;
    		REP(i, N-1){
    			if(D[i]>=C[i+1]) ok2 = true;
    		}
    		cout << (ok2 ? "Yes" : "No") << endl;
    	}else{
    		cout << "Yes" << endl;
    	}
    }else{
    	cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M;
    cin >> N >> M;

    ll S = 0;
    REP(i, M){
        ll A;
        cin >> A;
        S += A;
    }

    cout << (S<=N ? N-S : -1) << endl;

    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i< (int)(n); i++)
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define pb(e) push_back(e)
#define foreach(c, i) for(iter(c) i = (c).begin(); i != c.end(); ++i)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

const int sz = 4010;
int dp[sz][sz];
int last[sz][sz];
ll A[sz];
P S[sz];

int main(){
  int n;
  cin >> n;
  rep(i, n) cin >> A[i];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 0;
  rep(i, n) dp[0][i+1] = 1;
  
  for(int l = 1; l < n; l++){
    vector<pair<ll, P> > v;
    ll suml = 0;
    ll sumr = 0;
    for(int i = l - 1; i >= 0; i--){
      suml += A[i];
      v.push_back(make_pair(suml, P(dp[i][l], i)));
    }
    sort(v.begin(), v.end());
    S[0] = P(-INF, -1);
    rep(i, v.size()){
      if(v[i].second.first > S[i].first)  S[i+1] = v[i].second;
      else S[i+1] = S[i];
    }
    for(int r = l + 1; r <= n; r++){
      sumr += A[r-1];
      int ind = lower_bound(v.begin(), v.end(), make_pair(sumr, P(0, 0)))-v.begin();
      dp[l][r] = S[ind].first + 1;
      last[l][r] = S[ind].second;
    }
  }
  
  int v = 0;
  int pre;
  int best = 0;
  
  rep(i, n) if(best < dp[i][n]) {
    best = dp[i][n];
    v = i;
  }
  pre = n;
  vector<int> res;
  rep(i, best - 1){
    res.push_back(v);
    pre = v;
    v = last[v][n];
  }
  reverse(res.begin(), res.end());
  cout << best << endl;
  rep(i, res.size()){
    if(i > 0) cout << ' ';
    cout << res[i];
  }
  cout << endl;
  //rep(i, n + 1)rep(j, i) cout << j << "  " << i << " " << dp[j][i] << endl;
  return 0;
}

Measured memory_bytes: 127072
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);cout.tie(0);

   ll a;
   cin>>a;
   if(a==1) cout<<0<<endl;
   else cout<<1<<endl;


   return 0;
}


Measured memory_bytes: 3544
#include <stdio.h>
#define INFTY 10000
#define BLACK 2
#define WHITE 0
int prim(void);
	int n,a[100][100],d[100],color[100],mincost;
	
int main(){
	int i,j;

	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			scanf("%d",&a[i][j]);
			if(a[i][j]==-1) a[i][j]=INFTY;
		}
	}
	printf("%d\n",prim());
	
	return 0;
}

int prim(){
	int i,j,u,sum=0;
	
	for(i=0;i<n;i++){
		d[i]=INFTY;
		color[i]=WHITE;
	}
	d[0]=0;
	
	while(1){
		mincost=INFTY;
		for(i=0;i<n;i++){
			if(color[i]!=BLACK && d[i]<mincost){
				mincost=d[i];
				u=i;
			}
		}
		if(mincost==INFTY) break;
		
		color[u]=BLACK;
		
		for(j=0;j<n;j++){
			if(color[j]!=BLACK && a[u][j]<d[j]){
				d[j]=a[u][j];
			}
		}
	}
	
	for(i=0;i<n;i++){
		sum+=d[i];
	}
	return sum;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	string s,t;
	cin >> s >> t;
	isYes(t.substr(0,s.length()) == s);
}

Measured memory_bytes: 3600
import itertools
n, m, q = [int(i) for i in input().split()]
sm = 0
abcd = [[int(j) for j in input().split()] for i in range(q)]
a = [i[0] for i in abcd]
b = [i[1] for i in abcd]
c = [i[2] for i in abcd]
d = [i[3] for i in abcd]

it = itertools.combinations_with_replacement(range(1, m+1), n)
ans = 0
for i in it:
    sum = 0
    for j in range(len(a)):
        if(i[b[j]-1] - i[a[j]-1] == c[j]):
            sum += d[j]
    ans = max(sum,ans)

print(ans)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0),cin.tie(0);
    int n,sum=0;
    cin >> n;
    for(int i=1;i<=n;i++){
    	for(int j=1;j<=n;j++){
    		for(int k=1;k<=n;k++)
    			sum+=__gcd(__gcd(i,j),k);
    	}
    }
    cout << sum ;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;

int main(){
  vector<int> a(3);
  for(int i=0;i<3;++i) cin >> a.at(i);
  sort(a.begin(),a.end());
  int ans=abs(a.at(0)-a.at(1))+abs(a.at(2)-a.at(1));
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long long int res=0;
    int j=1;
    for(int i=1;i<n;i++)
    {
        if(i*j<n)
        {
            res++;
            i--;
        }
        else
        {
            j=0;
        }
        j++;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
	int n,m;cin>>n>>m;
	vector<string> a(n);
	for(int i=0;i<n;++i)cin>>a[i];
	vector<string> b(m);
	for(int i=0;i<m;++i)cin>>b[i];

	for(int i=0;i<n-m+1;++i)
	{
		for(int j=0;j<n-m+1;++j)
		{
			bool match=true;
			for(int k=0;k<m;++k)
			{
				
				for(int l=0;l<m;++l)
				{
					//cout<<a[i+k][j+l]<<b[k][l]<<endl;
					if(a[i+k][j+l]!=b[k][l]){
						match=false;
						break;}
				}
			}
			if(match)
				{
					cout<<"Yes"<<endl;
					return 0;
				}
		}	
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

#define DEBUG1  false
#define INF 1LL<<60

typedef long long ll;

ll f(const ll B, const ll N)
{
    if (B < 2)
    {
        return INF;
    }
    if (N < B)
    {
        return N;
    }
    ll a = f(B, N / B);
    ll c = N % B;
    return a + c;
}
ll solve(const ll N, const ll S)
{
#if DEBUG1
    std::cout << "DEBUG1: N: " << N << " S: " << S << std::endl;
#endif
    if (N == S)
    {
        return N + 1;
    }
    ll a = INF;
#if DEBUG1
    std::cout << "DEBUG1: sqrt(N): " << sqrt(N) << std::endl;
#endif
    for (int B = 2; B <= sqrt(N); B++)
    {
        if (S == f(B, N))
        {
            a = std::min(a, (ll)B);
        }
    }
#if DEBUG1
    std::cout << "DEBUG1: sqrt(N): " << sqrt(N) << std::endl;
#endif
    for (int P = 1; P < sqrt(N); P++)
    {
        ll B = (N - S) / P + 1;
        if (S == f(B, N))
        {
            a = std::min(a, B);
        }
    }
    if (INF == a)
    {
        return -1;
    }
    return a;
}
signed main(void)
{
    ll N, S;
    std::cin >> N >> S;
    std::cout << solve(N, S) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
 */

int y, m, d;

bool check()
{
  if(y < 2019) return true;
  else if(y > 2019) return false;
  if(m < 4) return true;
  else if(m > 4) return false;
  if(d <= 30) return true;
  return false;
}

int main()
{
  int n;
  cin >> n;

  double sy = 0, sb = 0;
  rep(i, n){
    double x;
    string u;
    cin >> x >> u;

    if(u == "JPY"){
      sy += x;
    }else{
      sb += x;
    }
  }

  printf("%.9f\n", sy+sb*380000);

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>

using namespace std;

typedef unsigned long long ll;

ll p[55], nlen[55];

ll solve(ll n, ll x) {
	if(x <= n) return 0;
	if(x >= nlen[n] - 1) return p[n];
	if(x == nlen[n] / 2 + 1) return (p[n] / 2 + 1);
	else if(x < nlen[n] / 2 + 1)
		return solve(n - 1, x - 1);
	else
		return p[n] / 2 + 1 + solve(n - 1, x - nlen[n] / 2 - 1);
}

int main() {
	for(int i = 0; i <= 50; ++i) {
		p[i] = pow(2, i + 1) - 1;
		nlen[i] = pow(2, i - 1) * 8 - 3;
	}
	ll n, x;
	cin>>n>>x;
	cout<<solve(n, x)<<endl;
}

Measured memory_bytes: 256
from collections import deque

n = int(input())
a = list(map(int, input().split()))

res = deque()
for i in range(n):
    if i % 2 == 0:
        res.append(a[i])
    else:
        res.appendleft(a[i])

if n % 2 == 0:
    for i in range(n):
        print(res[i], end=' ')
else:
    for i in range(n-1, -1, -1):
        print(res[i], end=' ')

Measured memory_bytes: 106792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
   string s;
   cin >> s;
   for(int i=0;i<s.size();i++){
       for(int j=0;j<=s.size();j++){
           string t = s;
           if(t.erase(i,j)=="keyence"){
               cout << "YES" << endl;
               return 0;
           } 
       }
   }
   cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
ll mod;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=1010;

int n,mx,n1;
int lb[N],cs[N];

ll dp[N][150][150];

void upd(ll &a,ll b) {
	a=(a+b)%mod;
}

int main() {
	scanf("%d%lld",&n,&mod);
	for (int i=0;i<2*n;i++) if (i*i*2<=4*n*n) {
		mx=i;
	}
	n1=2*n-mx-1;
	for (int i=0;i<=mx;i++) {
		cs[i]=min(2*n-1.0,floor(sqrt(4*n*n-i*i)+1e-9));
		cs[i]+=1;
		//printf("cs %d %d\n",i,cs[i]);
	}

	int pr=mx+1;
	for (int i=0;i<=mx;i++) {
		lb[i]=ceil(sqrt(max(n*n-i*i,0))-1e-9);
	}
	VI v;
	int D=0,R=1;
	for (int i=0;i<=mx;i++) {
		while (pr>lb[i]) {
			--pr; v.pb(D);
		}
		v.pb(R);
	}
	//printf("%d %d\n",n1,mx);
	//for (auto p:v) printf("%d ",p); puts("");
	dp[0][0][0]=1;
	int px=mx+1,py=0;
	rep(i,0,SZ(v)) {
		if (v[i]==D) px--;
		for (int covd=0;covd<=n1&&covd<=i;covd++) 
			for (int covr=0;covr<=n1&&covr<=i;covr++) {
			//	printf("zz %d %d %d %lld\n",i,covd,covr,dp[i][covd][covr]);
				if (dp[i][covd][covr]==0) continue;
				if (v[i]==D) {
					if (cs[px]-mx-1-covd>0) {
						upd(dp[i+1][covd+1][covr],dp[i][covd][covr]
								*(cs[px]-mx-1-covd));					
					}
					upd(dp[i+1][covd][covr],dp[i][covd][covr]);
				} else {
					if (cs[py]-mx-1-(n1-covr-1)>0)
						upd(dp[i+1][covd][covr+1],dp[i][covd][covr]
								*(cs[py]-mx-1-(n1-covr-1)));
					//printf("gg %d %d %d\n",(mx+1-px),covd,(py-covr));
					if ((mx+1-px)-covd-(py-covr)>0) {
						upd(dp[i+1][covd][covr],dp[i][covd][covr]
								*((mx+1-px)-covd-(py-covr)));
					}
				}
			}
		if (v[i]==R) py++;
	}
	printf("%lld\n",dp[SZ(v)][n1][n1]);
}


Measured memory_bytes: 123264
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

string S;

int main(){
    cin >> S;
    map<char, int> m;
    for(int i=0;i<4;i++)    m[ S[i] ]++;

    string ans = "Yes";
    if(m.size() == 2){
        for(auto i : m){
            if(i.second != 2){
                ans = "No";
                break;
            }
        }
    } else {
        ans = "No";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif
void tokenize(string str,const char delim,vector<string> & res){
	stringstream p(str);
	string token;
	while(getline(p,token,delim)){
		res.push_back(token);
	}
	return;
}

// Your workSpace ...

ll N,x;
void test_case(){
	cin >> N;
	int cnt = 0;
	for(int i = 1;i<=N;++i){
		cin >> x;
		if(i%2 != 0 && x%2 != 0)	
			++cnt;
	}
	cout << cnt;
}
	


	





int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<vector<int>> a(n + 1, vector<int>(n));
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < n - 1; j++) {
			cin >> a[i][j];
		}
	}
	vector<int> ptr(n + 1, 0);
	vector<int> mat;
	for (int i = 1; i <= n; i++) {
		int j = a[i][0];
		if (j < i) continue;
		if (a[j][0] != i) continue;
		mat.push_back(i);
		mat.push_back(j);
	}
	int day = 0;
	while (mat.size()) {
		day++;
		for (int x: mat) {
			ptr[x]++;
		}
		vector<int> tmp;
		set<int> used;
		for (int i: mat) {
			if (used.count(i)) continue;
			if (ptr[i] < n - 1) {
				int j = a[i][ptr[i]];
				if (a[j][ptr[j]] != i) continue;
				tmp.push_back(i);
				tmp.push_back(j);
				used.insert(i);
				used.insert(j);
			}
		}
		mat = tmp;
	}
	for (int i = 1; i <= n; i++) {
		if (ptr[i] != n - 1) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << day << endl;
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;



int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif


    int n;
    while (scanf("%d", &n) == 1) {
        vector<int> a(n);
        for (int i = 0; i < n; i++) {
            scanf("%d", &a[i]);
        }

        int ans = 0;
        int l = 0;
        while (l < n) {
            int r = l;
            int cur = 0;
            while (r + 1 < n) {
                int nw;
                if (a[r + 1] == a[r]) nw = 0;
                else if (a[r + 1] > a[r]) nw = 1;
                else nw = -1;

                if (nw == 0) r++;
                else if (cur == 0) {
                    cur = nw;
                    r++;
                } else if (cur == nw) {
                    r++;
                } else break;
            }
            ans++;
            l = r + 1;
        }
        printf("%d\n", ans);
    }


#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(x) cerr << #x << " == " << (x) << '\n';
#define all(X) X.begin(), X.end()
#define sz(X) (int)X.size()

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

// xz

int main()
{ _
    string S; cin >> S;

    int ans = 0;
    int cur = 0;
    for (int i = 0; i < 3; ++i)
    {
        cur = S[i] == 'S' ? 0 : cur + 1;
        ans = max(ans, cur);
    }

    cout << ans << endl;

    exit(0);
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)

int main(){
    int n,m=0;
    cin>>n;
    vi x(n),y(n);
    map<pair<int,int>,int> d;
    rep(i,n)cin>>x[i]>>y[i];
    rep(i,n){
        int a=x[i],b=y[i];
        rep(j,n){
            if(i==j)continue;
            d[{a-x[j],b-y[j]}]++;
        }
    }
    for(auto x:d){
        m=max(x.second,m);
    }
    cout<<n-m<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
ll MOD = 1e9 + 7;

using vc = vector<char>;
using vi = vector<int>;

ll BIG;

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        res %= MOD;
        a = a * a;
        a %= MOD;
        b >>= 1;
    }
    return res;
}

ll inverse(ll n) {
    return binpow(n, MOD-2);
}


ll fact(ll n) {
    ll ans = 1;
    FOR(i, 1, n+1) {ans *= i; ans %= MOD;}
    return ans;
}

ll choose(ll n, ll k) {
    return fact(n) * inverse(fact(k)) % MOD * inverse(fact(n-k)) % MOD;
}

ll calc(ll N, ll M) {
    ll ans = 0;
    F0R(i, N - 1) {
        ll ED = (N - i);
        ans += ED * BIG % MOD * M % MOD * (N-i-1) % MOD * M % MOD;
    }
    return ans;
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll N, M, K; cin >> N >> M >> K;
    BIG = choose(N * M - 2, K - 2);
    ll ans = 0;
    ans += calc(N, M); ans %= MOD;
    ans += calc(M, N); ans %= MOD;
    cout << (ans * inverse(2)) % MOD << endl;
}

Measured memory_bytes: 256
// インクルード
#include <bits/stdc++.h>

// 名前空間省略
using namespace std;

// メイン関数
int main()
{
	// 標準入出力　高速化
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	double r;
	cin >> r;
	cout << fixed << setprecision(15) <<2*r*M_PI << endl;
}


Measured memory_bytes: 3772
number = list(map(int,input().split()))
count = 0
while True:
	if len(set(number)) == 1:
		break
	number.sort()
	if number[0] == number[1]:
		number[0] += 1
		number[1] += 1
		count+=1
	else:
		number[0] += 2
		count+=1

print(count)


Measured memory_bytes: 2940
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		for(int i = 0; i < n; i++){
			if(sc.next().equals("Y")){
				System.out.println("Four");
				return;
			}
		}

		System.out.println("Three");
	}
}


Measured memory_bytes: 21712
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int k, s;
  cin >> k >> s;
  int res = 0;
  for (int x = 0; x <= (k); ++x){
    for (int y = 0; y <= (k); ++y){
      int z = s-x-y;
      if(0 <= z && z <= k) ++res;
    }
  }
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256