akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define inf 10000000000000007
#define eps 1e-13
#define PI 3.14159265359
#define sp printf(" ")
#define vi vector<int>
#define vl vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pcc pair<char, char>
#define mp make_pair
#define FF first
#define SS second
#define pb(x) push_back(x)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define sld(x) scanf("%ld", &(x))
#define pld(x) printf("%ld", (x))
#define pldn(x) printf("%ld\n", (x))
#define slf(x) scanf("%lf", &(x))
#define plf(x) printf("%.9lf", (x))
#define plfn(x) printf("%.9lf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define ios ios::sync_with_stdio(false); cin.tie(0) ; cout.tie(0)
#define endl '\n'
using namespace std;
int main()
{
    ll h,w;
    cin>>h>>w;
    ll ans=100000000000000000;
    for(ll i=1;i<=h;i++)
    {
        ll ma=(h-i)*w;
        ll mi=i*w;
        if(mi%2==0)
        {
            ll q=mi/2LL;
            ans=min(ans,abs(q-ma));
        }
        else
        {
            ll z=(i-1)/2LL;
            ll x=(i+1)/2LL;
            z=z*w;x=x*w;
            ll c=max(ma,x);
            z=min(z,ma);
            ans=min(ans,c-z);
            z=(w-1)/2LL;
            x=(w+1)/2LL;
            z=z*i;x=x*i;
            z=min(z,ma);
            c=max(x,ma);
            ans=min(ans,c-z);

        }
    }
    swap(h,w);
    for(int i=1;i<=h;i++)
    {
        ll ma=(h-i)*w;
        ll mi=i*w;
        if(mi%2==0)
        {
            ll q=mi/2LL;
           // ll mi=(h-i)*w/2LL;
            ans=min(ans,abs(q-ma));
        }
        else
        {
            ll z=(i-1)/2LL;
            ll x=(i+1)/2LL;
            z=z*w;x=x*w;
            z=min(z,ma);
            ll c=max(ma,x);
            ans=min(ans,abs(z-c));
            z=(w-1)/2LL;
            x=(w+1)/2LL;
            z=z*i;x=x*i;
            z=min(z,ma);
            c=max(x,ma);
            ans=min(ans,abs(c-z));

        }
    }
    cout<<ans<<endl;





}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
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;}

ll n;
ll s[410] = {};
ll dp[410][410];

ll rec(ll l, ll r) {
    if (l == r) return 0;
    if (dp[l][r] != -1) return dp[l][r];
    ll res = 1LL << 60;
    for (ll i = l+1; i <= r; i++) {
        chmin(res, rec(l, i-1) + rec(i, r) + s[r] - s[l-1]);
    }
    return dp[l][r] = res;
}

int main() {
    cin >> n;
    rep(i, n) {
        ll tmp;
        cin >> tmp;
        s[i+1] = s[i] + tmp;
    }
    memset(dp, -1, sizeof(dp));
    cout << rec(1, n) << endl;
}

Measured memory_bytes: 1536
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll n, a, b, ans = 0;
  scanf("%lld%lld%lld", &n, &a, &b);
  for (int i = 1; i <= n; i++)
  {
    int ii = i;
    ll tmp = 0;
    while (ii)
    {
      tmp += ii % 10;
      ii /= 10;
    }
    if (tmp >= a && tmp <= b)
    {
      ans += i;
    }
  }
  printf("%lld\n", ans);
  return 0;
}

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

int n;
string s;
vector<int> le, re, lw, rw;
int ans = 1e9+7;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> s;
	le.resize(n+2, 0);
	re.resize(n+2, 0);
	lw.resize(n+2, 0);
	rw.resize(n+2, 0);
	for(int i=0; i<n; ++i){
		if(s[i] == 'E'){
			le[i+1] = 1;
			re[i+1] = 1;
		}else{
			lw[i+1] = 1;
			rw[i+1] = 1;
		}
	}
	for(int i=1; i<n+2; ++i){
		le[i] += le[i-1];
		lw[i] += lw[i-1];
		re[n-i+1] += re[n-i+2];
		rw[n-i+1] += rw[n-i+2];
	}
	for(int i=0; i<n; ++i)
		ans = min(ans, lw[i] + re[i+2]);
	cout << ans << "\n";
}

Measured memory_bytes: 5380
s=input()

if s[0:2]=="01" or s[0:2]=="02" or s[0:2]=="03" or s[0:2]=="04" or s[0:2]=="05" or s[0:2]=="06" or s[0:2]=="07" or s[0:2]=="08" or s[0:2]=="09" or s[0:2]=="10" or s[0:2]=="11" or s[0:2]=="12":
    if s[2:4]=="01" or s[2:4]=="02" or s[2:4]=="03" or s[2:4]=="04" or s[2:4]=="05" or s[2:4]=="06" or s[2:4]=="07" or s[2:4]=="08" or s[2:4]=="09" or s[2:4]=="10" or s[2:4]=="11" or s[2:4]=="12":
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if s[2:4]=="01" or s[2:4]=="02" or s[2:4]=="03" or s[2:4]=="04" or s[2:4]=="05" or s[2:4]=="06" or s[2:4]=="07" or s[2:4]=="08" or s[2:4]=="09" or s[2:4]=="10" or s[2:4]=="11" or s[2:4]=="12":
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N, M;
ll ret = 0;
string s;

int main(void){
  
  IN(N);
  IN(M);

  ll l = 1;
  ll r = l + (M%2==1 ? M : M-1);
  while(r > l) {
    cout << l << " " << r << endl;
    l++;
    r--;
  }
  r = 2 * M + 1;
  l = r - (M%2==0 ? M : M-1);
  while(r > l) {
    cout << l << " " << r << endl;
    l++;
    r--;
  }

}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 200010;

int main(){
        lint n;
        scanf("%lld", &n);
        lint ans=0;
        for(lint p=1; p*(p+1)<n; ++p){
                if(n%p==0) ans+=n/p-1;
        }
        printf("%lld\n", ans);
}

Measured memory_bytes: 256
object Main extends App {
  val src = io.Source.stdin.getLines.map(_.toInt)
  src.next

  def myDiff(org: Int): Int = {
    val min = org.toString.sorted
    val max = min.reverse
    max.toInt - min.toInt
  }

  for (num <- src) println(myDiff(num))
}

Measured memory_bytes: 43960
#!/usr/bin/env python3
import sys
import numpy as np

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int, A: "List[int]"):
    A = np.array(A)
    n_sum = np.sum(A)/4/M
    if (A >= n_sum).sum() >= M:
        print(YES)
    else:
        print(NO)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 21616
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val q = sc.nextInt()
  val ab = List.fill(q)((sc.nextInt(), sc.nextInt()))

  val pw = new java.io.PrintWriter(Console.out)
  for ((a, b) <- ab) {
    val x = a.min(b)
    val y = a.max(b)
    val score = x.toLong * y

    def binSearch(begin: Int, end: Int): Int = {
      def check(k: Int): Boolean = {
        def maxProd(l: Int, r: Int, sum: Int): Long = {
          if (l > r) {
            Int.MinValue
          } else if (sum % 2 == 0) {
            if (r < sum / 2) {
              r.toLong * (sum - r)
            } else if (sum / 2 < l) {
              l.toLong * (sum - l)
            } else {
              (sum.toLong * sum) / 4
            }
          } else {
            if (r < sum / 2) {
              r.toLong * (sum - r)
            } else if (sum / 2 + 1 < l) {
              l.toLong * (sum - l)
            } else {
              (sum.toLong / 2) * ((sum / 2) + 1)
            }
          }
        }

        val mp = if (k < x) {
          maxProd(1, k, k+1)
        } else if (k < y) {
          maxProd(1, x-1, k+1).max(maxProd(x+1, k+1, k+2))
        } else if (k < x + y - 2) {
          maxProd(1, k-y+1, k+2).max(maxProd(k-y+2, x-1, k+1)).max(maxProd(x+1, k+1, k+2))
        } else {
          maxProd(1, x-1, k+2).max(maxProd(x+1, k-y+1, k+3)).max(maxProd(k-y+3, k+1, k+2))
        }

        mp < score
      }

      if (end - begin <= 1) {
        begin
      } else {
        val m = begin + (end - begin) / 2
        if (check(m)) binSearch(m, end) else binSearch(begin, m)
      }
    }

    pw.println(if (y == 1) 0 else binSearch(0, 2 * y))
  }
  pw.flush()
}


Measured memory_bytes: 55476
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
bool cmp(int A,int B){
	int C1,C2;
	C1=C2=0;
	rep(i,16)
		if(i)
		if((A>>i)&1) C1++;
	rep(i,16)
		if(i)
		if((B>>i)&1) C2++;
		return C1<C2;
}
int main(){
	fastio;
	int n;
	cin>>n;
	int cnt[16]={0},x[100000]={0};
	rep(i,n-1){
		int a,b,c;
		cin>>a>>b>>c;x[a]^= c,x[b]^=c;
	}
	rep(i,n)
		cnt[x[i]]++;
	int res=0;
	rep(i,16)
	if(i)
	res+=cnt[i]/2,cnt[i]=cnt[i]%2;
	int dp[1<<16];
	int  Nmask=0;
	rep(i,16)
		if(i)
		Nmask|=cnt[i]<<i;
	
	memset(dp,63,sizeof(dp));
	
	dp[Nmask]=0;
	vector<int> M;
	rep(i,1<<16){
		M.PB(i);
	}
	sort(ALL(M),cmp);
	rl(Cnt,(1<<16)-1,0){
		int i=M[Cnt];
		int cnt=0;
		rep(j,16)
			if(j)
			if(i&(1<<j)) cnt++;
		if(cnt>=2){
			rep(j,16){
				if(j)
				if(i&(1<<j))
				rep(k,16){
					if(k)
					if(k!=j&&(i&(1<<k))){
						int New=(k^j);
						int nmask=(i-(1<<j)-(1<<k));
						if(nmask&(1<<New)){
							dp[nmask-(1<<New)]=min(dp[nmask-(1<<New)],dp[i]+2);
						}
						else{
							dp[nmask+(1<<New)]=min(dp[nmask+(1<<New)],dp[i]+1);
						}
					}
				}
			}
		}
	}
	cout<<res+dp[0]<<endl;
	return 0;
}


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

#define MAX 1000000

int num[MAX];

int main()
{
	for (int i = 1; i <= MAX; i *= 2){
		for (int j = i; j <= MAX; j *= 3){
			for (int k = j; k <= MAX; k *= 5){
				num[k] = true;
			}
		}
	}

	for (int i = 1; i <= MAX; i++){
		num[i] += num[i - 1];
	}

	int m, n;

	while (scanf("%d", &m), m){
		scanf("%d", &n);
		printf("%d\n", num[n] - num[m - 1]);
	}

	return (0);
}

Measured memory_bytes: 5092
using System;
 
class program
{
  	static void Main()
    {
    	char c = Console.ReadLine()[0];
      	
    	if((c >= 'a') && (c <='z'))
        {
        	Console.WriteLine('a');
        }
      	else
        {
         	Console.WriteLine('A');
        }
    }
}

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

const ll MOD = 1000000007;
ll N;
ll A[100010];
ll c[100010];
ll fac;

ll modPow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = 1;
  while (n) {
    if (n & 1) (res *= x) %= MOD;
    (x *= x) %= MOD;
    n >>= 1;
  }
  return res;
}

ll modInv(ll x) {
  return modPow(x, MOD-2);
}

void make() {
  c[1] = 1;
  for (int i = 2; i < 100010; i++) {
    c[i] = (c[i-1] + modInv(i)) % MOD;
  }
  fac = 1;
  for (int i = 1; i <= N; i++) {
    (fac *= i) %= MOD;
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  make();
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ll sum = c[i+1] + c[N-i];
    (sum += MOD-1) %= MOD;
    (ans += sum*A[i]) %= MOD;
  }
  (ans *= fac) %= MOD;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

map<ll,ll> prime_factor(ll n){
	map<ll,ll> res;
	while(n % 2 == 0LL){
		res[2]++;
		n /= 2;
	}
	while(n % 5 == 0LL){
		res[5]++;
		n /= 5;
	}
    return res;
}

int main(){
	ll n;cin>>n;
	ll index = 1000000000;
	vector<P> a;
	vector<vector<int>> fact(100,vector<int>(100,0));
	for(int i = 0; i < n; i++) {
		string s;
		cin>>s;
		ll index = 9;
		ll x = 0; 
		bool flag = false;
		for(int i = 0; i < s.size(); i++) {
			if(s[i] != '.'){
				if(!flag){
					x = 10 * x + (s[i] - '0');
				}
				else{
					x = 10 * x + (s[i] - '0');
					index --;
				}
			}
			else{
				flag = true;
			}
		}
		for(int i = 0; i < index; i++) {
			x *= 10;
		}
		// cout << x << endl;
		map<ll,ll> pf= prime_factor(x);
		a.pb(mp(pf[2],pf[5]));
		fact[pf[2]][pf[5]]++;
	}
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		ll key1 = max(0LL,18 - a[i].fs);
		ll key2 = max(0LL,18 - a[i].sc);
		for(int j = key1; j < 100; j++) {
			for(int k = key2; k < 100; k++) {
				// cout << fact[j][k] << " ";
				ans += fact[j][k];
			}
			// cout << endl;
		}
		if(a[i].fs  >= key1 && a[i].sc >= key2){
			ans--;
		}
	}
	cout << ans / 2 << endl;
	return 0;

}

Measured memory_bytes: 7488
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    string s;
    cin >> s;
    char stage='R';
    int R_count=0,L_count=0,point,sum;
    vector<int> ans(s.length(),0);
    REP(i,0,s.length()){
        if(s[i]=='R'){
            if(stage=='L'){
                stage='R';
                sum=R_count+L_count;
                if(sum%2==0){
                    ans[point-1]=sum/2;
                    ans[point]=sum/2;
                }else{
                    if(R_count%2==0){
                        ans[point-1]=sum/2;
                        ans[point]=sum/2+1;
                    }else{
                        ans[point-1]=sum/2+1;
                        ans[point]=sum/2;
                    }
                }
                R_count=0;
                L_count=0;
            }
            R_count++;
        }else{
            if(stage=='R'){
                stage='L';
                point=i;
            }
            L_count++;
            if(i==s.length()-1){
                sum=R_count+L_count;
                if(sum%2==0){
                    ans[point-1]=sum/2;
                    ans[point]=sum/2;
                }else{
                    if(R_count%2==0){
                        ans[point-1]=sum/2;
                        ans[point]=sum/2+1;
                    }else{
                        ans[point-1]=sum/2+1;
                        ans[point]=sum/2;
                    }
                }
            }
        }
    }

    cout << ans[0];
    REP(i,1,s.length()){
        cout << " " << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int ans = 0,cnt = 0;
int len;

char s[100005];
void f(char x){
	for (int i = 0; i < len; i++){
		if (s[i] == x) ans++;
		if (ans == 1)	break;
	}
}

int main()
{
	scanf(" %s", &s);
	len = strlen(s);
	for (int i = 0; i < 26; i++){
		f ('a' + i);
		if (ans == 0){

			printf("%c\n", 'a' + i);
			cnt++;
			break;
		}
		ans = 0;
	}
	if (!cnt)	printf("None\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
using pii=pair<int,int>;
using vs=vector<string>;
using vvi=vector<vi>;
using vpii=vector<pii>;
using si=set<int>;

#define REP(i,a) for(int i=0;i<a;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rREP(i,a) for(int i=(a)-1;i>=0;i--)
#define rFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define out(S) cout<<(S)<<endl;
#define beginend(v) (v).begin(),(v).end()
#define IfOut(condition,text) if(condition){out(text);return 0;}
#define IfOutElse(condition,if_text,else_text) if(condition){out(if_text);return 0;}else{out(else_text);return 0;}
#define mod(s) ((s)%(ll)(1e9+7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a*modpow((ll)b,(ll)(1e9+5))))
#define pb(i) push_back(i)
#define fst first
#define snd second
#define Foreach(item,collection) for(auto item:collection)
#define INF (int)1e10
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) {ll prime;double sqrtmax = sqrt(max);vector<ll> primeVec, searchVec;FOR(i, 2, max + 1) searchVec.push_back(i);do{prime = searchVec[0];primeVec.push_back(prime);auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });searchVec.erase(itr, searchVec.end());} while (prime < sqrtmax);primeVec.reserve(primeVec.size() + searchVec.size());primeVec.insert(primeVec.end(), beginend(searchVec));return primeVec;}
ll sum(vi v) {ll sum=0;Foreach(i,v){sum+=i;}return sum;}
#define ShowAll(v) Foreach(i,v) out(i);
bool isInnerIndex(int kx,int ky,int mx,int my){ return (kx>=0&&kx<mx&&ky>=0&&ky<my); }


int main(){
    vi ans;
    int n;
    map<int,int> m;
    m[1]=0;
    m[2]=1;
    while (cin>>n,n)
    {
        int down=0,up=0;
        if(m.count(n)){
            down=m[n];
        }else{
            auto v=sieveOfEratosthenes(n);
            m[n]=v.size();
            down=m[n];
        }
        if(m.count(n*2)){
            up=m[n*2];
        }else{
            auto v=sieveOfEratosthenes(n*2);
            m[n*2]=v.size();
            up=m[n*2];
        }
        ans.pb(up-down);
    }
    
    ShowAll(ans);
    return 0;
}

Measured memory_bytes: 6760
#include<stdio.h>
int main(void)
{
	int a,b,i,c;
	char op;
	
	while(1){
		scanf("%d %c %d",&a,&op,&b);
	if(op=='+'){
		printf("%d\n",a+b);
	}
	else if(op=='-'){
		
		printf("%d\n",a-b);
	}
	else if(op=='*'){
		printf("%d\n",a*b);
	}
	else if(op=='/'){
		printf("%d\n",a/b);
	}
	else{
	return 0;
	}
	}
}


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

using namespace std;
typedef long long ll;

struct node{
    int max_edges=0;
};

void dfs(int sv,vector<int> *edges,unordered_set<int> &visited,vector<node> &nodes){
    visited.insert(sv);
    for(auto i:edges[sv]){
        if(visited.count(i)==0)
            dfs(i,edges,visited,nodes);
        nodes[sv].max_edges = max(1+nodes[i].max_edges,nodes[sv].max_edges);
    }
}

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

    int n,m;
    cin>>n>>m;

    vector<int> *edges = new vector<int>[n+1];
    vector<node> nodes(n+1);
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        edges[x].push_back(y);
    }

    unordered_set<int> visited;

    for(int i=1;i<=n;i++){
        if(visited.count(i)==0)
            dfs(i,edges,visited,nodes);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,nodes[i].max_edges);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 17864
import numpy as np

A = []
for _ in range(3):
    A.append([int(x) for x in input().split()])
A = np.array(A)
R = np.zeros((3,3))
N = int(input())
B = []

for _ in range(N):
    b = int(input())
    x, y = np.where(A == b)
    if len(x) > 0:
        for i in range(len(x)):
            R[x[i], y[i]] = 1

#列
row1 = (np.sum(R, axis=1) >= 3).sum()
row2 = (np.sum(R, axis=0) >= 3).sum()

c1 = R[0][0] + R[1][1] + R[2][2]
c2 = R[0][2] + R[1][1] + R[2][0]
if row1 > 0 or row2 > 0 or c1 >= 3 or c2 >= 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 21664
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
    string s; cin >> s;
    ll k; cin >> k;
    int n = s.size();
    rep(i,n){
        if(s[i] == '1' && i+1==k){
            cout << 1 << endl;
            return 0;
        }
        if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <bitset>
#include <iterator>
#include <valarray>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <tuple>
#include <initializer_list>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef tuple<int, int> tii;
template<typename T> ostream &operator<<(ostream &os, set<T> const &s) { if (s.size() == 0) return os << "{}"; os << "{"; decltype(s.begin()) iter; for (iter = s.begin(), ++iter; iter != s.end(); ++iter) { --iter; os << *iter << ", "; ++iter; } --iter; os << *iter << '}'; return os; }
template<typename T> ostream &operator<<(ostream &os, multiset<T> const &s) { if (s.size() == 0) return os << "{}"; os << "{"; decltype(s.begin()) iter; for (iter = s.begin(), ++iter; iter != s.end(); ++iter) { --iter; os << *iter << ", "; ++iter; } --iter; os << *iter << '}'; return os; }
template<typename T, typename U> ostream &operator<<(ostream &os, map<T, U> const &mp) { if (mp.size() == 0) return os << "{}"; os << "{" << endl; decltype(mp.begin()) iter; for (iter = mp.begin(), ++iter; iter != mp.end(); ++iter) { --iter; os << "  {" << iter->first << ", " << iter->second << "}," << endl; ++iter; } --iter; os << "  {" << iter->first << ", " << iter->second << "}" << endl << '}'; return os; }
template<typename T> ostream &operator<<(ostream &os, vector<T> const &v) { os << '['; rep(i, v.size()-1) os << v[i] << ", "; if (v.size() > 0) os << v[v.size()-1]; cerr << ']'; return os; }
template<typename T, unsigned N, unsigned Last> struct TuplePrinter { static void print(ostream &os, T const& v) { os << std::get<N>(v) << ", "; TuplePrinter<T, N + 1, Last>::print(os, v); } };
template<typename T, unsigned N> struct TuplePrinter<T, N, N> { static void print(ostream &os, T const &v) { os << std::get<N>(v); } };
template<typename... Types> ostream& operator<<(ostream &os, tuple<Types...> const &v) { os << "("; TuplePrinter<tuple<Types...>, 0, sizeof...(Types) - 1>::print(os, v); os << ")"; return os; }
template<typename T> void _dbg(T const &t) { cerr << t << endl; }
template<typename T, typename... Args> void _dbg(T const &t, Args... args) { cerr << t << " "; _dbg(args...); }
template<typename... Args> void __dbg(const char *fn, int l, Args... args) { cerr << "[" << fn << ":" << l << "] "; _dbg(args...); }
#define dbg(...) __dbg(__func__, __LINE__, __VA_ARGS__)

const ll infty = 1223372036854775807;
const double eps = 1e-8;

int main() {
	int n;
	string s;
	cin >> n >> s;
	char prev = s[0];
	int ans = 1;
	for (int i = 1; i < n; ++i) {
		char c = s[i];
		if (c != prev) {
			ans += 1;
			prev = s[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main() {
	int x=0;
	int y=0;
	int i;
	
	printf("");
	scanf("%d",&x);
	
	while (1) {
		if(x<=100 && x>=1){
			break;
		}else{
			printf("");
			scanf("%d",&x);
			continue;
		}
	}
	
	y=x;
	for (i=0;i<2;i++)
		x*=y;
	
	printf("%d\n",x);
	
	return 0;
}

Measured memory_bytes: 596
n = int(input())
d = {i: 0 for i in range(n+1)}
for i in range(1, n+1):
    for j in range(1, n+1):
        if j%i == 0:
            d[j] +=1
a = 0
for k, v in d.items():
    if k%2 == 1 and v == 8:
        a +=1
print(a)

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

int main() {
    while (true) {
        int H, W;
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if ((i + j ) % 2 == 0) {
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
while True:
    try:
        a,b=map(int,input().split())
        if a==0 and b==0:
            break
        else:
            if a<b:
                a,b=b,a
            else:
                pass
            i=0
            while True:
                c=a%b
                a=b
                b=c
                i+=1
                if b==0:
                    break
            print(a,i)
    except EOFError:
        pass




Measured memory_bytes: 5608
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean hasY = false;
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            if(s.equals("Y")){
                hasY = true;
                break;
            }
        }
        if(!hasY) System.out.println("Three");
        else System.out.println("Four");
        sc.close();

    }

}


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


int main(){
    ll h,x,a;
    x = 1;
    a = 0;
    cin >> h;
    a += x;
    while(h > 1){
        x *= 2;
        a += x;
        h /= 2;
    }
    cout << a << "\n";
    return 0;
}

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

typedef struct {
    char name[100];
    int time;
} P;

P Q[LEN];
int head, tail, n;

// int isFull() {
//     return head == (head+1)%LEN;
// }

int isEmpty() {
    return head == tail;
}

void enqueue(P x) {
    Q[tail] = x;
    tail = (tail+1)%LEN;
}

P dequeue() {
    P x = Q[head];
    head = (head+1)%LEN;
    return x;
}

int main() {
    int q, i, t=0;
    P x;
    head = tail = 0;
    cin >> n >> q;
    for (i=0; i < n; i++) {
        cin >> Q[i].name >> Q[i].time;
    }
    head = 0;
    tail = n;

    while (!isEmpty()) {
        x = dequeue();
        if (x.time > q) {
            t+=q;
            x.time-=q;
            enqueue(x);
        } else {
            t+=x.time;
            cout << x.name << " " << t << endl;
        }
    }
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

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

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

int main()
{   
    int n;
    cin >> n;
    vi a(n+1);
    rep(i, n) cin >> a[i+1];
    vi b(n+1);
    for(int i = n; i >= 1; i--) {
        int sum = 0;
        for(int j = i+i; j <= n; j+=i) {
            sum ^= b[j];
        }
        b[i] = sum^a[i];
    }
    vi ans;
    for(int i = 1; i <= n; i++) {
        if(b[i]) ans.push_back(i);
    }
    cout << ans.size() << endl;
    rep(i, ans.size()) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 5252
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int H, W;
    
    while (true) {
      StringBuilder s = new StringBuilder();
      String crlf = System.getProperty("line.separator");
      H = in.nextInt();
      W = in.nextInt();
      if(H == 0 && W == 0) break;
      
      for (int w = 0; w < W; w++) {
        s.append("#");
      }
      for (int h = 0; h < H; h++) {
        System.out.println(s);
      }
      System.out.print(crlf);
    }
  }
}

Measured memory_bytes: 21080
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
typedef pair<int,int>P;
#define fi first
#define se second
int h,w,a[200001],ls,ans;
main(){
	cin>>h;
	memset(a,0,sizeof(a));
	r(i,h)cin>>a[i];
	stack<P>st;
	r(j,h+1){
		if(st.empty())st.push(P(a[j],j));
		else if(st.top().fi==a[j])continue;
		else if(st.top().fi<a[j])st.push(P(a[j],j));
		else{
			while(!st.empty()&&st.top().fi>a[j]){
				ans=max(ans,(j-st.top().se)*st.top().fi);
				ls=st.top().se;
				st.pop();
			}
			st.push(P(a[j],ls));
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6156
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009

int main(void){
	bool p[100002];
	bool a[100002];
	vector<int>b;
	f(i, 100002){
		p[i] = false;
		a[i] = false;
	}
	int c[100002];
	int k, s;
	int n, m;
	bool v;
	int x, y, z;
	int ans = 0;

	for (int i = 2; i < 100001; i++){
		v = true;
		f(j, b.size()){
			if (i%b[j] == 0){
				v = false;
				break;
			}
		}
		if (v){
			b.push_back(i);
			p[i] = true;
		}
	}
	for(int i = 2; i < 100001; i++){
		if (i % 2 == 1 && p[i] && p[(i + 1) / 2])a[i] = true;
	}
	c[0] = 0;
	f(i, 100001){
		if (a[i + 1])c[i + 1] = c[i] + 1;
		else c[i + 1] = c[i];
	}

	scanf("%d", &n);


	f(i, n){
		scanf("%d %d", &x, &y);
		printf("%d\n", c[y] - c[x - 1]);
	}

	return 0;
}


Measured memory_bytes: 1280
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N; cin >> N;
    vi P(N); REP(i, N) cin >> P[i];

    vi idx;
    REP(i,N) {
        if (P[i] != i+1) idx.push_back(i);
    }

    if (idx.size() >= 2){
        swap(P[idx[0]], P[idx[1]]);
    }

    bool ok = true;
    REP(i,N-1) {
        if (P[i] > P[i + 1]) {
            ok = false;
            break;
        }
    }

    string ans = ok ? "YES" : "NO";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] x = new int[m];
        int[] interval = new int[m - 1];
        for (int i = 0; i < m; i++) {
            x[i] = sc.nextInt();
        }
        Arrays.sort(x);
        for (int i = 0; i < m - 1; i++) {
            interval[i] = x[i + 1] - x[i];
        }
        Arrays.sort(interval);
        int ans = 0;
        for (int i = 0; i < m - n; i++) {
            ans += interval[i];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 61084
#include <bits/stdc++.h>
#define ll long long
#define fort(i,n) for (int i = 1; i <= n; ++i)
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz size()
#define er erase
#define fr first
#define sc second
#define rc(x) return cout << x, 0
using namespace std;

ll k,a,b;

int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> k >> a >> b;
    if (a+2ll>=b||a>=k) rc(k+1ll);
    if ((k-a+1)%2==0) rc(b*(k-a+1)/2-a*(k-a-1)/2);
    cout << b*(k-a)/2-a*(k-a-2)/2+1ll;
}


Measured memory_bytes: 256
queue=[]
vector=[]
first_num=[int(w) for w in input().split()]

for i in range(first_num[0]):
    queue.append([int(w) for w in input().split()])

for i in range(first_num[0]):
    sum=0
    for w in range(first_num[1]):
        sum+=queue[i][w]
    queue[i].append(sum)

for i in range(first_num[1]+1):
    sum=0
    
    for w in range(first_num[0]):
        sum+=queue[w][i]
        
    vector.append(sum)
    
queue.append(vector)

for i in range(first_num[0]+1):
    print(' '.join(map(str,queue[i])))


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

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

    int v_even[100001] = {}, v_odd[100001] = {};
    for (int i = 0; i < n; ++i) {
        if (i % 2) ++v_odd[v[i]];
        else ++v_even[v[i]];
    }
    int maxfreq_o = 0, maxfreq_e = 0;
    for (int i = 1; i <= 100000; ++i) {
        if (v_odd[i] > v_odd[maxfreq_o]) maxfreq_o = i;
        if (v_even[i] > v_even[maxfreq_e]) maxfreq_e = i;
    }

    sort(v_odd, v_odd + 100001, greater<int>());
    sort(v_even, v_even + 100001, greater<int>());

    if (maxfreq_e != maxfreq_o) cout << n - v_odd[0] - v_even[0] << endl;
    else cout << min(n - v_odd[0] - v_even[1], n - v_odd[1] - v_even[0]);
    
    return 0;
}

Measured memory_bytes: 1408
N, X = gets.chomp.split(' ').map(&:to_i)
L = gets.chomp.split(' ').map(&:to_i)
dist = N.times.reduce(0) do |dist, i|
  new_dist = dist + L[i]
  if new_dist > X
    puts i.succ
    exit
  end
  dist + L[i]
end
puts N.succ

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int a[maxn],n,k;
int dp[maxn];		//dp[i]´ú±í´Ó0µ½iËùÐèµÄ²½Êý

int main() {
	cin>>n;
	for(int i =0 ;i< n;i++) cin>>a[i];
	dp[0] = 0;
	dp[1] = abs(a[0] - a[1]);
	for(int i = 2;i < n;i++) {
		dp[i] = min(dp[i-1]+abs(a[i-1]-a[i]),
					dp[i-2]+abs(a[i-2]-a[i]));
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
#define rep(i,n) for (ll i=0;i<n;i++)
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = max({a*c,b*d,a*d,b*c});
    cout << ans;


    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,T;cin>>N>>T;
  int c[N],t[N];
  for(int i=0;i<N;i++) cin>>c[i]>>t[i];
  int m=1001;
  for(int i=0;i<N;i++){
    if(t[i]<=T){
      m=min(m,c[i]);
    }
  }
  if(m==1001) cout<<"TLE"<<endl;
  else cout<<m<<endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (
                Scanner in = new Scanner(System.in);
                PrintWriter out = new PrintWriter(System.out))
        {
            String text = in.next();

            if (text.length() == 2) {
                out.println(text);
            } else if (text.length() == 3) {
                out.println(new StringBuilder(text).reverse());
            }
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10);
	#ifdef PIYUSH_AASHIRWAAD
		I_O;
	#else
	#define print(...) 0
	#endif
	int a, b;
	cin >> a >> b;
	int n = b - a - 1;
	n = (n*(n+1))/2;
	cout<<(n-a);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int maxn=1e5+1;

int k,t;
int a[101];
int main() {
	scanf("%d%d",&k,&t);

	int mx=0,id=0,sum=0;
	for (int i=1;i<=t;i++) {
		scanf("%d",&a[i]);
		sum+=a[i];
		if (mx<a[i]) {
			mx=a[i];
			id=i;
		}
	}

	sum-=mx;
	printf("%d\n",max(0,mx-(sum+1)));
	return 0;
}



Measured memory_bytes: 256
//
//  main.cpp
//  ATcode131
//
//  Created by didi on 2020/1/16.
//  Copyright © 2020年 didi. All rights reserved.
//

#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cassert>
#include <queue>
#include <list>
using namespace std;

#define ll long long

int main(int argc, const char * argv[]) {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N+1);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
    }
    int S, T;
    cin >> S >> T;
    queue<int> qu;
    vector<vector<int>> vis(N+1, vector<int>(4));
    int ans = -1;
    qu.push(S);
    vis[S][0] = 1;
    int depth = 0;
    while (!qu.empty()) {
        int len = qu.size();
        while (len--) {
            int val = qu.front();
            qu.pop();
            if (val == T) {
                ans = depth;
                break;
            }
            for (auto n1: G[val]) {
                if (vis[n1][1]) continue;
                vis[n1][1] = 1;
                for (auto n2: G[n1]) {
                    if (vis[n2][2]) continue;
                    vis[n2][2] = 1;
                    for (auto n3: G[n2]) {
                        if (vis[n3][3]) continue;
                        vis[n3][3] = 1;
                        qu.push(n3);
                    }
                }
            }
        }
        depth++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 11768
while True:
  try:
    data = list(map(float,input().split(",")))
  except EOFError:
    break
  vec1 = [data[2]-data[0],data[3]-data[1]]
  vec2 = [data[4]-data[0],data[5]-data[1]]
  vec3 = [data[6]-data[0],data[7]-data[1]]
  a = (vec2[0]*vec3[1] - vec2[1]*vec3[0]) / (vec1[0]*vec3[1] - vec1[1]*vec3[0])
  b = (vec2[0]*vec1[1] - vec2[1]*vec1[0]) / (vec1[1]*vec3[0] - vec1[0]*vec3[1])
  if (a < 0 or b < 0) or a+b < 1.0:
    print("NO")
  else:
    print("YES")


Measured memory_bytes: 5580
#include <iostream>
#include <string>
using namespace std;
int main(){
	int n;	cin>>n;
	string s;	cin>>s;
	int a,b;//0:羊	1:狼
	string dat="SW";
	string ans;
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			ans="";	ans+=dat[i];	ans+=dat[j];
			a=i;	b=j;
			for(int k=1;k<=n;k++){
				int tmp=b;
				if(s[k%n]=='o'){
					if(b)	b=1-a;
					else 	b=a;
				}
				else if(s[k%n]=='x'){
					if(b)	b=a;
					else 	b=1-a;
				}
				ans+=dat[b];
				a=tmp;
			}
			if(a==i&&b==j){
				cout<<ans.substr(0,n)<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const long inf=1e9;
int main(){
	int N;cin>>N;
	string s;cin>>s;
	rep(i,0,s.size()){
		s[i]=(char)(((int)s[i]-65+N)%26+65);
	}cout<<s<<endl;
}

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

using namespace std;

#define MAX 50001
#define INF 1e9

class YAML{
public:
  string s;
  int state;
  vector<string> next;
};

vector<int> space;
YAML yaml[MAX];

int getState(string &str,int d,vector<string> &v){
  string now = str.substr(d);
  string s,t;
  int x = -1;
  for(int i = 0 ; i < (int)now.size() ; i++){
    if(now[i] == ':'){ x = d+i+2; break; }
    s += now[i];
  }
  v.push_back(s);
  if(x < (int)str.size()){
    t = str.substr(x);
    v.push_back(t);
    return 1;
  }
  return 0;
}

vector<string> make_graph(int cur,int sp){
  int len = space.size();
  vector<string> res;
  if(cur == len || yaml[cur].state == 1){ return res; }
  int now = cur;
  while(true){
    if(now == len || sp > space[now]){ break; }
    if(space[now] == INF){ now++; continue; }
    if(sp == space[now]){
      res.push_back(yaml[now].s);
      cur = now;
    }else if(sp < space[now]){
      if(yaml[cur].next.size() == 0){
        yaml[cur].next = make_graph(now,space[now]);
      }
    }
    now++;
  }
  return res;
}

int main(){
  int idx = 1;
  string order,in;
  map<string,int> mp;
  space.push_back(-1);
  yaml[0].s = "->";
  cin >> order; cin.ignore();
  while(getline(cin,in)){
    int cnt = 0;
    for(int i = 0 ; i < (int)in.size() ; i++){
      if(in[i] == ' '){
        cnt++;
      }else{ break; }
    }
    space.push_back(cnt);
    vector<string> v;
    yaml[idx].state = getState(in,cnt,v);
    yaml[idx].s = v[0];
    mp[yaml[idx].s] = idx;
    if(yaml[idx].state == 1){
      yaml[idx].state = 0;
      yaml[idx].next.push_back(v[1]);
      idx++;
      yaml[idx].s = v[1];
      yaml[idx].state = 1;
      mp[yaml[idx].s] = idx;
      space.push_back(INF);
    }
    idx++;
  }
  yaml[0].next = make_graph(1,space[1]);
  string t;
  vector<string> strs;
  for(int i = 0 ; i < (int)order.size() ; i++){
    if(order[i] == '.'){
      if(!t.empty()){ strs.push_back(t); }
      t.clear();
    }else{
      t += order[i];
    }
  }
  strs.push_back(t);
  int now = 0,len = strs.size();
  bool found = true;
  for(int i = 0 ; i < len ; i++){
    vector<string> vec = yaml[now].next;
    bool ok = false;
    for(int j = 0 ; j < (int)vec.size() ; j++){
      if(vec[j] == strs[i]){
        ok = true;
        break;
      }
    }
    now = mp[strs[i]];
    if(!ok){
      found = false;
      break;
    }
  }
  int size = yaml[now].next.size();
  if(!found || size == 0){
    cout << "no such property" << endl;
  }else{
    if(size != 1){
      cout << "object" << endl;
    }else{
      string ans = yaml[now].next[0];
      if(yaml[mp[ans]].state == 1){
        cout << "string \"" << ans << "\"" << endl;
      }else{
        cout << "object" << endl;
      }
    }
  }
  return 0;
}

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

using namespace std;

int main() {
  int D, N;
  int ans = 1;
  
  cin >> D >> N;
  
  for (int i = 0; i < D; i++) {
  	ans *= 100;
  }
  
  ans = N == 100 ? ans * (N + 1) : ans * N;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	char a[20000];
	scanf("%s",a);
	int len=strlen(a);
	for(int i=len-1 ; i>=0 ; i--)
	printf("%c",a[i]);
	newline;
	return 0;
}

Measured memory_bytes: 3068
#include<stdio.h>
#include<math.h>
int main()
{
  char t[400000],s[400000];
 scanf("%s",&t);
 scanf("%s",&s);
 int i,j,count=0;
 for(i=0,j=0;i<strlen(s);i++,j++){
                     if(s[i]!=t[j]) count++;

                     }
 printf("%d",count);

    return 0;

}



Measured memory_bytes: 2124
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

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

int table[10];

int main() {
  rep(i, 10) cin >> table[i];
  sort(table, table+10);
  rep(i, 3) cout << table[9-i] << "\n";
  return 0;
}

Measured memory_bytes: 1168