akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=55;
int n,m;

signed main(){
	read(n,m);
	write(n-m+1);
}

Measured memory_bytes: 3548
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001
#define mod 1000000007

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int n;
    
    scanf("%d", &n);
    
    if (n==0) {
        n=1;
    } else {
        n=0;
    }
    
    printf("%d", n);
    
    return 0;
}


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

int main(){

  int N = 0;
  scanf("%d",&N);

  int i = 0;
  int A[N-1], count[N-1];
  for( i = 0; i < N-1; i++ ){
    scanf("%d",&A[i]);
    count[i] = 0;
  }

  int hako = 0;
  for( i = 0; i < N-1; i++ ){
    hako = A[i];
    count[hako-1]++;
  }

  for( i = 0; i < N-1; i++ ){
    printf("%d \n", count[i]);
  }
  printf("0 \n");

  return 0;
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  string s;
  cin >> s;
  map<char,int> mp;
  REP(i,sz(s)) {
    mp[s[i]]++;
  }
  if (mp.size() != 2) {
    cout << "No" << endl;
    return;
  }
  for (auto p:mp) {
    if (p.se != 2) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

int main(int argc, char *argv[]){

  /* Regular */
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }
  
  // /* AOJ */
  // solve();
  return 0;
}

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

using namespace std;

struct Score{
	int team_num;
	int ac=0;
	int time=0;
	int miss_tmp[20]={0};
};

bool asc(const Score& left, const Score& right) {
	return left.ac == right.ac ? (left.time == right.time ?  left.team_num > right.team_num : left.time < right.time) :
		   left.ac > right.ac;
}

int main(){
	while(1){
		int M, T, P, R; cin>>M>>T>>P>>R;
		if(!M && !T && !P && !R) break;
		vector <Score> score(T);
		for(int i=0; i<T; i++) score[i].team_num = i;

		for(int i=0; i<R; i++){
			int m, t, p, j; cin>>m>>t>>p>>j;
			t=t-1;//0オリジン
			if(j == 0){
				score[t].ac++;
				score[t].time += m+(score[t].miss_tmp[p]*20);
			} else{
				score[t].miss_tmp[p]++;
			}
		}
		sort(score.begin(), score.end(), asc);
		for(int i=0; i<T; i++){
			cout << score[i].team_num+1;
			if(i!=T-1){
				if(score[i].ac == score[i+1].ac && score[i].time == score[i+1].time) cout << "=";
				else cout << ",";
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    int t, a;
    cin >> t >> a;
    vector<int> H(n);
    rep(i, n) cin >> H[i];
    vector<P> h(n);
    rep(i, n) {
        h[i].second = i + 1;
        h[i].first = abs(1000 * t - H[i] * 6 - 1000 * a);
    }
    sort(h.begin(), h.end());
    cout << h[0].second << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;
  ll nega_count = 0;
  ll A_abs_sum = 0;
  ll A_abs_min = INFLL;
  REP(i, N){
    ll A;
    cin >> A;
    if(A<0) nega_count++;
    A_abs_sum += abs(A);
    A_abs_min = min(A_abs_min, abs(A));
  }

  if(nega_count%2==0) cout << A_abs_sum << "\n";
  else                cout << A_abs_sum - 2*A_abs_min << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;

const int N = 3e5 + 5;

int n;
string s;
int gp1[N], gp2[N];

int go(int x) {
    int ans = 0;
    while (x != 0)
        ans++, x %= __builtin_popcount(x);
    return ans;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> s;
    int k = 0;
    for (int i = 0; i < s.size(); i++)
        k += (s[i] - '0');
    if (k == 0) {
        for (int i = 1; i <= n; i++)
            cout << "1\n";
        return 0;
    }
    int m1 = 0, m2 = 0;
    gp2[0] = 1;
    for (int i = 1; i <= n; i++)
        gp2[i] = gp2[i - 1] * 2 % (k + 1);
    for (int i = 0; i < n; i++)
        m2 *= 2, m2 += (s[i] - '0'), m2 %= (k + 1);
    if (k != 1) {
        gp1[0] = 1;
        for (int i = 1; i <= n; i++)
            gp1[i] = gp1[i - 1] * 2 % (k - 1);
        for (int i = 0; i < n; i++)
            m1 *= 2, m1 += (s[i] - '0'), m1 %= (k - 1);
    }
    for (int i = 0; i < n; i++)
        if (s[i] == '1') {
            if (k == 1)
                cout << "0\n";
            else {
                int nm1 = m1;
                nm1 -= gp1[n - i - 1];
                nm1 %= (k - 1);
                nm1 = (nm1 + (k - 1)) % (k - 1);
                cout << go(nm1) + 1 << "\n";
            }
        } else {
            int nm2 = m2;
            nm2 += gp2[n - i - 1];
            nm2 %= (k + 1);
            //cout << nm2 << endl;
            nm2 = (nm2 + (k + 1)) % (k + 1);
            //cout << nm2 << endl;
            cout << go(nm2) + 1 << "\n";
        }
    return 0;
}


Measured memory_bytes: 6904
#include <stdio.h>
int main(void) {
	int H, W;
	int f = 0, i, k;

	while (f == 0) 
	{
		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0) {
			break;
		}

		for (i = 0; i < H; i++) {
			for (k = 0; k < W; k++) {
				printf("#");
			}
			printf("\n");
		}
                printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        int K = s.nextInt();
        int sum=0;
        for(int i=1;i<=K;i++){
            for(int j=1;j<=K;j++){
                for(int k=1;k<=K;k++){
                    sum+=gcd(gcd(i,j),k);
                }
            }
        }
        System.out.println(sum);
    }

    static int gcd(int a, int b)
    {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

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

int main() {
    string str;
    vector<string> vs = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};
    while (cin >> str) {
        if (str.size() % 2) {
            cout << "NA" << endl;
            continue;
        }
        string ans;
        for (int i = 0; i < str.size(); i+=2) {
            int a = str[i] - '0' - 1;
            int b = str[i+1] - '0' - 1;

            if (0 <= a && a < 6 && 0 <= b && b < 5) {
                ans += vs[a][b];
            } else {
                ans = "NA";
                break;
            }
         }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3156
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main = do
  [x, y, z] <- getIntList
  putStrLn $ (show z) ++ " " ++ (show x) ++ " " ++ (show y)


Measured memory_bytes: 3776
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define MO 1000000007
using namespace std;
typedef long long LL;
map<LL,LL> dp;
LL DP(LL n)
{
	if(dp.find(n)!=dp.end())
		return dp[n];
	if(n==0)
		return 1;
	if(n==1)
		return 2;
	dp[n]=((DP(n/2LL)+DP((n-1LL)/2LL))%MO+DP((n-2LL)/2LL))%MO;
	return dp[n];
}
int main()
{
	LL n;
	scanf("%lld",&n);
	printf("%lld\n",DP(n));
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	//ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> a(m+1);
	rep(i, m) {
		int s, c;
		cin >> s >> c;
		a[i] = make_pair( s,c );
	}
	if (m == 0) {
		if (n == 1) { cout << "0"; return 0; }
		else cout << pow(10, n - 1); return 0;
	}
	a[m] = make_pair(100, 100);
	rep(i, m) {
		if (a[i].first == 1 && a[i].second == 0) {
			if (n > 1) { cout << "-1"; return 0; }
			else { cout << "0"; return 0; }
		}
	}
	sort(a.begin(), a.end());
	rep(i, m-1) {
		if (a[i].first == a[i + 1].first&&a[i].second != a[i + 1].second) {
			cout << "-1"; return 0;
		}
	}
	int l = 0;
	if (a[0].first > 1) l +=pow(10,n-1);
	l += pow(10,(n - a[0].first))*a[0].second;
	//cout << l << endl;
	rep2(i, 1, m) {
		if(a[i].first!= a[i-1].first)l += pow(10,n  - a[i].first)*a[i].second;
	}
	cout << l;
	return 0;
}

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

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(), b.end());
    int cnt = 0;
    for (int i = 0; i < n; i++){
        if (a[i] != b[i]) cnt++;
    }
    if (cnt == 0 || cnt == 2){
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Entrance Examination
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);

			int m, nmin, nmax;
			m = parseInt(st.nextToken());
			nmin = parseInt(st.nextToken());
			nmax = parseInt(st.nextToken());
			if ((m | nmin | nmax) == 0) break;

			int[] ns = new int[m];
			for (int i = 0; i < m; i++) {
				ns[i] = parseInt(br.readLine());
			}

			int max = -1, n = nmin;
			for (int i = nmin - 1; i < nmax; i++) {
				int gap = ns[i] - ns[i + 1];
				if (max <= gap) {
					max = gap;
					n = i;
				}
			}
			System.out.println(n + 1);
		} //end while
	} //end main
}

Measured memory_bytes: 30708
#include <stdio.h>

#define TRUE 1
#define FALSE 0

int check(int W, int H, int x, int y, int r) {
    int up = y + r;
    int low = y - r;
    int left = x - r;
    int right = x + r;
    if (up <= H && low >= 0 && left >= 0 && right <= W) {
        return TRUE;
    }
    else {
        return FALSE;
    }
}

int main() {
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if (check(W, H, x, y, r))
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 2144
#include <iostream>
#include <string>

using namespace std;

int main(void){
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == '1') ++counter;
    if (s[1] == '1') ++counter;
    if (s[2] == '1') ++counter;
    
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;++i)cin>>a[i];
    int i=1;
    long long sum = 0;
    while(i<n)
    {
        if(a[i-1]>a[i])
        {
            sum+=abs(a[i]-a[i-1]);
            a[i] = a[i]+abs(a[i]-a[i-1]);
        }
        ++i;
    }
    cout<<sum;
    return 0;	
}

Measured memory_bytes: 4368
#include <stdio.h>

int main(void){
	char s[4];
	int a=0;
	for(int i=0; i<=3; i++){
		scanf("%c", &s[i]);
	}
	for(int i=0; i<=3; i++){
		if(s[i] == '+') a++;
		else a--;
	}
	printf("%d\n", a);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

struct Node
{
    vector<int> edges;
    int father = -1;
    int depth = 0;
    int size = 0;
};

using Tree = vector<Node>;

int FindSizes(Tree &t, int node)
{
    t[node].size = 1;
    for (const auto &son : t[node].edges) {
        if (son != t[node].father) {
            t[son].father = node;
            t[son].depth = t[node].depth + 1;
            t[node].size += FindSizes(t, son);
        }
    }
    return t[node].size;
}

int KthAncestor(const Tree &t, int node, int k)
{
    while (k > 0) {
        node = t[node].father;
        k -= 1;
    }
    return node;
}

bool FirstWins(Tree &t, int first, int second)
{
    auto total_size = FindSizes(t, first);
    auto distance = t[second].depth - 1;

    auto root_second = KthAncestor(t, second, distance / 2);
    auto turns_second = t[root_second].size;
    auto turns_first = total_size - turns_second;

    return turns_first > turns_second;
}

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

    Tree tree(nodes);
    for (int i = 1; i < nodes; i += 1) {
        int a, b;
        cin >> a >> b;
        tree[a - 1].edges.push_back(b - 1);
        tree[b - 1].edges.push_back(a - 1);
    }

    cout << (FirstWins(tree, 0, nodes - 1) ? "Fennec" : "Snuke") << "\n";
    return 0;
}


Measured memory_bytes: 11904
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>

int main(void) {
   int W,H,x,y;
 scanf("%d %d %d %d",&W,&H,&x,&y);
 double res=0;
 int count =0;
 double test = (double)W/2;
 if ((double)x==((double)W/2)) {res=H*((double)W/2);
                        count++;
                        }
 if ((double)y==((double)H/2)) {res=W*((double)H/2);
                        count++;
                       }
 if (count==0){
        res=(double)W*H/2;
 count++;
 }
if (count==2) printf("%lf 1",res);
else if (count<2) printf("%lf 0",res);
 return EXIT_SUCCESS;
}

Measured memory_bytes: 888
#include <stdio.h>
#include <utility>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main(void) {
  int i, j, k;
  pair<int, int> p[6];
  rep(i, 6) {
    scanf("%d%d", &p[i].first, &p[i].second);
    int t;
    if(p[i].first > p[i].second) t = p[i].first, p[i].first = p[i].second, p[i].second = t;
  }
  sort(p, p + 6);
  rep(i, 3) {
    if(p[i * 2].first != p[i * 2 + 1].first || p[i * 2].second != p[i * 2 + 1].second) {
      printf("no\n");
      return 0;
    }
  }
  if((p[0].first == p[2].first && p[0].second == p[4].first && p[2].second == p[4].second) || (p[0].first == p[2].second && p[0].second == p[4].first && p[2].first == p[4].second) || (p[0].first == p[2].second && p[0].second == p[4].second && p[2].first == p[4].first) || (p[0].first == p[4].second && p[0].second == p[2].first && p[2].second == p[4].first) || (p[0].first == p[4].second && p[0].second == p[2].second && p[2].first == p[4].first)) printf("yes\n");
  else printf("no\n");
  return 0;
}


Measured memory_bytes: 2612
s = list(input())
s = [int(i) for i in s]
mae = 0
ato = 0
if (s[0] == 0 and s[1] != 0) or (s[0] == 1 and (s[1] == 0 or s[1] == 1 or s[1] == 2)):
    mae = 1
if (s[2] == 0 and s[3] != 0) or (s[2] == 1 and (s[3] == 0 or s[3] == 1 or s[3] == 2)):
    ato = 1
if mae == 0 and ato == 1:
    print('YYMM')
if mae == 1 and ato == 0:
    print('MMYY')
if mae == 1 and ato == 1:
    print('AMBIGUOUS')
if mae == 0 and ato == 0:
    print('NA')


Measured memory_bytes: 3064
#![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 s = read::<String>().chars().collect::<Vec<_>>();
    let t = read::<String>().chars().collect::<Vec<_>>();
    let mut ans = 0;
    for i in 0..3 {
        if s[i] == t[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}

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: 4352
class FastModuloTransform():
    def __init__(self, n=2**20, mod=998244353, root=3):
        self.n = n
        self.mod = mod
        self.omega = pow(root, (mod - 1) // n, mod)
        self.rev = pow(self.omega, mod - 2, mod)

    def _bit_reverse_(self, A):
        n = self.n
        m = self.n // 2
        i = 0
        for j in range(0, m, 2):
            if j < i:
                A[i], A[j] = A[j], A[i]
                A[i + m + 1], A[j + m + 1] = A[j + m + 1], A[i + m + 1]
            A[i + 1], A[j + m] = A[j + m], A[i + 1]
            k = m // 2
            i ^= k
            while k > i:
                k //= 2
                i ^= k
        return A

    def _fmt_(self, A, base):
        halfpow = pow(base, self.n // 2, self.mod)
        n = self.n
        m = 1
        while n > 1:
            n //= 2
            w = pow(base, n, self.mod)
            k = 1
            for j in range(m):
                for i in range(j, self.n, 2 * m):
                    u = A[i]
                    v = (A[i + m] * k) % self.mod
                    A[i] = (u + v) % self.mod
                    A[i + m] = (u + v * halfpow) % self.mod
                k = (k * w) % self.mod
            m *= 2
        return A

    def fmt(self, f):
        A = f + [0] * (self.n - len(f))
        self._bit_reverse_(A)
        F = self._fmt_(A, self.omega)
        return F

    def ifmt(self, F):
        A = F + [0] * (self.n - len(F))
        self._bit_reverse_(A)
        nrev = pow(self.n, self.mod - 2, self.mod)
        f = [(e * nrev) % self.mod for e in self._fmt_(A, self.rev)]
        return f

    def convolute(self, f, g):
        F = self.fmt(f)
        G = self.fmt(g)
        H = [(s * t) % self.mod for s, t in zip(F, G)]
        h = self.ifmt(H)
        return h

    def autocorrelation(self, f):
        F = self.fmt(f)
        H = [(s * s) % self.mod for s in F]
        h = self.ifmt(H)
        return h

fmt = FastModuloTransform()

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

res = fmt.convolute(A, B)[:N + M - 1]

print(*res)

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

int main(){
    map<string, int> vote;
    string str;
    int n, i;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> str;
        vote[str] += 1;
    }
    int max_vote = 0;
    for(auto iter = begin(vote); iter != end(vote); ++iter){
        max_vote = max(iter->second, max_vote);
    }

    for(auto iter = begin(vote); iter != end(vote); ++iter){
        if(iter->second == max_vote){
            cout << iter->first << endl;
        }
    }
}

Measured memory_bytes: 25216
#include <iostream>
#include <cstdint>
#include <array>
#include <algorithm>

int main() {
  std::array<std::array<std::int_fast64_t, 401>, 401> dp;
  for (std::array<std::int_fast64_t, 401>& line : dp) {
    line.fill(-1);
  }
  dp[0][0] = 0;

  std::int_fast64_t n, ma, mb;
  std::cin >> n >> ma >> mb;
  for (std::int_fast64_t i = 0; i < n; ++i) {
    std::int_fast64_t a, b, c;
    std::cin >> a >> b >> c;
    for (std::int_fast64_t x = i * 10; x >= 0; --x) {
      for (std::int_fast64_t y = i * 10; y >= 0; --y) {
        if (dp[x][y] >= 0) {
          dp[x + a][y + b] = dp[x + a][y + b] >= 0 ? std::min(dp[x][y] + c, dp[x + a][y + b]) : dp[x][y] + c;
        }
      }
    }
  }

  std::int_fast64_t result = -1;
  for (std::int_fast64_t x = ma, y = mb; x <= 400 && y <= 400; x += ma, y += mb) {
    if (dp[x][y] >= 0) {
      result = result >= 0 ? std::min(dp[x][y], result) : dp[x][y];
    }
  }

  std::cout << result << std::endl;
  return 0;
}

Measured memory_bytes: 1536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
			int r = Integer.valueOf(br.readLine());
			int area = (int)(3 * Math.pow(r, 2));
			System.out.println(area);
		}
	}
}

Measured memory_bytes: 20820
package main

import (
	"fmt"
)

const (
	mod = int64(1000000007)
)

func modpow(x int64, y int64) int64 {
	if y == 0 {
		return 1
	} else if y == 1 {
		return x
	} else if y%2 != 0 {
		return x * modpow(x, y-1) % mod
	}
	t := modpow(x, y/2)
	return t * t % mod
}

func main() {
	var n, m, k int64
	fmt.Scan(&n)
	fmt.Scan(&m)
	fmt.Scan(&k)

	a := int64(1)
	b := int64(1)
	for i := int64(0); i < k-2; i++ {
		a *= n*m - 2 - i
		a %= mod
		a *= modpow(i+1, mod-2)
		a %= mod
	}
	num := a / b

	var sum int64
	for i := int64(1); i < m; i++ {
		sum += i * n * n * (m - i) * num
		sum %= mod
	}
	for i := int64(1); i < n; i++ {
		sum += i * m * m * (n - i) * num
		sum %= mod
	}

	fmt.Println(sum)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;

int dp[MAXN];
int pot2p[MAXN];
int pot2m[MAXN];

int next(int x) {
	if (! x) return 0;
	if (dp[x]) return dp[x];
	return dp[x]=1+next(x%__builtin_popcount(x));
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	string s;
	cin >> s;
	
	if (n == 1) {
		cout << (s[0]=='0') << "\n";
		return 0;
	}
	
	int c = count(s.begin(),s.end(),'1');
	
	if (c == 1) {
		for (int i = 0; i < n; i++){
			if (s[i] == '1') {
				cout << 0 << "\n";
			} else {
				if (i != n-1) {
					cout << 1+(s[n-1]=='1') << "\n";
				} else {
					cout << 2 << "\n";
				}
			}
		}
		return 0;
	}
	
	if (c == 0) {
		for (int i = 0; i < n; i++){
			cout << 1 << "\n";
		}
		return 0;
	}
	
	int mp = 0;
	int mm = 0;
	
	pot2p[0] = 1;
	pot2m[0] = 1;
	
	for (int i = 0; i < n; i++){
		mp = (mp*2+(s[i]-'0'))%(c+1);
		mm = (mm*2+(s[i]-'0'))%(c-1);
		if (i) {
			pot2p[i] = (pot2p[i-1]*2)%(c+1);
			pot2m[i] = (pot2m[i-1]*2)%(c-1);
		}
	}
	
	for (int i = 0; i < n; i++){
		if (s[i]=='0') {
			cout << 1+next( (mp+pot2p[n-i-1])%(c+1) ) << "\n";
		} else {
			cout << 1+next( (((mm-pot2m[n-i-1])%(c-1))+(c-1))%(c-1) ) << "\n";
		}
	}
	
		

}


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

int main()
{
    int a, b, c;
    cin >> a >> b >>c;

    if (a + b + c >= 22)
    {
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }

    return 0;
}

Measured memory_bytes: 3640
import java.util.*;
import static java.lang.Math.*;

class Main {
    final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        for (int i = 1; i <= 5; i++) {
            if (sc.nextInt() == 0) {
                System.out.println(i);
            }
        }
    }
}


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

typedef long long LL;

const int N=200000;
const LL INF=1LL<<40;

int n;
LL x[N+9],y[N+9];

int main(){
  scanf("%d",&n);
  LL mx[2]={-INF,-INF},mn[2]={INF,INF};
  for (int i=1;i<=n;++i){
	LL a,b,x,y;
	scanf("%lld%lld",&a,&b);
	x=a+b;y=a-b;
	mx[0]=max(mx[0],x);
	mx[1]=max(mx[1],y);
	mn[0]=min(mn[0],x);
	mn[1]=min(mn[1],y);
  }
  printf("%lld\n",max(mx[0]-mn[0],mx[1]-mn[1]));
  return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int A,B,C;cin>>A>>B>>C;
  
  if(B/A>=C){
    cout<<C<<endl;
  }
  else{
    cout<<B/A<<endl;
  }
}

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

#define ll long long
#define ld long double
#define oo 2e18

using namespace std;

const int N = 1e5 + 5;
int n, a, b, c;
vector<char> v;
map<char, int> p;
string s[N];
bool vis[N][2];

bool rec(int indx, bool pre) {
    if (indx == n) {
        if (a >= 0 && b >= 0 && c >= 0) {
            cout << "Yes\n";
            for (auto i : v) {
                cout << i << "\n";
            }
            exit(0);
        }
        return 0;
    }
    bool &re = vis[indx][pre];
    if (re) {
        return 0;
    }
    re = 1;
    if (p[s[indx][0]] > 0) {
        p[s[indx][0]]--;
        p[s[indx][1]]++;
        v.push_back(s[indx][1]);
        rec(indx + 1, 0);
        v.pop_back();
        p[s[indx][0]]++;
        p[s[indx][1]]--;
    }
    if (p[s[indx][1]] > 0) {
        p[s[indx][0]]++;
        p[s[indx][1]]--;
        v.push_back(s[indx][0]);
        rec(indx + 1, 1);
        v.pop_back();
        p[s[indx][0]]--;
        p[s[indx][1]]++;
    }
    return 0;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> a >> b >> c;
    p['A'] = a;
    p['B'] = b;
    p['C'] = c;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    rec(0, 0);
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 14940
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
    IOS;
    string s;
    cin >> s;
    if(s[0]=='S'){
        put("Cloudy");
    }else if(s[0]=='C'){
        put("Rainy");
    }else{
        put("Sunny");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int s,k,x,y,z,ss=0;
    cin>>k>>s;
    if(k*3==s) ss=1;
    else for(x=0;x<=k;x++) for(y=0;y<=k;y++) if(s-x-y<=k && s-x-y>=0) ss++;
    cout<<ss<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

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

const int N_MAX = 100;

int n, k;
int c[N_MAX];

int f() 
{
    int res = 0;
    REP(i, n-k+1) {
        int x = 1;
        REP(j, k) x *= c[i+j];
        res = max(res, x);
    }
    return res;
}
    
void solve()
{
    int ck = f();
    int ans = 0;
    REP(i, n) REP(j, n) if (i != j) {
        swap(c[i], c[j]);
        ans = max(ans, f()-ck);
        swap(c[i], c[j]);        
    }
    if (ans < 0) cout << "NO GAME" << endl;
    else cout << ans << endl;
}

int main()
{
    while (cin >> n >> k, n) {
        REP(i, n) cin >> c[i];
        solve();
    }
    return 0;
}


Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
	int n, d;
	int count = 0;

	scanf("%d %d", &n, &d);

	while (n > 0) {
		n = n - ((2 * d) + 1);
		count++;
	}

	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		String[] moji;
		String[] rts;
		int mazu=0;
		StringBuilder stb;

		while(true) {
			str=bfr.readLine();
			mazu=Integer.parseInt(str);
			if(mazu==0) {
				System.exit(0);
			}
			else {
				moji=new String[mazu];
				for(int i=0; i<mazu; i++) {
					moji[i]=bfr.readLine();
				}
				int[][] spread=new int[mazu+1][mazu+1];

				for(int i=0; i<mazu+1; i++) {
					for(int j=0; j<mazu+1; j++) {
						spread[i][j]=0;
					}
				}
				for(int i=0; i<mazu; i++) {
					rts=moji[i].split(" ");
					for(int j=0; j<mazu; j++) {
						spread[j][i]=Integer.parseInt(rts[j]);
					}
				}
				for(int i=0; i<mazu; i++) {
					for(int j=0; j<mazu; j++) {
						spread[mazu][i]+=spread[j][i];
					}
				}
				for(int i=0; i<=mazu; i++) {
					for(int j=0; j<mazu; j++) {
						spread[i][mazu]+=spread[i][j];
					}
				}
				for(int i=0; i<=mazu; i++) {
					stb=new StringBuilder();
					for(int j=0; j<=mazu; j++) {
						stb.append(String.format("%5s", spread[j][i]));
					}
					 System.out.println(stb.toString());
				}
			}
		}
	}
}


Measured memory_bytes: 28416
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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 (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion
void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

bool f(string& S, int n){
    bool ret = true;
    REP(i, n){
        if(S[i] != S[i+n]){
            ret = false;break;
        }
    }
    return ret;
}

void Main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    vec<vec<int> > memo(N+1, vec<int>(26));
    REP(i, N){
        REP(j, 26){
            memo[i+1][j] = memo[i][j];
        }
        memo[i+1][S[i]-'a']++;
    }
    int mx = 0;
    FOR(i, N-1, 1){
        int sum = 0;
        REP(j, 26){
            if(memo[i][j] && memo[N][j] > memo[i][j]){
                sum++;
            }
        }
        chmax(mx, sum);
    }
    cout << mx << el;
}



Measured memory_bytes: 3616
const val INF = 1L shl 60

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val xs = readLine()!!.split(" ").map(String::toInt)
  val ys = readLine()!!.split(" ").map(String::toInt)

  var currentCost = 0L
  while (true) {
    // dp[i][v]: Min cost to make xs[i] to v.
    val dp = Array(n, { LongArray(51, { INF }) })
    for (i in 0 until n) {
      dp[i][xs[i]] = 0L
    }

    for (k in 50 downTo 1) {
      for (i in 0 until n) {
        for (v in 0..50) {
          if (dp[i][v] < INF) {
            if (currentCost and (1L shl k) == (1L shl k)) {
              dp[i][v % k] = Math.min(dp[i][v % k], dp[i][v])
            } else {
              dp[i][v % k] = Math.min(dp[i][v % k], dp[i][v] + (1L shl k))
            }
          }
        }
      }
    }
    var maxCost = 0L
    for (i in 0 until n) {
      maxCost = Math.max(maxCost, dp[i][ys[i]])
    }
    if (maxCost == INF) {
      println(-1)
      return
    }
    if (maxCost == 0L) {
      println(currentCost)
      return
    }
    currentCost = currentCost or java.lang.Long.highestOneBit(maxCost)
  }
}


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

#define N_ 150
#define M_ 15000
#define INF 1e17
using namespace std;

class MaxFlow {
public:
	struct Edge {
		int b, e;
		long long f;
	}E[M_ * 2];
	vector<int>G[N_];
	int Level[N_], Q[N_], PV[N_], source, sink, n, EC;
	long long flow;
	void init(int N, int S, int T) {
		n = N, flow = 0; EC = 0;
		source = S, sink = T;
	}
	void Add_Edge(int a, int b, long long f) {
		G[a].push_back(EC);
		G[b].push_back(EC + 1);
		E[EC++] = { a,b,f };
		E[EC++] = { b,a,0ll };
	}
	bool GetLevel() {
		int i;
		for (i = 1; i <= n; i++)Level[i] = -1;
		int head = 0, tail = 0;
		Q[++tail] = source, Level[source] = 0;
		while (head < tail) {
			int x = Q[++head];
			for (auto &y : G[x]) {
				if (E[y].f && Level[E[y].e] == -1) {
					Q[++tail] = E[y].e;
					Level[E[y].e] = Level[x] + 1;
				}
			}
		}
		return Level[sink] != -1;
	}
	long long BlockFlow(int a, long long f) {
		if (a == sink)return f;
		for (int &i = PV[a]; i >= 0; i--) {
			int x = G[a][i];
			if (E[x].f && Level[E[x].e] == Level[a] + 1) {
				long long t = BlockFlow(E[x].e, min(f, E[x].f));
				if (t) {
					E[x].f -= t;
					E[x ^ 1].f += t;
					return t;
				}
			}
		}
		return 0;
	}
	void Dinic() {
		int t;
		while (GetLevel()) {
			for (int i = 1; i <= n; i++)PV[i] = G[i].size() - 1;
			while (t = BlockFlow(source, INF))flow += t;
		}
	}
}G;

int n, w[N_];

int main() {
	int i, j;
	scanf("%d", &n);
	for (i = 1; i <= n; i++)scanf("%d", &w[i]);
	G.init(n + 2, n + 1, n + 2);
	for (i = 1; i <= n; i++) {
		G.Add_Edge(G.source, i, -w[i] + 1e9);
		G.Add_Edge(i, G.sink, 1e9);
	}
	for (i = 1; i <= n; i++)for (j = i; j <= n; j+=i)G.Add_Edge(i, j, INF);
	G.Dinic();
	printf("%lld\n", (long long)1e9 * n - G.flow);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long 
#define ar array
#define f first
#define s  second
#define REP(i,n) for (int i=0;i<(n);i++)
#define wt(x) int x;cin>>x;while(x--)
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T>
using o_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; 

void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);

  freopen("output1.txt","w",stdout);
#endif
}
const int mod=1000000007;
int power(int a,int b,int mod){
  a=a%mod;
  if(a==0){
    return 1;
  }
  int res=1;
  while(b){
    if(b&1){
      res=(res*a)%mod;
    }
    b>>=1;
    a=(a*a)%mod;
  }
  return res;
}

int  MMI(int p){
  return power(p,mod-2,mod);
}
int32_t main()
{
 c_p_c();
 int x,k,d;
 cin>>x>>k>>d;
 x=abs(x);
 if(x>0 && x/d>=k){
  int t=x/d;
  x=x-(k*d);
  cout<<x<<"\n";

 }
 else{
  int y=x/d;
  x=x-(y*d);
  k-=y;
  if(k%2==0){
    cout<<abs(x)<<"\n";
  }
  else{
    cout<<min(abs(x-d),abs(x+d))<<"\n";
  }
 }

   
 
 
 return 0;  
 
}

Measured memory_bytes: 3620
#include <stdio.h>
int main(void){
    int x;
    int i;
    int co;
    scanf("%d", &x);
    while(x > 0){
        co = 0;
        for(i = 2;i < x;i ++){
            if(x % i == 0){
                co ++;
            }
        }
        if(co == 0){
            break;
        }
        else{
            x ++;
        }   
    }
    printf("%d\n", x);
    return 0;
}

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

#define ll long long
#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define repr(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back
#define debug(x) cout << x << endl;
#define END cout << endl;
#define sorti(x) sort(x.begin(), x.end())

int main() {
  int n;
  cin >> n;
  vector<int> data(n);
  
  map<ll,ll> mp1,mp;
  ll result = 0;
  rep(i,n) {
    cin >> data[i];
    mp1[data[i]] += 1;
  }

  ll pre = -1, total = n, remain = n;
  for (auto itr : mp1) {
    int cnt = itr.second, now = itr.first, sub;
    if (pre < 0) {
      pre = now;
      mp[remain] = now;
      remain -= cnt;
    } else {
      sub = now - pre;
      mp[remain] = sub;
      remain -= cnt;
      pre = now;
    }
  }

  for (auto itr : mp) {
    int cnt = itr.second, num = itr.first;
    if (cnt % 2 == 1) {
      result ^= num;
    }
  }

  if (result > 0) {
    cout << "first" << endl;
  } else {
    cout << "second" << endl;
  }
}

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

int main() {
    int N, K;
    cin >> N >> K;
    int i = 0;
    int y = 0;
    while (i < N) {
        int x;
        cin >> x;
        if (x*2 < K)
            y += x * 2;
        else
            y += (K - x) * 2;
        i++;
    }
    cout << y << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>


std::vector<int> depth_u;
std::vector<int> depth_v;
int cnt = 0;

void dfs(const std::vector< std::vector< int > > &Graph, int v, int p, int d, std::vector<int>& depth){ 
  depth[v] = d;

  for(auto next_v : Graph[v]){
    if(next_v == p){
      continue;
    }
    dfs(Graph, next_v, v, d+1, depth);
  }
}
int main(){
  //std::ifstream in("input.txt");
  //std::cin.rdbuf(in.rdbuf());

  int N, u, v, a, b, cnt;
  std::cin >> N >> u >> v;
  std::vector< std::vector< int > > Graph;
  Graph.resize(N+1);

  for(int i = 0; i < N-1; i++){
    std::cin >> a >> b;
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }

  int cn = 0;
  depth_u.resize(N+1);
  depth_v.resize(N+1);
  
  dfs(Graph, u, -1, 0, depth_u);
  dfs(Graph, v, -1, 0, depth_v);

  std::vector< int > array;
  for(int i = 0; i < N+2; i++){
    if( depth_v[i] > depth_u[i] ){
      array.push_back(depth_v[i]);
    }
  }
  std::cout << *std::max_element(array.begin(), array.end()) - 1 << std::endl;

  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n, a, b;
int main() {
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 200'000;

int n, m, k;
set<int> st[N + 1];

void solve(int test)
{
  cin >> n >> m >> k;
  for (int i = 0; i < k; ++i) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    st[y].insert(x);
  }
  for (int i = 0; i < m; ++i)
    st[i].insert(n);
  int ans = inf;
  int x = 0, c = 0;
  for (int i = 0; i < m; ++i) {
    auto it = st[i].upper_bound(x);
    ans = min(ans, c + *it - x);
    if (x + 1 < *it) {
      ++x;
      ++c;
    }
    int old = *it;
    it = st[i + 1].find(x);
    while (x + 1 < old && it != st[i + 1].end() && *it == x) {
      ++c;
      ++x;
      it = st[i + 1].find(x);
    }
    if (x + 1 == old)
      break;
  }
  cout << ans;
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
      solve(i);
  //cout << endl << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count();
  return 0;
}



Measured memory_bytes: 28416
import copy
import math
import string

N,K = map(int,input().split())
p = list(map(int,input().split()))
k = [0]*N
s = [0]*(N+1)
for i in range(N):
    k[i] = (1+p[i])/2
    s[i+1] = s[i]+k[i]

ans = 0
for i in range(N+1):
    if i - K < 0:
        continue
    ans = max(ans,s[i]-s[i-K])
print(ans)

Measured memory_bytes: 26372
from sys import stdin
import math
import fractions
from collections import deque
import itertools

INF = 10 ** 10


# N個整数A1～AN, N=10^5
N = int(stdin.readline().rstrip())
A = list(map(int, stdin.readline().rstrip().split()))
A_abs = [abs(x) for x in A]

# 2個の整数x, yを選んで消し、新たに1個の整数x-yを書く
# ただ1つ残る整数としてありうる値の最大値Mと、その最大値を達成する操作列を求める

if N == 2:
    x = max(A)
    y = min(A)
    print(x-y)
    print(x, y)
    exit()

# 答え
result = []

plus_num = []
minus_num = []

for Ai in A:
    if Ai > 0:
        plus_num.append(Ai)
    else:
        minus_num.append(Ai)

plus_num_cnt = len(plus_num)
minus_num_cnt = len(minus_num)

if minus_num_cnt == 0:
    # マイナスを作る
    plus_num.sort(reverse=True)
    x = plus_num.pop()
    y = plus_num.pop()
    if x > y:
        tmp = x
        x = y
        y = tmp
    
    result.append([x, y])
    minus_num.append(x-y)
    plus_num_cnt -= 2
    minus_num_cnt += 1

elif plus_num_cnt == 0:
    # プラスを作る
    minus_num.sort()
    x = minus_num.pop()
    y = minus_num.pop()
    if x < y:
        tmp = x
        x = y
        y = tmp

    result.append([x, y])
    plus_num.append(x-y)
    minus_num_cnt -= 2
    plus_num_cnt += 1

    


if plus_num_cnt > 0 and minus_num_cnt > 0:

    while(plus_num_cnt > 0):
        if plus_num_cnt == 1:
            break

        x = minus_num.pop()
        y = plus_num.pop()

        result.append([x, y])
        minus_num.append(x-y)
        plus_num_cnt -= 1


    while minus_num_cnt > 0:
        x = plus_num.pop()
        y = minus_num.pop()

        result.append([x, y])
        plus_num.append(x-y)
        minus_num_cnt -= 1

    print(plus_num[0])
    for i, j in result:
        print(i, j)


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    for(int i = 0; i < s.size(); i++){
        for(int j = 0; j < s.size(); j++){
            string str = "";
            for(int k = 0; k < s.size(); k++){
                if(i <= k && k <= j) continue;
                else str += s[k];
            }

            if(str == "keyence"){
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;

    return 0;
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int A , B;
    cin >> A >> B;
    int ans = max({A+B, A-B, A*B});
    cout << ans << endl;
}

Measured memory_bytes: 256