akhauriyash/Code-Regression huggingface dataset:
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    string S;
    cin >> S;
    S.erase(S.size() - 8, 8);
    print(S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void nil()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int sum=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int m= a[i]*a[j];
			sum=sum+m;
			//cout<<m<<endl;
		}
	}
	cout<<sum<<endl;
	
}
int main()
{
	#ifndef ONLINE_JUDGE

		freopen("input1.txt","r",stdin);
		freopen("output1.txt","w",stdout);
	#endif	
		nil();

}

Measured memory_bytes: 3592
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=deque(input())
t=deque(input())
for i in range(len(t)):
    s.appendleft(s[-1])
    s.pop()

    if s==t:

        print("Yes")
        exit()
print("No")

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu ((int)1e9+7)
//sieve generation begin
vi PRIME;
void sieve(int n)
{
	bool a[n+1];
	memset(a,0,sizeof(a));
	a[0]=1;
	a[1]=1;
	for(int i=2;i*i<=n;i++)
	{
		if(a[i]==0)
		{
			for(int j=i*i;j<=n;j+=i)
			a[j]=1;
		}
	}
	for(int i=2;i<=n;i++)
	{
		if(a[i]==0)
		PRIME.pb(i);
	}
}
//sieve generation end
ll gcd(ll a,ll b)
{
	while(b%a)
	{
		ll c=b;
		b=a;
		a=c%a;
	}
	return a;
}
ll bigpow(ll x,ll y)
{
	if(y==0)
	return 1;
	else if(y&1)
	{
		return (x*bigpow((x*x)%chotu,(y-1)/2))%chotu;
	}
	else 
	return bigpow((x*x)%chotu,y/2);
}
//fastio
/*void fastscan(int &number) 
{ 
    //variable to indicate sign of input number 
    bool negative = false; 
    register int c; 
  
    number = 0; 
    c = getchar(); 
    if (c=='-') 
    { 
        
        negative = true; 
  
        c = getchar(); 
    } 
    for (; (c>47 && c<58); c=getchar()) 
        number = number *10 + c - 48; 
    if (negative) 
        number *= -1; 
} 
*/
void solve()
{
si s;
for(int i=0;i<3;i++)
{
	int x;
	cin>>x;
	s.insert(x);
}
cout<<s.size();
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
	solve();
	cout<<'\n';
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 200010
#define inf 1<<29
#define linf 1e18
#define eps (1e-8)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  int n;
  int l[MAX],r[MAX];
  map<int,int> L,R;
  string s;

  cin>>n>>s;

  FOR(i,0,n)if(s[i]=='>')l[i]++;
  RFOR(i,n,0)if(s[i]=='<')r[i]++;
  FOR(i,1,n)l[i]+=l[i-1];
  RFOR(i,n,1)r[i-1]+=r[i];
  FOR(i,0,n){
    if(s[i]=='>')l[i]--;
    else r[i]--;
  }
  FOR(i,0,n)L[l[i]]=i;
  RFOR(i,n,0)R[r[i]]=i;
 
  int ans=0;
  FOR(i,0,n){
    if(s[i]=='>'){
      if(l[i]<r[i])ans=max(ans,R[r[i]-l[i]-1]+1);
      else ans=max(ans,n-L[l[i]-r[i]]);
    }
    else {
      if(l[i]<=r[i])ans=max(ans,R[r[i]-l[i]]+1);
      else ans=max(ans,n-L[l[i]-r[i]-1]);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 8696
#include <iostream>
#include <vector>
#include <stack>
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;
using ll = long long;

ll Calc(const vector<string> &a){
  stack<ll> buf;
  REP(i,a.size()){
    if(a[i] == "+"){
      ll x = buf.top(); buf.pop();
      ll y = buf.top(); buf.pop();
      buf.push(y + x);
    }
    else if(a[i] == "-"){
      ll x = buf.top(); buf.pop();
      ll y = buf.top(); buf.pop();
      buf.push(y - x);
    }
    else if(a[i] == "*"){
      ll x = buf.top(); buf.pop();
      ll y = buf.top(); buf.pop();
      buf.push(y * x);
    }
    else buf.push(stoll(a[i]));
  }
  return buf.top();
}

int main(){
  vector<string> input;
  string buf;
  while(cin >> buf) input.push_back(buf);
  cout << Calc(input) << endl;
  return 0;
}


Measured memory_bytes: 3176
#include<stdio.h>
#include<string.h>
int main()
{
	char s[20], t[20];
	scanf("%s %s", s, t);
	int a, b;
	scanf("%d %d", &a, &b);
	char u[20];
	scanf("%s", u);
	if (strcmp(s, u) == 0)
		a--;
	else
		b--;
	printf("%d %d\n", a, b);
	return 0;
}

Measured memory_bytes: 128
import sys

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

def calcr(k, n, start, a):
    if start == 0:
        return a[n - 1] - a[0]
    else:
        return k - a[start] + a[start - 1]

def calcl(k, n, start, a):
    if start == n - 1:
        return a[n - 1] - a[0]
    return a[start] + k - a[start + 1]

mindist = calcr(k, n, 0, a)
for i in range(n):
    mindist = min(mindist, calcr(k, n, i, a))
    mindist = min(mindist, calcl(k, n, i, a))

print(mindist)

Measured memory_bytes: 26444
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int main(){
	long long n,x=0,i;
	cin>>n;
	string s;
	cin>>s;
	for(i = 0;i <= s.size()-1;i ++)
	{
		if(s[i] =='D')
		{
			x --;
			a[i]=x;
		}	
		if(s[i] =='I')
		{
			x ++;
			a[i]=x;
		}
	}
	int mx=-1;
	for(i=0;i<=n;i++){
		if(mx<a[i]){
			mx=a[i];
		}
	}
	cout<<mx;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
	int i,j,c,kazu,csosu=0;
	Scanner sc = new Scanner(System.in);
	    i=sc.nextInt();
	for(j=0;j<i;j++){
	    kazu=sc.nextInt();
	    for(c=(int)Math.sqrt(kazu);c>1;c--){
		if(kazu%c==0){
		    csosu+=1;
		    break;
		}
	    } 
	}
	csosu=i-csosu;
	System.out.println(csosu);
    }
}



Measured memory_bytes: 42976
#include <iostream>

using namespace std;

int main() {
    int A, B, K;
    cin >> A >> B >> K;

    int cnt = 0;
    for (int i=B; i>0; i--) {
        if (A%i == 0 && B%i == 0) cnt++;
        if (cnt == K) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std ;
 
typedef double D ;
typedef long long ll ;
typedef long double ld ;
typedef unsigned int ui ;
typedef unsigned long long ull ;
 
# define F first
# define S second
# define R return
# define C continue 
# define pb push_back 
# define pf push_front
# define mp make_pair
 
# define vi vector <int>
# define vb vector <bool>
# define vll vector <ll>
# define vs vector <string>
 
# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >
 
# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >
 
# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >
# define vvpii vector < vector < pii > >
 
# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp
 
# define Fi(i,L,R) for (int i = L ; i <= R ; i++)
# define Fd(i,R,L) for (int i = R ; i >= L ; i--)

# define FAST ios_base :: sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0)
 
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))
 
const ll MOD = 1e9 + 7 ;
const int infi =  INT_MAX ;
const ll infll =  LLONG_MAX ;
const ld PI = 3.1415926535897932384626 ;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve (int test_case)
{
	int n , m ;
	cin >> n >> m ;
	ll sum = 0 ;
	for (int i = 0 ; i < m ; ++i)
	{
		int t ;
		cin >> t ;
		sum += t ;
	}
	if (sum > n)
	{
		cout << -1 ; R ;
	}
	cout << n - sum ;
}
 
int main()
{
	//freopen ("input.txt","r",stdin) ;
	//freopen ("output.txt","w",stdout) ;
	
	FAST ;
	int tc = 1 ;
//	cin >> tc ;
	while (tc--) 
	    solve (tc) ;
	return 0 ;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;


int main() {

    int n, q;
    cin >> n >> q;

    vector<queue<ll>> qs(n);

    rep(i, q) {
        int query, t;
        cin >> query >> t;
        if (query == 0) {
            ll x;
            cin >> x;
            qs[t].push(x);
        } else if (query == 1) {
            if (qs[t].empty()) continue;
            cout << qs[t].front() << endl;
        } else if (query == 2) {
            if (qs[t].empty()) continue;
            qs[t].pop();
        }
    }

}


Measured memory_bytes: 5056
#include<bits/stdc++.h>
using namespace std;
int n, b[105];
int main()
{
	cin >> n;
	for (int i=0;i<n-1;i++)
		cin >> b[i];
	int ans=b[0]+b[n - 2];
	for (int i=1;i<n-1;i++)
		ans+=min(b[i-1],b[i]);
	cout << ans << endl;
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 k;
    cin >> k;
    int64 ans = 0;
    REP(i,k)REP(j,k)REP(l,k){
        ans += gcd(i+1, gcd(j+1,l+1));
    }
    ANS(ans);
    return 0;
}


Measured memory_bytes: 3652
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc137/tasks/abc137_e
//有向グラフの、負の辺を含む最短路問題→ベルマンフォード法

//ベルマンフォード法について
//https://qiita.com/wakimiko/items/69b86627bea0e8fe29d5

//Bellman-Ford法とは、グラフの二点間の最短距離を求めるアルゴリズムです。
//Dijkstra法と比べて辺の重みが負でも動きますが、重みに負の数がないならDijkstra法を使った方が高速です。
//負の閉路があると正しい距離を求められませんが、負の閉路があることを検出できます。
//頂点の数をV、辺の数をEとした場合、計算量はO(VE)になります。
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;

int N,M,P;
//a->bへ行く際の、c=-(コインの価値-P)をtuple<a,b,c>のような感じでまとめる
vector<tuple<int,int,int>> edges;

int ans = 0;

//隣接リスト 点iから行ける点の集合をto[i]とおく
vector<int> to[2500];
//Nに辿り着けるかを調べるのに使う 点jへ行くことのできる点の集合をrev_to[j]とおく
vector<int> rev_to[2500];

bool reachable_from_1[2500];//点iが点1から見て到達可能かどうか
bool reachable_to_N[2500];//点Nが点iから見て到達可能かどうか

void dfs_from_1(){
	queue<int> q;
	q.push(0);
	reachable_from_1[0] = true;
	while(!q.empty()){
		int now = q.front();
		q.pop();
		for(int u:to[now]){
			if(!reachable_from_1[u]){
				q.push(u);
				reachable_from_1[u] = true;
			}
		}
	}
}
void dfs_to_N(){
	queue<int> q;
	q.push(N-1);
	reachable_to_N[N-1] = true;
	while(!q.empty()){
		int now = q.front();
		q.pop();
		for(int u:rev_to[now]){
			if(!reachable_to_N[u]){
				q.push(u);
				reachable_to_N[u] = true;
			}
		}
	}
}
 
void solve(){
	for(int i=0;i<N;i++){
		reachable_from_1[i] = false;
		reachable_to_N[i] = false;
	}
	//DFSで1から到達可能か調べる
	dfs_from_1();
	//Nへ到達可能か調べる
	dfs_to_N();

	bool ok[2500];//点iが　1から到達可能　かつ　Nへ到達可能　ならok[i]=true;
	for(int i=0;i<N;i++) ok[i] = reachable_from_1[i]&reachable_to_N[i];

	//ベルマンフォード開始
	vector<int> d(N,INF_INT);
	d[0] = 0;
	bool update = true;
	int step = 0;//何ループかかったかを記録
	while(update){
		update = false;
		for(int i=0;i<M;i++){
			int a,b,c;
			tie(a,b,c) = edges[i];
			if(!ok[a]) continue;
			if(!ok[b]) continue;
			int newD = d[a] + c;
			if(newD < d[b]){
				update = true;
				d[b] = newD;
			}
		}
		step++;
		if(step > N){//負閉路の検出
			ans = -1;
			return;
		}
	}
	ans = -d[N-1];
	ans = max(ans,0);
}
 
int main(){
	cin >> N >> M >> P;
	for(int i=0;i<M;i++){
		int a,b,c;
		cin >> a >> b >> c;
		a--;b--;
		c = -(c-P);
		edges.emplace_back(a,b,c);
		to[a].push_back(b);
		rev_to[b].push_back(a);
	}
 
	solve();
 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> S(n);
    for (int i = 0; i < n; i++)
    {
        cin >> S[i];
    }
    int c = 0;
    int q;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int t;
        cin >> t;
        c += find(S.begin(), S.end(), t) != S.end();
    }
    cout << c << endl;
}


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

int main(){
    int num;
    cin >> num;
    int P[num];
    for(int i = 0; i < num; i++) {
        cin >> P[i];
    }
    
    int min;
    int answer = 1;
    min = P[0];
    for(int i = 1; i < num; i++) {
        if(min >= P[i]){
            answer++;
            min = P[i];
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1024
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)


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

gl = []
g = 0
for aa in a:
    g = gcd(g, aa)
    gl.append(g)

gr = []
g = 0
for aa in reversed(a):
    g = gcd(g, aa)
    gr.append(g)
gr = list(reversed(gr))

ans = 0
for rm in range(n):
    if rm - 1 < 0:
        ans = max(ans, gr[rm + 1])
    elif rm + 1 >= len(gr):
        ans = max(ans, gl[rm - 1])
    else:
        ans = max(ans, gcd(gl[rm - 1], gr[rm + 1]))
print(ans)


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

bool comp(const pair<int, int> &a, const pair<int, int> &b) {
    return a.first < b.first;
}

int main(){
    int N, K; cin >> N >> K;
    vector<int> A(N); REP(i, N) cin >> A[i];

    sort(all(A));

    vector<pair<int, int>> mp(N);

    // 種類数
    int cnt = 0;
    int req = 0;
    for(int i = 1; i <= N; ++i) {
        req++;
        if(A[i - 1] != A[i]) {
            // map型変数にある値と個数を突っ込む
            mp[cnt] = make_pair(req, A[i - 1]);
            req = 0; // 個数カウンタを初期化
            cnt++; // 種類数カウンタをインクリメント
        }
    }

    sort(mp.begin(), mp.end(), comp);

    if(cnt <= K) {
        cout << 0 << endl;
    } else {
        int result = 0;
        for(int i = 0; i < N; ++i) {
            if(mp[i].first == 0) continue;
            cnt--;
            result = result + mp[i].first;
            if(cnt <= K) {
                cout << result << endl;
                break;
            }
        }
    }
}


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

int main() {
    int n;
    cin >> n;
    long a[n];
    map<int, int> mp;
    mp[0] = 0;
    long ans = 0;
    int l_min[n], r_min[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        auto itr = mp.lower_bound(a[i]);
        l_min[i] = (--itr)->second;
        mp.erase(++itr, mp.end());
        mp[a[i]] = i + 1;
    }
    mp.clear();
    mp[0] = n + 1;
    for (int i = n - 1; i >= 0; i--) {
        auto itr = mp.lower_bound(a[i]);
        r_min[i] = (--itr)->second;
        mp.erase(++itr, mp.end());
        mp[a[i]] = i + 1;
    }
    for (int i = 0; i < n; i++) {
        ans += a[i] * (r_min[i] - i - 1) * (i - l_min[i] + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12800
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long M = long.Parse(str[1]);
		long ans = 0;
		if(N==1){
			ans += 300000;
		} else if(N==2){
			ans += 200000;
		} else if(N==3){
			ans += 100000;
		}
		if(M==1){
			ans += 300000;
		} else if(M==2){
			ans += 200000;
		} else if(M==3){
			ans += 100000;
		}
		if(M==1 && N==1){
			ans += 400000;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int gcd(int x,int y){
    if(x<y){
        swap(x,y);
    }
    while(y!=0){
        int tmp = x % y;
        x = y;
        y = tmp;
    }
    return x;
}

int main(){
    int N,X;
    cin>>N>>X;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        int tmp;
        cin>>tmp;
        a[i] = abs(X-tmp);
    }
    int ans = gcd(a[0],a[0]);
    for(int i=1;i<N;i++){
        ans = gcd(ans,a[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,a,n) for(ll i=a;i<n;i++)
#define w(_t) ll _t;cin>>_t;while(_t--)

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    ll x,k,d;cin>>x>>k>>d;
    if(x<0) x=-x;
    ll div=x/d;
    if(div>=k) cout<<x-k*d;
    else{
        x=x-div*d;
        k-=div;
        if(k%2==0) cout<<x;
        else cout<<-(x-d);
        
    }
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

template <class T> struct Sum2d {
    vector<vector<T>> data;
    Sum2d(int h, int w) : data(h + 1, vector<T>(w + 1, 0)) {}
    void add(int y, int x, T val) {
        y++, x++;
        if(y >= (int)data.size() || x >= (int)data[0].size()) {
            return;
        }
        data[y][x] += val;
    }
    void build() {
        for(int i = 1; i < (int)data.size(); i++) {
            for(int j = 1; j < (int)data[i].size(); j++) {
                data[i][j] +=
                    (data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1]);
            }
        }
    }
    // [sx, gx) × [sy, gy)
    T get(int sx, int sy, int gx, int gy) {
        return (data[gy][gx] - data[sy][gx] - data[gy][sx] + data[sy][sx]);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    Sum2d<int> sum(4 * k, 4 * k);
    for(int i = 0; i < n; i++) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        if(c == 'W') {
            y += k;
        }
        x %= (2 * k);
        y %= (2 * k);
        for(int a = 0; a < 2; a++) {
            for(int b = 0; b < 2; b++) {
                sum.add(y + a * 2 * k, x + b * 2 * k, 1);
            }
        }
    }
    sum.build();
    int ans = 0;
    for(int i = 0; i < 2 * k; i++) {
        for(int j = 0; j < 2 * k; j++) {
            chmax(ans, sum.get(i, j, i + k, j + k) +
                           sum.get(i + k, j + k, i + 2 * k, j + 2 * k));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 62976
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 入力値を取得
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a*b%2 == 0){
			System.out.println("Even");
		}else{
			System.out.println("Odd");
		}
	}
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,sum=0,w[1001],ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		sum++;
		cin>>w[i];
		if(sum%2==1 && w[i]%2==1) ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3592
N = gets.to_i
ac = 0
wa = 0
tle = 0
re = 0

N.times do |i|
	tmp = gets.chomp.to_s
	if tmp == "AC"
		ac += 1
	elsif tmp == "WA"
		wa += 1
	elsif tmp == "TLE"
		tle += 1
	else
		re += 1
	end
end

puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"

Measured memory_bytes: 14380
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;
int n;

int main(){
  cin >> n;
  int ans = 1;
  if(n<=3){
    cout << 1 << endl;
    return 0;
  }
  for(int i=2;i<n; i++){
    int now = i * i;
    if(now > n) break;

    while(now<=n){
      if(now*i > n){
        ans = max(ans, now);
        break;
      }
      now *= i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  string A, B;
  cin >> A >> B;
  if (A.length() < B.length())
    cout << "LESS" << endl;
  else if (A.length() > B.length())
    cout << "GREATER" << endl;
  else
  {
    if (A < B)
      cout << "LESS" << endl;
    else if (A > B)
      cout << "GREATER" << endl;
    else
      cout << "EQUAL" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import math
N,D = map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]
a = []
for l in range(N-1):
    for j in range(l+1,N):
        b = 0
        for k in range(D):
            b += (X[l][k]- X[j][k])**2
        a.append(math.sqrt(b))
c = 0
for m in range(len(a)):
    if len(str(a[m])) <=5:
        c += 1
print(c)

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
const int rest=1000000007;
long kaijo(int a){
  long ans;
  ans=a;
  if(a==0) return 1;
  else{
  for(int i=1;i<a;i++){
    ans=ans*i;
  }
  }
  return ans;
}
long combi(int a,int b){
  long ans;
  ans=kaijo(a);
  ans=ans/kaijo(a-b);
  ans=ans/kaijo(b);
  ans=ans%rest;
  return ans;
}

int main(){
  int n,k;
  cin>>n>>k;
  long long comb[2001][2001];
  /*  comb[0][0]=1;
  comb[1][0]=1;
  comb[1][1]=1;*/
  //  int max=0;
  for(int i=0;i<=2000;i++){
    /*    if(i>k) max=k;
    else max=i;*/
    for(int j=0;j<=i;j++){
      if(j==0||j==i){
	comb[i][j]=1;
      }
      else{
	comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
      }
	comb[i][j]=comb[i][j]%rest;
	//	cout<<comb[i][j]<<" ";
    }
    //    cout<<endl;
  }
  /*  for(int i=0;i<k;i++){
    for(int j=i;j<k;j++){
      combi[i][j]=comb(i,j);
    }}*/
  
  long long ans;
  for(int i=1;i<k+1;i++){
    //    ans[i]=combi[n-k+1][i-1]*combi[k-1][i-1];
    ans=comb[n-k+1][i]*comb[k-1][i-1];
    ans=ans%rest;
    cout<<ans<<endl;
  }
  //  cout<<kaijo(n)<<endl;
  //  cout<<kaijo(k)<<endl;
  //  cout<<comb(n,k)<<endl;
  return 0;
}


Measured memory_bytes: 31488
import sys
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n=int(input())
if n==1:
    print(0)
    sys.exit()
l=factorization(n)
ans =0
for x in l:
    a=x[0] #素数
    b=x[1] #素数の個数
    k=0
    t=0
    while(True):
        t += 1
        k += t
        if k==b:
            ans += t
            break
        elif k > b:
            ans += t-1
            break
print(ans)

Measured memory_bytes: 63016
#include <cstdio>
#include <iostream>
using namespace std;

int main(){
	while(1){
		int n;
		scanf(" %d", &n);
		if(n==0) break;
		
		int ans=20000;
	
		for(int a=0; a*200<=n; ++a){
			int p=a/5;
			int x=380*5*p*4/5 + 380*(a-5*p);
			int wa=a*200;
			
			for(int b=0; wa+b*300<=n; ++b){
				int q=b/4;
				int y=550*4*q*17/20 + 550*(b-4*q);
				int wb=b*300;
				
				//????????§C???????????????????????°????±???????
				int wc=n-wa-wb;
				if(wc%500!=0) continue;
				else{
					int c=wc/500;
					int r=c/3;
					int z=850*3*r*22/25 + 850*(c-3*r);
					
					if(x+y+z < ans) ans=x+y+z;
				}
				
			}
		}
		
		printf("%d\n", ans);
	}
}

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

struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;
    int n;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
        n = N;
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
    int groups(){
        int cnt=0;
        for(int i=0; i<n; i++){
            if(r[i] < 0) {
                cnt++;
            }
        }
        return cnt;
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    int A, B;
    UnionFind UF(N);
    for(int i = 0; i < M; i++) {
        cin >> A >> B;
        A--;
        B--;
        UF.unite(A, B);
    }

    cout << (UF.groups() - 1) << endl;

    return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;
using M = map<int, int>;

int main()
{
  int n;
  cin >> n;
  int a[n];
  bool b = false;
  int ans = 0;
  int cnt;
  rep(i, n) {
    cnt = 0;
    cin >> a[i];
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      cnt++;
    }
    ans += cnt;
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    A=list(mi())

    A.sort(reverse=True)
    B = [A[0]]
    for i in range(1,N):
        B.append(A[i])
        B.append(A[i])
    
    print(sum(B[:N-1]))


if __name__ == "__main__":
    main()


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  string ans="";
  int a=0,b=0;
  for(int i=0;i<N;i++){
    if(S[i]=='('){a++;}
    else{
      if(a>0){a--;}
      else{b++;}
    }
  }
  for(int i=0;i<b;i++){ans+='(';}
  ans+=S;
  for(int i=0;i<a;i++){ans+=')';}
  cout << ans << endl;
}

Measured memory_bytes: 764
#include <iostream>
using namespace std;
int main(int, char**)
{
	int k, s;
	cin >> k >> s;
	int count = 0;
	for (int x = 0; x <= k; ++x)
	{
		for (int y = 0; y <= k; ++y)
		{
			auto z = s - (x + y);
			if (z >= 0 && z <= k)
			{
				++count;
			}
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
import numpy as np
N, D = [int(n) for n in input().split()]
X = [[int(n) for n in input().split()] for _ in range(N)]
cnt = 0
for i in range(N-1):
    for j in range(i+1, N):
        d2 = 0
        for k in range(D):
            d2 += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k])
        d = np.sqrt(d2)
        if d == int(d):
            cnt += 1
print(cnt)


Measured memory_bytes: 21464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N, T;
    cin >> N >> T;

    VL A(N+1), B(N+1);
    rep(i, 1, N+1) cin >> A[i] >> B[i];

    VVL dp1(3050, VL(3050, 0));
    rep(i, 1, N+1){
        rep(t, 0, T){
            if(t < A[i]) dp1[i][t] = dp1[i-1][t];
            else dp1[i][t] = max(dp1[i-1][t], dp1[i-1][t-A[i]] + B[i]);
        }
    }

    VVL dp2(3050, VL(3050, 0));
    for(ll i = N; i > 0; i--){
        rep(t, 0, T){
            if(t < A[i]) dp2[i][t] = dp2[i+1][t];
            else dp2[i][t] = max(dp2[i+1][t], dp2[i+1][t-A[i]] + B[i]);
        }
    }

    ll ans = 0;
    rep(i, 1, N+1){
        rep(t, 0, T){
            ans = max(ans, dp1[i-1][t] + dp2[i+1][T-t-1] + B[i]);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 145920
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ff first
#define ss second
const ll mod = 1e9 + 7 ;
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
///////////////////////////////////////////////////////////
const int nmax = 1e5 + 2 ;
vector < int > fac(nmax);
ll power( int x , int n){
    if(n==0) return 1 ;
    if(n==1) return x ;
    ll y = power(x,n/2);
    if(n%2==0) return multiply(y,y);
    return multiply(y,multiply(y,x));
}
ll nCr( int n , int r){
    if(r>n) return 0 ;
    return multiply(fac[n],multiply(power(fac[r],mod-2),power(fac[n-r],mod-2)));
}
//////////////////////////////////////////////////////////
void solve( ){
    int n , k ;
    cin >> n >> k ;
    vector < int > a(n) ;
    fac[0] = 1 ;
    for( int i = 1 ; i < nmax ; i++) fac[i] = multiply(fac[i-1],i);
    for( int i = 0 ; i< n ; i++) cin >> a[i] ;
    sort(a.begin(),a.end());
    ll ans = 0 ;
    for( int i = 0 ; i < n; i++){
        int l = i ;
        int r = n-i-1 ;
        //cout << nCr(r,k-1)  << " " << nCr(l,k-1) << "\n";
        ans = add(ans,multiply(a[i],nCr(l,k-1)-nCr(r,k-1)));
    }
    cout << ans ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test_case=1 ;
    //cin >> test_case ;
    for( int i = 1 ; i <= test_case ; i++){
        solve( );
    }
}


Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (a, b) = (v[0], v[1]);
    if a.abs() % 2 != b.abs() % 2 {
        println!("IMPOSSIBLE");
        return;
    }
    println!("{}", (a + b) / 2);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

#define ll long long int
ll mod=1e9+7;

int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    ll t = 1;
    // cin >> t;
    ll i,j,k;
    ll n = 10004;
    // ll arr[]
    vector<ll> arr(10004,0);
    
    for(k=1;k<10004;k++)
    {
        for(i=1;i<=100;i++)
        {
            for(j=1;j<=100;j++)
            {
                
                ll sum1 = i*i + j*j + i*j;
                ll sum2 = i+j;
                ll x = i;
                ll y = j;
                // ll prod = i*j + j*k + k*i;
                ll sq = sum2*sum2 - 4*sum1 + 4*k;
                // if(k == 6 && i == 1 && j == 1)
                // {
                //     cout << sum1 << " " << sum2 << " " << sq << '\n';
                // }
                if(sq >= 0)
                {
                    ll z = ((ll)sqrt(sq) - sum2)/2;
                    // if(k == 6 && i == 1 && j == 1)
                    // {
                    //     // cout << sum1 << " " << sum2 << " " << sq << '\n';
                    //     cout << z << '\n';
                    // }

                    ll sumsq = x*x + y*y + z*z;
                    ll sumprod = x*y + y*z + z*x;

                    if(z > 0 && (sumsq+sumprod == k))
                    {
                        arr[k]++;
                    }
                }

                // if(sum + prod)
            
            }
        }
    }

    while(t--)
    {        
        // ll n,i,j;
        // cin >> n;

        ll N;
        cin >> N;
        // ll arr[n];

        for(i=1;i<=N;i++)
        {
            // cin >> arr[i];
            cout << arr[i] << "\n";
        }
    }
    
    return 0;
}

Measured memory_bytes: 3800
using System;

public class Program {
  public static void Main(string[] args) {
    var str = Console.ReadLine().Split();
    int n = int.Parse(str[0]);
    int k = int.Parse(str[1]);
    double[] p = new double[n];
    double[] ex = new double[n];
    var str2 = Console.ReadLine().Split();
    double sum_ex = 0.0;
    double max = 0.0;
    //int flag = 0;
    
    for (int i = 0; i < n; i++) {
      p[i] = double.Parse(str2[i]);
      ex[i] = (1 + p[i]) / 2;
    }
    
    for (int i = 0; i < k; i++) {
      sum_ex += ex[i];
    }
    
    max = sum_ex;
    
    for (int i = k; i < n; i++) {
      sum_ex = sum_ex + ex[i] - ex[i-k];
      max = Math.Max(max, sum_ex);
    }
    
    Console.WriteLine(max);
    
  }
}

Measured memory_bytes: 33500
N,K=map(int,input().split())
S=input()
X=[]
j="1"
num=0
for i in S:
    if j!=i:
        X.append(num)
        j=i
        num=1
    else:
        num+=1
X.append(num)

if j=="0":
    X.append(0)
Y=[0]
for i in X:
    Y.append(Y[-1]+i)
ans=0
for i in range(1,len(Y),2):
    t=min(i+2*K,len(Y)-1)
    ans=max(ans,Y[t]-Y[i-1])
print(ans)


Measured memory_bytes: 47540
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			double num = sc.nextDouble();
			
			if(num > 91.00){
				System.out.println("heavy");
			} else if(num > 81.00){
				System.out.println("light heavy");
			} else if(num > 75.00){
				System.out.println("middle");
			} else if(num > 69.00){
				System.out.println("light middle");
			} else if(num > 64.00){
				System.out.println("welter");
			} else if(num > 60.00){
				System.out.println("light welter");
			} else if(num > 57.00){
				System.out.println("light");
			} else if(num > 54.00){
				System.out.println("feather");
			} else if(num > 51.00){
				System.out.println("bantam");
			} else if(num > 48.00){
				System.out.println("fly");
			} else {
				System.out.println("light fly");
			}
		}
		sc.close();
	}

}

Measured memory_bytes: 19276
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>

#define ll long long
using namespace std;

const int MAXN = 2e5+10;
const int mod = 1e9+7;

ll f[4010][4010],n,a[MAXN],b[MAXN],fac[8010],inv[8010],ans = 0;

ll qp(ll x,int t){
    ll res = 1;
    for(;t;t >>= 1,x = x*x%mod){
	if(t&1) res = x*res%mod;
    }
    return res;
}

ll c(ll x , ll y){
    return fac[x] * inv[x-y]%mod * inv[y]%mod;
}

int main(){
    scanf("%lld",&n);
    for(int i = 1;i <= n;i++){
	scanf("%lld %lld",&a[i],&b[i]);
    }
    fac[0] = fac[1] = 1;
    for(int i = 2;i <= 8000;i++) fac[i] = fac[i-1]*i%mod;
    inv[8000] = qp(fac[8000],mod-2);
    for(int i = 8000-1;i >= 0;i--) inv[i] = inv[i+1]*(i+1) % mod;
    
    for(int i = 1;i <= n;i++){
	f[2000-a[i]][2000-b[i]] ++;
    }
    for(int j = 1;j <= 4000;j++) f[0][j] = (f[0][j] + f[0][j-1])%mod;
    for(int i = 1;i <= 4000;i++){
	f[i][0] = (f[i][0] + f[i-1][0])%mod;
	for(int j = 1;j <= 4000;j++)
	    f[i][j] += (f[i-1][j] + f[i][j-1]) % mod;
    }
    for(int i = 1;i <= n;i++){
	ans += f[a[i]+2000][b[i]+2000];
    }
    for(int i = 1;i <= n;i++){
	ans = ans - c(a[i]+b[i]+a[i]+b[i],a[i]+a[i]);
	ans = (ans%mod+mod)%mod;
    }
    ans = ans * inv[2] % mod;
    printf("%lld\n",(ans+mod)%mod);
    return 0;
}


Measured memory_bytes: 132312
def inpl(): return list(map(int, input().split()))
N, M = inpl()
s = []
c = []
for i in range(N):
    s.append(inpl())
for i in range(M):
    c.append(inpl())
for s_i in s:
    ans = 0
    d = 10000000000
    for (j, c_j) in enumerate(c):
        temp = abs(s_i[0]-c_j[0])+abs(s_i[1]-c_j[1])
        if temp<d:
            d = temp
            ans = j+1
            
    print(ans)

Measured memory_bytes: 3064
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  s = list(map(int, list(input().strip())))
  odd1, odd0, even1, even0 = 0, 0, 0, 0
  for i in range(len(s)):
    if i%2 == 0:
      if s[i] == 0:
        even0 += 1
      else: 
        even1 += 1
    else:
      if s[i] == 0:
        odd0 += 1
      else:
        odd1 += 1
  print(min(even0+odd1, even1+odd0))

if __name__=='__main__':
  main()



Measured memory_bytes: 4652
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] mochi=new int[n];
    int kari=0;
    int cnt=0;
    for(int i=0;i<n;i++) mochi[i]=sc.nextInt();
    for(int i=0;i<=n-2;i++)
      for(int j=n-1;j>=i+1;j--)
        if(mochi[j]<mochi[j-1]){
          kari=mochi[j-1];
          mochi[j-1]=mochi[j];
          mochi[j]=kari;
        }
    for(int i=1;i<n;i++)
      if(mochi[i]!=mochi[i-1])cnt++;
    System.out.println(cnt+1);
  }
}

Measured memory_bytes: 23764
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func calcLoss(day int, c, last []int) (int, []int) {
	ret := make([]int, 26)
	tot := 0
	for i := 0; i < 26; i++ {
		ret[i] = c[i] * (day - last[i])
		tot += ret[i]
	}
	return tot, ret
}

func main() {
	sc.Split(bufio.ScanWords)
	D := getInt()
	getInts(26)
	s := make([][]int, D)
	for i := 0; i < D; i++ {
		s[i] = getInts(26)
	}

	// last := make([]int, 26)

	// for i := 1; i < D; i++ {
	// 	t := getInt()
	// 	last[t] = i
	// 	ret, _ := calcLoss(i, c, last)
	// 	out(ret)
	// }

	for i := 0; i < D; i++ {
		maxS := 0
		idxS := 0
		for j := 0; j < 26; j++ {
			if maxS < s[i][j] {
				maxS = s[i][j]
				idxS = j
			}
		}
		out(idxS + 1)
	}
}


Measured memory_bytes: 1924
#include <stdio.h>
#include <math.h>

struct data {
  double d, w, h, n, r[10000];
} d[50];

int check(int i, double r) {
  int a, b, c;
  double t[2];
  int tp = 0;  
  for (a = 0; a <= 1; a++)
    for (b = 0; b <= 1; b++)
      for (c = 0; c <= 1; c++)
        if ((a + b + c) == 2) {
          tp = 0;
          if (a == 1)
            t[tp++] = d[i].d;
          if (b == 1)
            t[tp++] = d[i].w;
          if (c == 1)
            t[tp++] = d[i].h;                   
          if (sqrt(pow(t[0]/2, 2)  + pow(t[1]/2, 2)) <r)
            return 1;                    
        }
  return 0;
}

int main() {
  int i, j, n;
  for (i = 0;; i++) {
    scanf("%lf %lf %lf", &d[i].d, &d[i].w, &d[i].h);
    if (d[i].d == 0 && d[i].w == 0 && d[i].h == 0)
      break;
    scanf("%lf", &d[i].n);
    for (j = 0; j < d[i].n; j++)
      scanf("%lf", &d[i].r[j]);
  }
  n = i;
  for (i = 0; i < n; i++) {
    for (j = 0; j < d[i].n; j++) {
      if (check(i, d[i].r[j]) == 1)
        printf("OK\n");
      else
        printf("NA\n");
    }
  }
  return 0;
}

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

typedef long long ll;
#define fori(n) for(int i=0;i<n;i++)
#define pb push_back
#define mp make_pair

ll power(ll base,ll e)
{
    ll answer=1;
    //ll e=1000000005;
    while(e)
    {
        if(e%2==1)
        {
            answer*=base;
        }
        base*=base;
       // base%=mod;
        e/=2;
       // answer%=mod;
    }
    return answer;
}

void mergearr(ll arr[], ll l,ll m, ll r)
{
    ll i,j,k;
    ll n1= m-l+1;
    ll n2 = r-m;
    ll L[n1],R[n2];
    for(i=0;i<n1;i++)
        L[i]=arr[l+i];
    for(i=0;i<n2;i++)
        R[i]=arr[m+1+i];

    i=0; j=0; k=l;
    while(i<n1 && j<n2)
    {
        if(L[i]<=R[j])
        {
            arr[k]=L[i];
            i++;
        }
        else
        {
            arr[k]=R[j];
            j++;
        }
        k++;
    }
    while(i<n1)
    {
        arr[k]=L[i]; i++; k++;
    }
    while(j<n2)
    {
        arr[k]=R[j]; j++; k++;
    }
}
void mergesort(ll arr[],ll l, ll r)
{
    if(l<r)
    {
        ll m = l+(r-l)/2;
        mergesort(arr,l,m);
        mergesort(arr,m+1,r);
        mergearr(arr,l,m,r);
    }
}


void sieveprimes(ll n)
{
        bool prime[n+1];
        memset(prime,true,sizeof(prime));

        for(ll i=2;i*i<=n;i++)
        {
            if(prime[i]==true)
            {
                for(ll j=i*i;j<=n;j+=i)
                {
                    prime[j]=false;
                }

            }

        }

        /*for (int p=2; p<=n; p++)
           if (prime[p])
              cout << p << " ";*/

    }


int main()
{

    ll n,k;
    cin>>n>>k;
    ll arr[n];
    fori(n)
    {

        cin>>arr[i];
    }

    sort(arr,arr+n);
    ll sum=0;
    for(int i=0;i<k;i++)
    {

        sum+=arr[i];
    }

    cout<<sum<<endl;
}




Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI isg;
bool gd(in n){
  while(n){
    if(!isg[n%10])
      return 0;
    n/=10;
  }
  return 1;
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,k;
  cin>>n>>k;
  isg=VI(10,1);
  in a;
  forn(z,k){
    cin>>a;
    isg[a]=0;
  }
  while(!gd(n))
    ++n;
  cout<<n<<endl;
  return 0;
}


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

using namespace std;

using int64 = long long;

class Range {
 private:
  struct RI {
    int x; int step;
    int operator*() { return x; }
    bool operator!=(RI& o){ return x < o.x; }
    void operator++(){ x += step; }
  };
  RI l, r;
 public:
  Range(int r) : l({0, 1}), r({r, 1}) {}
  Range(int l, int r, int step=1) : l({l, step}),r({r, step}) {}
  RI& begin(){ return l; } RI& end() { return r; }
};

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;

constexpr int64 P = 1000000007;

// Verified: ABC133E, ABC132D, ABC130E
struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 input_x) : x(input_x) {}
  FiniteField() : x(0) {}
  int64 Value() { return x; }
  inline FiniteField operator+(FiniteField o) {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

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

  int n, m;
  cin >> n >> m;
  vector<int> is_broken(n + 1);
  for (int i : Range(m)) {
    int a;
    cin >> a;
    is_broken[a] = 1;
  }

  vector<FiniteField> dp(n + 1);
  dp[0] = 1;
  for (int i = 1; i <= n; i++) {
    if (is_broken[i]) dp[i] = 0;
    else {
      dp[i] += dp[i - 1];
      if (i >= 2) dp[i] += dp[i - 2];
    }
  }
  cout << dp[n].Value() << endl;
}


Measured memory_bytes: 1408
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

fn is_prime(n: u64) -> bool {
    for i in 2..n {
        if n % i as u64 == 0 {
            return false;
        }
    }
    return true;
}



#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (x,) = input!(u64);

    let mut n = x;
    loop {
        if is_prime(n) {
            break;
        }
        n += 1;
    }
    println!("{}", n);
}

fn main() {
    solve();
}


Measured memory_bytes: 4352