akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N, M;
  cin >> N >> M;

  cout << ((N == M) ? "Yes" : "No") << endl;
}

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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)

#define L(x) ((x)*2)
#define R(x) ((x)*2+1)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    os << pai.first << ' ' << pai.second;
	return os;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    rep(i, sz(v)) cout << v[i] << ' ';
    return os;
}

template<typename T, typename V>
istream &operator>>(istream &is, pair<T, V> &pai) {
	is >> pai.first >> pai.second;
	return is;
}

char str[10000];
char sss[] = "keyence";
int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    
    cin >> str;
    int len = strlen(str);

    int c = 0, d = 0;
    rep(i, min(len, 7)) {
        if (sss[i] == str[i]) c++;
        else break;
    }

    rep(i, min(len, 7)) {
        if (sss[6-i] == str[len-1-i]) d++;
        else break;
    }

    if (c+d >= 7) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
using namespace std;
const int SIZE=1005;
const int INF=1<<29;
const LL p=1e9+7;
LL A[SIZE][SIZE];
LL edge[SIZE][SIZE];
LL solve(){
	LL N;
	cin >> N;
	REP(i,N) REP(j,N){
		cin >> A[i][j];
		edge[i][j]=A[i][j];
	}
	REP(i,N) REP(j,N) REP(k,N){
		if(i==k or j==k) continue;
		if(A[i][j]!=min(A[i][j],A[i][k]+A[k][j])) return -1;
//		cout << A[i][j] << " " << A[i][k] <<" "<<A[k][j] <<" " <<i <<" "<<j <<" " <<k<<" "<<endl;
		if(A[i][j]==A[i][k]+A[k][j]) edge[i][j]=0;
	}
	LL sum=0;
	REP(i,N) REP(j,N){
	//	cout << sum << endl;
		sum+=edge[i][j];
	}
	return sum/2;
}
int main(){
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 10112
// ARC087
// C - Good Sequence

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

int N;
map<int, int> cnt;

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        cnt[a]++;
    }

    int ans = 0;
    for (auto iter : cnt) {
        if (iter.second < iter.first) {
            ans += iter.second;
        } else {
            ans += iter.second - iter.first;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4736
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
ll n, k;
vector<vector<ll>> g;
ll ans;
ll nPrM(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) {
        ret *= i;
        ret %= MOD;
    }
    return ret;
}
void dfs(ll now, ll pa, ll depth){

    bool f = false;
    rep(i, g[now].size()){
        ll next = g[now][i];
        if(next == pa) continue;
        f = true;
        dfs(next, now, depth + 1);
    }
    
    if(depth == 1){
        ans *= nPrM(k - 1, max(0LL, (ll)g[now].size()));
    } else  {
        if(f){
            ans *= nPrM(k - 2, max(0LL, (ll)g[now].size() - 1));
        }
    }
    ans %= MOD;
    //cout << now << " " << ans << endl;

}
int main(void){

    cin >> n >> k;

    g.resize(n);

    rep(i, n - 1){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    ans = k;

    dfs(0, -1, 1);

    cout << ans << endl;

    
}

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

int main()
{
    int a, b, c;
    while (cin>>a>>b>>c) {
        int res=-1, x=0;
        for(int t=0; t<1000000; ++t) {
            if (x<=a and t%60==c) {
                res=t;
                break;
            }
            if (++x==a+b) x=0;
        }
        cout<<res<<endl;
    }
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> p(n),q(n);

  rep(i,n){
      cin >> p[i];
  }
  rep(i,n){
      cin >> q[i];
  }

  map<vector<int>,int> mp;
  vector<int> a(n);
  rep(i,n) a[i] = i+1;

  do{
     mp[a] = mp.size();
  }while(next_permutation(a.begin(),a.end()));

  cout << abs(mp[p]-mp[q]) << endl;


  






}

Measured memory_bytes: 5248
N = int(input())
P = {i : inp for i, inp in enumerate(map(int, input().split()), 1)}

ret = 0
for i in range(1, N):
  if P[i] == i:
    P[i], P[i+1] = P[i+1], P[i]
    ret += 1
    
if P[N] == N:
  ret += 1

print(ret)

Measured memory_bytes: 25068
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        if(k % 2 == 0) {
            long a = n / k;
            long b = n / (k / 2);
            long c = b - a;
            System.out.println(a * a * a + c * c * c);
        } else {
            long a = n / k;
            System.out.println(a * a * a);
        }
    }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin>>N;
    int *A=new int [N];
    for(int i=0; i<N; i++)
        cin>>A[i];
    sort(A,A+N,greater<int>());///降序;

    int res = 0;
    res += A[0];

    for (int i = 1; i < N-1; i++)
        res += abs(A[i]);

    res -= A[N-1];
    cout <<res << '\n';
    int i=1;
    for (; i < N - 1 && A[i] >= 0; i++)
    {
        cout << A[N-1] << ' ' << A[i] << '\n';
        A[N-1] -= A[i];
    }

    cout << A[0] << ' ' << A[N-1] << '\n';
    A[0] -= A[N-1];

    for (; i < N - 1; i++)
    {
        cout << A[0] << ' ' << A[i] << '\n';
        A[0] -= A[i];
    }
    return 0;
}


Measured memory_bytes: 2304
from collections import deque
n,m = map(int,input().split())
graph = [[] for _ in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
ans = [-1 for _ in range(n+1)]
ans[1] = 0
q = deque()
q.append(1)
while q:
    x = q.popleft()
    for y in graph[x]:
        if ans[y] == -1:
            q.append(y)
            ans[y] = x
print("Yes")
for i in range(2,n+1):
    print(ans[i])

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

int main()
{
  ll n;
  cin >> n;
  vector<string> s(n);
  rep(n) cin >> s[i];
  sort(s.begin(),s.end());
  ll tmp = 0, cur = 0;
  for (ll i = 0; i < n-1; i++)
  {
    if(s[i]==s[i+1]) tmp++;
    else {cur = max(tmp,cur); tmp = 0;}
  }
  cur = max(tmp,cur);

  for (ll i = 0; i < n-cur; i++)
  {
    if(s[i]==s[i+cur]) cout << s[i] << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 14208
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
while(true){

           int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();

if(op.equals("?"))break;

    switch(op){
            case "+":
                System.out.println(a+b);
                break;
            case "-":
                System.out.println(a-b);
                break;
            case "*":
                System.out.println(a*b);
                break;
            case "/":
                System.out.println(a/b);
                break;
            }


}
}
}


Measured memory_bytes: 26296
n,k,s = map(int,input().split())
ans = []
if s == 10 ** 9:
    num = 10 ** 9-1
else:
    num = 10 ** 9
for i in range(k):
    ans.append(str(s))
for i in range(n-k):
    ans.append(str(num))
print(" ".join(ans))

Measured memory_bytes: 13464
import java.util.*;

public class Main {

    public void run() {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        
        int count = 0;
        while(x <= y) {
            count++;
            x *= 2;
        }
        System.out.println(count);
    }

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

Measured memory_bytes: 21972
N,M=map(int, raw_input().split())
A=[ map(int, raw_input().split()) for i in range(N)]

A.sort(key=lambda x: x[0])

ans=0

for a,b in A:
	if b<M:
		ans+=a*b
		M-=b
	else:
		ans+=a*M
		break
print ans

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

typedef long long ll;
const int maxn=3e3+10;
ll n,mod,c[maxn][maxn],s[maxn][maxn],ans;

inline ll fpow(ll a,ll n,ll mod) {
	ll res=1;
	for(; n; n>>=1,a=a*a%mod)
		if(n&1ll)
			res=res*a%mod;
	return res;
}

int main() {
	cin>>n>>mod;
	for(int i=0; i<maxn; ++i) {
		c[i][0]=1;
		for(int j=1; j<=i; ++j)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	}
	for(int i=0; i<maxn; ++i) {
		s[i][0]=1;
		for(int j=1; j<=i; ++j)
			s[i][j]=(s[i-1][j-1]+s[i-1][j]*(j+1))%mod;
	}
	for(int i=0; i<=n; ++i) {
		ll k=c[n][i];
		if(i&1)
			k=(mod-k)%mod;
		ll cnt=0;
		ll kind=fpow(2,n-i,mod);
		ll x=fpow(2,n-i,mod-1);
		x=fpow(2,x,mod);
		for(ll j=0,y=1; j<=i; ++j) {
			cnt=(cnt+(s[i][j]*y%mod))%mod;
			y=kind*y%mod;
		}
		ans=(ans+(k*cnt%mod*x%mod))%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 140160
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int func(int a, int b) {
  string aa = to_string(a);
  string bb = to_string(b);
  return max(aa.size(), bb.size());
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x, y,z; cin >> x >> y >>z;
    swap(x,y);
    swap(x,z);
    cout <<  x << " " << y << " " << z << "\n";

}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

using namespace std;

#define int long long
#define str string
#define rtn return
#define pb push_back
#define db long double
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()

const int N = 1e5 + 7;

int dp[N];
int h[N];
int n;

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

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

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> X;
    int in;
    for (int i = 0; i < N; i++)
    {
        cin >> in;
        X.emplace_back(in);
    }

    vector<int> Xsort = X;
    sort(Xsort.begin(), Xsort.end());

    for (int i = 0; i < N; i++)
    {
        if (Xsort[(N - 1) / 2] < X[i])
        {
            cout << Xsort[(N - 1) / 2] << endl;
        }else
        {
            cout << Xsort[(N - 1) / 2 + 1] << endl;
        }
        
    }
    
    return 0;
}

Measured memory_bytes: 3956
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }

signed main()
{
	string s = in<string>();
	if (s[0] != 'A' || 'A' <= s[1] && s[1] <= 'Z')
	{
		cout << "WA" << endl;
		return 0;
	}
	for (int i = 2, i_l = s.length(); i < i_l; ++i)
	{
		static int c_cnt = 0;
		if (s[i] == 'C')++c_cnt;
		if (i >= i_l - 2 && c_cnt == 0 || c_cnt > 1 || 'A' <= s[i] && s[i] <= 'B' || 'D' <= s[i] && s[i] <= 'Z')
		{
			cout << "WA" << endl;
			return 0;
		}
	}
	cout << "AC" << endl;
}

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

int n, k;
int arr[109];
int dp[100009];


bool solve(int k) {
	if(k == 0)
		return false;
	
	if(dp[k] != -1) {
		return dp[k];
	}
	
	bool ans = false;
	bool curr;
	for(int i = 0 ; i < n; i++) {
		if(arr[i] > k) break;
		curr = !(solve(k - arr[i]));
		ans |= curr;
	}
	
	return dp[k] = ans;
}

int main() {
	cin>>n>>k;
	memset(dp, -1, sizeof(dp));
	for(int i = 0; i < n; i++) 
		cin>>arr[i];
	sort(arr, arr + n);
	
	if(solve(k)) cout<<"First\n";
	else cout<<"Second\n";
	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const double PI = 3.1415926535897932384626433832795;
const int mod = 1000000007;
const int INF = 1001001001;

ll comb(ll n, ll r) {
  ll res = 1;
  if(n <= 0 || r > n) return 0;
  rep(i, r) res *= n - i;
  rep(i, r) res /= i + 1;
  return res;
}

int main() {

  int n;
  string s;
  cin >> n >> s;

  ll ans = 1;
  map<char, ll> mp;
  rep(i, n) {
    mp[s[i]]++;
  }

  ans *= mp['G'] * mp['B'] * mp['R'];
  
  rep(i, n) {
    rep(j, n) {
      int l = j - i, r = j + i, m = j;
      if (l < 0 || r >= n) continue;
      if (s[l] == s[r] || s[l] == s[m] || s[m] == s[r]) continue;
      ans--;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
int main()
{
    string s,t;
    int ans=0;
    cin>>s>>t;
    rep(i,s.size()){
        if(s[i]!=t[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3916
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
using namespace std;
struct S{
	int town,l;
	S(int a=0,int b=0):town(a),l(b){}
};
int main(){
	int n,m,l;
	while(cin>>n>>m>>l,n){
		struct{
			int d,e;
		}g[100][101]; int cost[100][101];
		rep(i,100)rep(j,101)g[i][j].d=cost[i][j]=INF;
		int a,b,d,e;
		rep(i,m){
			cin>>a>>b>>d>>e,a--,b--;
			g[a][b].d=g[b][a].d=d;
			g[a][b].e=g[b][a].e=e;
		}
		vector<S> F;
		F.push_back(S(0,l)),cost[0][l]=0;
		while(!F.empty()){
			vector<S> nF;
			rep(i,F.size()){
				S cS=F[i],nS;
				rep(guard,2)rep(j,n){
					int tcost=guard*g[cS.town][j].d,dcost=guard?0:g[cS.town][j].e;
					if(g[cS.town][j].d!=INF&&tcost<=cS.l&&
					cost[j][cS.l-tcost]>cost[cS.town][cS.l]+dcost){
						cost[j][cS.l-tcost]=cost[cS.town][cS.l]+dcost;
						nS=cS,nS.town=j,nS.l-=tcost;
						nF.push_back(nS);
					}
				}
			}
			F=nF;
		}
		int mn=INF;
		rep(i,l+1)if(mn>cost[n-1][i])mn=cost[n-1][i];
		cout<<mn<<endl;
	}
	return 0;
}

Measured memory_bytes: 1372
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 25, M = 200, S = (1 << 19) + 5;
const int mod = 1e9 + 7;	

vector<pii> g[N];
int u[M], v[M], depth[N], par[N], up[N];
int dep[M];
int ctr[S];
ll ways[S], sum[S];
ll prod[M][M];

void dfs(int u, int p);

int main() {
	// cout << (2 * sizeof(ways)) / 1e6 << endl;
	// return 0;
	fast_cin();
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> u[i] >> v[i];
		if (i < n - 1) {
			g[u[i]].pb({v[i], i});
			g[v[i]].pb({u[i], i});
		}
	}
	dfs(1, 0);
	for (int i = n - 1; i < m; ++i) {
		int eu = u[i], ev = v[i];
		if (depth[eu] < depth[ev]) {
			swap(eu, ev);
		}
		while (depth[eu] > depth[ev]) {
			dep[i] |= (1 << up[eu]);
			eu = par[eu];
		}
		while (eu != ev) {
			dep[i] |= (1 << up[eu]);
			dep[i] |= (1 << up[ev]);
			eu = par[eu];
			ev = par[ev];
		}
		++ctr[dep[i]];
	}
	int subsets = (1 << (n - 1)), all = subsets - 1;
	// for (int mask = 0; mask < subsets; ++mask) {
	// 	cout << ctr[mask] << endl;
	// }
	for (int i = 0; i < n - 1; ++i) {
		for (int mask = 0; mask < subsets; ++mask) {
			if (mask & (1 << i)) {
				ctr[mask] += ctr[mask ^ (1 << i)];
			}
		}
	}
	// for (int mask = 0; mask < subsets; ++mask) {
	// 	cout << ctr[mask] << endl;
	// }
	ll all_sum = m - (n - 1);
	for (int mask = 0, comp = all; mask < comp; ++mask, --comp) {
		swap(ctr[mask], ctr[comp]);
		ctr[mask] = all_sum - ctr[mask];
		ctr[comp] = all_sum - ctr[comp];
	}
	for (int i = 1; i < M; ++i) {
		prod[i][i - 1] = 1;
		for (int j = i; j < M; ++j) {
			prod[i][j] = prod[i][j - 1] * j;
			prod[i][j] %= mod;
		}
	}
	ways[0] = 1;
	for (int mask = 0; mask < subsets; ++mask) {
		// cout << mask << ' ' << ways[mask] << ' ' << sum[mask] << ' ' << ctr[mask] << endl;
		// cout << mask << ' ' << ctr[mask] << endl;
		int b = __builtin_popcount(mask), tot = ctr[mask] + b;
		for (int i = 0; i < n - 1; ++i) {
			if (mask & (1 << i)) {
				continue;
			}
			int new_mask = mask | (1 << i);
			int k = ctr[new_mask] - ctr[mask];
			ll temp = prod[tot + 1][tot + k] * ways[mask];
			temp %= mod;
			ways[new_mask] += temp;
			ways[new_mask] %= mod;
			sum[new_mask] += prod[tot + 2][tot + k + 1] * sum[mask];
			sum[new_mask] += temp * (b + 1);
			sum[new_mask] %= mod;
		}
	}
	cout << sum[all] << endl;
}

void dfs(int u, int p) {
	for (auto &e : g[u]) {
		int v = e.first, id = e.second;
		if (v != p) {
			depth[v] = depth[u] + 1;
			par[v] = u;
			up[v] = id;
			dfs(v, u);
		}
	}
}

Measured memory_bytes: 10880
#include <set>
#include <iostream>
#include <cstdio>
#include <cstring>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

int h, w, p;
int g[1000][1000];
int pat[100][100];
int tmp[100][100];

int decode(char c){
  if('A' <= c && c <= 'Z') return c - 'A';
  if('a' <= c && c <= 'z') return c - 'a' + 26;
  if('0' <= c && c <= '9') return c - '0' + 52;
  if(c == '+') return 62;
  if(c == '/') return 63;
  return -1;
}

template<int N>
void get(int (&dist)[N][N], int h, int w){
  REP(i,h){
    char buff[1012];
    scanf("%s", buff);

    REP(j,w){
      int a = j / 6;
      int b = j % 6;
      dist[i][j] = (decode(buff[a]) & (1 << (5 - b))) != 0 ? 1 : 0;
    }
  }
}

struct Hash{
  unsigned long long h[2];
  Hash(){}
  Hash(int *p, int len){
    h[0] = h[1] = 0;
    REP(i,len)
      if(p[i]) h[i / 64] |= (1ll << (i % 64));
  }
};

inline bool operator == (const Hash &lhs, const Hash &rhs){
  return lhs.h[0] == rhs.h[0] && lhs.h[1] == rhs.h[1];
}
inline bool operator != (const Hash &lhs, const Hash &rhs){
  return !(lhs == rhs);
}

int ans[1000][1000];
Hash gh[1000][1000];
Hash ph[100];

int main(){
  while(scanf("%d%d%d", &w, &h, &p), w + h + p){
    REP(i,h) REP(j,w) ans[i][j] = 0;

    get(g, h, w);
    get(pat, p, p);

    REP(i,h) REP(j,w - p + 1)
      gh[i][j] = Hash(&g[i][j], p);

    int pcnt = 0;

    REP(i,p) REP(j,p) if(pat[i][j]) pcnt++;
    REP(i,h){
      int t = 0;
      REP(j,w){
        t += g[i][j];
        if(j >= p - 1){
          int tt = g[i][j - p + 1];
          g[i][j - p + 1] = t;
          t -= tt;
        }
      }
    }
    REP(j,w){
      int t = 0;
      REP(i,h){
        t += g[i][j];
        if(i >= p - 1){
          int tt = g[i - p + 1][j];
          g[i - p + 1][j] = t;
          if(g[i - p + 1][j] != pcnt) ans[i - p + 1][j] = 1;
          t -= tt;
        }
      }
    }

    int cnt = 0;
    REP(m,2){
      REP(r,4){
        REP(i,p) ph[i] = Hash(pat[i], p);

        // puts("p:");REP(i,p){REP(j,p) printf("%d", pat[i][j]);puts("");}

        REP(i,h - p + 1) REP(j,w - p + 1) if(ans[i][j] == 0){
          REP(k,p) if(gh[i + k][j] != ph[k]) goto next;
          ans[i][j] = 1;
          cnt++;
        next:;
        }

        // rotate
        REP(i,p) REP(j,p) tmp[i][j] = pat[i][j];
        REP(i,p) REP(j,p) pat[i][j] = tmp[p - j - 1][i];
        bool diff = false;
        REP(i,p) REP(j,p) if(pat[i][j] != tmp[i][j]) diff = true;
        if(!diff) r = 4;
      }
      // mirror
      REP(i,p) REP(j,p) tmp[i][j] = pat[i][j];
      REP(i,p) REP(j,p/2) swap(pat[i][j], pat[i][p - j - 1]);
      bool diff = false;
      REP(i,p) REP(j,p) if(pat[i][j] != tmp[i][j]) diff = true;
      if(!diff) m = 4;
    }

    printf("%d\n", cnt);
  }
  return 0;
}

Measured memory_bytes: 23000
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    long long x[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    long long m=1000000000000000;
    for(int i=0;i+k<=n;i++){
        m=min(m,min(abs(x[i]),abs(x[i+k-1]))+x[i+k-1]-x[i]);
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main()
{
  ll N; cin>>N;
  vector<ll> A(N); rep(i,N) cin>>A[i];
  
  map<tuple<ll,ll,ll>,ll> dp;
  queue<tuple<ll,ll,ll>> que;
  ll ans=0;
  dp[{0,0,0}]=1;
  que.push({0,0,0});
  while(!que.empty()){
    auto p=que.front(); que.pop();
    ll i,j,k; tie(i,j,k)=p;
    
    //cout<<i<<" "<<j<<" "<<k<<" "<<dp[{i,j,k}]<<endl;
    
    if(i+j+k==N) {ans=(ans+dp[{i,j,k}])%MOD; continue;}
    
    ll n=i+j+k;
    if(A[n]==i){
      if(!dp.count({i+1,j,k})) {dp[{i+1,j,k}]=dp[{i,j,k}]; que.push({i+1,j,k});}
      else dp[{i+1,j,k}]=(dp[{i+1,j,k}]+dp[{i,j,k}])%MOD;
    }
    if(A[n]==j){
      if(!dp.count({i,j+1,k})) {dp[{i,j+1,k}]=dp[{i,j,k}]; que.push({i,j+1,k});}
      else dp[{i,j+1,k}]=(dp[{i,j+1,k}]+dp[{i,j,k}])%MOD;
    }
    if(A[n]==k){
      if(!dp.count({i,j,k+1})) {dp[{i,j,k+1}]=dp[{i,j,k}]; que.push({i,j,k+1});}
      else dp[{i,j,k+1}]=(dp[{i,j,k+1}]+dp[{i,j,k}])%MOD;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 50772
#include<stdio.h>
int main(){
	
	int m, f, r;
	int n,i;
	

	while(1){
    	scanf("%d %d %d", &m, &f, &r);
  			if(m == -1 && f == -1 && r == -1) 
  				break;	
			
	
	
		if(m == -1 || f == -1 || m + f < 30)
			printf("F\n");
		else if(m + f >= 80)
			printf("A\n");
	    else if(m + f >= 65)
			printf("B\n");
	    else if(m + f >= 50)
			printf("C\n");
	    else if(m + f >= 30){
			if(r >= 50)
				puts("C");
			else
			printf("D\n");
	    }
		
	}
	return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main() {
	int n, k;
	string s;
	cin >> n >> k;
	cin >> s;
	if (s[k-1] == 'A')s[k-1] = 'a';
	else if (s[k-1] == 'B')s[k-1] = 'b';
	else s[k-1] = 'c';
	cout << s;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    
    int s = N / 100;
    if(N > (100*s + 10*s + s)) {
      System.out.println(100*(s+1) + 10*(s+1) + (s+1));
    } else {
      System.out.println(100*s + 10*s + s);
    }
  }
}

Measured memory_bytes: 22996
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    multiset<int, greater<int>> kek;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        auto it = kek.upper_bound(a[i]);
        if (it != kek.end()) {
            kek.erase(it);
        } else ans++;
        kek.insert(a[i]);
    }
    cout << ans;
}
/*

*/


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

int main()
{
   string s;
   cin>>s;
   int answer {0};
   for(int i = 0 ; i < s.length(); i++){
      int k = int(s[i]) - 48;
      answer= (answer+k)%9;
      //cout<<answer<<endl;
   }
   if(answer>=1){
      cout<<"No";
   }
   else cout<<"Yes";
   return 0;

}


Measured memory_bytes: 3732
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>


using namespace std;


typedef pair<int ,int > P;

int swaP(P *a,P *b){
	P c;
	c = *a;
	*a = *b;
	*b = c;
}

int bSort(P *start,P *end){
	int len = end-start;
	for(int i=0;i<len-1;i++){
		for(int j=0;j<len-1;j++){
			if(start[j] > start[j+1]){
				swap(start[j],start[j+1]);
			}
		}
	}
	return 0;
}

int main (void){

	int n;
	int ctrlNum;
	int cmd;

	P cards[256];

	scanf("%d",&n);
	for(int i=0;i<2*n;i++){
		cards[i] = P(i,i+1);
	}
	scanf("%d",&ctrlNum);
	for(int i=0;i<ctrlNum;i++){
		scanf("%d",&cmd);
		switch(cmd){
		case 0:
			for(int j=0;j<2*n;j++){
				if(cards[j].first < n){
					cards[j].first *= 2;
				}else if(cards[j].first >= n){
					cards[j].first -= n;
					cards[j].first *= 2;
					cards[j].first++;
				}
			}
			break;
		default:
			for(int j=0;j<2*n;j++){
				cards[j].first = ((cards[j].first + 2*n - cmd) % (2*n));
			}
			break;
		}
	}

	bSort(cards,cards+2*n);

	for(int i=0;i<2*n;i++){
		printf("%d\n",cards[i].second);
	}



	return 0;
}

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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  char a,b;
  cin >> a >> b;
  if(a == b){
    cout << 'H' << endl;
  }else{
    cout << 'D' << endl;
  }
}


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

int comp(const void* a, const void* b) {
	return (*(int*)a - *(int*)b);
}

int main() {
	int n;
	while (1) {
		cin >> n;
		if (n == 0) break;
		int points[n];
		for (int i = 0; i < n; i++) {
			cin >> points[i];
		}
		qsort(points, n, sizeof(int), comp);
		int sum = 0;
		for (int i = 1; i < n - 1; i++) {
			sum += points[i];
		}
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
def resolve():
    '''
    code here
    '''
    N = int(input())
    A_list = [int(item) for item in input().split()]

    cnt_list = [0,0]

    for i in A_list:
        if i % 4 == 0:
            cnt_list[1] += 1
        elif i % 2 == 0:
            cnt_list[0] += 1

    is_flag = False

    if N - cnt_list[1] <= cnt_list[1]+1:
        is_flag = True
    
    else:
        if N - sum(cnt_list) <= cnt_list[1]:
            is_flag = True


    print('Yes') if is_flag else print('No')


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 14252
#include<iostream>
using namespace std;
string s;
int cnt,now;
main()
{
	cin>>s;
	for(char c:s)
	{
		if(c=='R')
		{
			now++;
			cnt+=now==4;
		}
		else now--;
		now%=4;
	}
	cout<<cnt<<endl;
}


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

int main()
{
    string pstr;
    cin>>pstr;
    int n;
    cin>>n;
    int res=0;
    for(int i=0;i<n;++i){
        string str,str2;
        cin>>str;
        str2=str+str;
        if(str2.find(pstr)!=-1)res++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main(){
	long long int n,k;
	cin>>n>>k;
	vector<int>a(n);
	rep(i,n)cin>>a[i];
	int now = 0,cnt = 0;
	vector<long long int>map(n,-1);
	long long int i = 0;
	while(i<k){
		//cout<<i<<" "<<now<<endl;
		map[now]=i;//足跡をつける
		now = a[now]-1;//次に遷移
		if(map[now]!=-1){//すでに訪れてたら
			//cout<<k-i<<" "<<i-map[now]<<endl;
			i = k-((k-(i+1))%((i+1)-map[now]));
			//cout<<"##!"<<i<<endl;
		}else{
			i+=1;
		}
	}
	cout<<now+1<<endl;




	return 0;
}

Measured memory_bytes: 5636
import itertools
#import pprint
N, M, X = map(int, input().split())
C = []
for i in range(N):
    C.append(list(map(int, input().split())))
choice = list(itertools.product([False, True], repeat = N))
#pprint.pprint(choice)
best = False
for i in choice:
    cost = 0
    now = [0 for j in range(M)]
    flag = True
    for j in range(N):
        if i[j]:
            cost += C[j][0]
            now = [now[k] + C[j][k + 1] for k in range(M)]
    for j in now:
        if j < X:
            flag = False
#    print(i, now, cost)
    if flag:
        if best == False:
            best = cost
        elif best > cost:
            best = cost
if best == False:
    print(-1)
else:
    print(best)


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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
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;}

int main(){
ll int n;
cin >> n;
for(ll int i = 0; i < 100000; i++){
ll int t = i * (i + 1) /2;
ll int old = (i-1) * i / 2;
if(old < n && n <= t){
cout << i << endl;
return 0;
}
}
}

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

#define eb emplace_back
#define ld long double
#define ll long long

using namespace std;

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	int n = s.length(), m = t.length();
	int res = m;
	for (int i = 0; i + m - 1 < n; ++i) {
		int d = 0;
		for (int j = 0; j < m; ++j) {
			d += (s[i + j] != t[j]);
		}
		res = min(res, d);
	}
	cout << res << "\n";
}


Measured memory_bytes: 3656
#include <stdio.h>
 
using namespace std;
 
int main(){
    int n,x;
    scanf("%d",&n);
 
    for(int i = 1; i<= n; i++)
    {
        if(i%3 == 0){
            printf(" %d",i);
        }else{
            x = i;
            do{
                if(x%10 == 3){
                    printf(" %d",i);
                    break;
                }
                x /=10;
            }while(x);
        }
    }
    printf("\n");
}


Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define simplify ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

int binomialCoeff(int n,int r){
    int res=1;
    if(r>n-r)r=n-r;
    for(int i=0;i<r;i++){
        res*=(n-i);
        res/=(i+1);
    }
    return res;
}


int power(int x,int n,int mod){
    //(x^n)%mod
    int result=1;
    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}

int inverseMod(int x,int mod){
    return power(x,mod-2,mod);
}


int32_t main() {

    simplify
    int n;
    cin>>n;
    vector<int>arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr.rbegin(),arr.rend());

    int ans=arr[0];
    vector<int>toTake;

    for(int i=1;i<n;i++){
        toTake.push_back(arr[i]);
        toTake.push_back(arr[i]);
    }
    sort(toTake.rbegin(),toTake.rend());

    for(int i=0;i<n-2;i++){
        ans+=toTake[i];
    }
    cout<<ans;
    

    return 0;
}



Measured memory_bytes: 8984
#include<stdio.h>
int main(void){
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d = a/b;
	r = a%b;
	f = (double)a/b;
	printf("%d %d %lf",d,r,f);
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

Int gcd(Int x, Int y) {
   if( y == 0 ) return x;
   return gcd(y,x%y);
}

bool check(const std::vector<Int>& xs) {
   Int g = xs[0];
   Int total = 0;
   for(Int x : xs) {
      g = gcd(g,x);
      total += x;
   }
   if( g != 1 ) return false;
   for(Int x : xs) {
      if( gcd(total-x,x) == 1 ) {
         fprintf(stderr, "x=%ld\n", x);
         return false;
      }
   }
   for(Int x : xs) {
      if( not ( 1 <= x and x <= 30000 ) ) {
         fprintf(stderr, "over : %ld\n", x);
         return false;
      }
   }
   return true;
}

std::vector<Int> solve(Int n) {
   std::vector<Int> res;
   rep(i,n/8) {
      Int xs[] = {2,3,4,6,8,9,10,12};
      for(Int x : xs) {
         res.emplace_back(i*12+x);
      }
   }
   Int m = n/8;
   std::vector<Int> yss[] = {
      {},
      {12},
      {3,9},
      {3,6,9},
      {2,3,4,9},
      {2,3,4,6,9},
      {2,3,4,6,9,12},
      {2,3,4,8,9,10,12},
   };
   for(Int x : yss[n%8]) {
      res.emplace_back(m*12+x);
   }
   return res;
}

int main() {
   Int n;
   std::cin >> n;
   if( n == 3 ) {
      puts("2 5 63");
      return 0;
   }
   if( n == 4 ) {
      puts("2 5 20 63");
      return 0;
   }
   // for(Int i = 5; i <= 20000; ++i) {
   //    fprintf(stderr, "i=%ld\n", i);
   //    std::vector<Int> res = solve(i);
   //    bool b = check(res);
   //    if( not b ) {
   //       fprintf(stderr, "error : %ld\n", i);
   //       return 1;
   //    }
   // }
   // return 0;
   std::vector<Int> res = solve(n);
   printf("%ld", res[0]);
   for(Int i = 1; i < (Int)res.size(); ++i) {
      printf(" %ld", res[i]);
   }
   printf("\n");
   // puts(check(res) ? "Yes" : "No");
}


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

int main(){
    int N;
    std::cin >> N;
    std::vector< std::deque< int > > A(N);
    std::deque< int > cur;
    for(int i=0; i<N; i++){
        cur.push_back(i);
        for(int j=0; j<N-1; j++){
            int tmp;
            std::cin >> tmp;
            A[i].push_back(tmp - 1);
        }
    }
    
    int total = N * (N - 1);
    int day = 0;
    while(total != 0){
        std::set< int > next;
        while(!cur.empty()){
            int No = cur[0];
            cur.pop_front();
            
            if(A[No].size() != 0 && A[A[No][0]].size() != 0 && A[A[No][0]][0] == No){
                next.insert(No);
                next.insert(A[No][0]);
            }
        }
        if(next.size() == 0){
             std::cout << -1 << std::endl;
            return 0;
        }
        
        for(auto itr = next.begin(); itr != next.end(); itr++){
            A[*itr].pop_front();
            total--;
            cur.push_back(*itr);
        }
        day++;
    }
    
    
    std::cout << day << std::endl;
    
    return 0;
}



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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

int main() {
  int a,b;
  cin >> a >> b;
  bool ans=true;
  int k=(a+b)/2;
  if ((a+b)%2) ans= false;

  cout << (ans?to_string(k):"IMPOSSIBLE");
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)          
{
	long long int a[100][100], b[100][100],c[100][100];
	int n, m, l;
	int i, j, k;
	scanf("%d %d %d", &n, &m, &l);
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < l; j++)
		{
			c[i][j] = 0;
		}
	}
	
	for (i = 0; i < n; i++) 
	{
		for (j = 0; j < m; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}
	for (i = 0; i < m; i++)
	{
		for (j = 0; j < l; j++)
		{
			scanf("%d", &b[i][j]);
		}
	}
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < l; j++)
		{
			for (k = 0; k < m; k++)
			{
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < l; j++)
		{
			printf("%lli", c[i][j]);
			if (j != l - 1) printf(" ");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 836
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {

	ll N;
	cin >> N;
	vll b(N);
	rep(i, N) cin >> b[i];
	
	vll ans;
	while(!b.empty()) {
		ll flag = true;
		ford(i, 1, N + 1) {
			if (i <= b.size() && b[i - 1] == i) {
				ans.push_back(b[i - 1]);
				b.erase(b.begin() + i - 1);
				flag = false;
				break;
			}
		}
		if (flag) {
			cout << -1 << endl;
			return 0;
		}
	}

	reverse(all(ans));
	rep(i, N) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for i in range(A+1):
    a = i*500
    for j in range(B+1):
        b = j*100
        for k in range(C+1):
            c = k*50
            if(a+b+c == X):
                ans += 1
print(ans)

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

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

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

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
const int maxn = 2e6 + 10;
char str[maxn];
int n, pw[13], tag[maxn], tid[maxn], ch[maxn][3], ans[maxn];

void build(int k, int dep, int val) {
  if (dep == n) return tid[k] = val, void();
  ch[k][0] = k * 3, build(ch[k][0], dep + 1, val);
  ch[k][1] = k * 3 + 1, build(ch[k][1], dep + 1, val + pw[dep]);
  ch[k][2] = k * 3 + 2, build(ch[k][2], dep + 1, val + pw[dep] * 2);
}

void pushdown(int k) {
  if (tag[k]) {
    tag[k] = 0, swap(ch[k][1], ch[k][2]);
    tag[ch[k][0]] ^= 1, tag[ch[k][1]] ^= 1, tag[ch[k][2]] ^= 1;
  }
}

void upd(int k, int dep) {
  if (dep == n) return;
  pushdown(k);
  upd(ch[k][2], dep + 1);
  swap(ch[k][1], ch[k][2]), swap(ch[k][0], ch[k][1]);
}

void print(int k, int dep, int val) {
  if (dep == n) return ans[tid[k]] = val, void();
  pushdown(k);
  print(ch[k][0], dep + 1, val);
  print(ch[k][1], dep + 1, val + pw[dep]);
  print(ch[k][2], dep + 1, val + pw[dep] * 2);
}

void solve() {
  scanf("%d %s", &n, str + 1);
  pw[0] = 1;
  rep(i, 1, n) pw[i] = 3 * pw[i - 1];
  build(1, 0, 0);
  rep(i, 1, strlen(str + 1)) {
    if (str[i] == 'S') {
      tag[1] ^= 1;
    } else {
      upd(1, 0);
    }
  }
  print(1, 0, 0);
  rep(i, 0, pw[n] - 1) printf("%d ", ans[i]);
}

int main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}

Measured memory_bytes: 14644
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
using namespace std;
typedef long long ll;
int main()
{
	int n,m;
	int x;
	ll ans=0;
	priority_queue<int> q;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&x);
		q.push(x);
	}
	for(int i=0;i<m;i++)
	{
		x=q.top();
		q.pop();
		x/=2;
		q.push(x);
	}
	while(!q.empty())
	{
		ans+=q.top();
		q.pop();
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    int n;
    int top;
    int bottom;

    cin >> n;

    top = n / 10;
    bottom = n % 1000;

    if(top % 111 && bottom % 111)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
 
int main(){
    int a, b, A;
    char op;
     
     
    while(1)
{
        cin >> a >> op >> b;
         
        if ( op == '+')
{
            A = a + b;
        }
else if( op == '-'){
            A = a - b;
        }else if (op == '*'){
            A = a * b;
        }else if (op == '/'){
            A = a / b;
        }else{
            break;
        }
        cout << A << endl;
    }
       
    return 0;   
}

Measured memory_bytes: 3100
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, k; ll m;
    cin>>n>>k>>m;
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    ll dp[222][1<<10]={};
    for(int i=2; i<=min(n+1, k+1); i++){
        dp[i][(1<<(i-1))-1]=1;
    }
    for(int i=2; i<2*n; i++){
        for(int j=1; j<(1<<k); j++){
            int t=i;
            int u=i, s=i;
            for(int l=k-1; l>=0; l--){
                if(j&(1<<l)){
                    if(u==i) u=i-1-l;
                    else if(t==i) t=i-1-l, s=t;
                    else s=i-1-l;
                }
            }
            for(int l=i+1; l<=t+k; l++){
                int q;
                if(t==i){
                    if(l==i+1 || i+1-u>k) continue;
                    q=((1<<(l-i-1))-1);
                }else{
                    q=(j^(1<<(i-1-u)))<<(l-i);
                    if(i+1-s>k) continue;
                    q+=((1<<(l-i-1))-1);
                }
                if(q>=(1<<k)) continue;
                (dp[l][q]+=dp[i][j])%=m;
            }
        }
    }
    ll ans=0;
    for(int i=0; i<k; i++){
        (ans+=dp[2*n][1<<i])%=m;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4888