akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, K, A[200000];
    cin >> N >> K;
    REP(i, N) cin >> A[i];

    int l = 0, r = K;
    REP(i, N - K) {
        if (A[l] < A[r]) cout << "Yes" << endl;
        else cout << "No" << endl;
        l++; r++;
    }
    return 0;
}

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

using namespace std;

int main(void) {
  int n, m;
  while (cin >> n >> m, n) {
    vector<int> b(n), d(m);
    for (int i = 0; i < n; i++) {
      cin >> b[i];
    }
    for (int i = 0; i < m; i++) {
      cin >> d[i];
    }

    int pos = 0;
    for (int i = 0; i < m; i++) {
      int next = pos + d[i];
      pos = next + b[next];
      if (pos >= n - 1) {
        cout << i + 1 << endl;
        break;
      }
    }
  }

  return 0;
}


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

#define ll long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

#define Debug(x) cout<<(#x)<<" >> "<<(x)<<endl

using namespace std;

ll fastpow(ll angka,ll pangkat,ll MOD){
	ll res=1;
	while(pangkat){
		if(pangkat&1) res=(res*angka)%MOD;
		angka=(angka*angka)%MOD;
		pangkat=pangkat>>1;
	}
	return res;
}

ll fastpow(ll angka,ll pangkat){
	ll res=1;
	while(pangkat){
		if(pangkat&1) res=(res*angka);
		angka=(angka*angka);
		pangkat=pangkat>>1;
	}
	return res;
}

ll gcd(ll angka1,ll angka2){
	while(angka2){
		swap(angka1,angka2);
		angka2=angka2%angka1;
	}
	return angka1;
}

ll lcm(ll angka1,ll angka2){
	return (angka1/gcd(angka1,angka2))*angka2;
}

int f(int len,int x){
	return (len-1)/x;
}

void solve(){
	int n,k;
	cin>>n>>k;
	
	vector<int>v(n);
	for(int i=0;i<n;i++) cin>>v[i];
	
	int l,r;
	l=1;
	r=1;
	for(int i=0;i<n;i++) r=max(r,v[i]);
	
	int res=r;
	int m;
	while(l<=r){
//		cout<<l<<" "<<r<<endl;
		m=(l+r)/2;
		
		ll ct=0;
		for(int i=0;i<n;i++){
			ct+=f(v[i],m);
		}
		
		if(ct<=k){
			res=min(res,m);
			r=m-1;
		}
		else l=m+1;
		
	}
	cout<<res<<endl;
}

int main(){
	
//	fastio();
	
	int t=1;
//	cin>>t;
	
	for(int tt=0;tt<t;tt++){
//		cout<<"Case #"<<tt+1<<": ";solve();
//		if(solve()) cout<<""<<endl;
		solve();
	}
	
	return 0;
}




Measured memory_bytes: 4000
#include<iostream>
using namespace std;
string s;
main()
{
	int N;
	cin>>N>>s;
	int ans=0;
	int l=0,r=N-1;
	while(l<r)
	{
		while(l<N&&s[l]=='R')l++;
		while(r>=0&&s[r]=='W')r--;
		if(l<r)
		{
			ans++;
			l++;
			r--;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    int a,b; cin >> a >> b;
    int k = (a+b)/2;
    if(abs(a-k)==abs(b-k)){
        cout << k << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

int n;
void test() {
    cin>>n;
    cout<<1000*(n/500)+(n%500)/5*5<<endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int t; cin>>t;
    // while (t--) {
    //     test();
    // }
    test();
    // for (int i=1; i<=t; ++i) {
    //     cout<<"Case #"<<i<<": ";
    //     test();
    // }
    return 0;
}

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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const long long int MOD = 1e9 + 7;
const int MAXN = 2e5 + 10, MAX_FACTORIAL = 1e6 + 10;

ll REM( ll a )
{
	a %= MOD;
	if ( a < 0 )
	   a += MOD;
	return a;
}

ll ADD( ll a, ll b )
{
	return REM( REM( a ) + REM( b ) );
}

ll SUB( ll a, ll b )
{
	return REM( REM( a ) - REM( b ) );
}

ll MUL( ll a, ll b )
{
	return REM( REM( a ) * REM( b ) );
}

ll POT( ll n, ll k )
{
	if ( k == 0 )
		return 1;

	ll ret = POT( n, k / 2 );
	ret = MUL( ret, ret );

	if ( k % 2 )
		return MUL( ret, n );
	return ret;
}

ll DIV( ll a, ll b )
{
	return MUL( a, POT( b, MOD - 2 ) );
}

bool isPrime( ll x )
{
	for ( ll i = 2;i <= sqrt( x ); i++ )
		if ( x % i == 0 )
			return false;
	return true;
}

ll fact[ MAX_FACTORIAL ];
void factorials( )
{
	fact[ 0 ] = 1;
	FOR( i, 1, MAX_FACTORIAL )
	{
		fact[ i ] = MUL( fact[ i - 1 ], i );
	}
}

ll CHOOSE( ll n, ll k )
{
	return DIV( fact[ n ], MUL( fact[ k ], fact[ n - k ] ) );
}

ll a, b, k;

int main()
{
	cin >> a >> b >> k;
	ll a1 = a;
	a = max( 0LL, a - k );
	k = max( 0LL, k - a1 );
	b = max( 0LL, b - k );
	cout << a << ' ' << b << "\n";
	return 0;
}


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

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

    int n, m;
    cin >> n >> m;
    vector<int> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

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

    vector<pair<int, int>> P(m);
    for(int i = 0; i < m; i++){
        cin >> P[i].second >> P[i].first;
    }

    sort(P.rbegin(), P.rend());

    int m_i = 0;
    for(int i = 0; i < n; i++){
        if(A[i] >= P[m_i].first) break;
        A[i] = P[m_i].first;
        P[m_i].second--;
        if(P[m_i].second == 0){
            m_i++;
            if(m_i == m){
                break;
            }
        }
    }

    long long ans = 0;
    for(int i = 0; i < n; i++){
        ans += A[i];
    }
    
    cout << ans << endl;

    return 0;
}

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

int main(){
  int a,b,c,x,i,j,k;
  cin>>a;
  cin>>b;
  cin>>c;
  cin>>x;
  x/=50;
  int cnt=0;
  for(i=0;i<=a;i++){
    for(j=0;j<=b;j++){
      for(k=0;k<=c;k++){
        if(10*i+2*j+k==x)cnt++;
      }
    }
  }
  cout<<cnt;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;

vector<string>seqs;

void dfs(int index,int size,string seq){
    if(index==size){
        seqs.push_back(seq);
        return;
    }
    
    for(int i=index;i<size;i++){
        swap(seq[index],seq[i]);
        dfs(index+1,size,seq);
        swap(seq[index],seq[i]);
    }
}

int main(){
    int n;
    cin>>n;
    string pn,qn;
    for(int i=0;i<n;i++){
        string pi;
        cin>>pi;
        pn+=pi;
    }
    for(int i=0;i<n;i++){
        string qi;
        cin>>qi;
        qn+=qi;
    }
    string seq;
    for(int i=1;i<=n;i++) seq+=to_string(i);
    dfs(0,n,seq);
    sort(seqs.begin(),seqs.end());
    
    int a,b;
    for(int i=0;i<seqs.size();i++){
        if(pn==seqs[i]) a=i;
        if(qn==seqs[i]) b=i;
    }
    cout<<abs(a-b)<<endl;
    return 0;
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;

int main() {
  int MIN=10;
  int ans=0;
  rep(i,5){
    int t;
    cin >> t;
    if(t%10<MIN&&t%10!=0)MIN=t%10;
    ans+=(t+9)/10 *10;
  }
  cout << ans-10+MIN << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

ll n, s;
vpl v;

int main(){

  n = in();
  s = in();
  REP(i, n){
    ll x = in();
    ll p = in();
    v.pb(x, p);
  }

  SORT(v);

  ll ans = 0;
  ll l = 0, r = n - 1;
  int prv = -1;
  while(l != r){
    if(v[r].fi < s){
      break;
    }
    if(v[l].fi > s){
      l = r;
      break;
    }
    if(v[l].se < v[r].se){
      v[r].se += v[l].se;
      if(prv != 0){
        ans += v[r].fi - v[l].fi;
      }
      prv = 0;
      l++;
    } else {
      v[l].se += v[r].se;
      if(prv != 1){
        ans += v[r].fi - v[l].fi;
      }
      prv = 1;
      r--;
    }
  }
  ans += abs(s - v[l].fi);

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


Measured memory_bytes: 3444
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int r; cin >> r;
  cout << 3*r*r << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

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

    bool exist = false;
    for(ll i = 1; i < A*B*C; i++)
    {
        if ( (A*i - C)%B == 0 )
        {
            exist = true;
        }
    }
    
    if (exist)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
}

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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int a,b,upp1,upp2,g1,g2,r;
    cin >> a >> b;
    vector<int> v(1000,0);
    v[1]=1;
    for (int i=2;i<=999;i++)
       v[i]=v[i-1]+i;
    r=b-a;
    cout << v[r]-b;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#define SIZE 55

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;

ll X[SIZE],Y[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	set <P> st;
	for(int i=0;i<n;i++)
	{
		scanf("%lld %lld",&X[i],&Y[i]);
		st.insert(P(X[i],Y[i]));
	}
	vector <P> vx;
	int ret=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i==j) continue;
			P p=P(X[i]-X[j],Y[i]-Y[j]);
			int cnt=0;
			for(int k=0;k<n;k++)
			{
				P q=P(p.first+X[k],p.second+Y[k]);
				if(st.count(q)) cnt++;
			}
			ret=max(ret,cnt);
		}
	}
	printf("%d\n",n-ret);
	return 0;
}


Measured memory_bytes: 256
n,w = map(int,input().split())
wt = [0]*n
v = [0]*n
dp = [[0 for _ in range(w)]for _ in range(n)]
for i in range(n):
    wt[i],v[i] = map(int,input().split())
for i in range(w):
    if(wt[0]>i+1):dp[0][i] = 0
    else:dp[0][i] = v[0]
for i in range(1,n):
    for j in range(w):
        if(wt[i]>j+1):
            dp[i][j] = dp[i-1][j]
        else:
            remain = (j+1) - wt[i]
            res = 0
            if(remain > 0):
                res = v[i] + dp[i-1][remain-1]
            else:
                res = v[i]
            dp[i][j] = max(dp[i-1][j],res)

print(dp[n-1][w-1])



Measured memory_bytes: 171656
#include<bits/stdc++.h>
using namespace std;
using ll = long long ;
ll n,x,y;
using ld = long double;
map<pair<ll,ll>,ll> mp;
const ll mod = 1000000007;
ll zero;
ll h;
ll v;
ll ans = 1;
ll qpow(ll x,ll n)
{
    ll res =1;
    while(n>0)
    {
        if(n&1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
int main(){
	//freopen("in.txt","r",stdin);
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>x>>y;
		if(x==0 and y==0) zero++;
		else if(x==0) v++;
		else if(y==0) h++;
		else {
			ll g = __gcd(x,y);
			x/=g;
			y/=g;
			if(x<0) x=-x,y=-y;
			mp[{x,y}]++;	
		}	
	}
	for(auto i:mp){
		ll a = i.first.first;
		ll b = i.first.second;
		ll c = i.second;
		if(c==0) continue;
		ll cnt;
		if(-b<0) b=-b,a=-a;
		pair<ll,ll> pll = {-b,a};
		if(!mp.count(pll)){
			cnt = qpow(2,c); ans=(ans*cnt)%mod;
		}else{
			cnt = qpow(2,c)-1LL+qpow(2,mp[pll]);
			cnt %= mod;
			ans=(ans*cnt)%mod;
			mp[pll]=0;
		}
	}
	if(h!=0 and v!=0){
		ll foo = qpow(2,h)-1LL+qpow(2,v);
		foo %= mod;
		ans = (ans*foo)%mod;
	}else if(h==0 and v!=0){
		ll foo = qpow(2,v);
		ans = (ans*foo)%mod;
	}else if(h!=0 and v==0){
		ll foo = qpow(2,h);
		ans = (ans*foo)%mod;
	}
	ans = (ans+zero)%mod;
	ans-=1LL;
	ans+=mod;
	ans%=mod;
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n); 0<=i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());                   //昇順
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());    //降順
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper); 
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
#define SetPre(x) setprecision(x)

int main() {
	int N;
	cin >> N;
	VL A(N);
	VI B(1000001, 0);
	for (int i = 0; i < N; i++) cin >> A[i], B[A[i]]++;
	int ANS = 0;
	for (int i = 0; i < N; i++) {
		bool check = true;
		B[A[i]]--;
		for (int j = 1; j * j <= A[i]; j++) {
			if (A[i] % j == 0) {
				if (B[j] != 0) check = false;
				if (B[A[i] / j] != 0) check = false;
			}
		}
		B[A[i]]++;
		if (check) ANS++;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 8780
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 2000000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
 
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
 
 
 
int n, answ;
int a[2][100005];
 
int main() {
 
	cin >> n;
 
	rep(i, 2) {
		rrep(j, n) {
			int tmp;
			cin >> tmp;
			a[i][j] = a[i][j - 1] + tmp;
		}
	}
 
	rrep(i, n) {
		answ = max(answ, a[0][i] + (a[1][n] - a[1][i - 1]));
	}
 
	cout << answ << endl;
 int justin = 9;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int s[101];
	for(int i = 1; i <= n; i++){
		cin >> s[i];
	}
	int result[101][10010] = {};
	result[0][0] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= 10000; j++){
			result[i][j] = result[i - 1][j];
			if(j >= s[i]) result[i][j] = max(result[i][j], result[i - 1][j - s[i]]);
		}
	}
	int ans = 0;
	for(int i = 0; i <= 10000; i++){
		if(i % 10 == 0) continue;
		for(int j = 1; j <= n; j++){
			if(result[j][i] > 0){
				ans = max(ans, i);
			}
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int n, m, q;
int ans = 0;
vector<int> a(50, 0), b(50, 0), c(50, 0), d(50, 0);

bool jd(vector<int> A, int qidx){
    if(a[qidx] >= A.size() || b[qidx] >= A.size()) return false;
    if(A[b[qidx]] - A[a[qidx]] == c[qidx]) return true;
    return false;
}

void dfs(int idx, vector<int> A){
    //printf("idx %d\n", idx);
    for(int i = 0; i < idx; i++){
        //printf("%d ", A[i]);
    }
    //printf("\n");
    if(idx >= n){
        //printf("END\n");
        int point = 0;
        for(int i = 0; i < q; i++){
            point += jd(A, i) ? d[i] : 0;
        }
        //printf("point %d\n", point);
        if(ans < point) ans = point;
        return;
    }
    for(int i = (idx>0) ? A[idx-1] : 1; i <= m; i++){
        A[idx] = i;
        dfs(idx+1, A);
    }
}

int main(){
    cin >> n >> m >> q;
    cin.ignore();
    int ta, tb, tc, td;
    for(int i = 0; i < q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i];
        --b[i];
        cin.ignore();
    }

    vector<int> A(10, 0);
    dfs(0, A);

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

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		//データの読み込み
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if (a < b){
			System.out.println("a < b");
		}else if (a > b){
			System.out.println("a > b");
		}else{
			System.out.println("a == b");
		}
	}
}


Measured memory_bytes: 26180
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int ma = 0;
  int sum = 0;
  for (int i = 0; i < N; i ++) {
    int a;
    cin >> a;
    if (ma < a) {
      sum += ma;
      ma = a;
    }
    else sum += a;
  }
  cout << (ma >= sum ? "No" : "Yes") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

string S;
bool YM, MY;

int main() {
	cin >> S;
	int a, b;
	a = (S[0] - '0') * 10 + S[1] - '0';
	b = (S[2] -'0') * 10 + S[3] - '0';
	if (b&&b <= 12) {
		YM = true;
	}
	if (a&&a <= 12) {
		MY = true;
	}
	if (YM&&MY) {
		puts("AMBIGUOUS");
	}
	else if (YM) {
		puts("YYMM");
	}
	else if (MY) {
		puts("MMYY");
	}
	else {
		puts("NA");
	}
}

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

set<int> P[200055];

int H, W, N, Ans;

bool f(int y, int x) { return P[y].find(x) != P[y].end(); }
void upd(int t) { if(t < Ans) Ans = t; }

int main() {
	ios::sync_with_stdio(false);

	cin >> H >> W >> N;
	for(int i = 0, x, y; i < N; i++) {
		cin >> x >> y;
		P[y].insert(x);
	}
	for(int i = 1; i <= W; i++) P[i].insert(H+1);

	Ans = H;
	for(int y = 1, x = 1; y <= W; y++) {
		if(f(y, x+1)) {
			upd(x);
			break;
		}
		x++;
		upd(*P[y].lower_bound(x) - 1);
		if(y == W) break;
		for(; x <= H && f(y+1, x); x++);
		if(H < x) break;
	}

	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 28416
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int x, a, b;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> x >> a >> b;
	cout << ((abs(x - a) < abs(x - b)) ? "A\n" : "B\n");
	return 0;
}

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

int main()
{
  int N,M ;
  cin>>N>>M ;
  int L[M],R[M] ;
  int i ;
  for(i=0;i<M;i++) cin>>L[i]>>R[i] ;
  
  int left=L[0] ;
  int right=R[0] ;
  for(i=0;i<M;i++){
    if(R[i]<left||L[i]>right){
      cout<<0<<endl ;
      return 0 ;
    }else if(R[i]==left) right=left ;
    else if(L[i]==right) left=right ;
    else if(L[i]<=left&&R[i]<=right) right=R[i] ;
    else if(R[i]>=right&&left<=L[i]) left=L[i] ;
  }        
  
  cout<<right-left+1<<endl ;
      
  return 0 ;
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll k;
    cin >> k;
    ll ar[k];
    memset(ar,0,sizeof ar);
    ll x = 0;
    ar[0] = 1;
    for(ll i = 0;i < k;i++){
        x = x*10 + 7;
        if(x%k == 0){
            cout<<i+1<<"\n";
            return 0;
        }
        if(ar[x%k]){
            cout<<-1<<"\n";
            return 0;
        }
        else{
            ar[x%k] = 1;
            x %= k;
        }
    }
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n, d;

    cin>> n>> d;

    d= (d*2) +1;

    cout<< (n+ d-1)/ d;
    nl;


    return 0;
}




Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

int main(void) {
	long long n, m, i, j, k, mi, ma;
	cin >> n >> m;
	vector<long long> a(n);
	vector<long long> b(n);
	vector<long long> c(m);
	vector<long long> d(m);
	vector<long long> ans(n, 1);
	for (i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	for (i = 0; i < m; i++) {
		cin >> c[i] >> d[i];
		mi = abs(a[0] - c[i]) + abs(b[0] - d[i]);
		for (j = 1; j < n; j++) {

		}
	}
	for (i = 0; i < n; i++) {
		mi = abs(a[i] - c[0]) + abs(b[i] - d[0]);
		for (j = 1; j < m; j++) {
			if (min(mi, abs(a[i] - c[j]) + abs(b[i] - d[j])) != mi) {
				mi = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				ans[i] = j + 1;
			}
		}
	}

	for (i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
k=int(input())
if k<9:print(k);exit()
t=[i for i in range(1,10)]
c=9
while c<k:
  a=t.pop(0)
  for i in range(max(0,a%10-1),min(10,a%10+2)):
    t.append(a*10+i)
    c+=1
print(t[-1-c+k])

Measured memory_bytes: 5912
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<queue>


int main(){
	int l, r;

	std::cin>>l>>r;
	bool isAnsZero= false;

	int minVal= 2018;

	if(r-l>=2019){
		isAnsZero=true;
		minVal=0;
	}

	if(!isAnsZero){
		for(int i=l; i<=r; i++)
			for(int j=i+1; j<=r; j++){
				minVal=std::min(((i%2019)*(j%2019))%2019,minVal);
			}
	}

	std::cout<<minVal<<std::endl;

	return 0;
	
}

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

template<typename T> class Dijkstra {
public:
  struct edge {
    int to; T cost;
  };
  int V;
  vector<vector<edge>> G;
  vector<T> dist;
  using pti = pair<T,int>;
  Dijkstra(int n) : V(n), G(V), dist(V, numeric_limits<T>::max()) {}
  void add(int u, int v, T cost) {
    G.at(u).push_back((edge) {v, cost});
    G.at(v).push_back((edge) {u, cost});
  }
  void solve(int s) {
    priority_queue<pti, vector<pti>, greater<pti>> Q;
    dist.at(s) = 0;
    Q.push(pti(0, s));
    while (!Q.empty()) {
      pti p = Q.top();
      Q.pop();
      int v = p.second;
      if (dist.at(v) < p.first) continue;
      for (auto &w : G.at(v)) {
        if (dist.at(w.to) > dist.at(v) + w.cost) {
          dist.at(w.to) = dist.at(v) + w.cost;
          Q.push(pti(dist.at(w.to), w.to));
        }
      }
    }
  }
};

int main() {
  int N;
  cin >> N;
  Dijkstra<long> D(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    D.add(--a, --b, c);
  }
  int Q, K;
  cin >> Q >> K;
  D.solve(--K);
  while (Q--) {
    int x, y;
    cin >> x >> y;
    cout << D.dist.at(--x) + D.dist.at(--y) << "\n";
  }
}

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

int main ()
{
    vector<vector<pair<double,int> > > v(3, vector<pair<double,int> >(8));
    vector<pair<double,int> > tmp;
    for (auto &t : v) for (auto &i : t) cin >> i.second >> i.first;
    for (int i = 0; i < 3; i++)
        sort(v[i].begin(), v[i].end());

    for (int i = 0; i < 3; i++) {
        cout << v[i][0].second << " " << v[i][0].first << endl;
        cout << v[i][1].second << " " << v[i][1].first << endl;
        tmp.push_back(v[i][2]);
        tmp.push_back(v[i][3]);
    }

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

    for (int i = 0; i < 2; i++)
        cout << tmp[i].second << " " << tmp[i].first << endl;

    return 0;
}

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

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

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

int main() {
  int n;
  cin >> n;
  vector<P> d(n);
  rep(i, n) cin >> d[i].first >> d[i].second;

  int cnt = 0;
  bool ok = false;
  rep(i, n) {
    if (d[i].first == d[i].second) {
      ++cnt;
    } else {
      cnt = 0;
    }
    if (cnt >= 3) ok = true;
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();

		System.out.println((double) w * h / 2);
		if (w == x * 2 && h == y * 2) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}
	}
}


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

#define add_string "..."

int main()
{
    int k = 0;
    char s[105];
    char modified_s[105];

    scanf("%d", &k);
    scanf("%s", s);

    if (strlen(s) > k){
        strncpy(modified_s,s, k);
        modified_s[k] = (char)'\0';
        strcat(modified_s, add_string);
        printf("%s", modified_s);
    } else {
        printf("%s", s);
    }

    return 0;
}

Measured memory_bytes: 1736
//JSD
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#define ll long long
#define Mod 1000000007
using namespace std;
ll modular_exponentiation(ll a,ll b){
	if(b==0){
		return 1;
	}
	if(b==1){
		return a%Mod;
	}
	ll x=modular_exponentiation(a,b/2);
	x=(x*x)%Mod;
	if(b%2==1){
		x=(x*a)%Mod;
	}
	return x;
}
ll modular_divison(ll a,ll b){
    return (modular_exponentiation(b,Mod-2)*a)%Mod;
}

bool isPrime(ll n){
	if(n<=1) return 0;
	if(n==2 or n==3 ) return 1;
	if(n%2==0 or n%3==0) return 0;
	for(ll i=5;i*i<=n;i+=6){
		if(n%i==0 or n%(i+2)==0)
			return 0;
	}
	return 1;
}
struct primeFactorInfo{
	map<ll,ll> M;
	set<ll> S;
};
primeFactorInfo pfs(ll n){
	primeFactorInfo p;
	for(ll i=2;i<=sqrt(n);i++){
		if(n%i==0){
			p.S.insert(i);
			while(((n%i)==0)){
				p.M[i]++;
				n/=i;
			}
		}
	}
	if(n>1){
		p.M[n]++;
		p.S.insert(n);
	}
	return p;
}
void sieve(ll n,vector<ll>& v){
	bool isComposite[n+1]={0};
	isComposite[0]=isComposite[1]=1;
	for(ll i=2;i*i<=n;i++){
		if(!isComposite[i]){
			v.push_back(i);
			for(int j=2;j*i<=n;j++){
				isComposite[i*j]=1;
			}
		}
	}
}
primeFactorInfo pfsUsingSieve(ll n){
	primeFactorInfo p;
	vector<ll > v;
	sieve(n,v);
	for(auto i: v){
		if(n%i==0){
			p.S.insert(i);
			while(((n%i)==0)){
				p.M[i]++;
				n/=i;
			}
		}
	}
	if(n>1){
		p.M[n]++;
		p.S.insert(n);
	}
	return p;
}
int main(){
	ll h,n;
	cin>>h>>n;
	ll a[n];
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>=h){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}
	
	return 0;
}


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

#define eb emplace_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using ull = unsigned long long;
using Vi = vector<int>;

void run() {
    int n;
    cin >> n;
    vector<ll> ara(n);
    bool zero = 0;

    for (int i = 0; i < n; ++i) {
        cin >> ara[i];
        if(ara[i]==0) zero =1;
    }
    if(zero) {
        cout << 0 << endl;
        return;
    }
    ull answer = ara[0];

    for (int i = 1; i < n; ++i) {
        ll temp = (ll)(1e18)/answer;
        if(ara[i]>temp) {
            cout << -1 << endl;
            return;
        }
        answer*=ara[i];
    }
    cout << answer << endl;
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    double st = clock();

    int t  = 1;
    // cin >> t;

    while(t--) {
        run();
    }

    cerr << "\n" << "time = " << (clock() - st) / CLOCKS_PER_SEC << "\n";
    return 0;
}

Measured memory_bytes: 4040
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
#include <numeric>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back


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

    string S, T, ret="Yes";
    cin >> S >> T;
    int s = (int)(S.length()), t = (int)(T.length());
    
    if(t!=s+1) ret="No";
    else{
        rep(i, s){
            if(S[i]!=T[i]){
                ret="No";
                break;
            }
        }
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    while(1){
        int w,h;
        cin >> w >> h;
        if(w == 0) break;

        int dir = 1;
        int x = 1;
        int y = 1;
        string s;
        while(cin>>s, s!="STOP"){
            if(s == "RIGHT"){
                dir = (dir +3) %4;
            }else if(s == "LEFT"){
                dir = (dir +1) %4;
            }else if(s == "FORWARD"){
                int step;
                cin >> step;
                for(int i=0; i<step; i++){
                    int nx = x +dx[dir];
                    int ny = y +dy[dir];
                    if(nx<1 or w<nx or ny<1 or h<ny) break;
                    x = nx;
                    y = ny;
                }
            }else{
                int step;
                cin >> step;
                for(int i=0; i<step; i++){
                    int nx = x -dx[dir];
                    int ny = y -dy[dir];
                    if(nx<1 or w<nx or ny<1 or h<ny) break;
                    x = nx;
                    y = ny;
                }
            }
        }
        cout << x << " " << y << endl;
    }
    return 0;
}


Measured memory_bytes: 3124
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x
//最大化問題最小化問題
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin >> N;

    vvll X(N,vll(2));
    REP(i,N) cin >> X[i][0]>> X[i][1];

    REP(i,N-2){
        if(X[i][0]==X[i][1]&&X[i+1][0]==X[i+1][1]&&X[i+2][0]==X[i+2][1]){cout << "Yes";return 0;}
    }


    //本文
    //出力
    cout << "No" << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int n, x;
	cin >> n >> x;
	int arr[n], tmp;
	REP(i, 0, n){
		cin >> tmp;
		arr[i] = abs(x-tmp);
	}
	
	int ans=arr[0];
	REP(i, 1, n) ans = __gcd(arr[i], ans);
	
	cout << ans;
}


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

int n, d1, d2;
vector<pair<int, int>> V1, V2;
vector<int> G[400010];
bool vis[400010], c0[400010], c1[400010];

int main() {
    scanf("%d %d %d", &n, &d1, &d2);
    auto id = [&](int x, int y) {
        return x * 2 * n + y;
    };
    for (int i = 0; i * i <= d1; i++) {
        int t = sqrt(d1 - i * i);
        if (i * i + t * t == d1) V1.push_back({i, t});
    }
    for (int i = 0; i * i <= d2; i++) {
        int t = sqrt(d2 - i * i);
        if (i * i + t * t == d2) V2.push_back({i, t});
    }
    for (int i = 0; i < 2 * n; i++) {
        for (int j = 0; j < 2 * n; j++) {
            auto add = [&](int x, int y) {
                if (x >= 0 && x < 2 * n && y >= 0 && y < 2 * n) {
                    G[id(i, j)].push_back(id(x, y));
                }
            };
            for (auto p : V1) {
                add(i + p.first, j + p.second);
                add(i + p.first, j - p.second);
                add(i - p.first, j + p.second);
                add(i - p.first, j - p.second);
            }
        }
    }
    function<void(int)> dfs1 = [&](int v) {
        vis[v] = 1;
        for (int u : G[v]) if (!vis[u]) {
            c0[u] = c0[v] ^ 1, dfs1(u);
        }
    };
    memset(c0, -1, sizeof(c0));
    for (int i = 0; i < 4 * n * n; i++) {
        if (!vis[i]) c0[i] = 0, dfs1(i);
    }
    for (int i = 0; i < 4 * n * n; i++) {
        G[i].clear();
    }
    for (int i = 0; i < 2 * n; i++) {
        for (int j = 0; j < 2 * n; j++) {
            auto add = [&](int x, int y) {
                if (x >= 0 && x < 2 * n && y >= 0 && y < 2 * n) {
                    G[id(i, j)].push_back(id(x, y));
                }
            };
            for (auto p : V2) {
                add(i + p.first, j + p.second);
                add(i + p.first, j - p.second);
                add(i - p.first, j + p.second);
                add(i - p.first, j - p.second);
            }
        }
    }
    memset(vis, 0, sizeof(vis));
    memset(c1, -1, sizeof(c1));
    function<void(int)> dfs2 = [&](int v) {
        vis[v] = 1;
        for (int u : G[v]) if (!vis[u]) {
            c1[u] = c1[v] ^ 1, dfs2(u);
        }
    };
    for (int i = 0; i < 4 * n * n; i++) {
        if (!vis[i]) c1[i] = 0, dfs2(i);
    }
    int tot = 0;
    for (int i = 0; i < 2 * n; i++) {
        for (int j = 0; j < 2 * n; j++) {
            if (!c0[id(i, j)] && !c1[id(i, j)]) printf("%d %d\n", i, j), tot++;
            if (tot == n * n) exit(0);
        }
    }
    return 0;
}

Measured memory_bytes: 81536
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
const int MAX = 18;
int dp[MAX][1<<MAX]={};
int cst[MAX][1<<MAX]={};

signed main(){
  int n;
  cin>>n;
  vector<int> as(n),bs(n);
  for(int i=0;i<n;i++) cin>>as[i];
  for(int i=0;i<n;i++) cin>>bs[i];

  for(int i=1;i<n;i+=2) swap(as[i],bs[i]);

  const int INF = 1e9;
  for(int i=0;i<MAX;i++)
    for(int b=0;b<(1<<MAX);b++)
      dp[i][b]=INF;

  for(int i=0;i<n;i++)
    dp[i][1<<i]=0;

  const int sz=1<<n;
  for(int bit=0;bit<sz;bit++){
    for(int i=0;i<n;i++){
      if((bit>>i)&1) continue;
      for(int j=i;j<n;j++)
        cst[i][bit]+=(bit>>j)&1;
    }
  }

  for(int bit=0;bit<sz;bit++){
    int k=__builtin_popcount(bit);
    for(int l=0;l<n;l++){
      if((~bit>>l)&1) continue;
      // cout<<l<<" "<<bit<<":"<<dp[l][bit]<<endl;
      for(int i=0;i<n;i++){
        if((bit>>i)&1) continue;
        if(k&1){
          if(as[l]>bs[i]) continue;
        }else{
          if(bs[l]>as[i]) continue;
        }
        int nbit=bit|(1<<i);
        chmin(dp[i][nbit],dp[l][bit]+cst[i][bit]);
      }
    }
  }

  int ans=INF;
  for(int i=0;i<MAX;i++)
    chmin(ans,dp[i][sz-1]);

  if(ans==INF) ans=-1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 37120
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define EPS 1e-15

using namespace std;

typedef complex<double> point;
typedef vector<point> polygon;
typedef pair<int, int> paii;
typedef long long ll;

int main()
{
	int cnt = 0;
	vector<string> in;
	string str;
	
	while( cin >> str, !cin.eof())
	{
		in.push_back(str);
	}
	
	FOR(i, 0, (int)in.size())
	{
		string rstr = string(in[i].rbegin(), in[i].rend());
		
		if( in[i] == rstr )
			cnt++;
	}
	
	cout << cnt << endl;	
		
	return 0;
}

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

using namespace std;

int main() {
    long long n;
    scanf("%lld", &n);
    
    if (n & 1) return 0 * printf("0\n");
    
    long long exp = 5;
    n /= 2;
    long long res = 0;
    
    while (exp <= n) {
        res += n / exp;
        exp *= 5;
    }
    
    printf("%lld\n", res);
}

Measured memory_bytes: 256
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  cout<<a+b+c-max(a,max(b,c))<<endl;
  
}

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

int main() {
  int n;
  cin>>n;
  string p;
  cin>>p;
  string copy=p,op="";
  if(n==1){
    cout<<"()"<<endl;
    return 0;
  }
  
  for(int i=0;i<1000;i++){
    for(int j=0;j<copy.size()-1;j++){
      if(copy.at(j)=='('&&copy.at(j+1)==')'){
        copy.at(j)='@';
        copy.at(j+1)='@';
      }
    }
    op="";
    for(int j=0;j<copy.size();j++){
      if(copy.at(j)!='@'){
        op=op+copy.at(j);
      }
    }
    copy=op;
    if(copy.size()<=1){
      if(copy.size()==0){
        cout<<p<<endl;
        return 0;
      }
      if(copy=="("){
        cout<<p<<")"<<endl;
        return 0;
      }
      cout<<"("<<p<<endl;
      return 0;
    }
  }
  
  int h=0,g=0;
  for(int i=0;i<copy.size();i++){
    if(copy.at(i)=='('){
      g++;
      continue;
    }
    if(copy.at(i)==')'){
      h++;
    }
  }
  for(int i=0;i<h;i++){
    cout<<"(";
  }
  cout<<p;
  for(int i=0;i<g;i++){
    cout<<")";
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
void outPut(int Array[],char mark){
    for(int i = 1; i <= 13; i++){
        if(Array[i] == 0) printf("%c %d\n",mark,i);
    }
}
 
int main(){
    char mark[2];
    int n,S[14],H[14],C[14],D[14],tmp;
    for(int i = 0; i < 14; i++) S[i] = H[i] = C[i] = D[i] = 0;
    scanf("%d",&n);
 
    for(int i = 0; i < n; i++){
        scanf("%s %d",mark,&tmp);
        switch(mark[0]){
        case 'S':
            S[tmp] = 1;
            break;
        case 'H':
            H[tmp] = 1;
            break;
        case 'C':
            C[tmp] = 1;
            break;
        case 'D':
            D[tmp] = 1;
            break;
        }
    }
    outPut(S,'S');
    outPut(H,'H');
    outPut(C,'C');
    outPut(D,'D');
}


Measured memory_bytes: 2724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

int main() {
    string s, t; cin >> s >> t;
    cout << t << s;

    return 0;
}


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

int main(){
    int n;cin>>n;
    int min=101;

    int ans=0;
    for(int i=0;i<n;i++){
        int x;  cin>>x;
        ans+=x;
        if(min>x && x%2!=0)min=x;
    }

    if(ans%2!=0)ans-=min;

    cout<<ans/2<<endl;

    return 0;
}



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

const int MAX = 310000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    COMinit();
    ll answer = 1;//k=2より移動無しのケースは常にある
    ll maxZeroNum = min(n - 1, k);
    for(int i = 1; i <= maxZeroNum; i++)
    {
        answer = (answer + COM(n, i) * COM(n - 1, i)) % MOD;
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 7552
#include <stdio.h>
#include <string.h>
#define maxn 200
struct yagamiraito
{
    char s[maxn];
}a[maxn];
int main (void)
{
    int n,m;
    int i,j;
    while(~scanf("%d%d",&n,&m))
    {
        for(i=1;i<=n;i++)
            scanf("%s",&a[i].s);
        for(i=1;i<=m+2;i++)
        {
            printf("#");
        }
        printf("\n");
        for(i=1;i<=n;i++)
        {
            printf("#%s#\n",a[i].s);
        }
        for(i=1;i<=m+2;i++)
        {
            printf("#");
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int A, B, C, k; scanf("%d%d%d%d", &A, &B, &C, &k);
	std::vector<i64> a(A), b(B), c(C);
	for(int i = 0; i < A; i++) scanf("%lld", &a[i]); sort(begin(a), end(a), std::greater<>());
	for(int i = 0; i < B; i++) scanf("%lld", &b[i]); sort(begin(b), end(b), std::greater<>());
	for(int i = 0; i < C; i++) scanf("%lld", &c[i]); sort(begin(c), end(c), std::greater<>());
	
	std::vector<i64> vec;
	for(int i = 0; i < a.size(); i++) {
		for(int j = 0; j < b.size(); j++) {
			vec.push_back(a[i] + b[j]);
		}
	}
	sort(begin(vec), end(vec));
	
	std::function<bool (i64)> check = [&](i64 t) {
		i64 tmp = 0, cur = 0;
		for(int i = 0; i < c.size(); i++) {
			while(cur < vec.size() and vec[cur] + c[i] < t) cur++;
			tmp += vec.size() - cur;
			
			if(tmp >= k) return true;
		}
		return false;
	};
	i64 ok = 0, ng = 1LL << 60;
	while(ng - ok > 1) {
		
		i64 mid = (ok + ng) >> 1;
		
		if(check(mid)) ok = mid;
		else ng = mid;
	}
	
	int cur = 0;
	std::vector<i64> ans;
	for(int i = 0; i < c.size(); i++) {
		while(cur < vec.size() and vec[cur] + c[i] < ok) cur++;
		
		for(int j = cur; j < vec.size(); j++) ans.push_back(c[i] + vec[j]);
	}
	sort(begin(ans), end(ans), std::greater<>());
	
	for(int i = 0; i < k; i++) printf("%lld\n", ans[i]);
	return 0;
}


Measured memory_bytes: 141408