akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Aman Kumar Singh
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AHarmony solver = new AHarmony();
        solver.solve(1, in, out);
        out.close();
    }

    static class AHarmony {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            int a = ni();
            int b = ni();
            int mx = Math.max(a, b);
            int mn = Math.min(a, b);
            if ((mx - mn) % 2 == 0) {
                pn(mn + (mx - mn) / 2);
            } else {
                pn("IMPOSSIBLE");
            }

        }

        int ni() {
            return in.nextInt();
        }

        void pn(long zx) {
            out.println(zx);
        }

        void pn(String zx) {
            out.println(zx);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new UnknownError();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

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

        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 21460
l, r = map(int, input().split())

def mod2019(x):
    return x % 2019

s = True

if r-l < 2019:
    s = False

ans = 2019*2019

if s is True:
    print(0)
else:
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            kari = mod2019(i*j)
            if kari < ans:
                ans = kari
    print(ans)


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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if((A+B)<(C+D)){
    cout << "Right" << endl;
  }
  if((A+B)==(C+D)){
    cout << "Balanced" << endl;
  }
  if((A+B)>(C+D)){
    cout << "Left" << endl;
  }
}

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A[i];
    }

    ll M;
    cin >> M;

    vector<ll> B(M);
    FOR(i, 0, M){
        cin >> B[i];
    }

    FOR(i, 0, min(N, M)){
        if(A[i]<B[i]){
            p(1);
            return 0;
        }
        else if(A[i]>B[i]){
            p(0);
            return 0;
        }
    }

    if(N>=M){
        p(0);
    }else{
        p(1);
    }

    return 0;
}


Measured memory_bytes: 3180
#include <stdio.h>
int bubbleSort(int A[],int N);
int main(void)
{
	int i,n,result;
	scanf("%d", &n);
	int a[n];
	
	for(i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	
	result=bubbleSort(a,n);
	
	for(i=0; i<n; i++){
		if(i < n-1){
			printf("%d ",a[i]);
		}
		else{
			printf("%d",a[i]);
		}
	}
	printf("\n");
	printf("%d\n", result);
	
	return 0;
}
int bubbleSort(int A[],int N){
	int result=0,flag = 1,tmp;
	for(int i = 0; flag; i++){
		flag=0;
		for(int j = N-1; j>= i + 1; j--){
			if(A[j] < A[j-1]){
				tmp=A[j];
				A[j]=A[j-1];
				A[j-1]=tmp;
				flag=1;
				result++;
			}
		}
	}
	return result;
}



Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,m;
	cin>>n>>m;
	bool ac[100010]={false};
	ll wa[100010]={};
	for(ll i=0;i<m;i++){
		ll now;string s;
		cin>>now>>s;
		now--;
		if(s=="WA"){
			if(ac[now]==false){
				wa[now]++;
			}
		}
		else{
			ac[now]=true;
		}
	}
	ll accnt=0;ll wacnt=0;
	for(ll i=0;i<n;i++){
		if(ac[i]){
			accnt++;
			wacnt+=wa[i];
		}
	}
	cout << accnt<<" "<<wacnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 4472
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <assert.h>
#include <climits>
using namespace std;
#define ll long long int
 int main()
 {
     int A,B,C;
     int K;
     cin >> A >> B>>C>>K;
     int ans=0;
     while(A>=B){
         B=B*2;
         ans++;
              }
              while(B>=C){
                  C=C*2;
                  ans++;

              }
              if(ans<=K)
              cout << "Yes";
              else
              {
                  cout << "No";
              }
              
 }

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

const int MAX = 1e5+10;

ll N, K, Q;
ll A[MAX];
ll cnt[MAX];

void solve() {
    REP (q, Q) cnt[A[q]]++;
    FOR (i, 1, N+1) {
        string ans = (cnt[i] + K - Q >= 1) ? "Yes" : "No";
        cout << ans << endl;
    }
}

int main() {
    cin >> N >> K >> Q;
    REP (q, Q) cin >> A[q];
    solve();
}

Measured memory_bytes: 2176
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
#include <random>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

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

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

int main() {

    ll N,K; cin >> N >> K;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];

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

    if(K < A[0] || K > A[N-1]) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    ll g = A[0];
    REP(i,N-1) {
        g = gcd(g,A[i+1]);
    }

    if(g == 1) {
        cout << "POSSIBLE" << endl;
    } else {
        if(gcd(g,K) == 1) {
            cout << "IMPOSSIBLE" << endl;
        } else{
            cout << "POSSIBLE" << endl;
        }
    }

    return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long M, long long X, long long Y, std::vector<long long> x, std::vector<long long> y){
    LL maxX = -1000;
    x.PB(X);
    y.PB(Y);
    REP(i, x.size()) maxX = max(maxX, x[i]);

    REP(i, y.size()) {
        if(y[i] <= maxX) {
            cout << "War" << endl;
            return;
        }
    }

    cout << "No War" << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    std::vector<long long> x(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
    }
    std::vector<long long> y(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&y[i]);
    }
    solve(N, M, X, Y, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const ll MOD = 998244353;
//}}}

ll f[300010] = {0};

ll mod_pow(ll x, ll n){
  ll res = 1LL;
  while(n > 0){
    if(n & 1) res = res * x % MOD;
    x = x*x % MOD;
    n >>= 1;
  }
  return res;
}

ll mod_inv(ll x){
  return mod_pow(x, MOD-2) % MOD;
}

ll comb_mod(int n, int r){
  return (((f[n] * mod_inv(f[r])) % MOD) * mod_inv(f[n-r])) % MOD;
}

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;}

ll comb[300001];

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

  f[0] = f[1] = 1;
  for(int i=2; i<=N; ++i) f[i] = (i * f[i-1]) % MOD;

  rep(i, N + 1){
    comb[i] = comb_mod(N, i);
  }

  ll ans = 0;
  rep(a, 0, N + 1){
    if((K - a * A) % B != 0) continue;
    ll b = (K - a * A) / B;
    if(b < 0) continue;
    if(b > N) continue;

    ll add = comb[a] * comb[b];
    add %= MOD;
    ans += add;
    ans %= MOD;
  }

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


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;

int main(){
  int n;cin>>n;
  for(int j=0;j<n;++j){
    vector<char> a(8);
    for(int i=0;i<8;++i){
      cin>>a[i];
    }
    vector<char> b=a;
    sort(begin(a),end(a),greater<char>());
    sort(begin(b),end(b));

    string max_(a.begin(),a.end()),min_(b.begin(),b.end());
    cout << stoi(max_) - stoi(min_) << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
n = int(input())
import itertools
orig = list(itertools.permutations( list(range(1, n+1))))
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
#print(orig)
pn = orig.index(p)
qn = orig.index(q)
print(abs(pn-qn))


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

#define all(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int n, d ;
  cin >> n >> d ;
  
  if(n%(2*d+1)==0){
    cout <<n/(2*d+1)<<endl ;
  }
  else{
    cout <<n/(2*d+1)+1<<endl ;
  }
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    int A[3], B[3];
    cin >> N;
    for (int i = 0; i < 3; ++i)
        cin >> A[i];
    for (int i = 0; i < 3; ++i)
        cin >> B[i];

    int cnt = 0;
    for (int i = 0; i < 3; ++i)
        cnt += A[i] < B[i];

    ll ans = N;
    if (cnt == 0) {
        // B -> A
        for (int i = 0; i * B[0] <= N; ++i) {
            for (int j = 0; i * B[0] + j * B[1] <= N; ++j) {
                int k = N - i * B[0] - j * B[1];
                ll tmp = (ll)i * A[0] + j * A[1] + (k / B[2]) * A[2] + k % B[2];
                ans = max(ans, tmp);
            }
        }
    } else if (cnt == 1) {
        int idx = 0;
        for (int i = 0; i < 3; ++i)
            if (A[i] < B[i])
                idx = i;
        swap(A[0], A[idx]);
        swap(B[0], B[idx]);
        N = (N / A[0]) * B[0] + N % A[0];

        for (ll i = 0; i * B[1] <= N; ++i) {
            ll j = N - i * B[1];
            ll tmp = (ll)i * A[1] + (j / B[2]) * A[2] + j % B[2];
            ans = max(ans, tmp);
        }
    } else if (cnt == 2) {
        int idx = 0;
        for (int i = 0; i < 3; ++i)
            if (A[i] >= B[i])
                idx = i;
        swap(A[2], A[idx]);
        swap(B[2], B[idx]);
        for (ll i = 0; i * A[0] <= N; ++i) {
            ll j = N - i * A[0];
            ll tmp = (ll)i * B[0] + (j / A[1]) * B[1] + j % A[1];
            ans = max(ans, tmp);
        }

        ans = (ans / B[2]) * A[2] + ans % B[2];
    } else {
        // A -> B
        for (int i = 0; i * A[0] <= N; ++i) {
            for (int j = 0; i * A[0] + j * A[1] <= N; ++j) {
                int k = N - i * A[0] - j * A[1];
                ll tmp = (ll)i * B[0] + j * B[1] + (k / A[2]) * B[2] + k % A[2];
                ans = max(ans, tmp);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int cnt=0;
	for(int i=0;i<=a;i++)
	{
		for(int j=0;j<=b;j++)
		{
			for(int k=0;k<=c;k++)
			{
				if(500*i+100*j+50*k==d)
				cnt++;
			}
		}
	}
	cout<<cnt;
	return 0;
} 

Measured memory_bytes: 256
def itoa(i):
    alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',
                'p','q','r','s','t','u','v','w','x','y','z']
    return alphabet[i]
s = input()
score_list = []
for i in range(26):
    c = itoa(i)
    prev = -1
    score = 0
    flag=False
    for j in range(len(s)):
        if c==s[j]:
            score=max(j-prev-1,score)
            flag=True
            prev=j
    score = max(j-prev,score)
    if flag==False:
        score=10**3
    score_list.append(score)

print(min(score_list))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N, M, K;
string S, T;
vector<int> A;
vector<int> B;
//=============================
void input()
{
    cin >> N;
    cin >> S;
}
//=============================
void func() {}

//=============================
void solve()
{
    int ans = INF;

    vector<int> l(N,0);
    vector<int> r(N,0);
    rep(i,N){
        if (S[i]=='W') l[i]++;
        if (i != 0)l[i] += l[i-1];
    }
    rrep(i,N){
        if (S[i]=='E' ) r[i]++;
        if (i !=(N-1))r[i] += r[i+1];
    }
    debugv(l);
    debugv(r);

    rep(i,N){
        ans = min(ans, l[i]+r[i]);
    }
    if (ans>0)ans--;

    cout << ans << endl;
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 5508
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, m, n) for(int i = m; i <= n; i++)
#define per(i, m, n) for(int i = m; i >= n; i--)
#define pb push_back
#define mp make_pair
#define pii pair<int, int> 
#define vi vector<int> 
#define vll vector<ll> 
#define sz(v) (int) v.size()
const int INF = 0x3f3f3f3f;

const int maxn = (1 << 18) + 5;

struct Num {
	int maxx, sec_maxx; 
} a[maxn]; 

int main() {
    ios::sync_with_stdio(false); 
    cin.tie(0); cout.tie(0); 
    int N;
    cin >> N;
    for (int i = 0; i < (1 << N); i++) 
    	cin >> a[i].maxx; 
    for (int j = 0; j < N; j++) {
    	for (int i = 0; i < (1 << N); i++) {
    		if ((i >> j) & 1) {
    			int x = i ^ (1 << j); 
    			Num ans; 
    			ans.maxx = max(a[i].maxx, a[x].maxx); 
    			if (a[i].maxx > a[x].maxx) ans.sec_maxx = max(a[i].sec_maxx, a[x].maxx); 
    			else ans.sec_maxx = max(a[i].maxx, a[x]. sec_maxx); 
  				a[i] = ans; 
    		}
    	}
    }
    int ans = 0; 
    for (int i = 1; i < (1 << N); i++) {
    	ans = max(ans, a[i].maxx + a[i].sec_maxx); 
    	cout << ans << endl; 
    }
    return 0; 
}

Measured memory_bytes: 5704
x,n = map(int, input().split())
if n == 0:print(x)
else:
    p = list(map(int, input().split()))
    p.sort()
    ans = 10**9
    flag = False
    for i in range(1000):
        for j in range(n):
            if not x - i in p:
                print(x - i)
                flag = True
                break
            if x + i in p:continue
            else:
                print(x + i)
                flag = True
                break
        if flag:break

Measured memory_bytes: 9200
while True:
    t = 0
    n,m = map(int,input().split())
    if n != 0:
        a = list(map(int,input().split()))
        a.sort(reverse=True)
        for i in range(n - 1):
            k = a[i]
            for j in range(n - i - 1):
                if k + a[i+j+1] <= m:
                    if k + a[i+j+1] >= t:
                        t = k + a[i+j+1]
                    break
        if t == 0:
            print("NONE")
        else:
            print(t)
    else:
        break


Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
const int N=102;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,m,x,y,ans=0,sx[N][N],sy[N][N];
short f[N][N][N][N];
int main() {
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++) {
            char ch=getchar();
            while(ch!='.'&&ch!='o'&&ch!='E') ch=getchar();
            sx[i][j]=sy[i][j]=(ch=='o');
            sx[i][j]+=sx[i][j-1];sy[i][j]+=sy[i-1][j];
            if(ch=='E') x=i,y=j;
        }
    for(int i=x;i;i--)
        for(int j=y;j;j--)
            for(int k=x;k<=n;k++)
                for(int l=y;l<=m;l++) {
                    ans=max(ans,(int)f[i][j][k][l]);
                    if(i>1&&k+1<x+i) f[i-1][j][k][l]=max((int)f[i-1][j][k][l],f[i][j][k][l]+max(0,sx[i-1][min(l,m-y+j)]-sx[i-1][max(j-1,l-y)]));
                    if(k<n&&x+k<n+i) f[i][j][k+1][l]=max((int)f[i][j][k+1][l],f[i][j][k][l]+max(0,sx[k+1][min(l,m-y+j)]-sx[k+1][max(j-1,l-y)]));
                    if(j>1&&l+1<y+j) f[i][j-1][k][l]=max((int)f[i][j-1][k][l],f[i][j][k][l]+max(0,sy[min(k,n-x+i)][j-1]-sy[max(i-1,k-x)][j-1]));
                    if(l<m&&y+l<m+j) f[i][j][k][l+1]=max((int)f[i][j][k][l+1],f[i][j][k][l]+max(0,sy[min(k,n-x+i)][l+1]-sy[max(i-1,k-x)][l+1]));
                }
    printf("%d\n",ans);
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


Measured memory_bytes: 209280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;


template <typename T> vector<T> divisor(T a) {
    vector<T> res;
    for (T i = 1; i*i <= a; i++) {
        if(a%i == 0){
            res.push_back(i);
            if(i != a/i) res.push_back(a/i);
        }
    }
    return res;
}


int main()
{
    int N,K;
    cin >> N >> K;
    vi A(N);
    in(N,A);
    int sum = 0;
    rep(i,N) sum += A[i];
    vi B = divisor(sum);
    sort(all(B));
    reverse(all(B));
    //outve(B);
    
    rep(i,int(B.size())) {
        vi C;
        rep(j,N) C.pb(A[j]%B[i]);
        sort(all(C));
        //outve(C);
        vi Csum(N+1);
        Csum[0] = 0;
        reps(j,1,N+1) Csum[j] = Csum[j-1]+C[j-1];
    
        rep(j,N+1){
            ll a = (ll)B[i]*(ll)(N-j)-(ll)(Csum[N]-Csum[j]);
            
            if(abs((ll)Csum[j]-a) % (ll)B[i] == 0){
                if(Csum[j] <= K && a <= K){
                    cout << B[i] << endl;
                    return 0;
                }
            }
        }
        
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

/*
    i->i+1の個数に対応
*/ 
ll c[100010];

 
int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    c[0]=3;
    ll ans=1;
    for(ll i=0;i<n;i++){
        ll num=c[a[i]]-c[a[i]+1];
        if(num<=0)num=0;
        if(num>3)num=0;
        c[a[i]+1]++;
        ans=(ans*num)%N;
    }
    cout<<ans<<endl;
    return 0;
}

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

const ll INF = INT_MAX;
ll n, k;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ///freopen("input.in", "r", stdin);
    ///freopen("output.out", "w", stdout);
    cin >> n >> k;
    vector <ll> a (n + 1);
    for (ll i = 1; i <= n; ++i)
        cin >> a[i];

    vector <ll> dp (n + 1, INF);

    dp[1] = 0;

    for (ll i = 1; i <= min (n, k); ++i)
        for (ll j = 1; j <= i; ++j)
            dp[i] = min (dp[i], dp[j] + abs (a[j] - a[i]));

    for (ll i = k + 1; i <= n; ++i)
        for (ll j = i - k; j <= i; ++j)
            dp[i] = min (dp[i], dp[j] + abs (a[j] - a[i]));

    cout << dp[n] << '\n';
    return 0;
}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans=0;
    rep(i,n){
        if(i%2==0){
            if(a[i]%2==1){
                ans++;
            }
        }
    }
    
    cout<<ans<<endl;
    
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 7788
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		Arrays.parallelSort(A);
		if (A[N/2-1]==A[N/2]) {
			System.out.println(0);
			return;
		}
		System.out.println(A[N/2]-A[N/2-1]);
	}
}

Measured memory_bytes: 59772
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int main(){
  int n, m; string s;
  cin >> n >> m >> s;
  vector<int> dp(n+1,INF);
  dp[n] = 0;
  queue<int> q;
  q.push(0);
  for(int i = n-1; i >= 0; i--){
    while(true){
      if(q.size() == 0){
        puts("-1");
        return 0;
      }
      if(q.front() != INF && q.size() <= m) break;
      q.pop();
    }
    if(s[i] == '0') dp[i] = q.front()+1;
    q.push(dp[i]);
  }
  
  vector<int> ans;
  int x = 0;
  int rest = dp[0];
  while(x < n){
    rest--;
    int i = 1;
    while(dp[x+i] != rest) i++;
    ans.push_back(i);
    x += i;
  }
  rep(i,ans.size()){
    printf("%d%c", ans[i], i == int(ans.size())-1?'\n':' ');
  }
  return 0;
  
}

Measured memory_bytes: 1528
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

/* --------------------------------------- */

int main() {
//	ios::sync_with_stdio(false);
	cin.tie(0);
	ll _k, _a, _b;
	cin >> _k >> _a >> _b;
	__int128 k = _k, a = _a, b = _b;
	if(a <= b) {
		if(a >= k) cout << "1" << endl;
		else cout << "-1" << endl;
		return 0;
	}
	__int128 lb = -1, ub = INF * INF + INF;
	while(ub - lb > 1) {
		__int128 mid = (lb + ub) / 2;
		if(mid * a - (mid - 1) * b >= k) ub = mid;
		else lb = mid;
	}
	cout << (ll)(ub * 2 - 1) << endl;
	return 0;
}

/* --------------------------------------- */


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

int main() {
  vector<vector<int>> a(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a.at(i).at(j);
    }
  }
  int n;
  cin >> n; 
  vector<vector<bool>> flag(3, vector<bool>(3));
  int b;
  for (int k = 0; k < n; k++) {
    cin >> b;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if(a.at(i).at(j) == b){
          flag.at(i).at(j) = true;
        }
      }
    }
  }
  bool judge = true;
  for (int i = 0; i < 3; i++) {
    if (flag.at(i).at(0) && flag.at(i).at(1) && flag.at(i).at(2)) {
      cout << "Yes" << endl;
      judge = false;
      break;
    }
  }
  if (judge) {
    for (int j = 0; j < 3; j++) {
      if (flag.at(0).at(j) && flag.at(1).at(j) && flag.at(2).at(j)) {
        cout << "Yes" << endl;
        judge = false;
        break;
      }
    }
  }
  if (judge) {
    if (flag.at(0).at(0) && flag.at(1).at(1) && flag.at(2).at(2)) {
      cout << "Yes" << endl;
      judge = false;
    }
  }
  if (judge) {
    if (flag.at(0).at(2) && flag.at(1).at(1) && flag.at(2).at(0)) {
      cout << "Yes" << endl;
      judge = false;
    }
  }
  if (judge)
    cout << "No" << endl;
}

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

namespace /*DAG.cpp*/{
  int N,M; //頂点と辺の数
  vector<vector<int>> G; //グラフ
  vector<int> h; //入次数 : topoBFS
  vector<int> l_depth; //最大経路長 //recDFSでは探索済みかどうかも示す
  vector<int> s_depth; //最短経路長
  vector<int> ans; //答えを格納(recDFSではreverse必要)

  void input(){
    cin>>N>>M;
    G.resize(N);
    h.resize(N, 0);
    int f,t;
    for(int i=0; i<M; i++){
      cin>>f>>t;
      //f--;t--;
      G[f].push_back(t); //recDFSとtopoBFS両方に必要
      h[t]++; //topoBFSにのみ必要
    }
  }

  void topoBFS(){   
    queue<int> unchecked;
    for(int i=0; i<N; i++){
      if(h[i]==0){
        unchecked.push(i);
        l_depth[i] = 0;
        s_depth[i] = 0;
      }
    }
    while(!unchecked.empty()){
      int current = unchecked.front();
      unchecked.pop();
      ans.push_back(current+1);
      for(int next: G[current]){
        h[next]--;

        l_depth[next] = max(l_depth[next], l_depth[current]+1); //最長経路長
        s_depth[next] = min(s_depth[next], s_depth[current]+1); //最短経路長

        if(h[next]==0){
          unchecked.push(next);
        }
      }
    }
  }
}

int main(){
    input();
    l_depth.resize(N, -1);
    s_depth.resize(N, N);
    topoBFS();
    bool isDAG = ans.size()==N;
    cout<<!isDAG<<endl;
}


Measured memory_bytes: 3172
from collections import deque
S = input()
Q = int(input())
T = [input() for i in range(Q)]

d =deque(S)

count = True

for i in range(Q):
  t = T[i]
  if(int(t[0]) == 1):
    count = not count
  else:
    if(int(t[2]) == 1):
      if(count):
        d.appendleft(t[4])
      else:
        d.append(t[4])
    else:
      if(count):
        d.append(t[4])
      else:
        d.appendleft(t[4])

ans = list(d)

if(count):
  print("".join(ans))
else:
  print("".join(ans[::-1]))


Measured memory_bytes: 21980
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N,K;
  cin >> N >> K;
  vector<int> X(N);
  int cnt=0;
  REP(i,N){
    IN(X[i]);
    if(X[i] >= K) ++cnt;
  }
  OUT(cnt);
}

Measured memory_bytes: 640
N = int(input())
L = list(map(int, input().split()))
total = sum(L)

# e.g.) Sunuke takes i cards from the top (1 <= i <= N-1)
# Sunuke's score is sum(L[:i]) ... L[i] -> + L[i+1]
# Racoon's score is sum(L[i:]) ... sum(L) - L[i] -> L[i+1]


sunuke = 0
ans = 2**64-1
for i in range(N-1):
  sunuke += L[i]
  racoon = total - sunuke
  ans = min(ans, abs(sunuke - racoon))
print(ans)


Measured memory_bytes: 76752
import java.util.*;

class Main {
public static void main(String[] args){

Scanner sc = new Scanner(System.in);
String a = sc.next();
String b = sc.next();
String c = sc.next();

int win = 0;

String field = a.substring(0,1);
a = a.substring(1);

for(;;){
if(field.equals("a")){
if(a.equals("")){
win = 1;
break;
}
field = a.substring(0,1);
a = a.substring(1);
}else if(field.equals("b")){
if(b.equals("")){
win = 2;
break;
}
field = b.substring(0,1);
b = b.substring(1);
}else{
if(c.equals("")){
win = 3;
break;
}
field = c.substring(0,1);
c = c.substring(1);
}
}
if(win == 1){
System.out.println("A");
}else if(win == 2){
System.out.println("B");
}else{
System.out.println("C");
}

}
}

Measured memory_bytes: 23764
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
double pi = 3.141592653589793;
ll mod = 1000000007;

int main() {
    int N;
    cin >> N;
    bool t[N + 1];
    bool em[N + 1];
    em[0] = true;
    for (int i = 0; i < N; i++) {
        em[i + 1] = false;
    }
    int now;
    for (int i = 0; i < N; i++) {
        cin >> now;
        em[now] = true;
        if (em[now - 1]) {
            t[now] = true;
        } else {
            t[now] = false;
        }
    }
    int num = 0;
    int nowinc = 0;
    for (int i = 0; i < N; i++) {
        if (t[i + 1]) {
            nowinc++;
        } else {
            if (nowinc > num) {
                num = nowinc;
            }
            nowinc = 1;
        }
    }
    if (nowinc > num) {
        num = nowinc;
    }
    int ans = N - num;
    cout << ans << endl;
}


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

int main() {
  int l,r,n;
  cin >> l >> r >> n;
  int d[1111];
  memset(d,0,sizeof(d));
  for(int i=0; i<n; i++) {
    int x,y;
    cin >> x >> y;
    for(int j=x; j<y; j++) d[j]=1;
  }
  for(int i=l; i<r; i++) {
    if(d[i]) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int h,w;
    cin >> h >> w;
    int k[10][10];
    rep(i,10){
        rep(j,10){
            cin >> k[i][j];
        }
    }
    int dis[10];
    dis[1]=0;
    rep(i,10){
        rep(j,10){
            rep(l,10){
                k[j][l]=min(k[j][l],k[j][i]+k[i][l]); 
            }
        }
    }
    int ans=0;
    rep(i,h*w){
        int tmp;
        cin >> tmp;
        if(tmp>=0) ans+=k[tmp][1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Numerics;

class Program {
    static void Main(string[] args) {
            var data = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var a = data[0]-1;
            var b = data[1];
            var c = data[2];
            var d = data[3];
            var lcmCD = Lcm(c, d);
            var collectB = b - b / c - b / d + b / lcmCD;
            var collectA = a - a / c - a / d + a / lcmCD;
            Console.WriteLine(collectB - collectA);
    }

        // 最小公倍数を求める
        public static long Lcm(long a, long b) {
            return a * b / Gcd(a, b);
        }

        //最小公約数を求める
        public static long Gcd(long large, long small) {
            if(small ==0) {
                return large;
            }
            return Gcd(small, large % small);
        }
}

Measured memory_bytes: 13268
# -*- coding: utf-8 -*-
# 
import math
import sys
import bisect

# いっこ入力
n =int(input())

# n行の数をリストへ
a = [int(input()) for i in range(n)] 

# color
c = [-999]*n

for i in range(0,n):
#    if c[0] >= a[i]:
#        c.insert(0,a[i])
#    else:
    p = bisect.bisect_left(c, a[i])
    c[p-1]=a[i]
#        print(c)
#        print(p)

print(len(c) - bisect.bisect_left(c, -1))


Measured memory_bytes: 7844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1000000007;

void solve()
{        
    int n;
    cin >> n;
    vector<int>arr(n);
    for (int c=0;c<n;c++)
        cin >> arr[c];
    ll int sum=0;
    for (int c=1;c<n;c++)
        sum+=max(0,arr[c-1]-arr[c]),arr[c]=max(arr[c],arr[c-1]);
    cout << sum << endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);     
    int t;
    //cin >> t;
    t=1;
    for (int tt=1;tt<=t;tt++)
        {
            solve();
        }
        return 0;
}

Measured memory_bytes: 3988
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

typedef long long ll;

const int maxn = 4e5 + 7;

using namespace std;

int n, q, cnt;
int d[maxn];
int fa[maxn];
struct edge {
	int x, y, z;
	inline int operator < (const edge &a) const {
		return z < a.z;
	}
} e[maxn];

inline int read()
{
	int X = 0; char ch = getchar();
	while (ch < '0' || ch > '9') ch = getchar();
	while (ch >= '0' && ch <= '9') X = X * 10 + ch - '0', ch = getchar();
	return X;
}

int find(int x)
{
	return fa[x] == x ? x : fa[x] = find(fa[x]);
}

inline ll kruskal()
{
	ll ans = 0;
	sort(e + 1, e + cnt + 1);
	for (int i = 1; i <= cnt; i++) {
		int x = find(e[i].x), y = find(e[i].y);
		if (x != y) fa[x] = y, ans += e[i].z;
	}
	return ans;
}

int main(void)
{
	cin >> n >> q;
	for (int i = 0; i < n; i++) fa[i] = i, d[i] = 2e9;
	while (q--) {
		int a = read(), b = read(), c = read();
		e[++cnt] = (edge){a, b, c};
		d[a] = min(d[a], c + 1);
		d[b] = min(d[b], c + 2);
	}
	int r = 0;
	for (int i = 1; i < n; i++) if (d[i] < d[r]) r = i;
	for (int i = r + 1; i < r + n; i++) d[i % n] = min(d[i % n], d[(i - 1) % n] + 2);
	for (int i = 0; i < n; i++) e[++cnt] = (edge){i, (i + 1) % n, d[i]};
	cout << kruskal() << endl;
	
	return 0;
}

Measured memory_bytes: 10240
fun main(args: Array<String>) {
    val n = readInteger()
    val aList = readIntegerList().sorted()
    val bList = readIntegerList().sorted()
    val cList = readIntegerList().sorted()

    var ans = 0L
    for (i in bList) {
        val aCount = lowerBound(aList, i)
        val cCount = cList.size - lowerBound(cList, i + 1)

        ans += aCount.toLong() * cCount
    }

    println(ans)
}

fun <T : Comparable<T>>lowerBound(list: List<T>, target: T): Int {
    var left = -1
    var right = list.size
    while (right - left > 1) {
        val mid = (right + left) / 2
        if (target <= list[mid])  {
            right = mid
        } else {
            left = mid
        }
    }

    return right
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


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

typedef pair<int, int> P;

int N;
P X[500];
int C[501];

int main() {
  cin >> N;
  queue<int> y, d;
  vector<int> o;
  for (int i=0; i<N; i++) {
    int x;
    cin >> x;
    X[i] = P(x, i+1);
  }
  sort(X, X+N);
  for (int i=0; i<N; i++) {
    int n = X[i].second;
    for (int j=1; j<=n-1; j++) y.push(n), C[n]++;
  }
  int s = 1;
  for (int i=0; i<N; i++) {
    int x = X[i].first, n = X[i].second;
    while (s < x) {
      if      (!y.empty()) o.push_back(y.front()), C[y.front()]--, y.pop();
      else if (!d.empty()) o.push_back(d.front()), d.pop();
      else {
        cout << "No\n";
        return 0;
      }
      s++;
    }
    if (C[n] > 0) {
      cout << "No\n";
      return 0;
    }
    o.push_back(n);
    for (int j=n; j<N; j++) d.push(n);
    s++;
  }
  while (s <= N*N) {
    if (d.empty()) {
      cout << "No\n";
      return 0;
    }
    o.push_back(d.front()); d.pop();
    s++;
  }
  cout << "Yes\n";
  if (o.size() != N*N) return 1;
  for (int i=0; i<N*N; i++) {
    cout << o[i] << (i==N*N-1 ? '\n' : ' ');
  }
  return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;
typedef unordered_map<int,int> uoii;
typedef unordered_map<string,int> uosi;

const int MOD = 1e9+7;

const int INF = 1e10;




int32_t main()
{
   
    IOS
    int n,a,b;
    cin>>n>>a>>b;
    int tot=(n)/(a+b);
    int x=n-tot*(a+b);
    cout<<tot*a+min(a,x);


    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	string s;
	cin >> s;
	if (s == "Sunny") cout << "Cloudy" << endl;
	else if (s == "Cloudy") cout << "Rainy" << endl;
	else cout << "Sunny" << endl;
    
    return 0;
}



Measured memory_bytes: 3520
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    map<double,int>mp;
    vector<double>key(n);
    vector<double>v(n);
    map<double,int>ans;
    rep(i,n){
        double t; cin>>t;
        mp[t]++;
        key[i]=t; v[i]=t;
    }
    sort(all(v),greater<double>());
    for(int i=0;i<v.size();i++){
        ans[v[i]]=(int)(v.size()-mp[v[i]]-i)*3+mp[v[i]]-1;;
        i+=mp[v[i]]-1;
    }
    rep(i,n)cout<<ans[key[i]]<<endl;
}

Measured memory_bytes: 4788
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>
#include <numeric>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<30)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

ll gcd(ll m, ll n){
  // 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;

	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd

ll lcm( ll m, ll n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

// a x + b y = gcd(a, b)
int extgcd(int a, int b, int &x, int &y) {
  int g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
int invMod(int a, int m) {
  int x, y;
  if (extgcd(a, m, x, y) == 1) return (x + m) % m;
  else                         return 0; // unsolvable
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  ll A[1001000];
  ll t;
  for(int i=0;i<N;i++){
    cin >> t;
    A[i]=t;
  }
  sort(A,A+N);
  ll ans=A[0];
  for(int i=1;i<N;i++){
    if(A[i]%ans!=0){
      ans=A[i]%ans;
      ans=gcd(ans,A[i]);
    }
    if(ans==1LL)break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2816
#include <stdio.h>

int main(void){
	int a, b;
	int i, ans=0;
	char s[15];

	scanf("%d%d", &a, &b);
	scanf("%s", s);

	for (i = 0; i < a; i++){
		if (!('0' <= s[i] && s[i] <= '9')){
			printf("No\n"); return 0;
		}
	}
	if (s[a] != '-'){
		printf("No\n"); return 0;
	}
	for (i = a + 1; i <= a + b; i++){
		if (!('0' <= s[i] && s[i] <= '9')){
			printf("No\n"); return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256