akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
int N,M,Q;

void solve() {
    cin>>Q;
    int a,b,c;
    multiset<int> l, r;
    int ls=0, rs=0, bs=0;
    while(Q--) {
        cin>>c;
        if (c==2) {
            auto it = l.end();
            int lv = *(--it);
            int ans = bs;
            ans += lv * l.size() - ls;
            ans += rs - lv * r.size();
            out("%lld %lld\n", lv, ans);
            continue;
        }
        cin>>a>>b;
        bs += b;
        if (l.empty()) {
            l.insert(a);
            ls += a;
            continue;
        }
        auto it = l.end();
        int lv = *(--it);
        if (lv > a) {
            l.insert(a);
            ls += a;
            if (l.size() > r.size() + 1) {
                auto it = l.end();
                int lv = *(--it);
                r.insert(lv);
                l.erase(it);
                rs += lv;
                ls -= lv;
            }
            
        }
        else if (lv < a) {
            r.insert(a);
            rs += a;
            if (r.size() > l.size()) {
                int rv = *r.begin();
                l.insert(rv);
                r.erase(r.begin());
                ls += rv;
                rs -= rv;
            }
        }
        else {
            if (l.size() > r.size()) {
                r.insert(a);
                rs += a;
            } else {
                l.insert(a);
                ls += a;
            }
        }
    }
}

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

using namespace std;
using ll = long long;

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

int main() {
  int n, k;
  cin >> n >> k;
  int h[n];
  rep(i, n) cin >> h[i];

  sort(h, h + n);

  ll ans = 0;
  for (int i = 0; i < n - k; ++i) {
    ans += h[i];
  }

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


Measured memory_bytes: 1024
N, K = int(input()), 2
*h, = map(int, input().split())
a = [abs(h[0] - h[k]) for k in range(K)]
for n in range(N - K):
    a = a[1:] + [min([a[k] + abs(h[n + k] - h[n + K]) for k in range(K)])]
print(a[K - 1])


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

int main() {
    int n; cin >> n;
    vector<ll> t(n);
    for(int i = 0; i < n; i++){
        cin >> t[i];
    }
    ll l = t[0];
    for(int i = 1; i < n; i++){
        l = lcm(l, t[i]);
    }
    cout << l << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
using namespace std;

const int INF = INT_MAX/3;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
    int n;cin>>n;
    vector<pii> p(n+1);
    for(int i=0;i<n;i++) cin>>p[i].first>>p[i].second;

    vector<vi> mat(n+1,vi(n+1,INF));    //mat[i][j] : Mi*...*Mj???????°??????°
    for(int i=0;i<n;i++) mat[i][i] = 0;

    for(int sz=2;sz<=n;sz++){
        /*
         * mat[i][j] = min( mat[i][k]+mat[k+1][j]+Mi.first*Mk+1.first*Mk+1.second )
         */
      //  cout << "size = " << sz << endl;
        for(int i=0;i<=n-sz;i++){

            int j = i + sz - 1;

       //     cout << i << " : " << j << endl;

            for(int k=i;k<=j-1;k++){
        //        cout << i << ":" << j << ":" << mat[i][k] << ":" << mat[k+1][j] << endl;
                int tmp = mat[i][k] + mat[k+1][j] + p[i].first * p[k+1].first * p[j].second;
                //cout << tmp << endl;
                mat[i][j] = min(mat[i][j] , mat[i][k] + mat[k+1][j] + p[i].first * p[k+1].first * p[j].second);
            }
        }
    }

    /*
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout << mat[i][j] << "\t";
        }
        cout << endl;
    }
    */

    cout << mat[0][n-1] << endl;
}

Measured memory_bytes: 3168
#include<iostream>
#include<vector>
int main()
{
  int N,ans=0;		//3<=N<=20
  std::cin>>N;
  std::vector<int> P(N);
  for(int i=0;i<N;i++)
  {
    std::cin>>P[i];
  }
  
  for(int i=1;i<N-1;i++)
  {
    if(P[i-1]<P[i]&&P[i]<P[i+1]) ans++;
    else if(P[i-1]>P[i]&&P[i]>P[i+1]) ans++;
  }
  std::cout<<ans;
  return 0;
}

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


using namespace std;

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

typedef pair<int,int> pii;




pii parseAndCalc(string& st,int n){
    if(st[n]!='[') cerr << "???";
    n++;
    vector<int> v;
    pii r;

    for(;;){

        // cerr << "next: " << st[n] <<endl;

        if(st[n]=='['){
            r=parseAndCalc(st,n);
            v.push_back(r.first);
            n=r.second;
        }else if(st[n]==']'){
            // cout <<"!!!!!!!!!!!"<<endl;
            sort(v.begin(),v.end());
            int N=0;
            rep(i,v.size()/2+1){
                // cerr << "v["<<i<<"] = "<< v[i] <<endl;
                N+=v[i];
            }
            // cerr << "N : "<< N << endl;
            return pii(N,n+1);
        }else{
            int N=0;
            for(;st[n]!=']';n++) N=N*10+st[n]-'0';
            return pii(N/2+1,n+1);
        }
    }

}


int main(void){
    int numOdData;

    cin >> numOdData;

    while(numOdData--){
        string st;

        cin >> st;
        pii r = parseAndCalc(st,0);

        cout << r.first << endl;


    }
    return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>

int main(void){

	int i;
	int sum=0;
	while(1){
		char A[1002]={};
	scanf("%s",&A);
	if(A[0]=='0') break;
	sum=0;
	for(i=0;i<1000;i++){
		switch(A[i]){
			case '1':sum +=1; break;
			case '2':sum +=2; break;
			case '3':sum +=3; break;
			case '4':sum +=4; break;
			case '5':sum +=5; break;
			case '6':sum +=6; break;
			case '7':sum +=7; break;
			case '8':sum +=8; break;
			case '9':sum +=9; break;
		}
	}
		printf("%d\n",sum);
	}

	return 0;
}

Measured memory_bytes: 536
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
string S;
void input(){
    fast_io();
    cin >> N >> S;
}

char rev(char x){
    if(x=='S') return 'W';
    return 'S';
}

bool make(char init, char sec){
    string ans(N,'.');
    ans[0] = init;
    ans[1] = sec;
    for (int i = 1; i <= N; i++)
    {
        if(ans[i%N]=='S' && S[i%N]=='o'){
            ans[(i+1)%N] = ans[i-1];
        }
        else if(ans[i%N]=='S' && S[i%N]=='x'){
            ans[(i+1)%N] = rev(ans[i-1]);
        }
        else if(ans[i%N]=='W' && S[i%N]=='o'){
            ans[(i+1)%N] = rev(ans[i-1]);
        }
        else if(ans[i%N]=='W' && S[i%N]=='x'){
            ans[(i+1)%N] = (ans[i-1]);
        }
    }
    if(ans[0]==init && ans[1]==sec){
        cout << ans << endl;
        return true;
    }
    return false;
}

int solve(){
    if(make('S','S')) return 0;
    if(make('S','W')) return 0;
    if(make('W','S')) return 0;
    if(make('W','W')) return 0;
    cout << -1 << endl;
    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  int n;
  cin >> n;
  vector<double> p(n);
  rep (i, n) {
    cin >> p[i];
  }
  vector<vector<double> > dp(n + 1, vector<double>(2*n + 1));
  dp[0][n] = 1;
  rep1 (i, n) {
    rep (j, 2 * n + 1) {
      if (j != 0) {
        dp[i][j] += dp[i - 1][j - 1] * p[i - 1];
      }
      if (j != 2 * n) {
        dp[i][j] += dp[i - 1][j + 1] * (1 - p[i - 1]);
      }
    }
  }
  /*
  rep (i, n + 1) {
    rep (j, 2 * n + 1) {
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  //*/
  double ans = 0;
  for (int j = n + 1; j <= 2*n; j++) {
    ans += dp[n][j];
  }
  Sp(ans);
}


Measured memory_bytes: 141056
#include<stdio.h>
 
int main()
{
  int i,j,N,col,max;
  int flag[8]={0};
  j=0;
  col=0;
  scanf("%d",&N);
  int a[N];
  for(i = 0;i<N;i++){
    scanf("%d",&a[i]);
  }
  for(i = 0;i < N;i++){
    if(1<=a[i] && a[i] <= 399){
      flag[0] =1;
    }else if(a[i] <= 799){
      flag[1] =1;
    }else if(a[i] <= 1199){
      flag[2] =1;
    }else if(a[i] <= 1599){
     flag[3] =1;
    }else if(a[i] <= 1999){
      flag[4] =1; 
    }else if(a[i] <= 2399){ 
      flag[5] =1;
    }else if(a[i] <= 2799){
     flag[6] =1;    
    }else if(a[i] <= 3199){
      flag[7] =1;
    }else{
      j++;
    }
  }
    for(i=0;i<8;i++){
    	col+=flag[i];
    }
  max = col+j;
  if(col ==0){ 
    col=1;
    max = j;
  }
  printf("%d %d\n",col,max);
  return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import fractions
s = lambda n: sum(map(int, str(n)))

cands = []
for a in range(1000):
    for b in range(20):
        cands += [ a * 10 ** b + (10 ** b - 1) ]

snukes = []
min_f = float('inf')
for n in reversed(sorted(cands)):
    if n == 0 or (snukes and snukes[-1] == n):
        continue
    f = fractions.Fraction(n, s(n))
    if f <= min_f:
        min_f = f
        snukes += [ n ]
snukes.reverse()

k = int(input())
for n in snukes[: k]:
    print(n)


Measured memory_bytes: 6616
#include<cstdio>
long long x,y;
long long ww(long long a)
{
	if(a<0)a=-a;
	return a;
}
int main()
{
	scanf("%lld%lld",&x,&y);
	if(ww(x-y)<2)
		printf("Brown");
	else printf("Alice");
}

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

int main() {
  int n,x,sum = 0;
  int max;
  cin >> n >> x;
  vector<int>num(n);
  for (int i = 0; i < n; i++) {
    cin >> num.at(i);
  }
  for (int i = 0; i < n; i++) {
    max += num.at(i);
  }
  if (x >= max) cout << n+1;
  else {
    for (int i = 0; i < n; i++) {
      sum += num.at(i);
      if (sum > x) {
        cout << i+1;
        break;
      }
    }
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <sstream>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;

int A[4][4];
int B[4][4];
int N;

int main() {
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> A[i][j];
            B[i][j] = 0;
        }
    }
    cin >> N;
    int b;
    for (int n = 0; n < N; ++n) {
        cin >> b;
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (b == A[i][j]) {
                    B[i][j] = 1;
                }
            }
        }
    }

    bool flag = true;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (B[i][j] == 0) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << "Yes" << endl;
            return 0;
        } else {
            flag = true;
        }
    }

    flag = true;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (B[j][i] == 0) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << "Yes" << endl;
            return 0;
        } else {
            flag = true;
        }
    }

    flag = true;
    for (int i = 0; i < 3; ++i) {
            if (B[i][i] == 0) {
                flag = false;
                break;
            }
    }
    if (flag) {
        cout << "Yes" << endl;
        return 0;
    }

    flag = true;
    for (int i = 0; i < 3; ++i) {
        if (B[i][2-i] == 0) {
            flag = false;
            break;
        }
    }
    if (flag) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

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

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define log(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}



// TODO: write
int main() {
  ll a,b,n;cin>>a>>b>>n;
  if(b > n){
    print(a*n/b);
    return 0;
  }else{
    print(a*(b-1)/b);
  }
  return 0; 
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int temp = sc.nextInt();
	    if (temp >= 30) {
	        System.out.println("Yes");
	    } else {
	        System.out.println("No");
	    }
	}
}


Measured memory_bytes: 27052
import java.awt.geom.Point2D;
import java.util.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            if(n==0) break;
            Point2D.Double[] p = new Point2D.Double[n];
            for(int i=0;i<n;i++){
                String[] s = sc.next().split(",");
                double a = Double.valueOf(s[0]);
                double b = Double.valueOf(s[1]);
                p[i] = new Point2D.Double(a,b);
            }
            int max = 1;
            for(int i = 0; i < n; i++){
                for(int j = i + 1; j < n; j++){
                    if(p[i].distance(p[j]) <= 2.00001){
                        double xa = p[i].x, ya = p[i].y, xb = p[j].x, yb = p[j].y;
                        double[] x = new double[2];
                        double[] y = new double[2];
                        double A = xa - xb;
                        double B = ya - yb;
                        double C = (A*xa + A*xb + B*ya + B*yb)/2;
                        if(A==0){
                           double c = (C/B - ya)*(C/B - ya)+xa*xa - 1;
                            x[0] = xa + sqrt(xa*xa - c);
                            x[1] = xa - sqrt(xa*xa - c);
                            y[0] = C/B;
                            y[1] = C/B;
                        }else if(B==0){
                            double c = (C/A-xa)*(C/A-xa)+ya*ya-1;
                            y[0] = ya + sqrt(ya*ya - c);
                            y[1] = ya - sqrt(ya*ya - c);
                            x[0] = C/A;
                            x[1] = C/A;
                        }else{
                            double a = 1 + (A*A) / (B*B);
                            double b = (2*A*ya*B - 2*A*C - 2*xa*B*B)/(B*B);
                            double c = (C/B - ya)*(C/B - ya) + xa*xa - 1;
                            x[0] = (-b + sqrt(b*b - 4*a*c))/(2*a);
                            x[1] = (-b - sqrt(b*b - 4*a*c))/(2*a);
                            y[0] = (C - A*x[0])/B;
                            y[1] = (C - A*x[1])/B;
                        }
                         
                        for(int k = 0; k < 2; k++){
                            int cnt = 0;
                            for(int l = 0; l < n; l++){
                                if(p[l].distance(x[k],y[k]) <= 1.00001) cnt++;
                            }
                            max = max(max, cnt);
                        }
                    }
                }
            }
            System.out.println(max);
        }
    }   
}

Measured memory_bytes: 29592
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 200000
int a[MN+5],b[MN+5];
int main()
{
	int n=read(),i,j,ans=0,s;
	for(i=1;i<=n;++i)a[i]=read();
	for(i=1;i<=n;++i)b[i]=read();
	for(i=28;i>=0;--i)
	{
		for(j=1;j<=n;++j)a[j]&=(1<<i+1)-1,b[j]&=(1<<i+1)-1;
		sort(b+1,b+n+1);
		for(s=0,j=1;j<=n;++j)
			s+=b+n+1-
			   lower_bound(b+1,b+n+1,(1<<i+1)+(1<<i)-a[j])+
			   lower_bound(b+1,b+n+1,(1<<i+1)-a[j])-
			   lower_bound(b+1,b+n+1,(1<<i)-a[j]);
		if(s&1)ans+=1<<i;
	}
	printf("%d",ans);
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

ll factmod(ll a,ll b,ll m) {
  if(a<b)return 0;
  ll s=1;
  while(a>=b){
    s = s*a % m;
    a -= 1;
  }
  return s;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

ll combmod(ll a,ll b,ll m){
  if(b==0)return 1;
  ll c=factmod(a,a-b+1,m);
  ll d=modinv(factmod(b,1,m),m);
  ll e=(c*d)%m;
  return e;
}

ll powmod(ll a,ll n,ll m) {
    if(n == 0)
        return 1;

    if(n % 2 ==0){
        ll r = powmod(a,n/2,m);
        return r*r % m;
    }

    return a*powmod(a,n-1,m)%m;
}

int main(){

  ll k;
  string s;
  cin >> k >> s;
  ll n=s.size();
  
  ll t=0;
  ll c,d,e;
  ll a=1;
  c=combmod(n+k-1,n-1,mod);
  d=powmod(25,k,mod);
  e=powmod(26,0,mod);
  a*=c;
  a%=mod;
  a*=d;
  a%=mod;
  a*=e;
  a%=mod;
  t+=a;
  t%=mod;

  for(int i=1;i<=k;i++){
    a=1;
    c=(((c*modinv(n+k-i,mod))%mod)*(k-i+1))%mod;
    a*=c;
    d=(d*modinv(25,mod))%mod;
    a=(a*d)%mod;
    e=e*26%mod;
    a=a*e%mod;
    t+=a;
    t%=mod;
  }

  cout << t << endl;



}

Measured memory_bytes: 5232
from heapq import heappush, heappop
from collections import deque
import itertools
from itertools import permutations
import sys
import bisect
sys.setrecursionlimit(10**6)
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
YNeos='YNeos'
mo=10**9+7

s=input()

n=len(s)
b=[]
a=[0]*n

for i in range(n-1):
    if s[i:i+2]=='RL':
        b.append(i)

j=0
for i in range(n):
    if (b[j]-i)%2==0:
        a[b[j]]+=1
    else:
        a[b[j]+1]+=1
    if i<n-1 and s[i:i+2]=='LR':
        j+=1

print(*a)


Measured memory_bytes: 47932
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
  
      int a[] = new int[100];
      int n = 0;
      for(int i=1; i<=Math.min(A,B); i++){
      if(A%i==0 && B%i==0){
        n+=1;
        a[n] =i;
        }
      }
     System.out.println(a[n-K+1]);
    }
}
        

Measured memory_bytes: 21844
n, _ = map(int, input().split())
L = list(map(int, input().split()))
weight = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-1] * (n+1)
dp[0] = 0

for i in range(n+1):
    for a in L:
        if i+weight[a] < n+1:
            dp[i+weight[a]] = max(dp[i+weight[a]], dp[i]*10+a)

print(dp[n])

Measured memory_bytes: 14692
#include <bits/stdc++.h>
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)

int main( void ){
	int a, b, x;
	if (!scanf( "%d%d%d", &a, &b, &x ))
		return -1;
	if (a <= x && a+b >=x)
		printf( "YES\n" );
	else
		printf( "NO\n" );
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int yoso[100][100];
	int qty_r,qty_c;
	int i,j;
	int sum=0;
	int sum_i[100];
	int all_sum = 0;
	
	scanf("%d %d",&qty_r,&qty_c);
	
	for(i=0;i<100;i++)
	{
		sum_i[i] = 0;
	}
	
	for(i=0;i<qty_r;i++)
	{
		for(j=0;j<qty_c;j++)
		{
			scanf("%d",&yoso[i][j]);
		}
	}
	
	for(j=0;j<qty_c;j++)
	{
		for(i=0;i<qty_r;i++)
		{
			sum_i[j] += yoso[i][j];
		}
	}
	
	for(i=0;i<qty_r;i++)
	{
		sum = 0;
		
		for(j=0;j<qty_c;j++)
		{
			printf("%d ",yoso[i][j]);
			
			sum += yoso[i][j];
		}
		printf("%d",sum);
		
		printf("\n");
	}
	
	for(j=0;j<qty_c;j++)
	{
		printf("%d ",sum_i[j]);
	}
	
	for(j=0;j<qty_c;j++)
	{
		all_sum += sum_i[j];
	}
	
	printf("%d",all_sum);
	
	printf("\n");
	
	return 0;
}

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

const int N = 1e5 + 3;
int n, a[N];//, sg[N][N];

// int mex(set<int> st){
//     for(int i = 0; ; i++) if(st.find(i) == st.end()) return i;
// }
// int SG(int x, int y){
//     return mex(set<int>{sg[x][y + 1], sg[x + 1][y]});
// }

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a + 1, a + 1 + n); reverse(a + 1, a + 1 + n);
    for (int i=0;i<=n;i++)
		if (i+1>a[i+1])
		{
			int r=i;
			while (a[r+1]==i) r++;
			puts((((a[i]-i)&1)||((r-i)&1))?"First":"Second");
			break;
		}
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back
#define fi first
#define be begin()
#define en end()
#define se second

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

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; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int a,b;
  cin>>a>>b;
  if (a > b){
    cout << a -1 << endl;
  }else{
    cout << a << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;

int main() {
  int N, L;
  cin >> N >> L;
  vector<pair<int, int>> v;
  for (int i = 1; i <= N; ++i) {
    int A = L + i - 1;
    v.push_back(make_pair(abs(A), A));
  }
  sort(v.begin(), v.end());
  int total = 0;
  for (int i = 1; i < N; ++i) {
    total += v[i].second;
  }
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
 
n = int(input())
a = list(map(int, input().split()))
q = int(input())
 
counter = Counter(a)
sum_res = sum(a)
 
for _ in range(q):
  b, c = map(int, input().split())
 
  sum_res += (c - b) * counter[b]
 
  counter[c] += counter[b]
  counter[b] =0
 
  print(sum_res)

Measured memory_bytes: 24004
N = int(input())
alphabet = [chr(i) for i in range(97, 97+26)]

n = 1
s = 26
for i in range(1,12):
    if N <= s:
        n = i
        break
    else:
        s += 26**(i+1)
        
s = 0
for i in range(1,n):
    s += 26**i
    
N = N - s - 1
if N == 0:
    Ans = ""
    for _ in range(n):
        Ans += "a"
else:
    L = [0 for _ in range(n)]
    i = 1
    while N > 0:
        L[-i] = N%26
        N = N//26
        i +=1
    
    Ans = ""
    for x in L:
        Ans += alphabet[x]
print(Ans)

Measured memory_bytes: 9252
#include<iostream>
using namespace std;
int main(){
  long A,B;
  cin>>A>>B;
  long temp,m,n;
  m=A;
  n=B;
  while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
  cout<<((A*B)/n);
  return 0;
}

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

std::string s;

void solve( std::string s ) {
    std::vector<int> v;
    for (int i=0; i<s.length(); ++i) {
        v.push_back( s[i] - '0' );    
    }
    /*
    std::cout << "INITIAL STATE OF VECTOR V :\n";
    for (std::vector<int>::iterator itr=v.begin(); itr != v.end(); ++itr) std::cout << std::setw(2) << *itr;
    std::cout << std::endl;
    */
    for (int i=v.size()-1; i>0; --i) {
        std::vector<int> w;
        for (int j=0; j<i; ++j) {
            int a = (v[j] + v[j+1])%10;
            w.push_back( a );
        }
        v = w;
        /*
        for (std::vector<int>::iterator itr=v.begin(); itr != v.end(); ++itr) std::cout << std::setw(2) << *itr;
        std::cout << std::endl;
        */
    }
    std::cout << *(v.begin()) << std::endl;
}

int main() {
    while (std::cin >> s) {
        solve( s );
    }
    return 0;
}



Measured memory_bytes: 3208
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)

//C++で提出








int main()
{
	long long int w;
	
	cin >> w;
	long long int i=2;
	long long int j;
	long long int t=0;
	long long int min = w;
	
	int k=0;
	

	for (i = 3; i <= sqrt(w); i+=2) {
		if (w % i == 0 ||w%2==0) k = 1;
	}
	if (k == 0 || w==2) {
		cout << w - 1;
		return 0;
	}
	i = 2;


	while(i<=sqrt(w)) {
		if (w % i == 0) {
			j = (w / i);
			
			t = i + j - 2;

			if (t < min) min=t;

		}
		i++;
		
	}
	cout << min;
	
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define LL long long
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

int main(void) {
	int N, M;
	cin >> N >> M;

	vector<int> city(N + 1);
	for (int i = 0; i < M; i++)
	{
		int a, b;
		cin >> a >> b;

		city[a]++;
		city[b]++;
	}

	for (int i = 1; i <= N; i++)
	{
		cout << city[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if(a == 1) a = 14;
  if(b == 1) b = 14;
  cout << (a == b ? "Draw" : a > b ? "Alice" : "Bob") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> v(2*N);
  rep(i,2*N)cin >> v[i];
  sort(all(v));
  int ans = 0;
  rep(i,N)ans += v[2*i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FS r = new FS();
		int N = r.nextInt();
		int M = r.nextInt();
		int MOD = 1000000007;
		// dp[days][added town][looped size]
		int[][][] dp = new int[M+1][N+1][N+1];
		dp[0][1][1] = 1;
		for(int i=0; i<M; i++) {
			for(int j=0; j<=N; j++) {
				for(int k=0; k<=N; k++) {
					// add town unused
					if(j!=N) {
						dp[i+1][j+1][k] += (int)(((long)dp[i][j][k]*(N-j))%MOD);
						dp[i+1][j+1][k] %= MOD;
					}
					// add town used but not in loop
					dp[i+1][j][k] += (int)(((long)dp[i][j][k]*(j-k))%MOD);
					dp[i+1][j][k] %= MOD;
					// add town used and in loop
					dp[i+1][j][j] += (int)(((long)dp[i][j][k]*k)%MOD);
					dp[i+1][j][j] %= MOD;
				}
			}
		}
		System.out.println(dp[M][N][N]);
	}

	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}

		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}

Measured memory_bytes: 144632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;

int main(void) {
  int n, a, b; cin >> n >> a >> b;
  string s; cin >> s;
  int pass = 0;
  int rankB = 1;
  for(char c: s){
    if (c == 'c') yes(0)
    else if (c == 'a') {
      if (a+b > pass) {
        ++pass;
		yes(1);
      }else{
        yes(0);
      }
    } else if (c == 'b') {
      if (a+b > pass && rankB <= b){
        ++pass;
        ++rankB;
        yes(1);
      } else {
        yes(0);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3724
import math
def combinatorial(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
 
N, K = (int(x) for x in input().split())
for i in range(1, K+1):
    if N-K+1 >= i:
        ans = combinatorial(K-1, i-1)*combinatorial(N-K+1, i)%(10**9+7)
    else:
        ans = 0
    print(ans)

Measured memory_bytes: 3316
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int N;
    while (cin >> N, N) {
        // Q[d][i] := d 周期の i 時間目の量（0 < i < d）
        // 周期ごとにアクセス数をまとめる（t 時間のずれを吸収）
        vector<vector<int>> Q(25, vector<int>(25, 0));
        for (int i = 0; i < N; i++) {
            int d, t; cin >> d >> t;
            for (int j = 0; j < d; j++) {
                int q; cin >> q;
                Q[d][(j + d - t) % d] += q;
            }
        }
        const int L = 55440;
        vector<int> T(L, 0);
        int cop = 0;
        for (int i = 1; i <= 24; i++) {
            if (i == 13 || i == 17 || i == 19 || i == 23) {
                cop += *max_element(Q[i].begin(), Q[i].end());
            } else {
                for (int j = 0; j < L; j++) T[j] += Q[i][j % i];
            }
        }
        cout << cop + *max_element(T.begin(), T.end()) << endl;
    }
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int H[101010];
vector<int> E[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N) cin>>H[i];
	FOR(i,M) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	int ret=0;
	FOR(i,N) {
		ret++;
		FORR(e,E[i]) if(H[e]>=H[i]) {
			ret--;
			break;
		}
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ld long double
#define ff first
#define ss second

using namespace std;

int main() {
    pair <float, float> t, a;

    cin >> t.ff >> t.ss;
    cin >> a.ff >> a.ss;

    float t_turns = ceil(a.ff / t.ss), a_turns = ceil(t.ff / a.ss);
    // cout << "T = " << t_turns << endl;
    // cout << "A = " << a_turns << endl;

    if(t_turns <= a_turns) {
        cout << "Yes" << endl;
    }

    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3716
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        HashSet<Integer>[] map = new HashSet[N+1];
        for(int i=0;i<=N;i++) map[i]=new HashSet<>();
        for(int i=1;i<=N-1;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            map[a].add(b);
            map[b].add(a);
        }
        int[] color = new int[N+1];
        color[1]=1; // black is 1
        color[N]=-1; // white is -1;
        boolean isBlack = true;
        LinkedList<Integer> bCur = new LinkedList<>();
        LinkedList<Integer> bNext = new LinkedList<>();
        LinkedList<Integer> wCur = new LinkedList<>();
        LinkedList<Integer> wNext = new LinkedList<>();
        bCur.add(1);
        wCur.add(N);
        while(bCur.size()>0||wCur.size()>0){
            if(isBlack&&bCur.size()==0){
                isBlack = false;
                continue;
            }
            if((!isBlack)&&wCur.size()==0){
                isBlack=true;
                continue;
            }
            if(isBlack){
                int cur = bCur.poll();
                for(Integer w:map[cur]){
                    if(color[w]==0){
                        color[w]=1;
                        bNext.add(w);
                    }
                }
                if(bCur.size()==0){
                    bCur = bNext;
                    bNext = new LinkedList<>();
                    isBlack = !isBlack;
                }
            } else{
                int cur = wCur.poll();
                for(Integer w:map[cur]){
                    if(color[w]==0){
                        color[w]=-1;
                        wNext.add(w);
                    }
                }
                if(wCur.size()==0){
                    wCur = wNext;
                    wNext = new LinkedList<>();
                    isBlack = !isBlack;
                }
            }
        }
        int bCnt = 0;
        for(int i=1;i<=N;i++){
            if(color[i]==1) bCnt++;
        }
        String ans = "Snuke";
        if(bCnt>N-bCnt) ans = "Fennec";
        System.out.println(ans);
    }
}


Measured memory_bytes: 115988
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

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

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

    int n;
    cin >> n;

    vs32 a(n);
    rep (i, n) cin >> a[i];

    int g = 0;
    rep (i, n) g = gcd(g, a[i]);
    rep (i, n) a[i] /= g;

    sort(a.begin(), a.end());

    vector< bool > check(1000001, true);
    vector< bool > same(1000001, false);
    for (auto item : a)
    {
        if (same[item])
        {
            check[item] = false;
        }
        else if (check[item])
        {
            for (int j = item + item; j <= 1000000; j += item)
            {
                check[j] = false;
            }
            same[item] = true;
        }
    }

    int ans = 0;
    rep (i, a.size())
    {
        ans += check[a[i]];
    }
    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 4296
#include<stdio.h>

int main() {

 int x, n, ans=0, i, j, k;
 
   while(1) {
      ans=0;
      scanf("%d%d",&n,&x);
      if(x==0 && n==0)
         break;
      for(i=1; i<=n; i++)
         for(j=i+1; j<=n; j++)
            for(k=j+1; k<=n; k++)
               if(i+j+k==x)
                  ans=ans+1;
      printf("%d\n",ans);
   } 
   return 0;
} 

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int num=0,a[1000];
	for(int i='a';i<='z';i++)a[i]=0;
	for(int i=0;i<s.length();i++)a[s[i]]++;
	for(int i='a';i<='z';i++)if(a[i]!=0)num++;
	if(s.length()==6&&s[2]==s[3]&&s[4]==s[5])cout<<"Yes";
	else cout<<"No";
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> v(M+1);

    for(int i=0; i<N; i++) {
        int k;
        cin >> k;
        for(int j=0; j<k; j++) {
            int x;
            cin >> x;
            v[x]++;
        }
    }

    int count = 0;
    for(int i=0; i<v.size(); i++) {
        if(v[i] == N) {
            count++;
        }
    }
    cout << count << endl;
}



Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int k,a,b;
    cin >> k;
    cin >> a >>b;
    rep(i,a,b){
        if(i%k == 0){
            puts("OK");
            return 0;
        }
    }
    puts("NG");
    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3636
/*#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef unsigned long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
struct bity
{
	#define d 64
	vector<ll> wek;
	bity(){}
	bity(int v)
	{
		wek.resize((v/d)+2, 0);
	}
	void upper(int v)
	{
	    while(wek.size() < (v/d)+2) wek.pb(0);
	}
	void upp(int v){
	    while(wek.size() < v) wek.pb(0);
	}
	void ustaw(int v)
	{
		wek[v/d]|=(1LL<<(v%d));
	}
	void zeruj()
	{
		fill(wek.begin(), wek.end(), 0);
	}
	int licz()
	{
		int ret=0;
		for (const ll &i : wek)
			ret+=__builtin_popcountll(i);
		return ret;
	}
};
 
void oruj(bity &a, const bity &b)
{
	int r=min(a.wek.size(), b.wek.size());
	for (int i=0; i<r; i++)
		a.wek[i]|=b.wek[i];
}

int n;
char f[1505][1505];
bity B[10][1505];
ll ans;
int C[10];
int cur[10];
int main(){
	scanf("%d",&n); //n = 950; srand((unsigned)time(NULL));
	for(int i=0;i<n;i++) scanf("%s",&f[i]);
	rep(i,n)rep(j,n)if(f[i][j]!='#')C[f[i][j]-'0']++;
	//repn(x,9) rep(i,n) B[x][i] = bity(0);
	for(int i=0;i<2*n-1;i++){
		for(int j=min(i,n-1);j>=max(0,i-n+1);j--){
			int x = j, y = i-j;
			if(f[x][y] != '#'){
			    B[f[x][y]-'0'][x].upper(cur[f[x][y]-'0']+1);
			    repn(w,9) B[w][x].upp(B[w][x-1].wek.size());
				if(x){
				    repn(w,9) oruj(B[w][x],B[w][x-1]);
				}
				repn(w,9) ans += 1LL*w*(f[x][y]-'0')*(B[w][x].licz());
				B[f[x][y]-'0'][x].ustaw(cur[f[x][y]-'0']++);
			}
			else{
			    repn(w,9) B[w][x].upp(B[w][x-1].wek.size());
				repn(w,9) B[w][x].zeruj();
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 20224
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<utility>
#include<set>
#include<string>
using namespace std;
typedef pair<int, int>P;
set<P>st;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	int ns = 0;
	while (1) {
		if ((a & 1) ||( b & 1) || (c & 1))break;
		int ha = a / 2, hb = b / 2, hc = c / 2;
		a = hb + hc, b = ha + hc, c = ha + hb;
		st.insert(P(a, b));
		if (st.size() == ns) {
			ans = -1;
			break;
		}
		ns++;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
int main()
{
	SPEED
	int s;
	cin >> s;
	if(s==0)
	{
		cout << 1;
	}
	else
	{
		cout << 0;
	}
	return 0;
}

Measured memory_bytes: 3648