akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#define MAX 20000  // スタックの最大値

typedef struct{
  int top;         // スタックポインタ(一番上の位置)
  int S[MAX];
}Stack;


// スタック st の初期化
void initialize(Stack *st)
{
  st->top = 0;
  st->S[st->top] = 0;
}

// スタック st が空かどうかを確認
int isEmpty(Stack *st)
{
  return st->top == 0;
}

// スタック st が一杯かどうかを確認
int isFull(Stack *st)
{
  return st->top >= MAX - 1;
}

// スタック st に要素 x をプッシュ(一番上に要素を追加)
void push(int x, Stack *st)
{
  if (isFull(st))
    exit(1);

  st->top++;
  st->S[st->top] = x;
}

// スタック st から要素をポップ(一番上の要素を取り出す)
int pop(Stack *st) {
  if (isEmpty(st))
    exit(1);

  st->top--;
  return st->S[st->top+1];
}


int main(void)
{
  Stack st1;     // '\' の開始位置を格納するスタック
  Stack st2_j;   // 各水たまりの最も左の'\' の位置を格納するスタック
  Stack st2_a;   // 各水たまりの水量を格納するスタック

  // スタック初期化
  initialize(&st1);
  initialize(&st2_j);
  initialize(&st2_a);

  char c;
  int sum = 0;  // 水たまりの総水量
  int j;

  // 地形を読み込み，各水たまりの水量を計算
  for (int i = 0; (c = getchar()) != EOF; i++) {
    if (c == '\\') {                                 // '\' が出た時の処理
      // 位置 i を st1 にプッシュ(write your code)
      push(i,&st1);
    }else if (!isEmpty(&st1) && c == '/') {          // '/' が出た時の処理
      // 水たまりの総水量 sum を更新(write your code)
      j=pop(&st1);
      // st2_j と st2_a を用いて水たまりの水量を更新
      int a = i - j;   // 更新する水たまりの水量を a に格納していく
      sum+=a;
      while (!isEmpty(&st2_j) && st2_j.S[st2_j.top] > j) {  // 最も左の '\' の位置が j よりも大きい場合，以下を繰り返す
        // 水たまりの水量を求めていく (write your code)
        a=a+pop(&st2_a);
        pop(&st2_j);

      }
      // 更新した水たまりの「最も左の'\' の位置」および「水量」を更新 (write your code)
      push(j,&st2_j);
      push(a,&st2_a);

    }
  }

  printf("%d\n", sum);       // 水たまりの総水量を出力
  printf("%d", st2_a.top);   // 水たまりの個数を出力

  // 各水たまりの水量を断面図の左から出力(スタックの底から出力)
  for (int i = 1; i <= st2_a.top; i++)
    printf(" %d", st2_a.S[i]);
  printf("\n");

  return 0;
}




Measured memory_bytes: 2144
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

const int N = 1e6 + 5;
int fre[N];

void solve() {
   int n; cin >> n;
   int data[n+5];
   for(int i = 1; i <= n; i++) {
     cin >> data[i]; fre[data[i]]++;
   }
   int ans = 0;
   for(int i = 1; i <= n; i++) {
     int fl = 1;
     fre[data[i]]--;
     for(int j = 1; j * j <= data[i]; j++) {
        if(data[i]%j) continue;
        if(fre[j] || fre[data[i]/j]) {
            fl = 0; break;
        }
     }
     fre[data[i]]++;
     ans += fl;
   }
   cout << ans << '\n';
}

signed main() {   
   ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
      solve();
  }
}    


Measured memory_bytes: 12876
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int A, B, m;
    cin >> A >> B >> m;
    vector <int> a(A);
    cin >> a;
    vector <int> b(B);
    cin >> b;
    vector <vector <pii>> sales(A);
    forn (i, 0, m) {
        int x, y, c;
        cin >> x >> y >> c, --x, --y;
        sales[x].eb(y, c);
    }
    multiset <int> cur;
    for (int i : b)
        cur.insert(i);
    int ans = 1e9;
    forn (i, 0, A) {
        ans = min(ans, a[i] + *cur.begin());
        for (auto j : sales[i]) {
            cur.erase(cur.find(b[j.fs]));
            b[j.fs] -= j.sc;
            cur.insert(b[j.fs]);

            ans = min(ans, a[i] + *cur.begin());

            cur.erase(cur.find(b[j.fs]));
            b[j.fs] += j.sc;
            cur.insert(b[j.fs]);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 11392
n = int(input())
aList = sorted(list(map(int,input().split())))

if n == 1:
  if aList[0] != 0:
    print(0)
  else:
    print(1)
  exit(0)
if n % 2 != 0:
  if aList[0] != 0 and aList[1] == 0:
    print(0)
    exit(0)
  else:
    aList.pop(0)

for i in range(0,n-1,2):
  if i == 0:
    if aList[i] != aList[i+1]:
      print(0)
      exit(0)
  else:
    if aList[i] != aList[i+1] and aList[i] == aList[i-1]:
      print(0)
      exit(0)

result = 2
for i in range(1,n//2):
  result = (2*result)%  (10**9+7)

print(int(result))



Measured memory_bytes: 14008
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

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

    ll res = A[0];
    rep (i, 0, N) {
        res = __gcd(res, A[i]);
    }

    cout << res << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;
#include <string>
typedef long long int ll;
#include <algorithm>
#include <stack>
#include <vector>
#include <array>
#include <queue>

int main(){

  string S;
  cin >>S;

  int count = 0;
  if(S.size()==1){
    cout << 0;
  }else{
    for(int i=0;i<=S.size()/2-1;i++){
      //cout <<S[i]<<S[S.size()-1-i];
      if(S[i] != S[S.size()-1-i]){
        count += 1;
      }
    }
    cout << count;
  }




  return 0;

}


Measured memory_bytes: 256
s = input()

ans1 = (("S" in s) and ("N" in s)) or (("S" not in s) and ("N" not in s))
ans2 = (("E" in s) and ("W" in s)) or (("E" not in s) and ("W" not in s))

print("Yes" if ans1 and ans2 else "No")

Measured memory_bytes: 9072
import random
import time
import copy

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    ans = []    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][idx]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)
        

    while time.time() - start < 1.9:
        cp = ans.copy()
        last_d = [0 for i in range(26)]
        score2 = 0  
        
        idx1 = random.randint(0,25)
        idx2 = random.randint(0,25)
        if random.randint(0,1):
            d1 = random.randint(0,D-1) 
            d2 = random.randint(0,D-1)
            if idx1 == idx2:
                continue
            if random.randint(0,1):
                ans[d1] = idx1
            else:
                ans[d1] = idx1
                ans[d2] = idx2
             
        #2値入れ替え
        elif random.randint(0,1):           
            d1 = random.randint(0,D-19) 
            d2 = random.randint(d1+1,d1+18)
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp1
            
        #3値入れ替え          
        else:
            d1 = random.randint(0,D-17) 
            d2 = random.randint(d1+1,d1+8)
            d3 = random.randint(d2+1,d2+8) 
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            tmp3 = ans[d3]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp3
                ans[d3] = tmp1
            else:
                ans[d1] = tmp3
                ans[d2] = tmp1
                ans[d3] = tmp2
            
        for i in range(D):
            score2 += s[i][ans[i]]
            last_d[ans[i]] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans = cp.copy()
        else:
            score1 = score2
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


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


int main() {
  int N;
  cin >> N;
  vector<ll> L(N+1);
  L.at(0)=2;
  L.at(1)=1;
  for(int i=2;i<=N;i++){
    L.at(i)=L.at(i-1)+L.at(i-2);
  }
  cout << L.at(N) <<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm> 
using namespace std;
int main(){
  int n,a[3][101],t,sum=0,xx=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>t;
    a[1][i]=t;
  }
  for(int i=1;i<=n;i++){
    cin>>t;
    a[2][i]=t;
  }
  for(int i=1;i<=n;i++){
    int xn=1,yn=1,sum=0;
    sum+=a[yn][xn];
    if(1==i){
        yn++;
        sum+=a[yn][xn];
    }
    for(int j=2;j<=n;j++){
      if(j==i){
        yn++;
        sum+=a[yn][xn];
      }
      xn++;
      sum+=a[yn][xn];
    }
    if(sum>=xx) xx=sum;
  }
  cout<<xx<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
    ll n, m; cin>>n>>m;
    int a[4]={};
    rep(i,4) a[i]=-1;
    ll s,c;
    bool x=true;
    rep(i,m){
        cin>>s>>c;
        if(a[s]!=-1 && a[s]!=c) x=false;
        a[s]=c;
    }
    if(!x){
        cout<<-1;
        return 0;
    }
    if(n==1){
        if(a[1]==-1) cout<<0;
        else cout<<a[1];
        return 0;
    }
    if(a[1]==0){
        cout<<-1;
        return 0;
    }
    rep(i,n){
        if(a[i+1]!=-1) cout<<a[i+1];
        else if(i==0) cout<<1;
        else cout<<0;
    }

}

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

int main(){
int num[10000];
for(int i=0;i<10000;i++){
cin >> num[i];
if(num[i]==0) break;
}
for(int j=0;j<10000;j++){
if(num[j] == 0) break;
cout << "Case " << j+1 << ": " << num[j] << endl;
}
return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	double x1,y1,x2,y2,qx,qy;
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1,&y1,&x2,&y2,&qx,&qy) != EOF) {
		qx -= x1, qy -= y1, x2 -= x1, y2 -= y1;
		double cos = x2 / sqrt(x2*x2+y2*y2), sin = y2 / sqrt(x2*x2+y2*y2);
		double bx = qx;
		qx = cos*qx+sin*qy, qy = -sin*bx+cos*qy;
		bx = qx;
		qx = x1+cos*qx+sin*qy, qy = y1+sin*bx-cos*qy; 
		printf("%.6lf %.6lf\n", qx, qy);
	}
	return 0;
}

Measured memory_bytes: 1240
n = int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
import itertools

sec = [i+1 for i in range(n)]

permu = list(itertools.permutations(sec))

for i,v in enumerate(permu):
    
    if a == list(v):
        a_i = i+1
    if b == list(v):
        b_i = i+1

print(abs(a_i-b_i))




Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,ans=1;cin>>n;
    string s[2];cin>>s[0]>>s[1];
    vector<ll> a;
    for(ll i=0;i<n;){
        if(s[0][i]==s[1][i])a.push_back(1),i++;
        else a.push_back(2),i+=2;
    }
    if(a[0]==2)ans=6;
    else ans=3;

    for(ll i=1;i<(ll)a.size();i++){
        if(a[i]==1){
            if(a[i-1]==1)ans*=2;
            else ans*=1;
        }
        else{
            if(a[i-1]==1)ans*=2;
            else ans*=3;
        }
        ans%=mod;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<ctime>
const  int N = 2e6 + 5;
const long long mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
typedef long long ll;
typedef long double lw;
#define sc(n) scanf("%d",&n)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
int n, m;
int flag = 1;
ll f[N];
ll ans = 1;
int a[N];
int main()
{
	cin >> n>>m;
	f[0]=f[1] = 1, f[2] = 2;
	vector<int> v;
	v.push_back(0);
	fo(i, 1, m+1)
	{
		sc(a[i]);
		if (a[i] == a[i - 1]+1 && i != 1)
			flag = 0;
		v.push_back(a[i]);
	}
	if (flag)
	{
		fo(i, 3, n+1)
		{
			f[i] = (f[i - 1] + f[i - 2]) % mod;
		}
		if (m == 0)
			cout << f[n] << endl;
		else
		{
			v.push_back(n);
			int len = v.size();
			fo(i, 1, len)
			{
				int dis;
				if (i == 1 || i == len - 1)
					dis = v[i] - v[i - 1] - 1;
				else
					dis = v[i] - v[i - 1] - 2;
				ans = (ans*f[dis]) % mod;
			}
			cout << ans << endl;
		}
	}
	else
		cout << 0 << endl;
	return 0;
}

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

using namespace std;

int main() {
  int H,W;
  cin >> H;
  cin >> W;
  vector<string> tmp(H);

  for (int i=0; i<H; i++) {
        cin >> tmp[i];
  }

  for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
        if (tmp[i][j] == '.') {
          int s=0;

          for (int k=-1; k<2; k++) {
              for (int l=-1; l<2; l++) {
                if (i+k >= 0 && i+k < H && j+l >= 0 && j+l < W) {
                  if (tmp[i+k][j+l] == '#') {
                    s = s+1;
                  }
                }
              }
          }
          char s2 = '0' + s;
          tmp[i][j] = s2;
      }
    }
  }

  for (int i=0;i<H; i++) {
    cout << tmp[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 998244353;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M) % MOD;
}

ll fac[1000010], finv[1000010], inv[1000010];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 1000010; 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;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll N,M,K;
    cin >> N >> M >> K;
    ll ret = 0;
    COMinit();
    for(int i = 0;i <= K;i++) {
        ll cnt = COM(N - 1,N - 1 - i);
        ll cnt2 = M * RepeatSquaring(M - 1,N - i - 1,MOD) % MOD;
        ret += cnt * cnt2 % MOD;
        ret %= MOD;
    }
    cout << ret << endl;
}

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

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

    for (int i = 0; i <= N; ++i) {
        for (int j = 0; i + j <= N; ++j) {
            int k = N - i - j;
            if (10000 * i + 5000 * j + 1000 * k == Y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

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

	do{
		scanf("%d %d",&H,&W);

		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				printf("#");
			}
			printf("\n");
		}
		if((H!=0&&W!=0)){
			printf("\n");
		}
	}while(H!=0&&W!=0);
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

// kruskal.cpp depend on this.
#ifndef UNION_FIND_TREE
#define UNION_FIND_TREE
template<typename T>
class UnionFindTree{
	private:
		int N;
		vector<int> parent, rank, size;
		vector<T> diff_weight;

	public:
		void init(){
			for(int i = 0; i < (int) N; i++){
				parent[i] = i; rank[i] = 0; size[i] = 1; diff_weight[i] = 0;
			}
		}

		UnionFindTree(int N): N(N), parent(N), rank(N), size(N), diff_weight(N){
			init();
		}

		int root(int x){
			if(parent[x] == x){
				return x;
			}else{
				int r = root(parent[x]);
				diff_weight[x] += diff_weight[parent[x]];
				return parent[x] = r;
			}
		}

		T weight(int x){
			root(x);
			return diff_weight[x];
		}

		T diff(int x, int y){
			return weight(y) - weight(x);
		}

		// weight(y) = weight(x) + w となるようにmergeする
		bool unite(int x, int y, T w = 0){
			w += weight(x); w -= weight(y);
			x = root(x); y = root(y);
			if(x == y) return weight(y) - weight(x) == w;

			if(rank[x] < rank[y]){
				swap(x, y);
				w = -w;
			}

			parent[y] = x;
			size[x] += size[y];
			if(rank[x] == rank[y]) rank[x]++;
			diff_weight[y] = w;
			return true;
		}

		bool isSame(int x, int y){
			return root(x) == root(y);
		}
		
		int count(int x){
			return size[root(x)];
		}
};
#endif

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

	UnionFindTree<int> ut(N);
	bool res = true;
	for(int i = 0; i < M; i++){
		int l, r, d;
		cin >> l >> r >> d;
		l--; r--;
		if(not ut.unite(l, r, d)) res = false;
	}

	cout << (res ? "Yes" : "No") << '\n';

	return 0;
}

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

using namespace std;

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

#define mp make_pair
#define ff first
#define ss second
#define eps 1e-9
#define fcin freopen("input.txt", "r", stdin)
#define fcout freopen("output.txt", "w", stdout)
#define fstd ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define INF int(2e9 + 9)
#define mINF int(1e5 + 1)
#define BIG_INF ll(9e18)

ll binpow (ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res *= a;
        a *= a;
        b >>= 1;
    }
    return res;
}

////////////////
// change size//
///////////////

void solve()
{
    bool n;
    cin >> n;
    cout << !n;
}
int main()
{
//    fstd;
//    fcin;
//    fcout;
    ll t = 1;
//    cin >> t;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3612
/**
 *   @FileName	b.cpp
 *   @Author	kanpurin
 *   @Created	2020.05.17 22:12:17
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k) {
        cout << s << endl;
    } else {
        for (int i = 0; i < k; i++) {
            cout << s[i];
        }
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public void exec() {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int h=S/3600;
		int m=(S%3600)/60;
		int s=S%60;
		System.out.println(h+":"+m+":"+s);
	}

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

Measured memory_bytes: 26280
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue
from heapq import heappop, heappush
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m,k = inpl()
bla = 0
for i in range(n+1):
    bla = i*m
    for j in range(m+1):
        if bla + (n-2*i) * j == k:
            print('Yes')
            quit()
print('No')


Measured memory_bytes: 41068
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int N;
	cin>>N;
	
	int maxA = 0,maxB = 0;
	
	for(int i=0;i<N;i++){
		int A,B;
		cin>>A>>B;
		if(maxA<A){
			maxA=A;
			maxB=B;
		}
	}
	
	cout<<maxA+maxB<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4,sse4.1,sse4.2,avx,avx2,tune=native")
#include <bits/stdc++.h>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ if(a>b) a=b;}

using Pt = pair<double, double>;
bool compare_y(Pt a, Pt b){return a.second < b.second;};
double closest_pair(vector<Pt>& pos, int l, int r){
	if(r-l <=1) return 1e111;
	int mid = (l+r) /2 ;
	double x = pos[mid].first;
	double d = min(closest_pair(pos, l, mid), closest_pair(pos, mid, r));
	auto it = pos.begin(), itl = it+l, itm = it+mid, itr= it+r;
	inplace_merge(itl, itm, itr, compare_y);
	
	vector<Pt> near_line;
	rep2(i, l, r){
		if(abs(pos[i].first - x) >= d) continue;
		int m = sz(near_line);
		repr(j, m-1, 0){
			double px = pos[i].first  - near_line[j].first;
			double py = pos[i].second - near_line[j].second;
			if(py >= d) break;
			d = min(d, sqrt(px*px + py*py));
		}
		near_line.emplace_back(pos[i]);
	}
	return d;
}

int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<Pt> v(n);
	rep(i, n) cin >>v[i].first >>v[i].second;
	sort(all(v));
	auto ans = closest_pair(v, 0, n);
	printf("%.14f\n", ans);
	return 0;
}



Measured memory_bytes: 7812
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define db double
#define ld long double
#define IOS  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#pragma GCC optimize(2)
#define ull unsigned long long
#define maxn 110
signed main()
{
    IOS
    ll n;
    cin>>n;
    ll ans=1;
    for (ll i = 2; i <=(ll)sqrt(n) ; ++i) {
        ll now=n;
        while(now%i==0){
            now/=i;
            if((now-1)%i==0){
                ans++;
                break;
            }
        }
    }
    n--;
    for (ll l = 1; l <=(ll)sqrt(n) ; ++l) {
        if(n%l==0){
            ans+=2;
            if(l==1)ans--;
            if(l*l==n)ans--;
        }
    }
    cout<<ans;
    return 0 ;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec V(N); readv(V);
    vec C(N); readv(C);
    int ans = 0;
    REP(i, N) ans += max(0LL, V[i] - C[i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    string s;
    cin >> s;

    int n = s.size();
    bool flag = true;

    for (int i=0; i<n/2; i++)
        if (s[i] != s[n-1-i])
            flag = false;

    for (int i=0; i<n/4; i++) {
        if (s[i] != s[n/2-1-i])
            flag = false;
        if (s[n/2+1+i] != s[n-1-i])
            flag = false;
    }

    cout << (flag ? "Yes" : "No") << "\n";
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A, B, C, K; cin >> A >> B >> C >> K;
    ll cnt = 0;
    while (A >= B){B *= 2; cnt++;}
    while (B >= C){C *= 2; cnt++;}
    // cout << cnt << endl;
    if (cnt <= K){cout << "Yes" << endl;} else {cout << "No" << endl;}
}

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


Measured memory_bytes: 3648
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> &str {
    input!{
        source = src,
        a: isize,
        b: isize,
    }

    if a > 8 || b > 8 {
        return ":(";
    }
    return "Yay!";
}


Measured memory_bytes: 4352
N=int(input())
M=[input().split()[2:]for _ in[0]*N]
q=[0]
d=[0]+[-1]*N
while q:
 u=q.pop(0)
 for v in M[u]:
  v=int(v)-1
  if d[v]<0:d[v]=d[u]+1;q+=[v]
for i in range(N):print(i+1,d[i])



Measured memory_bytes: 5624
#include<stdio.h>


int main()
{
	int a, b, sum, cnt,temp, i = 0;
	int num[200] = { 0 };
	
	while (scanf("%d %d", &a,&b)!=EOF)
	{
		cnt = 1;
		sum = a + b;
		while (sum/=10)
		{
			++cnt;
		}
		num[i] = cnt;
		++i;
	}
	temp = i;
	for (i=0; i < temp;i++)
	{
		printf("%d\n", num[i]);
	}
	
	
	
	return 0;
}


Measured memory_bytes: 600
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;

typedef long long LL;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define OUT(a) cout<<(a)<<endl;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,q,a[100010],rank[100010]={},cnt=1,l,dat[100010]={100010};
    vector<int> res;
    cin >> n >> m >> q;
    REP(i,q){
        cin >> a[i];
    }
    for(int i= q-1; i>=0;--i){
        if(rank[a[i]]==0){
            rank[a[i]]=cnt;
            ++cnt;
            res.push_back(a[i]);
        }
    }
    REPN(i,1,m){
        if(rank[i]==0){
            rank[i]=cnt;
            ++cnt;
            res.push_back(i);
        }
    }

    for(int i=m-1;i>0;--i){
        if(res[i]<res[i-1]){
            l=i;
            break;
        }
    }

    for(int i= q-1; i>=0;--i){
        if(dat[rank[a[i]]]<dat[rank[a[i]]-1]){
        ++dat[rank[a[i]]];
        }
    }
    if(l==0){
        cout << "AAA" <<endl;
        return 0;
    }
    REPN(i,1,l){
        if(dat[l]<n){
            cout << "No" <<endl;
            return 0;
        }
    }
    cout << "Yes" <<endl;
    /*
    OUT(l)
    REP(i,m){
        OUT(res[i])
    }
    REP(i,m+1){
        OUT(dat[i])
    }
    //*/



    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <sstream>
#include <deque>
#include <string>
#include <cctype>
#include <cstring>
#include <cstdio>
const int M = 1e9 + 7;
#define ll long long int
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
using namespace std;

//insta  -------  __ansh7
//MSDIAN

// Basic Template




int main()
{
    fastio

    ll a[5];
    ll x;
    for(ll i=0;i<5;i++)
    {
        cin>>a[i];

        if(a[i]==0)
        {
            x=i;
        }
    }

    cout<<x+1<<"\n";







  





    return 0;
}

Measured memory_bytes: 3604
using System;
using System.Collections;
using System.Linq;

namespace ABC131
{
    class D
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] input;

            long[][] AB = new long[N][];

            for (int i = 0; i < N; i++)
            {
                input = Console.ReadLine().Split();
                AB[i] = new long[] { int.Parse(input[1]), int.Parse(input[0]) };
            }

            Array.Sort(AB, StructuralComparisons.StructuralComparer);

            long count = 0;
            foreach (var item in AB)
            {
                count += item[1];
                if (item[0] < count) { Console.WriteLine("No"); return; }
            }

            Console.WriteLine("Yes");

            /*
            Console.WriteLine("-----");
            foreach (var item in AB)
            {
                Console.Write(item[0]);
                Console.Write(' ');
                Console.Write(item[1]);
                Console.WriteLine();
            }
            */
        }
    }
}


Measured memory_bytes: 30268
#include <stdio.h>

int main(){
  int n,N;
  double x,y,v,t;

  while(scanf("%lf",&v)!=EOF){

    t=v/9.8;

    y=4.9*t*t;
    
    for(n=0;y>=5*n-5;n++);

    N=n;
    
    printf("%d\n",N);
  }
  
  return 0;
  
}

  

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


void BubbleSort(int Seq[], int n){
    int cnt=0;
    for(int i=0; i<n; i++){
        for(int j=n-1; j>i; j--){
            if(Seq[j] < Seq[j-1]){
                swap(Seq[j], Seq[j-1]);
                cnt++;
            }
        }
    }

    for(int i=0; i<n; i++){
        if(i != n-1){
            cout << Seq[i] << " ";
        }else{
            cout << Seq[i] << endl;
        }
    }
    cout << cnt << endl;

}


int main(){

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

    BubbleSort(Seq, n);

    return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
long long mod = 1e9+7;
int mark[20003] = {};
int limit = 0;
int dp[200005] = {};
long long getSum(int n)
{
    if(dp[n] != -1 && n >= 0)
    {
        return dp[n];
    }
    if(n == 0)
    {
        //cout << n << endl;
        //cout << Count << endl;
        //Count++;
        return 1;
    }
    if(n < 0)
    {
        return 0;
    }
    long long res = 0;
    for(int i = 1; i <= limit; i++)
    {
        //cout << mark[i] << endl;
        int tt = n-mark[i];
        if(tt >= 0)
        {
            res =(res+getSum(tt))%mod;
        }
    }
    //cout << n << " " << res << endl;
    return dp[n] = res%mod;
}
void solve()
{
    long long n; cin >> n;
    for(int i = 3; i <= n; i++)
    {
        limit++;
        mark[limit] = i;
    }
    //cout << limit << endl;
    long long sum = getSum(n)%mod;
    cout << sum << endl;
}
int main()
{
    memset(dp, -1, sizeof(dp));
    solve();
    return 0;
}


Measured memory_bytes: 4428
import math
b, a = map(int, input().strip().split(" "))
h = 2 * math.ceil(max((a - 1) / 25, (b - 1) / 25)) + 1
a -= 1
b -= 1
print("{} {}".format(h, 100))
for i in range(h):
    if i % 2 == 0:
        print("." * 50 + "#" * 50)
    else:
        if a > 0 and b > 0:
            ma = min(a, 25)
            mb = min(b, 25)
            print("#." * ma + "##" * (25 - ma) + "#." * mb + "##" * (25 - mb))
            a -= ma
            b -= mb
        elif a == 0 and b > 0:
            mb = min(b, 25)
            print("." * 50 + "#." * mb + "##" * (25 - mb))
            b -= mb
        elif a > 0 and b == 0:
            ma = min(a, 25)
            print("#." * ma + "##" * (25 - ma) + "#" * 50)
            a -= ma


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

//最大値問題
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    llong n,a[100002][3],dp[100002][3]={},ans=0;
    cin >> n;
    rep(i,n)  cin >> a[i][0] >> a[i][1] >> a[i][2];
    rep(i,n) rep(j,3) rep(k,3){
        if(j==k) continue;
        chmax(dp[i+1][k],dp[i][j] + a[i][k]);
    }
    rep(i,3) chmax(ans,dp[n][i]);
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
 

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	string s;
	cin >> s;
	vector <vector<ll>> arr(26);
	for (int z=0;z<n;z++){
		arr[s[z]-'0'].push_back(z);
	}
	ll ans = 0;
	for (int z=0;z<=999;z++){
		string t = to_string(z);
		while (t.size() < 3){
			t = '0' + t;
		}
		if (arr[t[2]-'0'].size() == 0) continue;
		if (arr[t[1]-'0'].size() == 0) continue;
		if (arr[t[0]-'0'].size() == 0) continue;
		ll i = arr[t[0]-'0'][0];
		ll j = arr[t[2]-'0'][arr[t[2]-'0'].size()-1];
		auto it = upper_bound(arr[t[1]-'0'].begin(),arr[t[1]-'0'].end(),i);
		if (i < *it && *it < j){
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 768
package main

import "fmt"

func main() {
	var N int
	var S string
	fmt.Scan(&N)
	fmt.Scan(&S)
	ans := 1
	for n := 0; n < N-1; n++ {
		if S[n] != S[n+1] {
			ans++
		}
	}
	fmt.Println(ans)
}


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

int main() {
    int n, ans = INT_MIN;
    cin >> n;
    vector<vector<int>> shop(n, vector<int>(10)), price(n, vector<int>(11));
    rep(i, n) rep(j, 10) cin >> shop.at(i).at(j);
    rep(i, n) rep(j, 11) cin >> price.at(i).at(j);
    rep(i, (1 << 10) - 1) {
        int temp = 0;
        rep(j, n) {
            int cnt = 0;
            rep(k, 10) if((1 & ((i + 1) >> k)) && shop.at(j).at(k)) cnt++;
            temp += price.at(j).at(cnt);
        }
        ans = max(ans, temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 303;
int T, n, m, a[N][N], cnt[N], q[N], front, rear, np[N];
bool vis[N];
inline bool check(int x){
	front = rear = 0;
	for(Rint i = 1;i <= m;i ++) cnt[i] = vis[i] = 0;
	for(Rint i = 1;i <= n;i ++) ++ cnt[a[i][np[i] = 1]];
	for(Rint i = 1;i <= m;i ++) if(cnt[i] > x) vis[q[rear ++] = i] = true;
	while(front < rear){
		int now = q[front ++];
		for(Rint i = 1;i <= n;i ++)
			while(np[i] <= m && vis[a[i][np[i]]]) ++ np[i];
		for(Rint i = 1;i <= m;i ++) cnt[i] = 0;
		for(Rint i = 1;i <= n;i ++) ++ cnt[a[i][np[i]]];
		for(Rint i = 1;i <= m;i ++) if(cnt[i] > x && !vis[i]) vis[q[rear ++] = i] = true;
	}
	for(Rint i = 1;i <= m;i ++) if(!vis[i]) return true;
	return false;
}
int main(){

		scanf("%d%d", &n, &m);
		for(Rint i = 1;i <= n;i ++)
			for(Rint j = 1;j <= m;j ++)
				scanf("%d", a[i] + j);
		int l = 1, r = n, mid, ans = 0;
		while(l <= r){
			mid = l + r >> 1;
			if(check(mid)) ans = mid, r = mid - 1;
			else l = mid + 1;
		}
		printf("%d\n", ans);

}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll H, W;
	cin >> H >> W;
	ll N;
	cin >> N;
	vector<ll> a(N);
	REP(i, N) cin >> a[i];

	ll c[H][W];
	ll i = 0;
	ll col = 0;
	while(i<H*W){
		if(a[col]<=0) col++;
		a[col]--;
		if((i/W)%2==0){
			c[i/W][i%W] = col+1;
		}else{
			c[i/W][W-1-i%W] = col+1;
		}
		i++;
	}
	REP(i, H){
		REP(j, W){
			cout << c[i][j] << " ";
		}
		cout << endl;
	}
    return 0;
}

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

int main()
{
    vector<int> v;
    int n;
    cin >> n;

    while (n--)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }

    int q;
    cin >> q;

    while (q--)
    {
        int a, b;
        cin >> a >> b;
        reverse(v.begin() + a, v.begin() + b);
    }

    for (n = 0; n < v.size(); n++)
    {
        if (n)
            cout << " ";
        cout << v[n];
    }
    cout << endl ;
}


Measured memory_bytes: 3156
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) { new MainClass().solve(); }

        Scanner cin = new Scanner();


        int N, L;
        string[] S;
        void solve() {
            N = cin.nextInt();
            L = cin.nextInt();
            S = new string[N];
            for (int i = 0; i < N;i++)
                S[i] = cin.next();

            Array.Sort(S);

            StringBuilder sb = new StringBuilder();
            foreach (string str in S)
                sb.Append(str);

            string ans = sb.ToString();

            Console.WriteLine(ans);
        }
        class Scanner {
            string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
            public Scanner() { nextBuffer = new string[0]; BufferCnt = 0; }
            public string next() {
                if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                BufferCnt = 0;
                return nextBuffer[BufferCnt++];
            }
            public int nextInt() { return int.Parse(next()); }
            public long nextLong() { return long.Parse(next()); }
            public double nextDouble() { return double.Parse(next()); }
        }
        class Mathf {
            private int mod = 1000000007;//10^9+7
            public int Mod { get; set; }
            public Mathf() { }
            public Mathf(int mod) { this.mod = mod; }
            public long Pow(long a, long b) {
                if (b == 0) return 1;
                if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
                else return Pow(a * a % mod, b / 2) % mod;
            }
            public long Fact(long n) { return n != 0 ? (n % mod * (Fact(n - 1) % mod) % mod) : 1; }
            public long C(long n, long r) {if (r == 0 || n == r) return 1;
                else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod;}
        }
    }
}

Measured memory_bytes: 13408
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<pair<string,int>> s(n);
    for(int i=0;i<n;i++){
        cin>>s[i].first>>s[i].second;
    }
    string str;cin>>str;
    bool f=0;
    int ans=0;
    for(int i=0;i<n;i++){
        if(s[i].first==str)f=1;
        else if(f)ans+=s[i].second;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int num=scan.nextInt();
    int tall=scan.nextInt();
    int can=0;
    for(int a=0;a<num;a++){
      int talls=scan.nextInt();
      if(talls>=tall){
        can++;
      }
    }
    System.out.println(can);
  }
}

Measured memory_bytes: 48260
#include<stdio.h>
#include<stdlib.h>
int main(){
    int a,s,i,j;
    int *retu;
    
    scanf("%d",&a);
    retu=(int *)malloc(a * sizeof(int));
    for(i=0;i<a;i++){
        scanf("%d",&retu[i]);
    }
    for(i=0;i<a;i++){
        s=retu[i];
        j=i-1;
        while(retu[j]>s && j>=0){
            retu[j+1]=retu[j];
            j--;
        }
	retu[j+1]=s;
	for(j=0;j<a;j++){
        printf("%d",retu[j]);
	if(j!=a-1)printf(" ");}
	printf("\n");
    }
}


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

int n,arr[200001],indeks[200001],nomor[200001],nomorbaru[200001],newsum;
long long k,sum;

int teleportation(int n,long long k){
	if(k > 0){
		sum++;
		return teleportation(arr[n],k - 1);
	}else{
		return n;
	}
}

void teleport(int n,long long k){
	if(k > 0){
		if(indeks[arr[n]] == 0) {
			nomor[sum + 1] = arr[n];
			sum++;
			indeks[arr[n]] = 1;
			teleport(arr[n],k - 1);
		}else{
			if(indeks[arr[n]] == 1){
				nomorbaru[newsum + 1] = arr[n];
				sum++;
				newsum++;
				indeks[arr[n]] = 2;
				teleport(arr[n],k - 1);
			}
		}
	}
}

int main(){
	cin>>n>>k;
	for(int i = 1;i <= n;i++){
		cin>>arr[i];
	}
	teleport(1,k);
	if(k <= sum){
		cout<<teleportation(1,k)<<endl;
	}else{
		k = k + newsum + newsum + newsum + newsum + newsum;
		if((k - (sum - newsum - newsum)) % newsum != 0) cout<<nomorbaru[(k - (sum - newsum - newsum)) % newsum]<<endl;
		else cout<<nomorbaru[newsum]<<endl;
	}
}


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

int root[100010]; //root[i]=i's parent
ll element[100010]; //element[i]=i's group's element
//element[find(i)] is better
 
void init(int n){
  for(int i=0;i<n;i++) root[i]=i,element[i]=1;
}//reset
int find(int x){
  if(root[x]==x){
    return x;
  }
  else{
    return root[x]=find(root[x]);
  }
}//search x's parent
bool same(int x,int y){
  return find(x)==find(y);
}
void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y) return;
  root[x]=y;
  element[y]+=element[x];
}//x"->"y

int main(){
  int n;
  cin>>n;
  ll vec[n];
  ll ans=0;
  ll vecb[100001]={};
  for(int i=0;i<n;i++){
    cin>>vec[i];
    vecb[vec[i]]++;
    ans+=vec[i];
  }
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int a,b;
    cin>>a>>b;
    cout<<ans-vecb[a]*a+vecb[a]*b<<endl;
    ans=ans-vecb[a]*a+vecb[a]*b;
    vecb[b]+=vecb[a];
    vecb[a]=0;
  }
}

Measured memory_bytes: 5196
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
string s;
int main(){
    cin>>s;
    map<char,int> mp;

    for(auto c:s){
        mp[c]++;
    }
    for(auto m:mp){
        if(m.second%2==1){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";


        
    return 0;
}


Measured memory_bytes: 256