akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef pair<int, int> pp;

int main(){
    int n, op;
    cin >> n;
    pp ary[n];
    rep(i, n){
        scanf("%d", &op);
        op--;
        ary[i] = (i < op ? pp(i, op) : pp(op, i));
    }
    sort(ary, ary + n);
    int ans = 0;
    rep(i, n-1){
        if(ary[i] == ary[i+1]) ans++;
    }
    cout << ans << "\n";
}

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

using namespace std;

const int vy[] = {1, 0, -1, 0};
const int vx[] = {0, 1, 0, -1};
const string vv = "NESW";

int N, X0, Y0, T;
bool mat[52][52][4];
int dir[1001];

int main()
{

  memset(dir, -1, sizeof(dir));

  cin >> N >> X0 >> Y0 >> T;
  for(int i = 0; i < N; i++) {
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    if(sx > gx) swap(sx, gx);
    if(sy > gy) swap(sy, gy);
    if(sx == gx) {
      for(int j = sy; j < gy; j++) {
        mat[j][sx][0] = true;
        mat[j + 1][sx][2] = true;
      }
    } else {
      for(int j = sx; j < gx; j++) {
        mat[sy][j][1] = true;
        mat[sy][j + 1][3] = true;
      }
    }
  }

  int st = 0;
  for(int i = 0; i < T; i++) {
    int a;
    char b;
    cin >> a >> b;
    st += a;
    dir[st] = (int) vv.find(b);
  }

  int latte[51][51][4] = {{{}}};
  for(int i = 0; i < 4; i++) latte[Y0][X0][i] = true;

  for(int i = 1; i <= st; i++) {
    int malta[51][51][4] = {{{}}};
    for(int j = 0; j <= 50; j++) {
      for(int k = 0; k <= 50; k++) {
        for(int l = 0; l < 4; l++) {
          if(!latte[j][k][l]) continue;
          for(int m = -1; m <= 1; m++) {
            int ndir = (l + m + 4) % 4;
            int ny = j + vy[l], nx = k + vx[l];
            if(ny < 0 || nx < 0) continue;
            if(!mat[ny][nx][ndir]) continue;
            if(~dir[i] && l != dir[i] && ndir != dir[i]) continue;
            malta[ny][nx][ndir] = true;
          }
        }
      }
    }

    swap(latte, malta);
  }

  set< pair< int, int > > vs;
  for(int i = 0; i <= 50; i++) {
    for(int j = 0; j <= 50; j++) {
      for(int k = 0; k < 4; k++) {
        if(latte[i][j][k]) vs.emplace(j, i);
      }
    }
  }
  for(auto &p : vs) {
    cout << p.first << " " << p.second << endl;
  }


}

Measured memory_bytes: 3264
/*
author: UncleGrandpa925
*/
/*input
5 9
3 2
3 1
4 1
4 2
3 5
5 3
3 4
1 2
2 5

2 2
1 2
2 1

3 3
1 2
1 3
2 3
*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define N 1005
#define bit(x,y) ((x>>y)&1LL)
#define loop(i,l,r) for(int i=(signed)(l); i<=(signed)(r); i++)

#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &a) {
    return os << '(' << a.first << ", " << a.second << ')';
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    for (unsigned int i = 0; i < a.size(); i++)
        os << a[i] << (i < a.size() - 1 ? ", " : "");
    os << ']';
    return os;
}
template <class T>
ostream &operator<<(ostream &os, const set<T> &a) {
    os << '{';
    for (typename set<T>::iterator it = a.begin(); it != a.end(); it++) {
        typename set<T>::iterator jt = it;
        os << *it << (++jt != a.end() ? ", " : "");
    }
    os << '}';
    return os;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, map<T1, T2> &a) {
    os << "{\n";
    for (typename map<T1, T2>::iterator it = a.begin(); it != a.end(); it++) {
        typename map<T1, T2>::iterator jt = it;
        os << "  " << it->first << ": " << it->second << (++jt != a.end() ? ",\n" : "\n");
    }
    os << '}';
    return os;
}

int n, m;
vector<vector<pair<int, int> > > a(N);
int cnt[N][N];
int mark[N][N];
bool ansOrder[200005];

void dfs(int u, int p, const int root, const int source) {
    if (u == root) return;
    if (cnt[root][u] >= 2) return;
    if (cnt[root][u] == 1 && mark[root][u] == source) return;
    cnt[root][u]++; mark[root][u] = source;
    for (auto it : a[u]) {
        int v = it.fi;
        if (v == p) continue;
        dfs(v, u, root, source);
    }
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    loop(i, 1, m) {
        int u, v; cin >> u >> v;
        a[u].push_back(mp(v, i));
    }
    loop(u, 1, n) {
        for (auto it : a[u]) {
            int v = it.fi;
            dfs(v, u, u, v);
        }
    }
    loop(u, 1, n) {
        for (auto it : a[u]) {
            int v = it.fi;
            bool diff = false;
            if (cnt[u][v] >= 2) {
                if (cnt[v][u] == 0) diff = true;
            }
            else if (cnt[u][v] == 1) {
                if (cnt[v][u] >= 1) diff = true;
            }
            ansOrder[it.se] = diff;
        }
    }
    loop(i, 1, m) {
        if (ansOrder[i] == false) cout << "same" << endl;
        else cout << "diff" << endl;
    }
}


Measured memory_bytes: 12288
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
#define NUM 1000000000000010
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll n,a,mini=NUM;
    cin>>n;
    rep(i,5){
        cin>>a;
        if(a<mini) mini=a;
    }
    ll ans;
    if(n%mini==0) ans=n/mini+4;
    else ans=n/mini+5;
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
import sys
import math

input_methods=['clipboard','file','key']
using_method=1
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007

#+++++

def main():
	L = int(input())
	#b , c = tin()
	#s = input()
	v = int(math.log2(L))
	#pa(v)
	num_p = v
	path_info=[]
	for i in range(v):
		path_info.append([i,i+1,0])
		path_info.append([i,i+1,2**i])
	
	#for li in path_info:
	#	print(*li)
	
	nokori = L - (2 ** v)
	
	#print(nokori)
	for i in range(v+1):
		m = v - i
		if 2 ** m <= nokori:
			path_info.append([m, v, L - nokori])
			nokori -= 2 ** m
	print(v+1, len(path_info))
	for l in path_info:
		f,t,w = l
		print(*[f+1, t+1, w])
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)


Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main () {
  int N;
  cin >> N;
  int k = N;
  while (k >= N / 2) {
    int kj = k * 108;
    kj /= 100;
    if (kj == N) {
      cout << k << endl;
      return 0;
    }
    k --;
  }
  cout << ":(" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=105;

struct Edge {
	int from,to,cap,flow;
	Edge(int u,int v,int c,int f):from(u),to(v),cap(c),flow(f) {}
};

int n,m;
vector<Edge>edges;
vector<int>G[maxn];
int a[maxn],p[maxn];

int maxflow (int s,int t) {
	int flow=0;
	while (1) {
		memset(a,0,sizeof(a));
		queue<int>q;
		q.push(s);
		a[s]=INF;
		while (q.size()) {
			int x=q.front(); q.pop();
			for (int id:G[x]) {
				Edge &e=edges[id];
				if (!a[e.to] && e.cap>e.flow) {
					p[e.to]=id;
					a[e.to]=min(a[x],e.cap-e.flow);
					if (a[t]) break;
					q.push(e.to);
				}
			}
		}
		if (!a[t]) break;
		for (int u=t;u!=s;u=edges[p[u]].from) {
			edges[p[u]].flow+=a[t];
			edges[p[u]^1].flow-=a[t];
		}
		flow+=a[t];
	}
	return flow;
}

int main() {
	cin>>n>>m;
	for (int i=0;i<m;i++) {
		int u,v,c; cin>>u>>v>>c;
		edges.pb(Edge(u,v,c,0));
		edges.pb(Edge(v,u,0,0));
		int id=edges.size()-2;
		G[u].pb(id);
		G[v].pb(id+1);
	}
	cout<<maxflow(0,n-1)<<'\n';
}



Measured memory_bytes: 3220
//https://atcoder.jp/contests/abc143/tasks/abc143_b
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
void recursive_comb(vector<ll>& indexes, ll s, ll rest, std::function<void(vector<ll>&)> f) {
    if (rest == 0) {
        f(indexes);
    } else {
        if (s < 0) return;
        recursive_comb(indexes, s - 1, rest, f);
        indexes.at(rest - 1) = s;
        recursive_comb(indexes, s - 1, rest - 1, f);
    }
}
// nCkの組み合わせに対して処理を実行する
void foreach_comb(ll n, ll k, std::function<void(vector<ll>&)> f) {
    vector<ll> indexes(k);
    recursive_comb(indexes, n - 1, k, f);
}
//foreach_comb(N-1, 2, [&](vector<ll>& indexes) {
//    dump(indexes[0],indexes[1]);
//}
int main() {
    ll N; cin>>N;
    vector<ll> dn(N);
    for(auto&& d:dn){
        cin>>d;
    }
    ll ans=0;    
    foreach_comb(N,2,[&](vector<ll>& a){
        ll x=a.at(0);
        ll y=a.at(1);
        ans += dn.at(x)*dn.at(y);
    });
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
l={}
ans=[]
for i in range(n):
    s=input()
    if s in l:
        l[s]+=1
    else:
        l.setdefault(s,1)
max_l=max(l.values())

for i in l.keys():
  if l[i]==max_l:
    ans.append(i)
    
ans.sort()
 
for j in ans:
  print(j)

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

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

	long long ans = 0;
	set<long long> st;
	for( long long n = 1; n * n < N; n++ ) {
		long long mul = N - n;
		if( mul % n == 0 ) {
			long long m = mul / n;
			if( st.count( m ) == 0 && N / m == N % m ) {
				ans += m;
				st.insert( m );
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 384
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int maxSumSequence(int[] a) {
    auto dp = new int[a.length];
    dp[0] = a[0];
    for (int i = 1; i < a.length; i++) {
        dp[i] = max(dp[i - 1] + a[i], a[i]);
    }
    return dp.reduce!max;
}

void main() {
    while (true) {
        int n = readint;
        if (n == 0) break;
        int[] a;
        for (int i = 0; i < n; i++) a ~= readint;
        writeln(maxSumSequence(a));
    }
}



Measured memory_bytes: 2320
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>
#include <numeric>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
//const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 1LL*1e11;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 1e6 + 10;





signed main() {
    speed;
   int a,b;
   cin >> a >> b;
   cout << a*b;
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
ll A[300100];
int main() {
	ll N;
	cin >> N;
	REP(i, N)cin >> A[i];
	ll cnt[61];
	REP(i, 61)cnt[i] = 0;
	for (ll i = 0; i < N; ++i) {
		for (ll j = 0; j < 61; ++j) {
			if ((A[i] & ll(1LL << j))) {
				cnt[j]++;
			}
		}
	}
	ll ans = 0;
	for (ll i = 0; i<60; ++i) {
		if (cnt[i] != 0) {
			ans += ((1LL<<i)%INF) * (cnt[i] * (N - cnt[i])%INF);
			ans %= INF;
		}

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


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  int sum = 0;
  vector<int> w(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &w[i]);

    sum += w[i];
  }

  int s = 9999999;

  int sum2 = 0;
  for (int i = 0; i <= 100; i++) {
    sum2 += w[i];
    sum -= w[i];
    s = min(s, abs(sum - sum2));
  }

  cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
        int a, b, y , req = 0;
        cin >> a >> b;
        int x = b;
        y = 0;
        while (x){
                x /= 10;
                y ++;
        }
        while(y--){
                a *= 10;
        }
        int z = a+b;
        req = sqrt(z);
        if(req * req == z) cout << "Yes" << endl;
        else cout << "No" << endl;
return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int c, dr; //c = contest, ir = inner rating, dr = displayed rating
	scanf("%d %d", &c, &dr);
	
	if(c >= 10)
{
	printf("%d", dr);
}	
	else
{
	printf("%d", dr+100*(10-c));
}
	return 0;	
}

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


void solve(long long N, std::vector<long long> V, std::vector<long long> C){
  long long ans = 0;
  for(long long i = 0; i < N; ++i){
    long long temp = V.at(i) - C.at(i);
    if(temp > 0){
      ans += temp;
    }
  }
  cout << ans << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> V(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&V[i]);
    }
    std::vector<long long> C(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&C[i]);
    }
    solve(N, std::move(V), std::move(C));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,C,D;
  
  cin >> A >> B >> C >> D;
  if (A+B>C+D) {
    cout << "Left" << endl;
    }
  if (A+B==C+D) {
    cout << "Balanced" << endl;
    }
  if (A+B<C+D) {
    cout << "Right" << endl;}
  }
    
    
  
    
    
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//string s;
	int a[100];
	for(int i=0;i<100;i++){
		a[i]=((i+1)*(i+2))/2;
	}
	int n,t;
	cin>>n;
	t=n;
	map<int,int> mp;
	for(int i=2;i*i<=t;i++){
		while(n%i==0){
			n/=i;
			mp[i]++;
		}
	}
	if(n>1) mp[n]++;
	int ans=0;
	for(auto i:mp){
		ans+=(upper_bound(a,a+100,i.second)-a);
	}
	cout<<ans;
}




Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,w,d;
    while(1){
        cin>>n>>w>>d;
        if(n==0 && w==0 && d==0) return 0;

        vector<pair<int,int>> v;
        v.push_back({w,d});
        rep(i,n){
            int id,s;
            cin>>id>>s;
            id--;
            auto cut=v[id];
            w=cut.first,d=cut.second;
            v.erase(v.begin()+id);
            s%=w+d;
            if(s<w){
                int nw1=min(s,w-s),nw2=max(s,w-s);
                v.push_back({nw1,d});
                v.push_back({nw2,d});
            }
            else{
                int nd1=min(s-w,d-s+w),nd2=max(s-w,d-s+w);
                v.push_back({w,nd1});
                v.push_back({w,nd2});
            }
        }

        vector<int> p;
        rep(i,v.size()) p.push_back(v[i].first*v[i].second);
        sort(all(p));
        for(int i=0;i<(int)v.size();i++){
            cout << p[i] << (i+1==(int)p.size()?"\n":" ");
        }
    }
    return 0;
}



Measured memory_bytes: 3172
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

int main(){
  int N;
  cin>>N;
  map<int, int>mp;
  int a;
  REP(i, N){
    cin>>a;
    ++mp[a];
  }
  int ans=0;
  for(auto itr=mp.begin(); itr != mp.end(); ++itr){
    ans += (itr->second)%2;
  }
  cout<<ans<<endl;

  return 0;
}


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

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

typedef long long ll;

const int INF=1e9+7;
const int MAX_N=1e7;
bool data[MAX_N];
int main(){
	int n,m;
	while(cin>>m>>n && m){
		fill(data,data+MAX_N,false);
		int ans=m;
		while(n || data[ans]){
			if(!data[ans]){
				n--;
				for(int i=ans;i<MAX_N;i+=ans)data[i]=true;
			}
			ans++;
		}
		cout<<ans<<endl;
	}

}

Measured memory_bytes: 12836
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int a,b;
	int tap = 1;
	int ans = 0;
	scanf("%d%d",&a,&b);

	while(tap < b){
		tap += (a - 1);
		++ans;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;

#define REP(i,b,e) for(ll i=b; i<e; i++)

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

struct UnionFind {
	std::vector<int> data;

	UnionFind(int sz) {
		data.assign(sz, -1);
	}

	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if(x == y) return (false);
		if(data[x] > data[y]) std::swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return (true);
	}

	int find(int k) {
		if(data[k] < 0) return (k);
		return (data[k] = find(data[k]));
	}

	int size(int k) {
		return (-data[find(k)]);
	}
};

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	UnionFind uf(n);

	REP(i, 0, m){
		int a, b;
		scanf("%d %d", &a, &b);
		uf.unite(a-1, b-1);
	}

	int ans = 0;
	REP(i, 0, n){
		ans = std::max(ans, -uf.data[i]);
	}
	printf("%d\n", ans);
	return 0;
}




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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

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

int H,W;
int f[50][50];

bool inside(int i, int j)
{
    return (0<=i&&i<H&&0<=j&&j<W);
}

void dfs(int y, int x)
{
    f[y][x]=0;
    rep(i,8){
        int ny = y+dy[i];
        int nx = x+dx[i];
        if (!inside(ny,nx) || f[ny][nx]==0) continue;
        dfs(ny,nx);
    }
}

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin>>W>>H, H>0){
        rep(i,H)rep(j,W) cin>>f[i][j];
        int ans=0;
        rep(i,H)rep(j,W)if(f[i][j]){
            ans++;
            dfs(i,j);
        }
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 3268
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    try {
      int n = sc.nextInt();
      int now = 0;
      for (int i = 0; i < n; i++) {
        int a = sc.nextInt();
        if (now + 1 == a) {
          now = a;
        }
      }
      System.out.println(now == 0 ? -1 : n - now);
    } finally {
      sc.close();
    }
  }
}

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

int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(0);
      
      int k,x;
      
      cin >> k >> x;
      
      int sum = 0;
      for(int i=0;i<k;i++){
          sum += 500;
      }
      if(sum >= x){
          cout<<"Yes"<<"\n";
      }
      else{
          cout<<"No"<<"\n";
      }
      return 0;
}


Measured memory_bytes: 256
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/
 
#include <bits/stdc++.h>
using namespace std;
 
 
#define ll                          long long
#define ld                          long double
 
#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second
 
#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
#define  MN                           INT_MIN
#define  MX                           INT_MAX
 
bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}

int32_t main()
{
	int n;
	cin >> n;
	int cntmx = 0;
	int mx = 0, otherx = 0;
	int a[n];
	for(int i = 0;i < n;i++)
	{
		cin >> a[i];
		mx = max(mx,a[i]);
	}
	for(int i = 0;i<n;i++)
	{
		if(a[i] == mx){
			cntmx++;
		}else{
			otherx = max(otherx,a[i]);
		}
	}
	for(int i = 0;i<n;i++)
	{
		if(a[i] == mx && cntmx  < 2)
		{
			cout << otherx << endl;
		}else{
			cout << mx << endl;
		}
	}
}

Measured memory_bytes: 4404
#include<iostream>

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


//bitDPだそうだ
//http://d.hatena.ne.jp/shioshiota/20110614/1308066812

using namespace std;
const int INF = 1000000000;

int main(){
	int n;
	while(cin >> n){
		if(n == 0)break;
		int dp[(1 << n)], t[n][n+1];
		rep(i, n){
			rep(j, n+1){
				cin >> t[i][j];
			}
		}
		rep(i, (1<<n)){
			dp[i] = INF;
		}
		dp[0] = 0;
		rep(i, (1<<n)){
			rep(stage, n){
				if((i & (1<<stage))!= 0)continue; 
				dp[i + (1<<stage)] = min(dp[i] + t[stage][0], dp[i+(1<<stage)]);
				rep(tool, n){
					if((i & (1 << tool)) == 0)continue;
					dp[i + (1<<stage)] = min(dp[i] + t[stage][tool+1], dp[i+(1<<stage)]);
				}
			}
		}
		cout << dp[(1<<n)-1] << endl;
	}
	return 0;
}


Measured memory_bytes: 1416
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String mew = sc.next();
		sc.close();

		while (mew.indexOf("mew") != -1 && !mew.equals("mew")) {
			mew = mew.replaceAll("mew", "");
		}

		if (mew.equals("mew")) {
			System.out.println("Cat");
			return;
		}
		System.out.println("Rabbit");
	}
}

Measured memory_bytes: 21288
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=105;
const double EPS=1e-6;

vector<int> pre;

int main(){
	/*main function start*/
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int tmp;
		scanf("%d",&tmp);
		if(tmp-1>pre.size()){
			puts("-1");
			return 0;
		}
		pre.insert(pre.begin()+tmp-1,tmp);
	}
	for(int i=0;i<n;i++){
		printf("%d\n",pre[i]);
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)
#define pi 3.141592653589793238462643
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

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

void solve(){
    ll n, m;
    cin>>n>>m;
    // ll a[n];
    ll b[n];
    loop(i,0,n){
        cin>>b[i];
        b[i] = b[i] >> 1ll;
    }
    ll lc = b[0];
    for(ll i=1; i<n; i++){
        lc = ((lc/gcd(lc, b[i])) * b[i]);
    }
    for(ll i=0; i<n; i++){
        ll ooi = lc/b[i];
        if(ooi % 2 == 0){
            print(0);
            ret;
        }
    }

    ll ans = m/lc;
    if(ans%2 == 1) ans = (ans+1)/2;
    else ans = ans/2;
    print(ans);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        

}


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

#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;


int main(){
  ll n;
  string s, t, u;
  ll a, b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  
  if(u == s)
    a--;
  if(u == t)
    b--;
  
  
  cout << a << " " << b << endl;
}



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

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

  vector<int> A(N);
  rep(i, N) cin >> A[i];

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

  cout << abs(A[N - 1] - A[0]) << endl;
}

Measured memory_bytes: 256
using System;

namespace AtCoder.ABC096
{
    public class A
    {
        public static void Solve()
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            var num = 0;
            if (a <= b)
            {
                num = a;
            }
            else
            {
                num = a - 1;
            }
        
            Console.WriteLine(num);
        }    
    }
}

namespace AtCoder {
    class Program
    {
        static void Main(string[] args)
        {
            ABC096.A.Solve();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int N = 207;

int f[N][N];
bool dp[N][N][N * N];

void solve() {
    int n, m;
    cin >> n >> m;
    loop1(i, n)
        loop1(j, m)
            cin >> f[i][j];
    loop1(i, n)
        loop1(j, m) {
            int x; cin >> x;
            f[i][j] = abs(f[i][j] - x);
        }
    dp[1][1][f[1][1]] = 1;
    loop1(i, n)
        loop1(j, m)
            loop(sum, N * N)
                if (dp[i - 1][j][sum] || dp[i][j - 1][sum])
                    dp[i][j][sum + f[i][j]] = dp[i][j][abs(sum - f[i][j])] = 1;
    loop(i, N * N)
        if (dp[n][m][i]) {
            cout << i; break;
        }
}

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


Measured memory_bytes: 69076
#include<bits/stdc++.h>
using namespace std;
int N, Q;
int S[202020], T[202020], X[202020];
int main()
{
  const int INF = 2e9+10;
  scanf("%d%d", &N, &Q);
  vector<pair<int, int> > V;
  for(int i=0; i<N; ++i)
  {
    scanf("%d%d%d", S+i, T+i, X+i);
    V.emplace_back(S[i]-X[i], X[i]);
    V.emplace_back(T[i]-X[i], -X[i]);
  }
  for(int i=0; i<Q; ++i)
  {
    int t; scanf("%d", &t);
    V.emplace_back(t, INF);
  }
  multiset<int> M;
  sort(V.begin(), V.end());
  for(auto x: V)
  {
    int a = x.first, b = x.second;
    if(b<0) M.erase(M.find(-b));
    else if(b==INF)
    {
      if(M.size() == 0) printf("%d\n", -1);
      else printf("%d\n", *M.begin());
    }
    else M.insert(b);
  }
  
}

Measured memory_bytes: 18920
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int h, n; cin >> h >> n;
	vi dp(h + 1, inf);
	dp[0] = 0;
	rep(i, n){
		int a, b; cin >> a >> b;
		rep(j, h) dp[min(h, j + a)] = min(dp[min(h, j + a)], dp[j] + b);
	}
	cout << dp[h] << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int w,h,x,y,r;
  
  scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
  
  if(r <= y && r <= x && x + r <= w && y + r <= h)
    puts("Yes");
  else
    puts("No");
}


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

using namespace std;

#define long long long
#define INF 2e18
#define MOD (long) (1e9 + 7)
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n;
        string s, t;
        cin >> n >> s >> t;

        for (long i = 0; i < n; i++) {
            putchar(s[i]);
            putchar(t[i]);
        }
        puts("");
    }
}


Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main(){

  int a, b;

  cin >> a >> b;

  if((a+b)%3==0){
    cout << "Possible" <<endl;
  }

  else if(a%3==0){
    cout << "Possible" <<endl;
  }

  else if(b%3==0){
    cout << "Possible" <<endl;
  }

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

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int x,n,i,a;
    vector<int> p(102,1);
    cin >> x >> n;
    for(i=0;i<n;i++){
        cin >> a;
        p[a]=0;
    }
    for(i=0;i<102;i++){
        if(p[x-i]) {cout << x-i;break;}
        if(p[x+i]) {cout << x+i;break;}
    }
}

Measured memory_bytes: 3580
#include <cstdio>
#include <algorithm>

int main()
{
  long long n;
  long long a[100000];
  scanf("%lld", &n);
  for (long long i = 0; i < n; ++i)
  {
    scanf("%lld", a + i);
  }
  std::sort(a, a + n);
  long long acc[100001];
  acc[0] = 0;
  for (long long i = 0; i < n; ++i)
  {
    acc[i + 1] = acc[i] + a[i];
  }
  long long ans = 0;
  for (long long i = 0; i < n; ++i)
  {
    long long *p = a;
    long long s = *(acc + i + 1);
    while (true)
    {
      long long *q = std::upper_bound(p + 1, a + n, 2 * s);
      if (q - 1 == p)
      {
        break;
      }
      else if (q == a + n)
      {
        ++ans;
        break;
      }
      p = q - 1;
      s = *(acc + (p - a) + 1);
    }
  }
  printf("%lld\n", ans);
  return 0;
}

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

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

  rep(i, max(a, b)) cout << min(a, b);
  return 0;
}

Measured memory_bytes: 3484
from collections import deque

H, W = map(int,input().split())

mp = [input() for _ in range(H)]

rlt = 0
dxy = [[-1,0],[1,0],[0,-1],[0,1]]

for i in range(H):
  for j in range(W):
    if mp[i][j] == '#':
      continue
    memo = [[405]*W for _ in range(H)]
    memo[i][j] = 0
    q = deque([[i, j, 0]])
    tmp = 0
    while q:
      t = q.popleft()
      for d in dxy:
        if t[0]+d[0] >= 0 and t[0]+d[0] < H and t[1]+d[1] >= 0 and t[1]+d[1] < W:
          if mp[t[0]+d[0]][t[1]+d[1]] == '.' and memo[t[0]+d[0]][t[1]+d[1]] == 405:
            memo[t[0]+d[0]][t[1]+d[1]] = t[2] + 1
            q.append([t[0]+d[0], t[1]+d[1], t[2] + 1])
            tmp = max(tmp, t[2]+1)
    rlt = max(rlt, tmp)
    
print(rlt)

Measured memory_bytes: 75240
def main():  
  import sys
  read = sys.stdin.buffer.read
  readline = sys.stdin.buffer.readline
  readlines = sys.stdin.buffer.readlines

  n,m = map(int,readline().split())
  a = list(map(int,readline().split()))
  d5 = False
  d9 = False

  if 5 in a:
    d5 = True
  if 9 in a:
    d9 = True
  chk = set()
  for i in a:
    if d5 and (i == 2 or i == 3):
      continue
    if d9 and i == 6:
      continue
    chk.add(i)

  dp = [-float('inf')]*(n+1)
  dp[0] = 0
  f = [0,2,5,5,4,5,6,3,7,6]

  for i in range(2,n+1):
    for j in chk:
      F = f[j]
      if F <= i:
        dp[i] = max(dp[i-F]*10+j,dp[i])

  print(dp[n])

if __name__ == '__main__':
    main()


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

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

	for(int i=A; i<=B; ++i)
		if(i%K == 0) {
			cout << "OK" << endl;
			return 0;
		}

	cout << "NG" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second

#define END puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();

int main() {
    clue();
    return 0;
}
int clue() {


    int x;
    cin>>x;
    (x>=30)?cout<<"Yes"<<endl:cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define __ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int maxn = 1e5 + 10;
int p[maxn], n, m;
bool vis[maxn];

int main() {
    __;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)vis[i] = 0;
    for (int i = 1; i <= n; ++i)p[i] = 1;
    vis[1] = 1;
    for (int i = 1; i <= m; ++i) {
        int x, y;
        cin >> x >> y;
        if (vis[x])vis[y] = 1;
        p[x]--;
        p[y]++;
        if (p[x] == 0)vis[x] = 0;
    }
    int ct = 0;
    for (int i = 1; i <= n; ++i)if (vis[i])++ct;
    cout << ct << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
using namespace std;
int N, A[100005], dis;
int main(){
  int i;
  scanf("%d", &N);
  for(i=1; i<=N; i++){
    scanf("%d", &A[i]);
    dis+=abs(A[i]-A[i-1]);
  }
  dis += abs(A[N]);
  for(i=1; i<=N; i++){
    cout << dis-abs(A[i]-A[i-1])-abs(A[i]-A[i+1])+abs(A[i-1]-A[i+1]) << endl;
  }
  return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
long long int  m,t;
long long int a[200005];
int main()
{
	cin >> t;
	for (int i = 1; i <= t; i++)
	{
		cin >> a[i];
	}
	sort(a + 1, a + 1 + t);
	m = a[t];
	int j = t - 1;
	for (int i = (t - 2) / 2; i > 0; i--)
	{
		m += 2 * a[j--];
	}
	if (t % 2 == 1)
	{
		m += a[j];
	}
	cout << m;
}


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

using namespace std;

typedef long long ll;
#define _ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

#define sll(x) scanf("%I64d",&x)
#define sd(x)  scanf("%d",&x)
#define pll(x) printf("%I64d",x)
#define pd(x)  printf("%d",x)

#define clr(x) memset(x,0,sizeof x)

#define mid    ((l+r)>>1)
#define Pi acos(-1)
#define EPS 1e-12
#define MOD  1000000007
#define MOD1 1000000009
#define INFL 10000000000000LL
#define INF  2000000000

#define N 100015

pair<int,int> ar[1000];
ll dp[110][N],n,W;
ll solve(int i, ll w){
if(w > W) return -1*INFL;
if(i == n) return 0;

if(dp[i][w] != -1) return dp[i][w];

ll c1 = -1*INFL,c2= -1*INFL;
c1 = solve(i+1,w+ar[i].first) +ar[i].second;
c2 = solve(i+1,w);

ll ret = max(c1,c2);

return dp[i][w] = ret;

}

int main()
{_

    cin >> n >> W;
    ll maV=0;
    for(int i=0;i<n;i++){
        int wi,vi; cin >> wi >> vi;
        ar[i] = {wi,vi};
        maV += vi;
    }
    // will try working on REACHING "ALL VALUES" with minimum coast
    for(int i=0;i<n;i++)
        for(int j=0;j<=maV;j++) dp[i][j] = INFL;
        dp[0][0] = 0;

    for(int i=0;i<n;i++)
        for(int curV=0;curV<=maV;curV++){
            if(curV >= ar[i].second){
                dp[i+1][curV] = min(dp[i][curV],dp[i][curV-ar[i].second] + ar[i].first);
            }
            else
                dp[i+1][curV] = dp[i][curV];
        }

    ll ans = 0;
    for(int i=0;i<=maV;i++) if(dp[n][i] <= W) ans = i;
    cout << ans;

    return 0;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

bool check(vector<int>& v, int x, int isx) {
    vector<vector<int>> dp(2, vector<int>(16010, 0));
    int cur = 0;
    dp[cur][8000] = 1;
    REP (i, v.size()) {
        REP (j, dp[cur ^ 1].size()) dp[cur ^ 1][j] = 0;
        REP (j, dp[cur].size()) if (dp[cur][j]) {
            dp[cur ^ 1][j + v[i]] = 1;
            if (!isx || i) dp[cur ^ 1][j - v[i]] = 1;
        }
        cur ^= 1;
    }
    return dp[cur][x + 8000];
}

void _main() {
    string s;
    int x, y;
    cin >> s >> x >> y;
    vector<vector<int>> v(2);
    int idx = 0, sum = 0;
    s += "T";
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'T') {
            v[idx].push_back(sum);
            sum = 0;
            idx ^= 1;
            continue;
        }
        sum++;
    }
    cout << (check(v[0], x, 1) && check(v[1], y, 0) ? "Yes" : "No") << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 780
#include<stdio.h>
int main(){
	int i,j,n,k,m,x,y;
	while(scanf("%d%d",&n,&k),n!=0 && k!=0){
		scanf("%d",&m);
		int dp[17][17]={0};
		for(i=0;i<m;i++){
			scanf("%d%d",&x,&y);
			dp[x-1][y-1]=-1;
		}
		dp[0][0]=1;
		for(i=0;i<n;i++){
			for(j=0;j<k;j++){
				if(dp[i][j]!=-1){
					if(dp[i+1][j]!=-1)dp[i+1][j]+=dp[i][j];
					if(dp[i][j+1]!=-1)dp[i][j+1]+=dp[i][j];
				}
			}
		}
		printf("%d\n",dp[n-1][k-1]);
	}
	return 0;
}


Measured memory_bytes: 1988
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  long long int n,i,line,count=0;
  cin >> n;
  vector <int> d(n);
  for(i=0;i<n;i++)
  {
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  line = d[0];
  count++;
  for(i=1;i<n;i++)
  {
    if(d[i] > line)
    {
      line = d[i];
      count++;
    }
  }
  cout << count;
  return 0;
}

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

void solve(long long a, long long b){
    if ((a * b) % 2) cout << "Odd" << '\n';
    else cout << "Even" << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int n, i;
	if (scanf("%d", &n) == 0) return 1;
	for (i = n / 100; i < 10; i++) if (n <= i * 111) {
		printf("%d", i * 111);
		break;
	}
	return 0;
}


Measured memory_bytes: 128
from sys import stdin, stdout

INF = float('inf')
n, C = map(int, stdin.readline().split())
W = 10 ** 5

dp = [[INF for i in range(W + 1)] for j in range(2)]
dp[0][0] = 0
cur = 0

for i in range(n):
    w, c = map(int, stdin.readline().split())
    w, c = c, w
    
    for j in range(W + 1):
        dp[cur ^ 1][j] = min(dp[cur ^ 1][j], dp[cur][j])
        
        if j + w <= W:
            dp[cur ^ 1][j + w] = min(dp[cur ^ 1][j + w], dp[cur][j] + c)
        
        dp[cur][j] = INF
    
    cur ^= 1

ans = 0
for i in range(W + 1):
    if dp[cur][i] <= C:
        ans = i
        
stdout.write(str(ans))

Measured memory_bytes: 123964