akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
const int mod = 1e9 + 7 ;
void solve(){
	int n , m;
	cin >> n >> m ;
	map < int , int > mp ;
	for( int i = 0 ; i < m ; i++){
		int a ; 
		cin >> a; 
		mp[a]++;
	}
	vector < ll > dp(n+1,0);
	dp[0] = 1 ;
	if(mp.find(1)==mp.end())
		dp[1] = 1 ;
	for( int i = 2 ; i <= n ; i++){
		if(mp.find(i)==mp.end()){
			dp[i] += dp[i-1];
			if(dp[i]>=mod)
				dp[i]-=mod;
			dp[i] += dp[i-2];
			if(dp[i]>=mod)
				dp[i]-=mod;
		}
	}
	//for( int i = 0 ; i <=n;  i++) cout <<dp[i] << " " ;
	cout << dp[n] << " " ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}


Measured memory_bytes: 5760
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def modinv2(x,r):
  return pow(x,r-2,r)

def comb(n,a):
    dend = n
    for i in range(1,a):
        dend = (dend*(n-i))%R
    sor = 1
    for i in range(2,a+1):
        sor = (sor*i)%R
    return (dend*modinv2(sor,R))%R

n,k = inm()
if n-1<=k:
    print(comb(2*n-1,n-1))
    exit()
c = [1]*(k+1)
d = [1]*(k+1)
for i in range(1,k+1):
    m = modinv2(i,R)
    c[i] = (c[i-1]*(n-i+1)*m)%R
    d[i] = (d[i-1]*(n-i)*m)%R
ddprint("c,d")
ddprint(c)
ddprint(d)
sm = 0
#for j in range(n-k,n+1):
#    sm = (sm+comb(n,j)*comb(n-1,j-1))%R
for j in range(k+1):
    sm = (sm+c[j]*d[j])%R
#if k==1:
#    sm = (sm-1)%R
print(sm)


Measured memory_bytes: 78260
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  int n, x;
  cin >> n >> x;
  vector<ll> a(n);
  ll o = 0;

  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  for(int i = 0; i < n - 1; i++) {
    if(a.at(i) + a.at(i + 1) > x) {
      o += a.at(i) + a.at(i + 1) - x;
      a.at(i + 1) -= a.at(i) + a.at(i + 1) - x;
      if(a.at(i + 1) < 0)
        a.at(i + 1) = 0;
    }
  }
  cout << o << endl;
}

Measured memory_bytes: 1024
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	set<int> x;
	x.insert(a);
	x.insert(b);
	x.insert(c);
	cout << x.size() << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXT = (1 << 20) + 1;
int bit[MAXT];

int read(int idx) {
    int sum = 0;

    while (idx > 0) {
        sum += bit[idx];
        idx -= (idx & -idx);
    }

    return sum;
}

void update(int idx, int val) {
    while (idx < MAXT) {
        bit[idx] += val;
        idx += (idx & -idx);
    }
}

const int MAXN = 200005;
LL a[MAXN];

int n; LL k;

set<LL> prefixes;
map<LL, int> compress;

int main() {
    GI(n);
    GLL(k);

    LL prefix = 0;
    prefixes.insert(prefix);

    FOR1(i, n) {
        GLL(a[i]);
        a[i] -= k;

        prefix += a[i];
        prefixes.insert(prefix);
    }

    int next = 1;

    for (auto& p : prefixes) {
        compress[p] = next++;
    }

    update(compress[0], 1);

    prefix = 0;
    LL res = 0;

    FOR1(i, n) {
        prefix += a[i];
        int c = compress[prefix];
        res += read(c);
        update(c, 1);
    }

    printf("%lld\n", res);
    return 0;
}


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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, A;
    cin >> H >> A;
    cout << (H + A - 1) / A << endl;
}


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

int main()
{
   ios_base::sync_with_stdio(false) ;
   cin.tie(NULL) ;
   long long int k ;
   cin>>k ;
   long long int cur=0;
   for(long long  i=1 ;i<=10000000 ;i++)
   {
       cur=cur*10 + 7 ;
       cur=cur%k ;
       if(cur ==0)
       {
           cout<<i<<endl;
           return 0;
       }
   }
   cout<<-1<<endl ;
   return 0 ;
  
}


Measured memory_bytes: 3616
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

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

	final long MODULO = 1000003;

	void run() {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long S = A + B + C;
		int cnt = 0;
		while (true) {
			if (A % 2 != 0 || B % 2 != 0 || C % 2 != 0) {
				break;
			} else {
				A = (S - A) / 2;
				B = (S - B) / 2;
				C = (S - C) / 2;
				++cnt;
			}
			if (cnt == 1_000_000) {
				break;
			}
		}
		if (cnt == 1_000_000) {
			System.out.println(-1);
		} else {
			System.out.println(cnt);
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}


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

int main(void)
{
	int A,K,B;
	bool isFound=false;
	cin>>K>>A>>B;
	for(int i=A;i<=B&&(!isFound);++i)
		if(i%K==0)
			isFound=true;
	if(isFound)
		cout<<"OK";
	else
		cout<<"NG";
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

using ll = long long;
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define tc() int t; cin>>t; while(t--)
#define print(n) cout<<n<<"\n"
#define inp(n) int n; cin>>n
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define maxn 1000010
#define mod 1e9+7
#define ff  first
#define ss  second
#define fora(var, start, end) for(int var = start; var < end; var++)
int main()
{
    fast();
    ll h;
    cin>>h;
    ll k=1;
    ll ans=1;
    while(k<h)
    {
       
        k*=2;
       if(k<=h) ans+=k;
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

int main() {
  int n;
  cin >> n;
  int ra = 1000, rb = -1;
  rep (i, n) {
    int a, b;
    cin >> a >> b;
    if (rb < b || (rb == b && ra > a)) {
      ra = a;
      rb = b;
    }
  }
  cout << ra << " " << rb << endl;
  return 0;
}

Measured memory_bytes: 1168
import Control.Applicative

check :: Bool -> Bool -> (Integer -> Integer -> Integer -> Integer -> Integer)
check True True = \a b c d -> d - a
check True False = \a b c d -> d - c
check False True = \a b c d -> b - a
check False False = \a b c d -> b - c

main = do
  [a,b,c,d] <- map read . words <$> getLine
  let flag1 = b > d
  let flag2 = a > c
  let f = check flag1 flag2
  print $ max 0 $ f a b c d


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

using namespace std;

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

const int INF10=1e10+1,ID_MAX=20;
const long mod=1e9+7;
const long long INF18=1e18+1;

struct edge{
    int to;
    long cost;
};

void sort2array(double *a,long *b,long n){
    for(int i=0;i<n;i++){
        b[i]=i;
    }
    sort(b,b+n,[a](long i,long j)->bool {return a[i]<a[j];} );
}
//bを何回足せばaを超えるか(O(a/b))
int wtover(int a,int b){
    if(a%b>0)return (a/b)+1;
    else return a/b;
}
int bi_e[ID_MAX]={0};
//2進数表示したときの最高桁(O(log n))
int bi_max(long n){
    int m=0;
    for(m;(1<<m)<=n;m++);m=m-1;
    return m;
}
//bi_eに二進数表示したやつを代入(O(log^2 n))
void bi_exs(long n){
    memset(bi_e,0,sizeof(bi_e));
    if(n<(1<<ID_MAX)){
        for(int i=0;n>0;n=(n>>1),i++)bi_e[i]=n&1;
    }
}
//x^n mod m (nが負の時は０)(O(log n))
long myPow(long x, long n, long m){
  if(n<0)return 0;
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
//mのn分割数(O(nm))のmod
int divNum(int n,int m){
    long long d[n+1][m+1];
    rep(j,n+1){
        d[j][0]=1;
    }
    rep(j,m){
        d[0][j+1]=0;
    }
    for(int j=1;j<=n;j++){
        for(int k=1;k<=m;k++){
            if(j>k)d[j][k]=d[j-1][k];
            else d[j][k]=(d[j-1][k]+d[j][k-j])%mod;
        }
    }
    return d[n][m];
}

int main(){
    int i;
    //入力
    long a,b,c,k;
    cin>>a>>b>>c>>k;
    //処理
    long res;
    if(k<=a){
        res=k;
    }else if(a+b>=k){
        res=a;
    }else{
        res=a-(k-(a+b));
    }
    //出力
    cout<<res<<endl;
}

Measured memory_bytes: 3640
N, K = map(int, input().split())
def count(x, y):
    cnt = 0
    while x < y:
        x = x * 2
        cnt += 1
    return(cnt)

p = [0 for _ in range(N)]
for i in range(1, N + 1):
    p[i - 1] = 0.5 ** count(i, K)
print(sum(p) / N)


Measured memory_bytes: 6296
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){

    int h,w;
    cin >> h >> w;
    char c[51][51];
    REP(i,51){
        REP(j,51){
            c[i][j] = 'a';
        }
    }

    for(int i = 1;i <= h;i++){
        for(int j = 1;j <= w;j++){
            cin >> c[i][j];
        }
    }

    bool ans = true;
    for(int i = 1;i <= h;i++){
        for(int j = 1;j <= w;j++){
            int count = 0;
            if(c[i][j] == '.'){
                continue;
            }
            if(c[i+1][j] == '#'){
                count++;
            }
            if(c[i-1][j] == '#'){
                count++;
            }
            if(c[i][j+1] == '#'){
                count++;
            }
            if(c[i][j-1] == '#'){
                count++;
            }
            if(count == 0){
                ans = false;
                break;
            }
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl; 
    }


    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	while (true) {
		int x, y; cin >> x >> y;
		if (x == 0 && y == 0)break;

		VI s(5); s[0] = x + y;
		FOR(i, 1, 5) {
			int a, b; cin >> a >> b;
			s[i] = a + b;
		}

		auto ans = max_element(all(s));
		Cout2((char)('A' + (ans - s.begin())), *ans);
	}
}


Measured memory_bytes: 3028
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  vector<ll> a(n); cin >> a;
  map<ll, ll> m;
  rep(i, n) {
    m[a[i]]++;
  }
  ll ans = 0;
  for (auto it = m.rbegin(); it != m.rend(); ++it) {
    if (it->second == 0) continue;
    ll x = it->first;
    ll nxt = 1;
    while (nxt <= x) nxt <<= 1;
    ll y = nxt - x;
    if (y > x) continue;
    if (m.count(y) > 0) {
      if (x == y) {
        ans += it->second / 2;
        it->second %= 2;
      }
      else {
        ll use = min(it->second, m[y]);
        it->second -= use;
        m[y] -= use;
        ans += use;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 14336
import sys
import math
sys.setrecursionlimit(10**9)

def main():
    N = int(input())
    A = list(map(int,input().split()))

    dic = [{},{}]
    counted = [set(),set()]

    def count(x,type):
        type = type - 1
        if x <= 0:
            return

        if not x in counted[type]:
            dic[type][x] = 1
            counted[type].add(x)
        else:
            dic[type][x] += 1


    for i in range(N):
        type1 = (i+1)-A[i]
        type2 = (i+1)+A[i]

        count(type1,1)
        count(type2,2)

    ans = 0
    # print(dic,counted)
    for index,cnt in dic[0].items():
        if index in counted[1]:
            ans += cnt * dic[1][index]


    print(ans)



if __name__ == "__main__":
  main()

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

int main() {
	vector<int> cnt(32);
	int n;
	cin >> n;
	vector<vector<int>> memo(n, vector<int>(32));
	FOR(i, 0, n-1) {
		int a;
		cin >> a;
		FOR(j, 0, 31) {
			if (a&(1 << j)) {
				cnt[j]++;
				memo[i][j] = 1;
			}
		}
	}
	FOR(j, 0, 31) {
		if (cnt[j] % 2) {
			FOR(i, 0, n - 1) {
				if (memo[i][j] == 1) {
					memo[i][j] = 0;
				}
				else {
					memo[i][j] = 1;
				}
			}
		}
	}
	FOR(i, 0, n - 1) {
		int tmp = 0;
		FOR(j, 0, 31) {
			if (memo[i][j]) {
				tmp += (1 << j);
			}
		}
		cout<<tmp;
		if (i == n - 1) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 35856
#include <cstdio>
#include <algorithm>
using namespace std;

int a[(int)1e5 + 10];

int main() {
    int n;
    while(~scanf("%d", &n)) 
    {
	
		for (int i = 0; i < n; i++) {
	        scanf("%d", &a[i]);
	    }
	    int begin = 0;
	    int ans;
	    int flag = 0;
	    while (true) {
	        sort(a + begin, a + n);
	        while (a[begin] == 0) begin++;
	        if (begin == n - 1) break;
	        for (int i = begin + 1; i < n; i++) {
	            a[i] %= a[begin];
	            if (a[i] == 1) {
	                ans = 1;
	                flag = 1;
	                break;
	            }
	        }
	        if(flag)
	        	break;
	    }
	    if(!flag)
	    	ans = a[n-1];
	    printf("%d\n", ans);
	}
    return 0;
}

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

int main()
{
	string s,t;
    cin>>s;
    cin>>t;
   long long  int count=0,i,n;
    n=s.length();
     
    for(i=0;i<n;i++)
    {
     if(s[i]!=t[i])
     {count++;}
    }
    cout<<count;
	return 0;
}

Measured memory_bytes: 3844
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int N, K;
	cin >> N >> K;
	while(K--){
		int a, b;
		cin >> a >> b;
		--a; --b;
		if(a > (N / 2)){ a = N - a - 1; }
		if(b > (N / 2)){ b = N - b - 1; }
		cout << (min(a, b) % 3 + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>

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

int main() {
	char w[101]; cin >> w;

	int c[26];
	rep(i, 0, 26)c[i] = 0;

	rep(i, 0, 101) {
		if (w[i] == '\0')break;
		c[w[i] - 'a']++;
	}
	rep(i, 0, 26) {
		if (c[i] % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
X = int(input())
if X<600:
    print(8)
elif X<800:
    print(7)
elif X<1000:
    print(6)
elif X<1200:
    print(5)
elif X<1400:
    print(4)
elif X<1600:
    print(3)
elif X<1800:
    print(2)
elif X<2000:
    print(1)

Measured memory_bytes: 61676
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define IOS ios::sync_with_stdio(false),cin.tie(0)
using namespace std;
typedef long long ll;


int main() {
	IOS;
	ll a, b, c;
	cin >> a >> b >> c;	
	ll cnt = 0;
	if (a == b && b == c && a % 2 == 0) {
		cout << -1 << endl;
		return 0;
	}
	while (1) {
		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)break;
		ll x = (a + b) / 2, y = (b + c) / 2, z = (c + a) / 2;
		cnt++;
		a = y, b = z, c = x;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
use std::io;
use std::collections::VecDeque;

fn main() {

	const INFINITY : i64 = 1e9 as i64;

	let mut line = String::new();

	io::stdin().read_line(&mut line).expect("Failed to read line.");
	let mut tmp : Vec<i64> = line.trim().split(" ").map(|val| val.parse().unwrap()).collect();
	let (h_board, w_board) = (tmp[0],tmp[1]);

	line = "".to_string();
	io::stdin().read_line(&mut line).expect("Failed to read line.");
	tmp = line.trim().split(" ").map(|val| val.parse().unwrap()).collect();
	let (ch,cw) = (tmp[0]-1,tmp[1]-1);

	line = "".to_string();
	io::stdin().read_line(&mut line).expect("Failed to read line.");
	tmp = line.trim().split(" ").map(|val| val.parse().unwrap()).collect();
	let (dh,dw) = (tmp[0]-1,tmp[1]-1);

	let mut s : Vec<Vec<char>> = Vec::new();
	let mut v_cost : Vec<Vec<i64>> = Vec::new();
	// let mut s : Vec<String> = Vec::new();
	for _ in 0..h_board {
		line = "".to_string();
		io::stdin().read_line(&mut line).expect("Failed to read line.");
		s.push(line.trim().chars().collect());

		let mut cost_w : Vec<i64> = Vec::new();
		for _ in 0..w_board {
			cost_w.push(INFINITY);
		}
		v_cost.push(cost_w);
	}

	// let mut ans = -1;

	let mut cost0 = VecDeque::new();

	cost0.push_back((ch,cw,0));
	// let ch_u : usize = ch as usize;
	// let cw_w : usize = cw as usize;
	v_cost[ch as usize][cw as usize] = 0;

	let walk=[(1,0),(0,1),(-1,0),(0,-1)];
	let mut warp = Vec::<(i64,i64)>::new();
	for i in -2..3 {
		for j in -2..3 {
			warp.push((i,j));
		}
	}
	// let warp = [ (i,j) for i in range(-2,3,1) for j in range(-2,3,1) ];

	let mut cost1 = VecDeque::new();

	while 0 < cost0.len() {
		if let Some(tmp)=cost0.pop_front() {
			let (h,w,c)=(tmp.0,tmp.1,tmp.2);
			cost1.push_back((h,w,c));

			for (i,j) in walk.iter() {
				let nh : i64 = (h + i) as i64;
				let nw : i64 = (w + j) as i64;
				if 0 <= nh && nh < h_board && 0 <= nw && nw < w_board {
					if s[nh as usize][nw as usize] == '.' && c < v_cost[nh as usize][nw as usize] {
						v_cost[nh as usize][nw as usize] = c;
						cost0.push_front((nh,nw,v_cost[nh as usize][nw as usize]));
					}
				}
			}
		}

		if cost0.len() == 0 {
			while 0 < cost1.len() {
				// if let Some(tmp)=cost1.pop_front();
				let (h,w,c)=cost1.pop_front().unwrap();
				// if let Some(tmp)=cost1.pop_front() {
					// let (h,w,c)=(tmp.0,tmp.1,tmp.2);
				for (i,j) in warp.iter() {
				// for i in -2..3 {
				// 	for j in -2..3 {
						
					let nh : i64 = (h + i) as i64;
					let nw : i64 = (w + j) as i64;
					if 0 <= nh && nh < h_board && 0 <= nw && nw < w_board {
						if s[nh as usize][nw as usize] == '.' {
							if c + 1 < v_cost[nh as usize][nw as usize] {
								v_cost[nh as usize][nw as usize] = c + 1;
								cost0.push_back((nh,nw,v_cost[nh as usize][nw as usize]));
							}
						}
					}
				}
				// }
			}
		}
	}

	if v_cost[dh as usize][dw as usize] == INFINITY {
		println!("{}", -1);
	} else {
		println!("{}", v_cost[dh as usize][dw as usize]);
	}
}

Measured memory_bytes: 14488
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    ll ans=0, ss=0, xs=0;
    int r=0;
    rep(l,n){
        while(r<n && (ss+p[r])==(xs^p[r])){
            ss+=p[r]; xs^=p[r];
            r++;
        }
        ans+=(r-l);
        if(r==l) r++;
        else{
            ss-=p[l]; xs^=p[l];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4044
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A1 = sc.nextInt();
		int A2 = sc.nextInt();
		int A3 = sc.nextInt();
		sc.close();

		System.out.println(A1+A2+A3 <= 21 ? "win" : "bust");

	}

}

Measured memory_bytes: 21972
#B問題
N = int(input())
P = []
for i in range(N):
    P.append(int(input()))

count = [0 for i in range(N)]
now = [-1 for i in range(N+1)]
for i in range(N):
    if P[i] == 1:
        now[P[i]-1] = P[i]
        count[P[i]-1]+=1
    elif now[P[i]-2] == -1:
        now[P[i]-1] = P[i]
        count[P[i]-1]+=1
    else:
        now[P[i]-1] = P[i]
        count[P[i]-1] = count[P[i]-2]+1
        
#print(count,now)
MAX = max(count)
ans = N-MAX
print(ans)

Measured memory_bytes: 20424
#include <string>
#include <sstream>
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <queue>

using namespace std;

#define ll long long


class Main {
public:
	ll getOptimal(vector<int> candies, int upBound) {
		ll count = 0;
		vector<int> temp = candies;
		if (upBound < temp[0]) {
			count += temp[1];
			temp[1] -= temp[1];
			count += (temp[0] - upBound);
			temp[0] -= (temp[0] - upBound);
		}else if(upBound < temp[0] + temp[1]){
			count += (temp[0] + temp[1] - upBound);
			temp[1] -= (temp[0] + temp[1] - upBound);
		}

		for (int i = 1;i <= candies.size() - 2;i++) {
			if (upBound < temp[i] + temp[i + 1]) {
				count += (temp[i] + temp[i + 1] - upBound);
				temp[i + 1] -= (temp[i] + temp[i + 1] - upBound);
			}
		}

		return count;
	}
};


int main()
{
	Main m;
	int n;
	vector<int> as;
	int ub;

	cin >> n >> ub;
	for (int i = 0;i < n;i++) {
		int inp;
		cin >> inp;
		as.push_back(inp);
	}

	cout << m.getOptimal(as, ub) << endl;

    return 0;
}



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

using namespace std;

int r, d, x;
int dp[11];

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

    cin >> r >> d >> x;

    dp[1] = r * x - d;
    cout << dp[1] << "\n";
    for(int i = 2; i <= 10; i++)
    {
        dp[i] = r * dp[i - 1] - d;
        cout << dp[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int N = 505;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

template <typename T> inline void cmin(T &x, T y) {
	if (x > y) x = y;
}

const int nx[4] = {0, 1, 0, -1};
const int ny[4] = {1, 0, -1, 0};

int n, nn, leave[N * N], dis[N][N], has[N][N], ans;
deque<int> qx, qy;

void init() {
	read(n); nn = n * n;
	for (int i = 1; i <= nn; ++i) {
		read(leave[i]);
	}
}

void solve() {
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			has[i][j] = 1;
			dis[i][j] = min(i, j);
			cmin(dis[i][j], n - i + 1);
			cmin(dis[i][j], n - j + 1);
		}
	}
	for (int i = 1; i <= nn; ++i) {
		int x = (leave[i] - 1) / n + 1;
		int y = (leave[i] - 1) % n + 1;
		ans += (--dis[x][y]);
		has[x][y] = 0;
		qx.push_back(x);
		qy.push_back(y);
		while (!qx.empty()) {
			int ux = qx.front(); qx.pop_front();
			int uy = qy.front(); qy.pop_front();
			for (int k = 0; k < 4; ++k) {
				int vx = ux + nx[k], vy = uy + ny[k];
				if (vx < 1 || vx > n || vy < 1 || vy > n) continue;
				if (dis[vx][vy] > dis[ux][uy] + has[vx][vy]) {
					dis[vx][vy] = dis[ux][uy] + has[vx][vy];
					if (has[vx][vy]) {
						qx.push_back(vx);
						qy.push_back(vy);
					} else {
						qx.push_front(vx);
						qy.push_front(vy);
					}
				}
			}
		}
	}
	printf("%d\n", ans);
}

int main() {
	init();
	solve();
	return 0;
}


Measured memory_bytes: 7132
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int money = scan.nextInt();
		
		System.out.println(((int)(money / 500) * 1000) + ((int)money % 500 / 5) * 5);
		
		
		
	}
	
}

Measured memory_bytes: 21972
N, K, C = map(int, input().split())
S = input()
L = [-1] * K
R = [-1] * K
L_index = 0
L_count = 0
R_index = N - 1
R_count = K - 1

while L_index < N and L_count < K:
    if S[L_index] == "o":
        L[L_count] = L_index
        L_index += (C + 1)
        L_count += 1
    else:
        L_index += 1
while R_index >= 0 and R_count >= 0:
    if S[R_index] == "o":
        R[R_count] = R_index
        R_index -= (C + 1)
        R_count -= 1
    else:
        R_index -= 1

for i in range(K):
    if L[i] == R[i]:
        print(L[i] + 1)

Measured memory_bytes: 20616
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).ok();
    let input:usize = input.trim().parse().unwrap();

    let mut ans;
    if input < 1200 {
        ans = "ABC";
    } else if input < 2800 {
        ans = "ARC";
    } else {
        ans = "AGC";
    }

    println!("{}", ans);
}

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

using namespace std;
const int MAXN = 112345;

vector < int > g[MAXN];
int vis[MAXN], dp[MAXN], in_degree[MAXN];

void dfs (int u) {
    vis[u] = 1;
    for (int v : g[u]) {
        if (!vis[v]) {
            dp[v] = max (dp[v], 1 + dp[u]);
            --in_degree[v];
            if (in_degree[v] == 0) dfs (v);
        }
    }
}


int main () {

    int n, m;
    scanf("%d %d", &n, &m);

    while (m--) {
        int x, y;
        scanf("%d %d", &x, &y);
        g[x].push_back(y);
        ++in_degree[y];
    }

    for (int i = 1; i <= n; ++i) {
        if (!vis[i] && in_degree[i] == 0) dfs (i);
    }

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

    printf("%d\n", ans);





    return 0;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  long long N;
  cin >>N;
  long long sum=0;
  sum=N*(N-1)/2;
  cout <<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef pair<ll,P> PP2;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define MAX_N 100010
struct UF {
	int par[MAX_N],rank[MAX_N];
	
	void init(int n){
		for(int i = 0; i < n; i++){
			par[i] = i;
			rank[i] = 0;
		}
	}
	
	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}
	
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		
		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = par[x];
			if(rank[x] == rank[y]) rank[y]++;
		}
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(){
	int n; cin>>n;
	vector<PP> v(n);
	rep(i, n){
		cin>>v[i].fst.fst>>v[i].fst.snd;
		v[i].snd = i;
	}
	UF uf;
	uf.init(n);
	sort(all(v));
	vector<PP2> d(2*n-2);
	rep(i, n-1) d[i] = PP2(v[i+1].fst.fst-v[i].fst.fst, P(v[i+1].snd, v[i].snd));
	rep(i, n) swap(v[i].fst.fst, v[i].fst.snd);
	sort(all(v));
	rep(i, n-1) d[i+n-1] = PP2(v[i+1].fst.fst-v[i].fst.fst, P(v[i+1].snd, v[i].snd));
	sort(all(d));
	ll res = 0;
	rep(i, 2*n-2){
		int u = d[i].snd.fst, v = d[i].snd.snd;
		if(!uf.same(u, v)){
			uf.unite(u, v);
			res += d[i].fst;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <queue>

using namespace std;

int n, m;

struct pos
{
	int val, dis;
	inline bool operator<(const pos &other) const
	{
		int x = 1.0 * this->val / (1 << this->dis);
		int y = 1.0 * other.val / (1 << other.dis);
		return x < y;
	}
};

priority_queue <pos> pq;

int main()
{
	cin >> n >> m;
	for (int i = 1;i <= n;++i)
	{
		int x;
		pos aux;
		cin >> x;
		aux.val = x;
		aux.dis = 0;
		pq.push(aux);
	}
	for (int i = 1;i <= m;++i)
	{
		pos aux = pq.top();
		if ((int)(1.0 * aux.val / (1 << aux.dis)) == 0)
			break;
		pq.pop();
		aux.dis++;
		pq.push(aux);
	}
	long long ans = 0;
	while (!pq.empty())
	{
		pos aux = pq.top();
		pq.pop();
		ans += (int)(1.0 * aux.val / (1 << aux.dis));
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>

int main(void)
{
	int N,day,total=0,i,a;
	scanf("%d",&day);
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&a);
		total+=a;
	}
	if(day-total>=0){
		printf("%d",day-total);
	}else printf("-1");
	return 0;
}

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

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	
	int cnt[31] = {0};
	for (int i = 0; i < n; i++) {
		int k;
		scanf("%d", &k);
		
		while (k--) {
			int x;
			scanf("%d", &x);
			cnt[x]++;
		}
	}
	
	int ans = 0;
	for (int i = 1; i <= m; i++)
		ans += cnt[i] == n;
	printf("%d\n", ans);
	
	return 0;
}

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

using namespace std;

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

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

#endif

void Main() {
    ll x, y;
    cin >> x >> y;
    cout << __gcd(x, y) << '\n';

}

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



Measured memory_bytes: 3184
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T, class U> inline void chmax(T &a, const U &b) { if ((a) < (b)) (a) = (b); }
template <class T, class U> inline void chmin(T &a, const U &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    int x;
    cin>>x;

    if (x == 1) {
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }
    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3564
#include <stdio.h>
int main(void)
{
	int a,b;
	int aa,bb;
	
	scanf("%d %d",&a,&b);
	
	aa=a*b;
	bb=a+a+b+b;
	
	printf("%d %d\n",aa,bb);
	
	return 0;
}

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

const int maxn = 1e3+10, maxm = 2e5+10;

int n, m;
vector<int> g[maxn];
int a[maxm], b[maxm];
int v[maxn][maxn], w[maxn][maxn], vis2[maxn];
int rt;

void add(int a,int b){g[a].push_back(b);}

void dfs2(int u) {
	v[rt][u] = vis2[u] = 1;
	for (auto y: g[u]) {
		if (!vis2[y]) dfs2(y);
	}
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		scanf("%d%d", a+i, b+i);
		add(a[i], b[i]);
	}
	for (rt = 1; rt <= n; ++rt) {
		memset(vis2, 0, sizeof(vis2));
		vis2[rt] = 1;
		for (auto x: g[rt]) {
			if (!vis2[x]) dfs2(x);
			else w[rt][x] = 1;
		}
		memset(vis2, 0, sizeof(vis2));
		vis2[rt] = 1;
		reverse(g[rt].begin(), g[rt].end());
		for (auto x: g[rt]) {
			if (!vis2[x]) dfs2(x);
			else w[rt][x] = 1;
		}
	}
	for (int i = 1; i <= m; ++i) {
		puts(v[b[i]][a[i]]^w[a[i]][b[i]]?"diff":"same");
	}
}


Measured memory_bytes: 12288
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int a[110000];

int main()
{
  int i,j,n,ans;
  scanf("%d",&n);
  for (i=0;i<n;i++)
    scanf("%d",&a[i]);
  sort(a,a+n);
  j=0;
  ans=0;
  for (i=0;i<n;i++)
  {
    while ((j<n)&&(a[j]<=a[i]+2)) j++;
    if (j-i>ans) ans=j-i;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int cnt = 0;
    rep(i,n){
        int a;
        cin >> a;
        if(a%2 == 1) ++cnt;
    }
    if(cnt%2 == 1) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
const int MAXN=1e5+5;
int dp[MAXN][2],n,val[MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=dp[i][1]=2147483647;
		scanf("%d",&val[i]);
	}
	dp[0][0]=dp[0][1]=0;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=1;j++)
			for(int k=0;k<=1;k++)
			{
				if(val[i]-k>=dp[i-1][j])
				{
					dp[i][k]=std::min(dp[i][k],val[i]-k);
				}
			}
	if(dp[n][0]==2147483647&&dp[n][1]==2147483647) printf("No"); else printf("Yes");
	return 0;
}


Measured memory_bytes: 1280
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int R;
inline void solve(){
  IN(R);
  if(R<1200)OUT("ABC");
  else if(R<2800)OUT("ARC");
  else OUT("AGC");
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <bits/stdc++.h>
#define MOD 1000000007
#define int long long
using namespace std;
#define ss second
#define ff first
int32_t main()
{
    fastio;
    int T,n,m,i,j,k,a,b,c;
    T=1;
    string str;
    while(T --> 0)
    {
        cin>>n>>str;
        vector<int> R,G;
        unordered_map<int,bool> B;
        for(i=0;i<n;i++)
        if( str[i] == 'R')
            R.emplace_back(i);
        else if( str[i] == 'G')
            G.emplace_back(i);
        else
            B[i]=true;
 
        m=B.size();
        int ans=R.size()*G.size()*m;
        for(auto a:R)
        for(auto b:G)
        {
            if( (a+b)%2==0 and B[(a+b)/2])
                ans--;
            if( B[2*a-b])
                ans--;
            if( B[2*b-a])
                ans--;
        }
        cout<<ans;
    }
}

Measured memory_bytes: 4100
#include<stdio.h> 
int main(void) { 
int ball[10]; 
int i,j;
 int B,C;
 int n,flag;

scanf("%d",&n); 
for(i=0;i<n;i++) { 
flag=1; 
for(j=0;j<10;j++) { 
scanf("%d",&ball[j]);
 }
 B=C=0;
 for(j=0;j<10;j++) {
 if(B<ball[j]) B=ball[j];
 else if(C<ball[j]) C=ball[j];
 else { 
flag=0; 
break;
 }
 }
 if(flag==1) printf("YES\n"); 
else printf("NO\n");

}

return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, n, m) for(int i = n; i < (int)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define PI 3.14159265358979

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

ll MOD = 1000000007;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> tree(N);
    REP(i, M) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        tree[a]++;
        tree[b]++;
    }
    REP(i, N) {
        if (tree[i] % 2 == 1) {
            PRINT("NO");
            return 0;
        }
    }
    PRINT("YES");
    return 0;
}


Measured memory_bytes: 1024
#include<algorithm>
#include<string>
#include<iostream>
#include<cstdio>

using namespace std;

string a,b;

bool check()
{
    getline(cin,a),getline(cin,b);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end(),greater<char>());
    if(a<b)return 0;
    
    return 1;
}

int main()
{
    if(check())printf("No\n");
    else printf("Yes\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,s=0;cin>>n>>a>>b;
  for(int i=1;i<=n;i++){
    int k=i-9*(i/10+i/100+i/1000+i/10000);
    if(k>=a&&k<=b)s+=i;
  }
  cout<<s<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
int main() {
    int n;
    scanf("%d", &n);
    int a[n], b[n];
    int i;
    int temp = 0;
    int check = 0;
    int left = 0, right = n-1;
    
    for(i = 0; i < n; i ++){
    scanf("%d", &a[i]);
    }
    for(i = 0; i < n; i ++){
    scanf("%d", &b[n - i - 1]);
    }
    
    for (i = 0; i < n; i ++) {
        if (a[i] == b[i]) {
            if(a[left] != b[i] && b[left] != a[i]){
                temp = b[i];
                b[i] = b[left];
                b[left] = temp;
                left ++;
            }else if(a[right] != b[i] && b[right] != a[i]){
                temp = b[i];
                b[i] = b[right];
                b[right] = temp;
                right --;
            }else{
                check = -1;
                break;
            }
            }
    }
    
    if(check == 0){
        printf("Yes\n");
        for (i = 0; i < n; i ++) {
            printf("%d ", b[i]);
        }
    }else{
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 3272
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

S = read().decode().rstrip()
for i in range(1, 6):
    acc = "hi" * i
    if acc == S:
        print("Yes")
        sys.exit()
print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t N; cin >> N;
  int64_t ans=20000001;
  int64_t k=sqrt(N);
  for(int64_t i=k;i>=1;i--){
    if(N%i==0){
      cout << i+(N/i)-2 << endl;
      return 0;
    }
  }
}

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

namespace Dwacon6
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string[] s = new string[n];
			int[] t = new int[n];
			string str;
			string[] strs = new string[2];

			for(int i = 0; i < n; i++)
			{
				str = Console.ReadLine();
				strs = str.Split(' ');
				s[i] = strs[0];
				t[i] = int.Parse(strs[1]);
			}

			string x = Console.ReadLine();
			int startIndex = 0;
			int time = 0;

			startIndex = Array.IndexOf(s, x) ;

			for(int i = startIndex + 1; i < t.Length; i++)
			{
				time += t[i];
			}

			Console.WriteLine(time);
		}
	}
}

Measured memory_bytes: 13148
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N, K = list(map(int, input().split()))
S = input().strip()

# 初期の幸せ度を調べる
happiness = 0
previous_face = S[0]
for i in range(1, N):
    if S[i] == previous_face:
        happiness += 1
    else:
        previous_face = S[i]

# 並べ替え後の幸せ度
happiness = happiness + 2 * K
if N - 1 < happiness:
    happiness = N - 1

# 出力
print(happiness)


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

#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;

#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

int main()
{
    int n,k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i,n)cin >> h[i];
    ssort(h);
    ll count=0;
    rep(i,n-k){
        count+=h[i];
    }
    cout << count << endl;



}

Measured memory_bytes: 4828