akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define cout if (1) cout

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define pb push_back

int n;
char a[102];

int main () {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a,a+n);
	n = unique(a,a+n) - a;
	cout << (n==3?"Three":"Four") << endl;
}


Measured memory_bytes: 256
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a[50],n,p,q;
  memset(a,0,sizeof(a));
  while(cin>>n>>p&&n+p){
    q=p;
    for(i=0;;i=(i+1)%n){
      if(p){
	p--;
	a[i]++;
	if(a[i]==q)
	  break;
      }else{
	p=a[i];
	a[i]=0;
      }
    }
    a[i]=0;
    cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 868
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
typedef long long ll;

int main()
{
	int N;
	ll A, B;
	ll distance;
	ll ans = 0;
	cin >> N >> A >> B;
	vector<int> X(N);
	rep(i, N) cin >> X[i];
	rep(i, N - 1) {
		distance = (ll)X[i + 1] - (ll)X[i];
		if (distance * A > B) ans += B;
		else ans += distance * A;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int a[20][20], cur[20], c[20];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, m, x;
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>c[i];
		for(int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	int ans=1e9;
	for(int i=0;i<(1<<n);i++){
		int cost=0;
		memset(cur, 0, sizeof cur);
		for(int j=0;j<n;j++){
			if((1<<j)&i){
				//cout<<j<<" ";
				cost+=c[j];
				for(int k=0;k<m;k++){
					cur[k]+=a[j][k];
				}
			}
		}
		//cout<<":";
		for(int j=0;j<m;j++){
			//cout<<cur[j]<<" ";
			if(cur[j]<x) goto hell;
		}
		ans=min(ans, cost);
		hell:;
	}
	if(ans==1e9) cout<<-1;
	else cout<<ans;
}

Measured memory_bytes: 3640
sx, sy, tx, ty = map(int, raw_input().split())
ans = ""
nx = tx - sx
ny = ty - sy
ans += "U" * ny
ans += "R" * nx
ans += "D" * ny
ans += "L" * nx
ans += "LU"
ans += "U" * ny
ans += "R" * nx
ans += "RD"
ans += "RD"
ans += "D" * ny
ans += "L" * nx
ans += "LU"
print ans

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

int main(){
    ll h, w;
    cin >> h >> w;
    vector<vector<char>> t(h+2, vector<char>(w+2, '.'));
    rep(i, 1, h+1){
        string s;
        cin >> s;
        rep(j, 1, w+1){
            t[i][j] = s[j-1];
        }
    }
    vector<pair<ll,ll>> d = {{1,0},{-1,0},{0,1},{0,-1}};
    rep(i, 1, h+1){
        rep(j, 1, w+1){
            if(t[i][j] == '#'){
                bool f = true;   
                for(auto p : d){
                    if(t[i+p.first][j+p.second] == '#') f = false;
                }
                if(f){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 200
#define MIN(A,B) \
  ( (A) < (B) ? (A) : (B) )
#define MAX(A,B) \
  ( (A) > (B) ? (A) : (B) )

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int x[ N ] = { 0 }, y[ N ] = { 0 };
    int l = 0, r = 0
      , t = 0, b = 0;
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    for ( i = 1; i < n; ++i )
    {
      int no, d;

      scanf ( "%d%d", &no, &d );
      x[ i ] = x[ no ]; y[ i ] = y[ no ];
      switch ( d )
      {
        case 0: --x[ i ]; break ;
        case 1: ++y[ i ]; break ;
        case 2: ++x[ i ]; break ;
        case 3: --y[ i ]; break ;
      }

      l = MIN( l, x[ i ] ); r = MAX( r, x[ i ] );
      t = MIN( t, y[ i ] ); b = MAX( b, y[ i ] );
    }

    printf ( "%d %d\n", r - l + 1, b - t + 1 );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int A[100000];

void update(int p, int x){
    A[p] = x;
}


int find(int s, int t){
    int min = pow(2,31)-1;
    for(int i=s; i<=t; i++){
        if(A[i] < min){
            min = A[i];
        }
    }
    printf("%d\n", min);
    //cout << min << endl;
}

int main(){
    int n, q;
    cin >> n >> q;
    for(int i=0; i<n; i++){
        A[i] = pow(2,31) -1;
    }

    int com, x, y;
    for(int j=0; j<q; j++){
        cin >> com >> x >> y;
        if(com == 0){
            update(x, y);
        }
        else{//com==1
            find(x,y);
        }
    }
    return 0;
}


Measured memory_bytes: 3596
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( '\n' );
  var output = [];
  for( var index=0; index<data.length; index++ ) {
    var nums = data[index].split( ' ' ).map( Number );
    if( 0 == nums[0] && 0 == nums[1] ) { break; }
    
    var row = [];
    for( var i=0; i<nums[0]; i++ ) {
        for( var j=0; j<nums[1]; j++ ) {
          row.push( '#' );
        }
        row.push( '\n' );
    }
    output.push( row.join( '' ) );
  }
  console.log( output.join( '\n' )  );
});

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

int a, b;
ll ans = 0;

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

int main() {
  cin >> a >> b;
  ans = ll(a) * b / gcd(a, b);
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    VI A(N);
    VI cnt(N);
    REP(i,N)
    {
        cin >> A[i];
        cnt[i] = 0;
        while(A[i] % 2 == 0)
        {
            A[i] /= 2;
            cnt[i]++;
        }
    }
    int ans = INF;
    REP(i,N)
    {
        if(ans > cnt[i]) ans = cnt[i];
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

map<ll,ll> prime_factor(ll n){
    map<ll,ll> res;
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            ++res[i];
            n/=i;
        }
    }
    if(n!=1) res[n]=1;
    return res;
}

signed main(){
  int N;cin>>N;
  map<ll,ll> mp=prime_factor(N),mp2;
  int cnt=0;
  if(!mp.size()){
    print(0);
    re 0;
  }
  // each(m,mp){
  //   mp2[m.second]++;
  // }
  int ans=0;
  each(m,mp){
    REP(k,0,INF){
      if(2*m.se<k*(k+1)){
        ans+=k-1;
        br;
      }
    }
  }
  print(ans);

  


}


Measured memory_bytes: 3648
#include <stdio.h>

int main(void)
{
	int H[1024],W[1024],i,j,k,l;
	for(k=0;k<1024;k++){
		scanf("%d %d",&H[k],&W[k]);
		if(H[k]==0&&W[k]==0) break;
	}
	for(l=0;l<1024;l++){
		if(H[l]==0&&W[l]==0) break;
		for(i=0;i<H[l];i++){
			if(i%2==0){
				for(j=0;j<W[l];j++){
					if(j%2==0){
						printf("#");
					}else{
						printf(".");
					}
				}
			}else{
				for(j=0;j<W[l];j++){
					if(j%2==0){
						printf(".");
					}else{
						printf("#");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 580
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
MOD = 10**9+7

MAXN = N+5
fac = [1,1] + [0]*MAXN
finv = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def comb(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

ans = 0
for n in range(K-1,N):
    c = comb(n,K-1)
    mx = A[n]
    mn = A[-1-n]
    ans += (mx-mn)*c
    ans %= MOD
print(ans)

Measured memory_bytes: 25488
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

int main(void) {
  int K, X;
  cin >> K >> X;
  if (500 * K >= X) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

#define pb push_back
#define MAX 100005
#define ff first
#define M 1000000007
#define ss second
#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...);
}

typedef long long ll;
ll dp[1<<22];
int n;
int a[22][22];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i = 0; i<n; ++i){
        for(int j = 0; j<n; ++j)
            cin>>a[i][j];
    }
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    for(int mask = 0; mask<(1<<n)-1; ++mask){
        int  i = __builtin_popcount(mask);
        for(int j =0; j<n; ++j){
            if(((mask>>j)^1)==0)continue;
            if(!a[i][j])continue;
            int nxt_mask = mask^(1<<j);
            dp[nxt_mask] += dp[mask];
            if(dp[nxt_mask]>=M)
                dp[nxt_mask] -= M;
        }
    }
    cout<<dp[(1<<n)-1]<<"\n";
    return 0;
}

Measured memory_bytes: 33152
n = int(input())
l = list(map(int,input().split()))
ans = [0]*9

for i in l:
  x = i//400
  if x >= 8:
    ans[8] += 1
  else:
    ans[x] += 1
count = 0
for i in range(8):
  if ans[i] > 0:
    count += 1
if ans[8]==0:
  print(count,count)
else:
  if count != 0:
    print(count,count+ans[8])
  else:
    print(1,ans[8])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define ll long long

void exgcd(int a, int b, int& x, int& y) {
	if (!b) {
		x = 1, y = 0;
	} else {
		exgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
}

int inv(int a, int n) {
	int x, y;
	exgcd(a, n, x, y);
	return (x < 0) ? (x + n) : (x);
}

const int Mod = 998244353;

template <const int Mod = :: Mod>
class Z {
	public:
		int v;

		Z() : v(0) {	}
		Z(int x) : v(x){	}
		Z(ll x) : v(x % Mod) {	}

		friend Z operator + (const Z& a, const Z& b) {
			int x;
			return Z(((x = a.v + b.v) >= Mod) ? (x - Mod) : (x));
		}
		friend Z operator - (const Z& a, const Z& b) {
			int x;
			return Z(((x = a.v - b.v) < 0) ? (x + Mod) : (x));
		}
		friend Z operator * (const Z& a, const Z& b) {
			return Z(a.v * 1ll * b.v);
		}
		friend Z operator ~(const Z& a) {
			return inv(a.v, Mod);
		}
		friend Z operator - (const Z& a) {
			return Z(0) - a;
		}
		Z& operator += (Z b) {
			return *this = *this + b;
		}
		Z& operator -= (Z b) {
			return *this = *this - b;
		}
		Z& operator *= (Z b) {
			return *this = *this * b;
		}
		friend boolean operator == (const Z& a, const Z& b) {
			return a.v == b.v;
		} 
};

Z<> qpow(Z<> a, int p) {
	Z<> rt = Z<>(1), pa = a;
	for ( ; p; p >>= 1, pa = pa * pa) {
		if (p & 1) {
			rt = rt * pa;
		}
	}
	return rt;
}

typedef Z<> Zi;

const int N = 3e6 + 5;

int n, m;
Zi fac[N], _fac[N];

void prepare(int n) {
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = fac[i - 1] * i;
	_fac[n] = ~fac[n];
	for (int i = n; i; i--)
		_fac[i - 1] = _fac[i] * i;
}
Zi comb(int n, int m) {
	return (n < m) ? (0) : (fac[n] * _fac[m] * _fac[n - m]);
}

int main() {
	scanf("%d%d", &n, &m);
	prepare(3 * m + n - 1);
	Zi ans = comb(3 * m + n - 1, n - 1) - comb(m + n - 2, n - 1) * n;
	for (int num = m + 1; num <= n && num <= 3 * m; num++) {
		if ((3 * m - num) & 1)
			continue;
		int sum = (3 * m - num) >> 1;
		Zi tmp = comb(sum + n - 1, n - 1);
		// mx is odd
		tmp -= num * comb(sum - m + n - 1, n - 1);
		// mx is even
		tmp -= (n - num) * comb(sum - m + n - 2, n - 1);
		tmp *= comb(n, num);
		ans -= tmp;
	}
	printf("%d\n", ans.v);
	return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int result = C - (A - B);

    if (result < 0) {
        cout << 0 << endl;
    } else {
        cout << result << endl;
    }
}


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

int h1, m1, h2, m2, k, ans;

int main() {
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    ans = (h2-h1) * 60;
    ans += m2-m1;
    ans -= k;
    cout << ans << "\n";
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ri register int
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// input a letter
	template <class I>
	inline void get (I &x) {
		for (c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		x = c;
	}
	// input a string
	inline void read (char *s){
		for(c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		for(; c >= 'A' && c <= 'Z'; c = gc()) *++s = c;
		*++s = '\0';
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: get;
using io :: read;
using io :: putc;
using io :: print;
const int N=1e5+5;
int a[N],deg[N],ans[N];
struct cmp{
	inline bool operator ()(int x,int y){
		return deg[x]==deg[y]?x<y:deg[x]>deg[y];
	}
};
set<int,cmp> s;
set<int> s2;
int p[N];
inline void solve(ri pre,ri l,ri r){
	ri i,m=0;
	for(auto o:s2)
		p[++m]=o;
	do{
		if(pre==p[1])
			continue;
		for(i=2;i<=m;++i)
			if(a[p[i-1]]==p[i])
				break;
		if(i>m){
			for(i=l;i<=r;++i)
				ans[i]=p[i-l+1];
			return;
		}
	}while(next_permutation(p+1,p+1+m));
	puts("-1");exit(0);
}
int main(){
	ri n,i,x;
	gi(n);
	for(i=1;i<=n;++i) gi(a[i]),++deg[a[i]];
	for(i=1;i<=n;++i) s.insert(i),s2.insert(i);
	for(i=1;i<=n&&n-i+1>4;++i){
		set<int,cmp> ::iterator it=s.begin();
		if(deg[*it]==n-i){
			if(a[ans[i-1]]==*it)
				return puts("-1"),0;
			ans[i]=*it;
		}
		else{
			set<int> ::iterator it2=s2.begin();
			if(a[ans[i-1]]==*it2){
				if(s2.size()==1)
					return puts("-1"),0;
				else
					ans[i]=*++it2;
			}
			else
				ans[i]=*it2;
		}
		s.erase(ans[i]);
		s2.erase(ans[i]);
		it=s.find(a[ans[i]]);
		if(it!=s.end())
			x=*it,
			s.erase(it),
			--deg[x],
			s.insert(x);
	}
	solve(a[ans[i-1]],i,n);
	for(i=1;i<=n;++i) print(ans[i]),putc(' ');
	putc('\n');
	return 0;
}

Measured memory_bytes: 13952
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

let S=readLine()!

var diff=0

var i=0

for _ in S{
  let c1=S[S.index(S.startIndex,offsetBy:i)]
  let c2=S[S.index(S.endIndex,offsetBy:-i-1)]
  if c1 != c2{diff+=1}
  i+=1
}

print(diff/2)

Measured memory_bytes: 13236
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$N = $key->A[0];
$M = $key->X[1][0];
for($i=0;$i<$M;$i++) {
  $wk = 0;
  for($j=0;$j<$N;$j++) {
    if ($j == $key->X[2+$i][0]-1) {
      $wk += $key->X[2+$i][1];
    }
    else {
      $wk += $key->X[0][$j];
    }
  }
  printf("%d\n",$wk);
}


Measured memory_bytes: 3832
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
typedef long long int ll;

int main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;

  vector<ll> a(n);
  rep(i,n) cin >> a.at(i);

  deque<ll> que;

  rep(i, n){
    if(i%2==0) que.push_back(a.at(i));
    else que.push_front(a.at(i));
  }
  if(n%2==0){
    rep(i, n-1) cout << que.at(i) << " ";
    cout << que.at(n-1) << endl;

  }
  else{
    for (int i = n-1; i > 0 ; --i) cout << que.at(i) << " ";
    cout << que.at(0) << endl;
  }

  return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>

using namespace std;
typedef pair<double,double> P;

int main(){
	double xa = 0,ya = 0,xb = 0,yb = 0,xc = 0,yc = 0,xd = 0,yd = 0;
	//cout << "OK" << endl;
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd) != EOF){
		double a = 0, b = 0, c = 0, d = 0;
		//cout << xa << " " << ya << " " << xb << " " << yb << endl;
		P AB, BC, CD, DA;
		AB.first = xb - xa;
		AB.second = yb - ya;
		//cout << AD.first << " " << AD.second << endl;
		BC.first = xc - xb;
		BC.second = yc - yb;
		a = AB.first*BC.second + (-1)*AB.second*BC.first;
		//cout << a << endl;
		//cout << AB.first << " " << AB.second << endl;
		//cout << BC.first << " " << BC.second << endl;
		CD.first = xd - xc;
		CD.second = yd - yc;
		//cout << CD.first << " " << CD.second << endl;
		b = BC.first*CD.second + (-1)*BC.second*CD.first;

		DA.first = xa - xd;
		DA.second = ya - yd;
		//cout << DA.first << " " << DA.second << endl;
		c = CD.first*DA.second + (-1)*CD.second*DA.first;
		//cout << a << b << d << endl;

		d = DA.first*AB.second + (-1)*DA.second*AB.first;

		//cout << a << b << c << d << endl;

		if((a >= 0 && b >= 0 && c >= 0 && d >= 0) || (a < 0 && b < 0 && c < 0 && d < 0)) cout << "YES" << endl;
		else cout << "NO" << endl;

	}
	return 0;
}

Measured memory_bytes: 1228
N,M=map(int,input().split())
pattern=[]
ans=0
for i in range(M):
    s=list(map(int,input().split()))
    del s[0]
    pattern.append(s)
p=list(map(int,input().split()))
for i in range(2**N):
    tentou=[]
    for j in range(N):
        if ((i>>j)&1):
            tentou.append(j+1)
    for index,f in enumerate(pattern):
        cnt=0
        for g in f:
            if g in tentou:
                cnt+=1
        hantei=cnt%2
        if hantei==p[index]:
            continue
        else:
            break
    else:
        ans+=1
print(ans)        
    


Measured memory_bytes: 3064
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    int x = b / a;

    if (x >= c) {
      System.out.println(c);
    } else {
      System.out.println(x);
    }
  }
}


Measured memory_bytes: 21844
#include<array>
#include<map>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

LL f(LL a, LL b) {
    if (a == 0) return 0;
    a--;
    for (int i=61; i>=0; i--) {
	if ((a>>i&1) != (b>>i&1)) {
	    assert(~a>>i&1);
	    assert(b>>i&1);
	    return __builtin_popcountll(b>>i);
	}
    }
    assert(false);
    return 0;
}

using Ar = array<LL, 200>;
map<Ar, vector<pair<LL, LL> > > mp;

int N;
LL K;
LL A[211];
LL B[211];
LL C[211];

Ar ar;

const LL MOD = 1e9+7;

void MAIN() {
    scanf("%d%lld", &N, &K);
    REP (i, N) scanf("%lld", A+i);

    sort(A, A+N);

    REP (s, 61) {
	LL mask = (1LL<<s)-1;
	REP (i, N) {
	    B[i] = A[i] & mask;
	}
	sort(B, B+N);
	int len = unique(B, B+N) - B;

	LL prv = 0;
	REP (i, len) {
	    LL cst = s + f(prv, B[i]);
	    if (cst <= K) {
		LL w = 1LL<<61;
		REP (k, N) {
		    C[k] = A[k] >> s;
		    if ((A[k]&mask) < B[i]) C[k]--;
		    amin(w, C[k]);
		}
		if (w < 0) break;

		REP (k, N-1) {
		    ar[k] = C[k+1] - C[k];
		}
		LL g = min(w, K-cst);
		mp[ar].emplace_back(w-g, w+1);
	    }
	    prv = B[i] + 1;
	}

	if ((A[N-1]>>s) == 0) break;
    }

    LL ans = 0;
    EACH (e, mp) {
	vector<pair<LL, LL> > &v = e->second;
	sort(v.begin(), v.end());
	pair<LL, LL> cur(-1, -1);
	EACH (f, v) {
	    if (cur.second < f->first) {
		ans += cur.second - cur.first;
		ans %= MOD;
		cur = *f;
	    } else {
		amax(cur.second, f->second);
	    }
	}
	ans += cur.second - cur.first;
	ans %= MOD;
    }
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 16128
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>>adj;
map<pair<int,int>,int>m;
int dfs(int x,int p)
{
	int a,b,c=0,used=-1,ans=0;
	a=min(x,p);
	b=max(x,p);
	if(x!=p)used=m[{a,b}];
	if(used==c)c++;
	for(int y:adj[x])
	{
		if(y!=p)
		{
			a=min(x,y);
			b=max(x,y);
			m[{a,b}]=c++;
			if(used==c)c++;
			ans=max(ans,dfs(y,x));
		}
	}
	return max(c,ans);
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,a,b,i;
	cin>>n;
	adj.resize(n);
	vector<pair<int,int>>v(n-1);
	for(i=1;i<n;i++)
	{
		cin>>a>>b;
		a--;
		b--;
		adj[a].emplace_back(b);
		adj[b].emplace_back(a);
		v[i-1]={a,b};
	}
	cout<<dfs(0,0)<<'\n';
	for(auto x:v)
		cout<<m[{x.first,x.second}]+1<<'\n';
}


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

using namespace std;

int main(){
  vector<int>vec(1000,0);
  int n,m; cin>>n>>m;
  for(int i=0; i<n;i++)cin>>vec[i];
  sort(vec.begin(),vec.end(),greater<int>());
  int sum=0;
  for(int i=0; i<m;i++)sum+=vec[i];
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int N;
	scanf("%d",&N);
	int data[N];
	int i,j;
	int min=100000000;
	for(i=0;i<N;i++){
		scanf("%d",&data[i]);
		if(data[i]<min){
			min=data[i];
		}
	}
	int search[min];
	for(i=0;i<min;i++){
		search[i]=1;
	}
	for(i=0;i<N;i++){
		for(j=1;j<min;j++){
			if(data[i]%(j+1)!=0){
				search[j]=0;
			}
		}
	}
	for(i=0;i<min;i++){
		if(search[i]==1){
			printf("%d\n",i+1);
		}
	}
	return 0;
}

Measured memory_bytes: 5536
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int dsum( int x ){
	int res = 0;
	while( x > 0 ){
		res += x%10;
		x /= 10;
	}
	return res;
}

int main(){
	int n; cin >> n;
	int ans = inf;
	for( int a = 1; a < n; ++a ){
		int b = n-a;
		ans = min(ans, dsum(a)+dsum(b));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define MAX_N 100010
short int num[MAX_N];
bool red[MAX_N];
int n, m;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    int i;
    for(i = 0; i < n; ++i){
        num[i] = 1;
    }
    red[0] = true;
    while(--m >= 0){
        int a, b;
        cin >> a >> b;
        red[b - 1] |= red[a - 1];
        --num[a - 1];
        ++num[b - 1];
        if(num[a - 1] == 0){
            red[a - 1] = false;
        }
    }
    int counts = 0;
    for(i = 0; i < n; ++i){
        counts += red[i];
    }
    cout << counts << '\n';
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  bool used[26];fill(used,used+26,false);
  if(s.size()<=25){
    for(int i=0;i<s.size();i++){
      used[s[i]-'a']=true;
    }
    for(int i=0;i<26;i++){
      if(used[i]==false){
        char t=i+'a';
        cout<<s<<t<<endl;
        return 0;
      }
    }
  }
  for(int i=25;i>=0;i--){
    int now=s[i]-'a';
    for(int j=now+1;j<26;j++){
      if(used[j]){
        char r=j+'a';
        cout<<s.substr(0,i)<<r<<endl;
        return 0;
      }
    }
    used[now]=true;
  }
  cout<<-1<<endl;
}
  
  
  

Measured memory_bytes: 256
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-4-14 19:57:06
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

vector<int> V;
int N;
vector<int> W;

int main()
{
  cin >> N;
  for (auto i = 0; i < N; i++)
  {
    int x;
    cin >> x;
    V.push_back(x);
  }
  W = V;
  sort(W.begin(), W.end());
  int A = W[N / 2 - 1];
  int B = W[N / 2];
  for (auto i = 0; i < N; i++)
  {
    if (V[i] <= A) {
      cout << B << endl;
    } else {
      cout << A << endl;
    }
  }
}

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

int main() {
  int n;
  cin >>n;
  int a[n+1];
  rep(i,n)cin >> a[i];
  a[n]=0;
  int ans=0;
  rep(i,n){
    if(a[i]<=a[i+1]){continue;}else{
      ans+=a[i]-a[i+1];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class AABCARC {
public:
  static void solve(istream &cin, ostream &cout) {
    int x;
    cin >> x;
    if (x < 1200)
      cout << "ABC" << endl;
    else {
      cout << "ARC" << endl;
    }
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  AABCARC solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

int main() {
  string S;
  long long K;
  cin>>S>>K;
  char x;
  string T;
  rep(i,S.size()){
    if(S[i]=='1'){
      T += '1';
      if(T.size()==K) {
        puts("1");
        return 0;
      }
    }
    else {
      cout<<S[i]<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

std::string S;

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> S;

    out << std::string_view(S).substr(0, 3) << endl;

    return 0;
}
#endif


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
#define ll long long
void slove()
{
    ll a, b, c, d;
    scanf("%lld %lld %lld %lld" ,&a ,&b ,&c ,&d);
    a --;
    ll ans = b - a;
    ll lcm = c * d / __gcd(c, d);
    ans -= b / c - a / c;
    ans -= b / d - a / d;
    ans += b / lcm - a / lcm;
    printf("%lld\n" ,ans);
    return ;
}
signed main()
{
    slove();
    return 0;
}


Measured memory_bytes: 256
import sys
import heapq
import bisect

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def Eratosthenes(N):
    r = [True]*(N+1)
    r[0] = False
    r[1] = False
    i = 2
    while i*i<=N:
        if r[i]: 
            j = i
            while i*j<=N:
                prime[i*j]=False
                j+=1
        i+=1
    return(r)

def main():
    s = S()
    N = len(s)
    
    ca = 0
    ans = 0
    i = 0
    while i<N:
        if s[i] == "A":
            ca += 1
            i += 1
        elif i<N-1 and s[i:i+2] == "BC":
            ans += ca
            i += 2
        else:
            ca = 0
            i += 1
    return(ans)
    





if __name__ == "__main__":
    print(main())


Measured memory_bytes: 40544
import java.util.Scanner;

public class Main{

  public static void main (String[] args){

    Scanner sc = new Scanner (System.in);

    int N = sc.nextInt();
    
    int[] list = new int [N];
    int maxNum = 0;
    int nextMaxNum = 0;
    int maxIndex = 0;
    
    for (int index=0; index<N; index++){
      int temp = sc.nextInt();
      list [index] = temp;
      if (maxNum<temp){
        maxNum=temp;
        maxIndex=index;
      } else if (nextMaxNum<temp){
        nextMaxNum=temp;
      }
    }
    
    for (int index=0; index<N; index++){
      if (index==maxIndex){
        System.out.println(nextMaxNum);
      } else {
        System.out.println(maxNum);
      }
    }
  }
}

Measured memory_bytes: 91132
import java.io.*;
/**
 * Created by TmhrMrs on 2016/04/13.
 */
class Main {
    public static void main(String[] args)throws java.io.IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String str = in.readLine();
        int a = Integer.parseInt(str);
        System.out.println(a*a*a);
    }
}

Measured memory_bytes: 24320
#include <iostream>
using namespace std;
int main(){
  char a[6];
  for(int i=0;i<6;i++){
    cin>>a[i];
  }
  if(a[2]==a[3]&&a[4]==a[5]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N, K; cin >> N >> K;
    vec a(N);
    rep(i, N) cin >> a[i];
    vec s(N+1, 0), st(N, N);
    auto tmp = s;
    rep(j, K){
        rep(i, N){
            int l = max(0, i-a[i]);
            int r = min(N, i+a[i]+1);
            s[l]++;
            s[r]--;
        }
        rep(i, N) s[i+1] = min(N, s[i+1]+s[i]);
        rep(i, N) a[i] = s[i];
        s = tmp;
        if(a == st){
            break;
        }
    }
    rep(i, N){
        cout << a[i];
        if(i != N-1) cout << " ";
        else cout << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 10548
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <bitset>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define pii pair<int,int>
#define pdd pair<db,db>

using namespace std;

typedef long long ll;
typedef double db;

const int N = 1e5+10,M=1e4+10,MOD = 1e9+7;

int fa[N*2],fb[2*N];
//int ans[N*2];

void init(int n){
    for(int i=0;i<=n;i++)
        fa[i]=fb[i]=i;
}

int finda(int x){
    if(fa[x]!=x)fa[x]=finda(fa[x]);
    return fa[x];
}
int findb(int x){
    if(fb[x]!=x)fb[x]=findb(fb[x]);
    return fb[x];
}

int main()
{
    int n,k,l;
    while(~scanf("%d%d%d",&n,&k,&l)){
        init(n);
        for(int i=0;i<k;i++){
            int x,y;
            scanf("%d%d",&x,&y);
            int fx=finda(x),fy=finda(y);
            if(fx!=fy)fa[fx]=fy;
        }
        for(int i=0;i<l;i++){
            int x,y;
            scanf("%d%d",&x,&y);
            int fx=findb(x),fy=findb(y);
            if(fx!=fy)fb[fx]=fy;
        }
        map<int,pii> m1;
        map<pii,int> m2;
        for(int i=1;i<=n;i++){
            int xa=finda(i),xb=findb(i);
           //cout<<xa<<" "<<xb<<endl;
            m1[i]=mp(xa,xb);
            m2[mp(xa,xb)]++;
           // cout<<"("<<m1[i].x<<","<<m1[i].y<<") "<<m2[mp(xa,xb)]<<endl<<endl;
        }

        for(int i=1;i<=n;i++){
            cout<<m2[m1[i]]<<" ";
        }
        cout<<endl;
       
    }
}


Measured memory_bytes: 25728
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll x,y;
  cin >> x >> y;
  if(x*y%2) pr("Odd");
  else pr("Even");
}

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


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

int main(){
  
  int a,b; cin >> a >> b;
  int x = a+b;
  
  if((a+b)%2 == 0){
    cout << x/2 << endl;
  }
  else{
  cout << x/2+1 << endl;
  }
  return 0;
  
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int A, B;
  cin >> A >> B;
  cout << max(max(A+B, A-B), A*B) << endl;

  return 0;
}



Measured memory_bytes: 256
program main
	implicit none
	character a*4
	integer j(4),i
	read(*,*)a
	do i=1,4
		read(a(i:i),*)j(i)
	enddo
	if((j(1)==j(2).and.j(1)==j(3)).or.&
	&(j(3)==j(2).and.j(4)==j(3)))then
		write(*,*)"Yes"
	else 
		write(*,*)"No"
	endif
end program main


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

using namespace std;

int InsertionSort(int x[], int n, int g) {
    int cnt = 0;
    for(int i = g; i < n; i++) {
        int v = x[i];
        int j = i -g;
        while(j >= 0 && x[j] > v) {
            x[j + g] = x[j];
            j = j - g;
            cnt ++;
        }
        x[j+g] = v;
    }
    
    return cnt;
}

void ShellSort(int x[], int n) 
{
    int cnt = 0;
    vector<int> g;
    int m = 1;
    while(m <= n) {
        g.push_back(m);
        m = m * 3 + 1;
    }
    
    cout << g.size() << endl;
    
    for(int i = g.size() -1; i >= 0 ; i--) {
        cout << g[i] << ((i == 0) ? "\n" : " ");
        cnt += InsertionSort(x, n, g[i]);
    }
    cout << cnt << endl;
}
int main() {
    int n;
    cin >> n;
    
    int x[n];
    rep(i, n) cin >> x[i];

    ShellSort(x, n);
    
    rep(i, n) cout << x[i] << endl;
    
}
    



Measured memory_bytes: 6976
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif


int main ()
{
    #ifdef Lollipop
        freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    int k, n;
    cin >> k >> n;
    vector<int> ara(n);
    for (int i = 0; i < n; i++){
        cin >> ara[i];
    }
    int mx = ara[0] + (k - ara[n - 1]);
    int l = 0;
    int r = n - 1;
    for (int i = 1; i < n; i++){
        int cur = ara[i] - ara[i - 1];
        if (cur > mx){
            mx = cur;
            l = i;
            r = i - 1;
        }
    }
    trace(mx, l, r);
    int res = 0;
    while (l != r){
        if (l == n - 1){
            res += (k - ara[l]) + ara[0];
            l = 0;
        }
        else{
            res += abs(ara[l] - ara[l + 1]);
            l++;
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 1024
n, m = map(int, input().split())
hs = list(map(int, input().split()))


ans = [1] * n
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if hs[a] < hs[b]:
        ans[a] = 0
    elif hs[a] == hs[b]:
        ans[a] = 0
        ans[b] = 0
    else:
        ans[b] = 0

print(sum(ans))

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

typedef long long LL;
const int Mod = 1000000007;
const int MV = 2000005;

inline int qPow(int b, int e) {
	int a = 1;
	for (; e; e >>= 1, b = (LL)b * b % Mod)
		if (e & 1) a = (LL)a * b % Mod;
	return a;
}
inline int gInv(int b) { return qPow(b, Mod - 2); }

int Fac[MV], iFac[MV];
inline void Init(int N) {
	Fac[0] = 1;
	for (int i = 1; i <= N; ++i) Fac[i] = (LL)Fac[i - 1] * i % Mod;
	iFac[N] = gInv(Fac[N]);
	for (int i = N; i >= 1; --i) iFac[i - 1] = (LL)iFac[i] * i % Mod;
}
inline int Binom(int N, int M) {
	if (M < 0 || M > N) return 0;
	return (LL)Fac[N] * iFac[M] % Mod * iFac[N - M] % Mod;
}
inline int Calc(int N, int M) {
	return Binom(N + M, N);
}

int X1, X2, X3, X4, X5, X6;
int Y1, Y2, Y3, Y4, Y5, Y6;

int sx[4], sy[4], tx[4], ty[4];
int Ans;

int main() {
	Init(2000000);
	scanf("%d%d%d%d%d%d", &X1, &X2, &X3, &X4, &X5, &X6);
	scanf("%d%d%d%d%d%d", &Y1, &Y2, &Y3, &Y4, &Y5, &Y6);
	sx[0] = X1 - 1, sy[0] = Y1 - 1;
	sx[1] = X1 - 1, sy[1] = Y2;
	sx[2] = X2, sy[2] = Y2;
	sx[3] = X2, sy[3] = Y1 - 1;
	tx[0] = X6 + 1, ty[0] = Y6 + 1;
	tx[1] = X6 + 1, ty[1] = Y5;
	tx[2] = X5, ty[2] = Y5;
	tx[3] = X5, ty[3] = Y6 + 1;
	for (int sk = 0; sk < 4; ++sk) {
		for (int tk = 0; tk < 4; ++tk) {
			int spx = sx[sk], spy = sy[sk];
			int tpx = tx[tk], tpy = ty[tk];
			int coef = (sk ^ tk) & 1 ? -1 : 1;
			int Sum = 0;
			for (int i = X3; i <= X4; ++i) {
				Sum = (Sum + (LL)Calc(i - spx, Y3 - 1 - spy) * Calc(tpx - i, tpy - Y3) % Mod * -(i + Y3 - 1)) % Mod;
				Sum = (Sum + (LL)Calc(i - spx, Y4 - spy) * Calc(tpx - i, tpy - Y4 - 1) % Mod * (i + Y4)) % Mod;
			}
			for (int j = Y3; j <= Y4; ++j) {
				Sum = (Sum + (LL)Calc(X3 - 1 - spx, j - spy) * Calc(tpx - X3, tpy - j) % Mod * -(X3 - 1 + j)) % Mod;
				Sum = (Sum + (LL)Calc(X4 - spx, j - spy) * Calc(tpx - X4 - 1, tpy - j) % Mod * (X4 + j)) % Mod;
			}
			Ans = (Ans + coef * Sum) % Mod;
		}
	}
	printf("%d\n", (Ans + Mod) % Mod);
	return 0;
}

Measured memory_bytes: 17360