akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <regex>
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <numeric>
#include <iomanip>
#include <stack>
#include <string>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main () {
    ll N;cin >> N;
    vector<string> S(N);
    for(auto &s:S) cin >> s;
    ll nu = 0;
    ll v[4] = {0};
    for (int i = 0; i < S.size(); i++)
    {
        string s = S[i];
        ll k = 0;
        if(s[0] == 'B') k++;
        if(s[s.size()-1] == 'A') k+=2;
        v[k]++;
        bool isa = s[0] == 'A' ? true : false;
        for(int c = 1; c < s.size(); c++) {
            if(isa && s[c] == 'B') {
                nu++;
            }
            isa = s[c] == 'A' ? true : false;
        }
    }
    ll ans = nu;
    ll add = 0;
    ll mn;
    add += max(0LL, v[3] - 1);
    if(v[3] >= 1 && v[2] >= 1) {
        v[2]--;
        add++;
    }
    if(v[3] >= 1 && v[1] >= 1) {
        v[1]--;
        add++;
    }
    if(v[2] >= 1 && v[1] >= 1) {
        mn = min(v[1], v[2]);
        add += mn;
        v[1]-=mn;
        v[2]-=mn;
    }
    //cout << add << endl;
    //cout << v[1] << " ";
    //cout << v[2] << " ";
    //cout << v[3] << " ";
    //cout << endl;
    
    //cout << add << endl;
    
    //cout << add << endl;
//
    //cout << v[1] << " ";
    //cout << v[2] << " ";
    //cout << v[3] << " ";
    //cout << endl;
    cout << ans + add << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int32_t main()
{
	fastIO
	inp_out();
	int n; 
	cin >> n; 
	string s = ""; 
	while(n != 0)
	{
		s += (((n % 26)  - 1) % 26 +26) % 26+ 'a'; 
		n /= 26; 
		if(s[s.size() - 1] == 'z')
			 -- n; 
	}

	reverse(s.begin(), s.end()); 
	cout << s; 

	return 0;
}

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

int main() {
    int N,A[300][300],B[300][300],i,j,k,t,o;
    long long a;
    scanf("%d",&N);
    for(i=0;i<N;i++)for(j=0;j<N;j++)scanf("%d",&A[i][j]),B[i][j]=A[i][j];
    for(i=0;i<N;i++)for(j=0;j<N;j++)for(k=0;k<N;k++)if(B[j][k]>(t=B[j][i]+B[i][k]))B[j][k]=t;
    for(i=0;i<N;i++)for(j=0;j<i;j++)
    if(B[i][j]<A[i][j]){printf("-1\n");return 0;}
    else{o=1;for(k=0;k<N;k++)if(k!=i&&k!=j&&B[i][j]==B[i][k]+B[k][j])o=0;if(o)a+=A[i][j];}
    printf("%lld\n",a);
}

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

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

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

int cnt[26], a[26], N;

int main() {
	scanf("%d", &N);
	memset(a, 127, sizeof(a));
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		memset(cnt, 0, sizeof(cnt));
		for (int j = 0; j < S.length(); j++)
			cnt[S[j] - 'a']++;
		for (int j = 0; j < 26; j++)
			a[j] = min(a[j], cnt[j]);
	}
	for (int i = 0; i < 26; i++)
		for (int j = 0; j < a[i]; j++)
			printf("%c", 'a' + i);
	printf("\n");
}


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

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

Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
int s[10], iwa[10][10];
signed main() {
	int n, m;
	cin >> n >> m;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		iwa[a][b] = iwa[b][a] = 1;
	}
	rep(i, n) {
		s[i] = i+1;
	}
	int ans = 0;
	do {
		loop(i,1,n) {
			if (iwa[s[i - 1]][s[i]] == 0)goto ioi;
		}
		ans++;
	ioi:;
	} while (next_permutation(s + 1, s + n));
	cout << ans << endl;
end:;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;
	const ll m = 2019;
	vl dp(m);

	ll res = 0;
	for (char c: s) {
		c -= '0';
		dp[0]++;
		vl ndp(m);
		FOR(i,0,m) ndp[(10*i+c)%m] += dp[i];
		dp = ndp;
		res += dp[0];
	}
	cout << res << endl;
}



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

int main(){
  int n, t, btime, bcost, time,cost;
  	cin >> n;
  	cin >> t;
    cin >> bcost;
  	cin >> btime;
  for(int i = 0; i < n - 1; ++i){
    cin >> cost;
  	cin >> time;
    if(cost < bcost && time <= t){
    	bcost = cost;
      	btime = time;
    }
  }
if(btime <= t){
	cout << bcost << endl;

}else{
	cout << "TLE" <<endl;
}
  
return 0;
}

Measured memory_bytes: 256
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]

ans = 0
for i in s:
    if s.count(i) - t.count(i) > ans:
        ans = s.count(i) - t.count(i)
print(ans)


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

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    ll x = 0;
    ll y = 0;

    ll t = a[0];
    ll c = 0;
    for (ll i = 0; i < n; i++){
        //cout << c << endl;
        if (a[i] == t){
            c++;
        }
        else{
            if (x == 0){
                if (c >= 4){
                    x = t;
                    y = t;
                    break;
                }
                else if (c >= 2){
                    x = t;
                }
            }
            else if (y == 0){
                if (c >= 2){
                    y = t;
                    break;
                }
            }
            c = 1;
        }
        t = a[i];
    }
    if (c != 0){
        if (x == 0){
            if (c >= 4){
                x = t;
                y = t;
            }
            else if (c >= 2){
                x = t;
            }
        }
        else if (y == 0){
            if (c >= 2){
                y = t;
            }
            
        }
    }
    //cout << x << endl;
    //cout << y << endl;

    cout << x*y << endl;
    

}

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

using namespace std;

long long rec( int i, int j, const vector<int>& weights, const vector<int>& values, vector<vector<long long>>* memo )
{
    if ( i == 0 ) return 0;
    if ( ( *memo )[ i ][ j ] != 0 ) return ( *memo )[ i ][ j ];

    return ( *memo )[ i ][ j ] = j >= weights[ i - 1 ] ?
        max( rec( i - 1, j, weights, values, memo ), rec( i - 1, j - weights[ i - 1 ], weights, values, memo ) + values[ i - 1 ] ) :
        rec( i - 1, j, weights, values, memo );
}

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

    int W;
    cin >> W;

    vector<int> weights( N );
    vector<int> values( N );
    for ( int i = 0; i < N; ++i ) cin >> weights[ i ] >> values[ i ];

    vector<vector<long long>> memo( N + 1, vector<long long>( W + 1, 0 ) );
    cout << rec( N, W, weights, values, &memo ) << endl;
}

Measured memory_bytes: 80256
#include <iostream>
#include <queue>
using namespace std;

struct P{
    int x;
    int y;
    int d;
    P() {}
    P(int a, int b, int c) : x(a), y(b), d(c) {}
};

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

int main(){
    int w, h,i,j;
    int wall[200][100];
    int maze[100][100];
    for(;cin>>w>>h, w||h;){
        for(i=0;i<200;i++){
            for(j=0;j<100;j++){
                wall[i][j] = 0;
                maze[i/2][j] = 0;
            }
        }
        for(i = 0; i < 2*h-1; i++){
            for(j = 0; j < w - 1 + i%2; j++){
                cin >> wall[i][j];
            }
        }
        queue< P > que;
        que.push( P(0,0,1) );
        maze[0][0] = 1;
        P e;
        int ans = 0;
        while( !que.empty() ){
            e = que.front();
            que.pop();
            if( e.x == h-1 && e.y == w-1 ){
                    ans = e.d;
                    break;
            }
            maze[e.x][e.y] = 1;
            for(i=0;i<4;i++){
                int xx = e.x + dx[i], yy = e.y + dy[i];
                if( 0 <= xx && xx < h &&
                    0 <= yy && yy < w &&
                    maze[xx][yy] == 0){
                    if( wall[2*e.x + (1-i%2) - i*(1-i%2)][e.y-i/3] ) continue;
                    que.push( P(xx, yy, e.d+1) );
                    maze[xx][yy] = 1;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1332
#include <stdio.h>

int main(void){
  int H,W;
  int i,j;

  while(1){
    scanf("%d %d",&H,&W);
    if( H==0 && W==0 ) break;
    for(i=0;i<H;i++){
      if(i%2==0){
	for(j=0;j<W;j++){
	  (j%2==0)?printf("#"):printf(".");
	}
      }else{
	for(j=0;j<W;j++){
	  (j%2==0)?printf("."):printf("#");
	}
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

const char *anss(bool b)
{
	return b ? "Yes" : "No";
}

int main()
{
	int A, B, C;
	std::cin >> A >> B >> C;

	bool ans;
	if (A == B && A != C)
		ans = true;
	else if (B == C && C != A)
		ans = true;
	else if (C == A && A != B)
		ans = true;
	else
		ans = false;
	
	std::cout << anss(ans);
}

Measured memory_bytes: 256
/*
 * atcoder/abc95/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * i: XとYが異なる場合) XとYが等しくなるまで買い、等しい場合に帰着させる.
 * ii: XとYが等しい場合）min(AとBの値段, ABの値段)
 *
 * iの補足) XとYの差分をdとするとABの場合にはd*2枚必要. AまたはBの場合にはd枚必要.
 */
int A, B, AB, X, Y;
void solve() {
  cin >> A >> B >> AB >> X >> Y;
  int cost = 0;
  if (X != Y) {
    int d = abs(X-Y);
    cost += min(d*2*AB, X > Y ? d * A : d * B);
    X=min(X,Y);
  }

  cost += min(X*A+X*B, X*2*AB);
  cout << cost << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


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

using namespace std;

int N, A[100];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A, A + N, greater<>());

    int alice = 0, bob = 0;

    for (int i = 0; i < N; i++) {
        alice += A[i];
        i++;
        bob += A[i];
    }
    cout << alice - bob << endl;
    return 0;
}

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

using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

int main(){

    vector<char> v;

    char tmp;
    while(cin>>tmp){
        if('0'==tmp){
            v.push_back('0');
        }else if('1'==tmp){
            v.push_back('1');
        }else if(!v.empty()){
              v.pop_back();
        }
    }

    REP(i,v.size()){
        cout << v[i];
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = input().split()
b = [0]*8
c = 0

for a in A:
    a = int(a)
    if 1<=a<=399:
        b[0] += 1
    elif 400<=a<=799:
        b[1] += 1
    elif 800<=a<=1199:
        b[2] += 1
    elif 1200<=a<=1599:
        b[3] += 1
    elif 1600<=a<=1999:
        b[4] += 1
    elif 2000<=a<=2399:
        b[5] += 1
    elif 2400<=a<=2799:
        b[6] += 1
    elif 2800<=a<=3199:
        b[7] += 1
    elif 3200<=a:
        c += 1

if c == 0:
    print(8-b.count(0), end=" ")
else:
    print(max(8-b.count(0),1), end=" ")

print(8-b.count(0)+c)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    long N;
    cin >> N;

    long ans;

    if (N % 1000 == 0) {
        ans = 0;
    } else {
        ans = 1000 - N % 1000;
    }

    std::cout << ans << std::endl;
}

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

int main()
{
    bool c = false, f = false;
    string s;
    cin >> s;

    int slen = s.length();
    
    for (int i = 0; i < slen; i++)
    {
        if (s[i] == 'C') 
        {
            for (int j = i+1; j < slen; j++)
            {
                if (s[j] == 'F')
                {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
        
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
      int a[100];
      int i,n;
      scanf("%d",&n);
       for(i=0;i<n;i++){
            scanf("%d",&a[i]);
          }
       for( i=n-1; i>0; i--){
            printf("%d ",a[i]);
          }

           printf("%d\n",a[0]);
        return 0;
}



Measured memory_bytes: 2068
import numpy as np
import math

# K = int(input())
# N, K = map(int, input().split())
# A = list(map(int, input().split()))

N, M, X, Y = map(int, input().split())

x = list(map(int, input().split()))
y = list(map(int, input().split()))

maxx = max(x)
miny = min(y)

maxxx = max(maxx, X)
minyy = min(miny, Y)

if maxxx < minyy:
    print('No War')
else:
    print('War')


Measured memory_bytes: 12508
#include <bits/stdc++.h>
using namespace std;
const int N=100110;
int n,k;
int a[N],f[N];
int main()
{
  cin>>n>>k;
  for(int i=1;i<=n;++i) cin>>a[i];
  memset(f,127,sizeof(f));
  f[1]=0;
  for(int i=1;i<n;++i) for(int j=1;j<=k;++j)
    f[i+j]=min(f[i+j],f[i]+abs(a[i+j]-a[i]));
  cout<<f[n];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,X,Y,x,xmax,y,ymin;
  cin >> N >> M >> X >> Y;
  xmax=X,ymin=Y;
  for(int i=0 ; i<N ; i++){
    cin >> x;
    xmax=max(x,xmax);
  }
  for(int j=0 ; j<M ; j++){
    cin >> y;
    ymin=min(y,ymin);
  }
  if(xmax<ymin)
    cout << "No War" << endl;
  else
    cout << "War" << endl;
}

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

const int MAX_N = 45;
const int MAX_G = 15;
const int UB = MAX_N * MAX_G;
const int INF = (1 << 28);

int a[MAX_N], b[MAX_N], c[MAX_N];
int dp[UB][UB];

int main() {
    int n, ma, mb;
    cin >> n >> ma >> mb;

    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    for (int a_i = 0; a_i < UB; a_i++) {
        for (int b_i = 0; b_i < UB; b_i++) {
            dp[a_i][b_i] = INF;
        }
    }
    dp[0][0] = 0;

    for (int drug_i = 0; drug_i < n; drug_i++) {
        for (int a_amou = UB - 1; a_amou >= 0; a_amou--) {
            for (int b_amou = UB - 1; b_amou >= 0; b_amou--) {
                if (a_amou - a[drug_i] >= 0 && b_amou - b[drug_i] >= 0) {
                    dp[a_amou][b_amou] = min(dp[a_amou][b_amou],
                                             dp[a_amou - a[drug_i]][b_amou - b[drug_i]] + c[drug_i]);
                }
            }
        }
    }

    int ans = INF;
    for (int a_amou = 1; a_amou < UB; a_amou++) {
        for (int b_amou = 1; b_amou < UB; b_amou++) {
            if (a_amou * mb == b_amou * ma) {
                ans = min(ans, dp[a_amou][b_amou]);
            }
        }
    }

    if (ans >= INF) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2048
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();
		
		if((a*b)%2==0) {
			System.out.println("Even");
		}else {
			System.out.println("Odd");
		}
	}

}

Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <time.h>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iomanip>
using namespace std;

int main() {
    double x1, x2, y1, y2, distance;
    cin >> x1 >> y1 >> x2 >> y2;
    distance = sqrt(pow(x2 - x1, 2.0) + pow(y2 - y1, 2.0));
    cout << setprecision(20) << distance << endl;
    return 0;
}

Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int w,h,x,y,flag=0;
	cin>>w>>h>>x>>y;
	if(w%2==0&&x==w/2&&h%2==0&&y==h/2)flag=1;
	double s=(double)w*(double)h;
	printf("%.6lf %d",s/2,flag);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, count = 0;
  bool n_ch[101] = {false};
  pair<int, int> ab[101];
  pair<int, int> cd[101];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ab[i].second >> ab[i].first;
  }
  for (int i = 0; i < n; i++) {
    cin >> cd[i].first >> cd[i].second;
  }

  sort(ab, ab + n);
  reverse(ab, ab + n);
  sort(cd, cd + n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (ab[i].first < cd[j].second && ab[i].second < cd[j].first && n_ch[j] == false) {
        n_ch[j] = true;
        count++;
        break;
      }
      
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N, C;
    cin >> N >> C;
    vector<vector<ll>> D(C, vector<ll>(C));
    rep(i, C){
        rep(j, C){
            cin >> D.at(i).at(j);
        }
    }
    vector<vector<ll>> c(N, vector<ll>(N));
    rep(i, N){
        rep(j, N){
            cin >> c.at(i).at(j);
            c.at(i).at(j)--;
        }
    }
    vector<vector<ll>> iwa(3, vector<ll>(C, 0));
    rep(i, N){
        rep(j, N){
            ll a = (i+j)%3;
            rep(k, C){
                iwa.at(a).at(k) += D.at(c.at(i).at(j)).at(k);
            }
        }
    }
    ll ans = INF;
    rep(i, C){
        rep(j, C){
            if(j == i){
                continue;
            }
            rep(k, C){
                if(k == i || k == j){
                    continue;
                }
                chmin(ans, iwa.at(0).at(i)+iwa.at(1).at(j)+iwa.at(2).at(k));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
const int MX = 1'000'000 + 1;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), p(MX);
  for (int &i : a) {
    cin >> i;
    p[i]++;
  }
  int pw = 1;
  for (int i = 2; i < MX; i++) {
    int cnt = 0;
    for (int j = i; j < MX; j += i) cnt += p[j];
    if (cnt > 1) {
      pw = 0;
      break;
    }
  }
  if (pw) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  int g = 0;
  for (int i : a) g = gcd(g, i);
  if (g == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
  return 0;
}

Measured memory_bytes: 10992
import java.util.*;

public class Main {
        public static void main(String[] args){
            Scanner sc =new Scanner(System.in);
            int n = sc.nextInt();
            int[] h = new int[n];
            for(int i=0;i<n;i++){
                h[i] = sc.nextInt();
            }
            int max = h[0];
            int sum = 1;
            for(int j=1;j<n;j++){
                if(h[j]>=max){
                    sum++;
                    max=h[j];
                }
            }
            System.out.println(sum);
            for(long k = 0;k<100000000;k++){
                sum=sum*2;
                sum=sum/2;
            }
        }

        }



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

char str[128];
int h,w;

int main(void){
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++){
			scanf("%s",str);
			if(!strcmp(str,"snuke"))
				return printf("%c%d\n",j+'A'-1,i),0;
		}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >>n;
  int x;
  
  for(int i=1; i<=n; i++){
    x=i;
    if( (i%3)==0 ){
      cout <<" "<<i;
    }
    else{
      do{
	if((x%10)==3){
	  cout <<" "<<i;
	  break;
	}
	x/=10;
      }while(x);
    }
  }
  cout<<endl;

  return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  int tmp = 1;
  rep(i, N) {
    tmp = min(tmp*2, tmp+K);
  }
  cout << tmp << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define P pair<int,int>

main(){
	int n,a,b ;
	vector<P> c ;
	
	cin >> n ;
	for( int i=0 ; i<n ; i++ ){
		cin >> a >> b ;
		c.push_back( P(a,b) ) ;
	}
	cin >> n ;
	for( int i=0 ; i<n ; i++ ){
		cin >> a >> b ;
		c.push_back( P(a,b) ) ;
	}
	
	sort( c.begin() , c.end() ) ;
	
	a = c[0].first ;
	b = c[0].second ;
	cout << a << ':' ;
	if( b < 10 ) cout << 0 ;
	cout << b ;
	
	for( int i=0 ; i<c.size() ; i++ ){
		if( a == c[i].first && b == c[i].second ) continue ;
		
		cout << " " ;
		cout << c[i].first << ':' ;
		if( c[i].second < 10 ) cout << 0 ;
		cout << c[i].second ;
		
		a = c[i].first ;
		b = c[i].second ;
	}
	cout << endl ;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), ans;
    rep(i,n) cin >> a[i], --a[i];
    rep(i,n) {
        int temp = -1;
        for(int j = a.size()-1; j >= 0; --j){
            if(a[j]==j){
                temp = j;
                break;
            }
        }
        if(temp==-1){
            cout << -1 << endl;
            return 0;
        }
        ans.push_back(temp+1);
        a.erase(a.begin()+temp);
    }
    reverse(all(ans));
    for(int x : ans){
        cout << x << endl;
    }
    return 0;
}

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

int main(){
    string a,b;
    cin >> a >> b;
    
    int c = stoi(a + b);
    for(int i = 0; i < 318; i++){
        if(pow(i,2) == c){
            cout << "Yes" << endl;
            break;
        }else if(pow(i,2) > c){
            cout << "No" << endl;
            break;
        }
    }
}

    

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int aCount = 0;
		int zCount = 0;
		int answer = 0;
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		String[] splitStr = str.split("",0);
		
		for(int i = 0; i < splitStr.length; i++){
			if(splitStr[i].equals("A")){
					aCount = i;
					break;
			}
		}
		for(int i = 0; i < splitStr.length; i++){
			if(splitStr[i].equals("Z") && i > aCount){
				zCount = i;
			}
				answer = zCount - aCount + 1;
		}
		System.out.println(answer);
	}

}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  double x[n];
  string u[n];
  double sum = 0;
  for(int i = 0; i < n; ++i) {
    cin >> x[i] >> u[i];
    if(u[i] == "JPY") sum += x[i];
    else {
      sum += x[i] * 380000;
    }
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static Dictionary<Tuple<long, long>, long> dic = new Dictionary<Tuple<long, long>, long>();


        static void Main(string[] args)
        {

            var nn = ReadLongArr();
            var n = nn[0];
            var a = nn[1];
            var b = nn[2];

            long res = 0;
            long tmp = 0;

            if((a+b)%2 == 0)
            {
                res = (b - a) / 2;
            }
            else
            {
                if((a-1) < (n - b)){
                    res = a - 1 + calc(1, b-a+1);
                }else
                {
                    res = n - b + calc(a+n-b, n);
                }
            }

            Console.WriteLine(res);
        }

        private static long calc(long a, long b)
        {
            return ((b - a) / 2) + ((b - a) % 2);
        }



        class BitArr
        {
            public bool[] bitArr = new bool[64];

            public BitArr(long l)
            {
                var ll = l;
                for(int i=0; i<64; i++)
                {
                    bitArr[i] = (ll % 2) == 1;
                    ll = ll / 2;
                }
            }
        }

        public static int Digit(long num)
        {
            // Mathf.Log10(0)はNegativeInfinityを返すため、別途処理する。
            return (num == 0) ? 1 : ((int)Math.Log10(num) + 1);
        }

        public static long nCm(long n, long m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            var a = n * nCm(n - 1, m - 1) / m;
            return a % 1000000007;
        }

        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArr()
        {
            return Console.ReadLine().Split(' ');
        }
        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadLongArr()
        {
            string[] s = ReadStringArr();
            long[] l = new long[s.Length];
            for(int i=0; i<l.Length; i++)
            {
                l[i] = long.Parse(s[i]);
            }

            return l;
        }
    }

}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
const long long inf = 1LL << 60;
typedef long long ll;
vector<pair<int,ll> > G[maxn];
int n,m;
long long d[maxn];
void bellman_ford(){
	fill(d,d+maxn,inf);
	d[1] = 0;
	bool circle = false;
	for(int i = 0; i < n; i++){
		for(int j = 1; j <= n; j++){
			if(d[j] == inf) continue;
			for(auto v : G[j]){
				ll w = v.second; 
				int to = v.first;
				if(d[to] > d[j] + w){		
					d[to] = d[j] + w;
					if(i == n-1 && to == n) circle = true;	
				}			
			}	
		}	
	}
	if(circle){
		puts("inf");	
	} else {
		printf("%lld\n", -d[n]);	
	}
}

int main(){
	cin >> n >> m;
	int u,v;
	ll w;
	for(int i = 0; i < m; i++){
		scanf("%d%d%lld", &u, &v, &w);
		G[u].push_back(make_pair(v,-w));
	}	
	bellman_ford();
	return 0;	
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main() {

    int N;
    cin >> N;
    vector <ll> a(N);
    vector <ll> b(N);
    vector <ll> amb(N);
    ll wa = 0;
    ll maiwa;
    ll res = 0;

    REP(i,N)cin >> a[i];
    REP(i,N)cin >> b[i];
    REP(i,N)
    {
        amb[i] = a[i] - b[i];
        wa += amb[i];
        if(amb[i] < 0)
        {
            res++;
            //負の必要な値を調べる
            maiwa += min(0ll, amb[i]);
        }

    }

    if(wa < 0)
    {
        cout << -1 << endl;
        return 0;
    }

    sort(amb.rbegin(),amb.rend());
    
    
    for(int i = 0; i < N; ++i)
    {
        if(maiwa >= 0)break;
        maiwa += amb[i];
        ++res;
    }


    cout << res << endl;

    return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
#define PI 3.141592
using namespace std;

int main()
{
	int x, a;
	cin >> x >> a;

	printf("%d", x < a ? 0 : 10);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int main(){
  long n,l,t;
  cin>>n>>l>>t;
  vector<long> xx(n), w(n);
  rep(i,n) cin>>xx[i]>>w[i];

  vector<long> x(n);
  repl(i,1,n) x[i] = xx[i] - xx[0];
  x[0]=0;
  bool mirror=false;
  if(w[0]==2){
    mirror=true;
    rep(i,n){
      if(w[i]==1) w[i]=2;
      else w[i]=1;
      x[i] = (l - x[i])%l;
    }
    reverse(w.begin()+1, w.end());
    reverse(x.begin()+1, x.end());
  }

  vector<long> v(n);
  rep(i,n){
    if(w[i]==1) v[i] = (x[i] + t)%l;
    else v[i] = (x[i] - t%l + l) % l;
  }
  sort(all(v));

  long cnt = 0;
  repl(i,1,n) if(w[i]==2) cnt++;
  cnt *= (2*t)/l;

  long q = (2*t)%l;
  for(int i=0; (i<n)&&(x[i]<q); i++) if(w[i]==2) cnt++;

  int id = lower_bound(all(v), t%l) - v.begin();
  int init = (id - cnt%n + n)%n;

  vector<long> ans(n);
  rep(i,n) ans[i] = v[(init+i)%n];

  if(mirror){
    rep(i,n) ans[i] = (l - ans[i])%l;
    reverse(ans.begin()+1, ans.end());
  }

  rep(i,n) cout << (ans[i]+xx[0])%l << endl;

  return 0;
}


Measured memory_bytes: 5120
// header {{{
using namespace std;

// C++
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

#pragma GCC optimization_level 3

// util {{{
#define print(x)	        cout << (x)
#define printvec(x,y)       for(int i = 0;i < (y);i++)cout << (x).at(i) << " ";cout << endl
#define println(x)	        cout << (x) << endl
#define printn		        cout << endl
#define read(x)	            cin >> (x)
#define readvec(x,y)        for(int i = 0; i < (y);i++)cin >> (x).at(i)

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

#define all(x) 		        (x).begin(),(x).end()
#define vint                vector<int>
#define outif(x,y,z)        if(x) cout<<(y)<<endl; else cout<<(z)<<endl
#define loop 		        while(true)

// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

void solve() {
    int in;
    int h,m,s;
    scanf("%d",&in);

    h = in / 3600;
    in %= 3600;

    m = in / 60;
    in %= 60;

    s = in;

    printf("%d:%d:%d\n",h,m,s);
}

signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 3252
from collections import defaultdict

h, w, m = map(int, input().split())

rowsum = [0] * h
rowmax = 0
colsum = [0] * w
colmax = 0
targets = defaultdict(int)
for _ in range(m):
    hi, wi = map(int, input().split())
    hi -= 1
    wi -= 1
    rowsum[hi] += 1
    rowmax = max(rowmax, rowsum[hi])
    colsum[wi] += 1
    colmax = max(colmax, colsum[wi])
    targets[(hi, wi)] = 1

rowindices = []
for i, v in enumerate(rowsum):
    if v == rowmax:
        rowindices.append(i)

colindices = []
for i, v in enumerate(colsum):
    if v == colmax:
        colindices.append(i)

ans = rowmax + colmax - 1
for ri in rowindices:
    for ci in colindices:
        if targets[(ri, ci)]:
            continue
        print(rowmax + colmax)
        exit()

print(ans)

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

typedef pair<int,int> P;
typedef pair<int,P>  Q;

const int INF = 1<<28;

int main() {
    int N, M;
    while (cin >> N >> M, N || M) {
        vector<vector<int>> v(N), d(N), c(N);
        for (int i = 0; i < M; i++) {
            int x, y, z, w;
            cin >> x >> y >> z >> w;
            x--, y--;
            v[x].push_back(y);
            v[y].push_back(x);
            d[x].push_back(z);
            d[y].push_back(z);
            c[x].push_back(w);
            c[y].push_back(w);
        }

        vector<int> dp(N, INF);
        vector<int> cdp(N, INF);
        int ans = 0;
        priority_queue<P, vector<P>, greater<P>> que;
        dp[0] = 0;
        cdp[0] = 0;
        que.push(P(0,0));
        while (!que.empty()) {
            P p = que.top(); que.pop();
            int now = p.second;
            int dist = p.first;

            if (dp[now] < dist) continue;
            ans += cdp[now];
            
            for (int i = 0; i < v[now].size(); i++) {
                int next = v[now][i];
                int ndist = dist + d[now][i];
                if (dp[next] > ndist) {
                    dp[next] = ndist;
                    cdp[next] = c[now][i];
                    que.push(P(ndist, next));
                } else if (dp[next] == ndist) {
                    cdp[next] = min(cdp[next], c[now][i]);
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

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

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=998244353;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	int n;
	cin>>n;
	int a[100010];
	rep(i,n)cin>>a[i];
	bool ok=true;
	int s=accumulate(a,a+n,0ll);
	if(s%(n*(n+1)/2)!=0)ok=false;
	s/=n*(n+1)/2;
	int b[100010];
	b[0]=a[n-1]-a[0];
	rep(i,1,n)b[i]=a[i-1]-a[i];
	rep(i,n){
		if((b[i]+s)%n!=0)ok=false;
		b[i]=(b[i]+s)/n;
	}
	rep(i,n)if(b[i]<0)ok=false;
	if(ok)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 1792
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a = LI()
    if sum(a) >= 22:
        return 'bust'

    return 'win'


print(main())




Measured memory_bytes: 5836
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    string str, x, y;
    cin >> str;
    int q;
    cin >> q;
    int a, b, p;
    for(int i = 0; i < q; i++){
        cin >> x >> a >> b;
        p = b - a + 1;
        if(x == "print"){
            cout << str.substr(a, p) << endl;     
        }
        if(x == "reverse"){
            b += 1;
            reverse(str.begin() + a,str.begin() + b);
        }
        if(x == "replace"){
            cin >> y;
            str.replace(a, p, y);
        }
    }
    
    return 0;
}



Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int n;
long long sum=0;
int f(int a,int b)
{
	int sum1,sum2;
	if(a==b) sum1=sum2=1;
	else sum1=sum2=0;
	if(a*10+b<=n) sum1++;
	if(b*10+a<=n) sum2++;
	for(int s1=0;s1<=9;s1++)
	{
		if(a*100+s1*10+b<=n) sum1++;
		if(b*100+s1*10+a<=n) sum2++;
		for(int s2=0;s2<=9;s2++)
		{
			if(a*1000+s1*100+s2*10+b<=n) sum1++;
			if(b*1000+s1*100+s2*10+a<=n) sum2++;
			for(int s3=0;s3<=9;s3++)
			{
				if(a*10000+s1*1000+s2*100+s3*10+b<=n) sum1++;
				if(b*10000+s1*1000+s2*100+s3*10+a<=n) sum2++;
				for(int s4=0;s4<=9;s4++)
				{
					if(a*100000+s1*10000+s2*1000+s3*100+s4*10+b<=n) sum1++;
					if(b*100000+s1*10000+s2*1000+s3*100+s4*10+a<=n) sum2++;
				}
			}
		}
	}
	sum=sum+sum1*sum2;
}
int main()
{
	cin>>n;
	if(n<=9) sum=n;
	else if(n==10) sum=9;
	else
	{
		for(int i=1;i<=9;i++)
		{
			for(int j=1;j<=9;j++)
			{
				f(i,j);	
			}	
		}
	}
	printf("%lld\n",sum);
	return 0;
} 

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

int main() {
  int A , B , C ;
  cin >> A >> B >> C ;
  
  if (A==5 && B==5 && C==7) {
    cout << "YES" << endl;
}
   else if (A==5 && B==7 && C==5) {
    cout << "YES" << endl;
}
   else if (A==7 && B==5 && C==5) {
    cout << "YES" << endl;
}
  else  {
    cout << "NO" << endl;
}

}


Measured memory_bytes: 256
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, k;
  scanf("%d %d", &n, &k);
  
  int ans;
  
  if(k == 1) ans = 0;
  else ans = n - k;
  printf("%d\n", ans);
  
  return 0;
}

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

int main()
{
	int N;
	string S;
	cin >> N >> S;
	vector<int> sum1(N + 1), sum2(N + 1);
	for (int i = 0; i < N; i++) {
		sum1[i + 1] = sum1[i] + (S[i] == '#');
		sum2[i + 1] = sum2[i] + (S[i] != '#');
	}
	int res = N;
	for (int i = 0; i <= N; i++) {
		res = min(res, (sum1[i] - sum1[0]) + (sum2[N] - sum2[i]));
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 2180
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define all(c) begin(c),end(c)
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using vi = vector<int>; using vs = vector<string>;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	int N;
	while (cin >> N, N) {
		vector<int> A(N);
		for (int i = 0; i < N; i++) {
			cin >> A[i];
		}
		sort(A.begin(), A.end());
		int sum = 0;
		for (int i = 1; i < N - 1; i++) {
			sum += A[i];
		}
		sum /= (N - 2);
		cout << sum << endl;
	}
}

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


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


int main(void){
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  r(i,h)cin>>s.at(i);

  r(i,w+2)cout<<"#";
  cout<<endl;
  r(i,h){
    s[i].insert(0, "#");
    s.at(i)+="#";
    cout<<s.at(i)<<endl;
    }

  r(i,w+2)cout<<"#";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }



void solve()
{
    ll n;
    cin >> n; ll c, k; cin >> c >> k;
    ll a[n];
    rep(i, n) cin >> a[i];
    ll ans = 0;
    sort(a, a+n);

    for(ll i = 0, j = 0; i < n; )
    {
        while(j < n && (j-i+1) <= c && a[j]-a[i] <= k) j++;
        ans++;
        i = j; //cout << j << " ";
    }
    cout << ans;

}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 1024