akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<functional>
#include<algorithm>
using namespace std;

#define INF (1<<29)
#define EPS 1e-10
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end())
#define INDEX(v,x) (find(ALL(v),x)-v.begin())

typedef unsigned long long ull;

int d[100000];
int p[100000];
bool cut[100000];

int hoge(int a){//短絡
	if(p[a]==0)return a;
	if(cut[a]){
		if(p[a]==INF)return INF;
		return a+p[a];
	}
	cut[a]=true;
	int t=p[a];
	p[a] = INF;
	t = hoge(a+t);
	if(t!=INF)p[a]=t-a;
	return t;
}
int main(){
	int n;
	cin>>n;
	REP(i,n)cin>>p[i];
	REP(i,n){
		hoge(i);
	}
	fill(d,d+n,INF);
	d[0]=0;
	queue<int> q;
	q.push(0);
	while(!q.empty()){
		int a=q.front();q.pop();
		for(int i=1;i<=6;i++){
			int next=p[a+i];
			if(next==INF)continue;
			next=a+i+next;
			if(d[a]+1 < d[next]){
				d[next]=d[a]+1;
				q.push(next);
			}
		}
	}
	cout<<d[n-1]<<endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  if(N < 105){
    cout << 0 << endl;
  }
  else if(N < 135){
    cout << 1 << endl;
  }
  else if(N < 165){
    cout << 2 << endl;
  }
  else if(N < 189){
    cout << 3 << endl;
  }
  else if(N < 195){
    cout << 4 << endl;
  }
  else if(N < 201){
    cout << 5 << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while(true){
            int height = sc.nextInt();
            int weight = sc.nextInt();
            
            if( height == 0 && weight == 0) break;
            for(int h = 0; h < height; h++){
                for(int w = 0; w < weight; w++){
                    if( (h + w) % 2 == 0){
                        System.out.print("#");
                    }else{
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 34612
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	ll a, b, c, x;
	cin >> a >> b >> c >> x;
	ll res = 0;
	REP(i, a+1) REP(j, b+1) REP(k, c+1) if (500*i + 100*j + 50*k == x) ++res;
	cout << res << endl;
	return 0;
}
 

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

using namespace std;

#define int long long

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

	int n;
	cin >> n;
	int ans = 0;
	//x < m
	//x * m + x == n
	//x * (m + 1) == n
	auto relax_x = [&](int x) {
		int m = n / x  - 1;
		if (x < m) {
			ans += m;
		}
	};
	for (int i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			relax_x(i);
			if (i * i < n) relax_x(n / i);
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3196
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <functional>
using namespace std;

int main(void) {
	long int N;
	string s;
	cin >> N;
	if (N == 0) {
		cout << "0" << endl;
		return 0;
	}
	long int p = 1;
	for (int i = 1;N != 0 ;i++) {
		p *= -2;
		if (N % p == 0)
			s.append("0");
		else {
			s.append("1");
			N -= (p/(-2));
		}

	}
	reverse(s.begin(), s.end());

	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int num[4],n;
int main(){
	int i,j;
	for(i=0;i<3;i++){
		scanf("%d",&num[i]);
	}
	scanf("%d",&n);
	sort(num,num+3);
	int sum=num[2];
	while(n--){
		sum*=2;
	}
	sum+=(num[0]+num[1]);
	printf("%d\n",sum);
	return 0;
}

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

const int MAXN = 50;
const int MAXM = 100;
const int MOD = int(1E9) + 7;

int pow_mod(int b, int p) {
	int ret = 1;
	while( p ) {
		if( p & 1 ) ret = 1LL*ret*b%MOD;
		b = 1LL*b*b%MOD;
		p >>= 1;
	}
	return ret;
}

int N, M, K;

int s[MAXM + 5][MAXM + 5], fct[MAXM + 5];
void init() {
	s[0][0] = 1;
	for(int i=1;i<=MAXM;i++)
		for(int j=1;j<=i;j++)
			s[i][j] = (s[i-1][j-1] + 1LL*(i-1)*s[i-1][j]%MOD) % MOD;
	fct[0] = 1;
	for(int i=1;i<=MAXM;i++)
		fct[i] = 1LL*fct[i-1]*i%MOD;
}

struct edge{
	int to; edge *nxt;
}edges[2*MAXM + 5], *adj[MAXM + 5], *ecnt = edges;
void addedge(int u, int v) {
	edge *p = (++ecnt);
	p->to = v, p->nxt = adj[u], adj[u] = p;
	p = (++ecnt);
	p->to = u, p->nxt = adj[v], adj[v] = p;
}

int f[2][MAXM + 5];
void copy() {
	for(int i=0;i<=M;i++)
		f[1][i] = f[0][i], f[0][i] = 0;
}
void update(int x, int k) {
	for(int i=x;i<=M;i++)
		f[0][i] = (f[0][i] + 1LL*f[1][i-x]*k%MOD)%MOD;
}

int gcd(int x, int y) {
	return y == 0 ? x : gcd(y, x % y);
}

int dfn[MAXM + 5], low[MAXM + 5], dcnt;
int stk[MAXM + 5], Gsiz, tp;
void dfs(int x, int fa) {
	dfn[x] = low[x] = (++dcnt);
	for(edge *p=adj[x];p;p=p->nxt) {
		if( p->to == fa ) continue;
		if( !dfn[p->to] ) {
			stk[++tp] = p->to, dfs(p->to, x);
			if( low[p->to] >= dfn[x] ) {
				int cnt = 0, tot = 0;
				do {
					if( stk[tp] == -1 ) cnt++;
					tot++;
				}while( stk[tp--] != p->to );
				copy();
				if( cnt == 0 ) update(1, 1);
				else if( cnt == 1 ) {
					for(int i=1;i<=tot;i++)
						update(gcd(tot, i), 1);
					Gsiz = 1LL*Gsiz*tot%MOD;
				}
				else {
					for(int i=1;i<=tot;i++)
						update(i, s[tot][i]);
					Gsiz = 1LL*Gsiz*fct[tot]%MOD;
				}
			}
			low[x] = min(low[x], low[p->to]);
		}
		else {
			low[x] = min(low[x], dfn[p->to]);
			if( dfn[p->to] < dfn[x] )
				stk[++tp] = -1;
		}
	}
}
int main() {
	init(), scanf("%d%d%d", &N, &M, &K);
	for(int i=1;i<=M;i++) {
		int u, v; scanf("%d%d", &u, &v);
		addedge(u, v);
	}
	Gsiz = f[0][0] = 1;
	for(int i=1;i<=N;i++)
		if( !dfn[i] ) dfs(i, 0);
	int ans = 0;
	for(int i=0,t=1;i<=M;i++,t=1LL*t*K%MOD)
		ans = (ans + 1LL*t*f[0][i]%MOD) % MOD;
	printf("%lld\n", 1LL*ans*pow_mod(Gsiz, MOD-2)%MOD);
}

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

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

 int main() {
   int N, a;
   cin >> N;
   vector<int> t(N + 1), x(N + 1), y(N + 1);
   t.at(0) = 0;
   x.at(0) = 0;
   y.at(0) = 0;

   for (int i = 1; i <= N; i++) cin >> t.at(i) >> x.at(i) >> y.at(i);

   string ans = "Yes";
   rep(i, N) {
     if (abs(x.at(i + 1) - x.at(i)) + abs(y.at(i + 1) - y.at(i)) > t.at(i + 1) - t.at(i) || (t.at(i + 1) - t.at(i)) % 2 != (abs(x.at(i + 1) - x.at(i)) + abs(y.at(i + 1) - y.at(i))) % 2) {
       ans = "No";
       break;
     }
   }

   cout << ans << endl;
 }


Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e3+10;
vector <int> g[N];
ll dp[N],sz[N],dis[N],val[N];
bool can[N];
void dfs(ll v,ll p){
    sz[v]=val[v];
    vector <pii> a;
    for (auto u : g[v]){
        if (u==p) continue;
        dfs(u,v);
        sz[v]+=sz[u];
        dis[v]+=dis[u]+sz[u];
        a.pb({dis[u]+sz[u],dp[u]});
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    if (!a.size()) return ;
    ll w=0;
    for (int i=1;i<a.size();i++){
        w+=a[i].F;
    }
    if (w+2*a[0].S>=a[0].F && (w+a[0].F)%2==0){
        w+=a[0].F;
        dp[v]=w/2;
        can[v]=1;
        return;
    }
    if (w+2*a[0].S>=a[0].F){
        w+=a[0].F;
        w--;
        dp[v]=w/2;
        return;
    }
    w+=a[0].S;
    dp[v]=w;
    return ;
}
int32_t main(){
    ll n;
    string s;
    cin >> n >> s;
    for (int i=0;i<n;i++){
        if (s[i]=='1'){
            val[i+1]=1;
        }
    }
    for (int i=0;i<n-1;i++){
        ll u,v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    ll ans=(ll)1e15;
    for (int i=1;i<=n;i++){
        memset(dis,0,sizeof dis);
        memset(sz,0,sizeof sz);
        memset(dp,0,sizeof dp);
        memset(can,0,sizeof can);
        dfs(i,i);
        if (dis[i]%2==0 && can[i]){
            ans=min(ans,dis[i]/2);
        }
    }
    if (ans==(ll)1e15){
        kill(-1);
    }
    kill(ans);


}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
const int MaxN = 1e5 + 2;
const int Pt = 1e9 + 7;
typedef long long LL;
using namespace std;
int vis[MaxN + 5] , a[MaxN + 5];
LL f[MaxN + 5] , di[MaxN + 5];
int n;
LL qwe(LL x , LL y){
	LL res = 1;
	while(y != 0){
		if(y & 1) res = res * x % Pt;
		y >>= 1;
		x = x * x % Pt;
	}
	return res;
}
void Init(){
	f[0] = 1;
	for(LL i = 1;i <= MaxN;i++) f[i] = f[i - 1] * i % Pt;
	di[MaxN] = qwe(f[MaxN] , Pt - 2);
	for(LL i = MaxN;i >= 2;i--) di[i - 1] = di[i] * i % Pt;
	di[0] = 1;
}
int main()
{
	Init();
	while(~scanf("%d" , &n)){
		int tmp = 0;
		memset(vis , 0 , sizeof(vis));
		for(int i = 1;i <= n + 1;i++){
			scanf("%d" , &a[i]);
			vis[a[i]]++;
			if(vis[a[i]] == 2) tmp = a[i];
		}
		int l = 0 , r = 0;
		for(int i = 1;i <= n + 1;i++){
			if(a[i] == tmp) {
				if(l == 0) l = i;
				else r = i;
			}
		}
		int res = l + n - r;
		LL ans = 0;
		for(int i = 1;i <= n + 1;i++){
			if(res - i + 1 >= 0) ans = (Pt + f[n + 1] * di[n + 1 - i] % Pt * di[i] % Pt - f[res] * di[res - i + 1] % Pt * di[i - 1] % Pt) % Pt; 
			else ans = f[n + 1] * di[n + 1 - i] % Pt * di[i] % Pt;
			printf("%lld\n" , ans);
		}
	}
}

Measured memory_bytes: 3456
// https://atcoder.jp/contests/abc169/tasks/abc169_b
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> v(N);
    bool zero = false;
    REP(i, N) {
        cin >> v[i];
        if (v[i] == 0) {
            zero = true;
        }
    }
    if (zero) {
        cout << 0 << endl;
    } else {
        mp::cpp_int mul = 1;
        for (auto &x : v) {
            mul *= x;
            if (mul > (int)1e18) {
                cout << -1 << endl;
                return 0;
            }
        }
        cout << mul << endl;
    }

    return 0;
}


Measured memory_bytes: 3968
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner kbd = new Scanner(System.in);
	
	while(kbd.hasNext()) {
	    int n = kbd.nextInt();
	    if(n == 1) break;
	    search(n);
	}
    }

    static void search(int n) { //月曜土曜素因数を捜索
	System.out.print(n + ":");
	int i=6;
	int a = 2;
	while(i<=n) {
	    if(n%i==0 && checkI(i)) System.out.print(" " + i);
	    i += a;
	    if(a==2) a=5;
	    else a=2;
	}
	System.out.println();
    }

    static boolean checkI(int s) { //割り切れた数は「月曜土曜素数」？
	int t = 6;  //最小の月曜土曜素数
	int a = 2;  //月曜／土曜シフト用
	while(t < s) {
	    if(s%t == 0) return false;
	    t += a;
	    if(a==2) a=5;
	    else a=2;
	}
	return true;
    }	
}

Measured memory_bytes: 12000
def ans():
  N, M = map(int,input().split())
  X = sorted(list(map(int,input().split())))
  tmp = sorted([X[i+1] - X[i] for i in range(M-1)])
  if(M <= N):
    print(0)
  else:
    print(sum(tmp[:M-N]))
ans()

Measured memory_bytes: 13968
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
 	return r;
}

void solve()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int res = 0, bal = 0;
	rep(i, sz(s)) (bal += (s[i] == 'I' ? 1 : -1)), ckmax(res, bal);
	cout << res;
} 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}


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

using namespace std;

const int N = 2345, mod = 1e9 + 7;

void add(int& x, int y) {
  x += y;
  if (x >= mod) {
    x -= mod;
  }
}

int n, m, k, dp[N << 1][N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  dp[0][0] = 1;
  int answer = 0;
  for (int i = 1; i <= (n + m - 1) / (k - 1); ++i) {
    for (int j = 0; j <= m; ++j) {
      for (int l = 1; l <= min(j, k - 1); ++l) {
        add(dp[i][j], dp[i - 1][j - l]);
      }
      if (j % (k - 1) == m % (k - 1) && (k - 1) * i - j < n && ((k - 1) * i - j) % (k - 1) == (n - 1) % (k - 1)) {
        add(answer, dp[i][j]);
      }
      add(dp[i][j], dp[i - 1][j]);
    }
  }
  cout << answer << '\n';
  return 0;
}

Measured memory_bytes: 37120
#include<cmath>
#include<iostream>
#define ll long long
using namespace std;
int main(){
	ll n,h[100001],best[100001];
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>h[i];
		if(i==2) best[2]=abs(h[2]-h[1]);
		if(i==3) best[3]=min(abs(h[3]-h[1]),best[2]+abs(h[3]-h[2]));
		if(i>=4) best[i]=min(best[i-1]+abs(h[i]-h[i-1]),best[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<best[n];
}

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

int main() {
	char c;
	cin >> c;

	cout << (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' ? "vowel" : "consonant") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long Q, std::vector<long long> A, std::vector<long long> B) {
    rep(i, Q) {
        ll a = A[i], b = B[i];
        if (a == b) {
            cout << 2 * a - 2 << endl;
            continue;
        }
        auto check = [&](ll d) {
            ll m;
            m = (d + 1) / 2 * ((d + 1) - (d + 1) / 2);
            if (m < a * b)
                return true;
            else
                return false;
        };

        // 二分探索
        ll left = 0, right = 2001000001;
        while (right - left > 1) {
            ll mid = (left + right) >> 1LL;
            if (check(mid))
                left = mid;
            else
                right = mid;
        }
        cout << left - 1 << endl;
    }
}

int main() {
    long long Q;
    scanf("%lld", &Q);
    std::vector<long long> A(Q);
    std::vector<long long> B(Q);
    for (int i = 0; i < Q; i++) {
        scanf("%lld", &A[i]);
        scanf("%lld", &B[i]);
    }
    solve(Q, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [0]*N
B = [0]*N
for i in range(N):
	A[i], B[i] = map(int, input().split())

S = 0
ans = 'Yes'

L = sorted(range(N), key=lambda k: B[k])
for j in L:
	S += A[j]
	if S > B[j]:
		ans = 'No'
		break

print(ans)	

Measured memory_bytes: 28568
rank = []
p = []
w = []

def makeSet(x):
    p.append(x)
    rank.append(0)
    w.append(0)


def union(x, y):
    link(findSet(x), findSet(y))


def link(x, y):
    if rank[x] > rank[y]:
        p[y] = x

    else:
        p[x] = y
        if rank[x] == rank[y]:
            rank[y] = rank[y] + 1


def findSet(x):
    if p[x] == x:
        return x

    i = findSet(p[x])
    w[x] += w[p[x]]
    p[x] = i
    return i


def same(x, y):
    return findSet(x) == findSet(y)

def relate (x,y,z):
    i = findSet(x)
    j = findSet(y)

    if rank[i] < rank[j]:
        p[i] = j
        w[i] = z - w[x] + w[y]
    else:
        p[j] = i
        w[j] = -z - w[y] + w[x]
        if rank[i] == rank[j]:
            rank[i] += 1

n, q = map(int, input().split())
for i in range(n):
    makeSet(i)
for i in range(q):
    com, *cmd = map(int, input().split())
    if com == 0:
        relate(cmd[0], cmd[1],cmd[2])
    else:
        x, y = cmd
        if same(x, y):
            print(w[x] - w[y])
        else:
            print("?")



Measured memory_bytes: 12072
import java.io.*;
class Main
{
public static void main(String args[])throws IOException
{
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int x,sum=0;
    String n=br.readLine();
    for(int i=0;i<n.length();i++)
      sum+=n.charAt(i)-'0';
    if(sum%9==0)
        System.out.println("Yes");
        else
             System.out.println("No");
}
}

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

int main()
{
	
		int m[100000+5]={0};
		int max1=0;
		int a;
		int n;
		cin>> n;
		for(int i=0;i<n;i++){
			cin >> a;
			m[a+1]++;
			max1=max(m[a+1],max1);
			if(a!=0){
				m[a-1]++;
				max1=max(m[a-1],max1);
			}
			m[a]++;
			max1=max(m[a],max1);
		}
		cout << max1 << endl;
	
 } 

Measured memory_bytes: 4000
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
#define vi vector<int>
#define pb push_back
using namespace std;
const int N=1e5+5;
int n,m,a[N];
bool f[N];
ll dp[N];
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)cin>>a[i],f[a[i]]=true;
	dp[0]=1;
	dp[1]=1;
	for(int i=2;i<=n;i++)
	{
		dp[i]=dp[i-1]+dp[i-2];
		if(f[i-1])dp[i]-=dp[i-1];
		if(f[i-2])dp[i]-=dp[i-2];
		dp[i]%=(ll)(1e9+7);
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1536
s = input()[::-1]
n = len(s)

a = [0]*2019
a[0] = 1
count = 0
val = 1
current = 0
for c in s:
    current = (current + val * int(c)) % 2019
    count += a[current%2019]
    a[current%2019] += 1
    val = val * 10 % 2019

print(count)

Measured memory_bytes: 9316
#include <stdio.h>

int main (){
	//belum selesai masalah kalau input angka 0
	int A,B,x,y,z;
	scanf("%d %d",&A,&B);
	x=A+B;
	y=A-B;
	z=A*B;
	if(x>y && x>z){
		printf("%d\n",x);
	}
	else if(y>x && y>z){
		printf("%d\n",y);
	}
	else if(z>y && z>x){
		printf("%d\n",z);
	}
	else if(A==0 & B==0){
		printf("0\n");
	}
	else if(A==0||B==0){
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 888
N = int(input())
A = list(map(int,input().split()))
count = 0
break1 = 0
for i in range(1000000000):
    j = 0
    for j in range(N):
        if A[j]%2 == 0:
            A[j] = int(A[j]/2)
        else:
            break1 = 1
            break
    if break1 == 1:
        break
    count+=1
print(count)

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

#define ll long long
#define endl "\n"
const int m = 1e9 + 7;

ll bin_pow(ll a, ll n, ll p){
	a %= p;
	ll ans = 1;
	while(n){
		if(n&1){
			ans = (ans * a) % p;
		}
		a = (a * a) % p;
		n >>= 1;
	}
	return ans%p;
}

ll choose(ll n, ll a, ll p){
	if(a > n)
        return 0;
        
    ll num = 1, dem = 1;
    for(ll i = a; i > 0; i--){
        num = (num * n) % p;
        dem = (dem * a) % p;
        n--, a--;
    }
    
    ll res = (num * bin_pow(dem, p-2, p))%p;
    return res;
}

int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans=(bin_pow(2, n, m)%m-1+m)%m;
	ll a1=choose(n, a, m);
	ll b1=choose(n, b, m);
	ans = (ans%m - a1%m + m)%m;
	ans = (ans%m - b1%m + m)%m;
	cout<<ans<<endl;
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;


void solve() {
	unsigned I, O, T, J, L, S, Z; cin >> I >> O >> T >> J >> L >> S >> Z;
	ULL ans = 0;
	ans += O;
	if(I>0 && J>0 && L>0)
		if (I % 2 + J % 2 + L % 2 >= 2) {
			ans += 3;
			I--; J--; L--;
		}
	ans += (I / 2 * 2 + J / 2 * 2 + L / 2 * 2);
	cout << ans << endl;
}


int main() {

	solve();

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

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

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

double cut(int r,int n,int i){
    double res=r*r-(r-r*(double)i/(double)n)*(r-r*(double)i/(double)n);
    return pow(res,0.5)*2;
}

int main(){
    int a,b;
    vector<int> c(4,0);
    for(int i=0;i<3;i++){
        cin>>a>>b;
        a--;b--;
        c[a]++;c[b]++;
    }
    for(int i=0;i<4;i++){
        if(c[i]==3){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
using ll = long long;
using P = pair<int,int>;

int main(){
	int n,m;
	map<string,int> mp;
	cin>>n;
	string s[n];
	rep(i,n){
		cin>>s[i];
		mp[s[i]]+=1;
	}
	cin>>m;
	string t[m];
	rep(i,m){
		cin>>t[i];
		mp[t[i]]-=1;
	}
	int mx=0;
	rep(i,n){
		mx=max(mp[s[i]],mx);
	}
	rep(i,m){
		mx=max(mp[t[i]],mx);
	}
	puts(mx);
	
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	int N;
	cin >> N;

	int minNum = 1000000001;
	vector<int> A;
	for(int i=0; i<N; i++) {
		int a;
		cin >> a;
		A.push_back(a);
		minNum = min(minNum, a);
	}
	bool flg = true;
	while(flg && minNum != 1) {
		flg = false;
		int tmpMin = 1000000001;
		for(int i=0; i<A.size(); i++) {
			int mod = A[i]%minNum;
			if(mod == 0) continue;
			tmpMin = min(tmpMin, mod);
		}
		if(tmpMin < minNum) {
			minNum = tmpMin;
			flg = true;
		}
	}
	cout << minNum;

	return 0;
}



Measured memory_bytes: 892
//B
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){

    int N;
    cin >> N;
    
    set<string> s;
    string w;
    cin >> w;
    s.insert(w);
    string old = w;
    for(int i=1; i<N; i++){
        cin >> w;
        if(s.count(w) == 1){
            cout << "No" << endl;
            return 0;
        }
        if(old[old.size()-1] != w[0]){
            cout << "No" << endl;
            return 0;
        }
        s.insert(w);
        old = w;
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

	if (A % 3 == 0) {
		cout << "Possible" << endl;
	}
	else if (B % 3 == 0) {
		cout << "Possible" << endl;
	}
	else if ((A + B) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}

}


Measured memory_bytes: 256
#include<stdio.h>
int a,b,cnt,flg[50][50],x,y;
int main(void)
{
	int n,i,j;
	while(1){
		scanf("%d%d",&a,&b);
		if(a==0&&b==0) break;
		scanf("%d",&n);
		for(i=0;i<a;i++){
			for(j=0;j<b;j++) flg[i][j]=0;
		}
		for(i=0;i<n;i++){
			scanf("%d%d",&x,&y);
			flg[x][y]=1;
		}
		cnt=0;
		func(1,1);
		printf("%d\n",cnt);
	}
	return 0;
}
int func(int x1,int y1){
	// printf("x1=%d y1=%d\n",x1,y1);
	if(x1==a&&y1==b) cnt++;
	else if(x1<=a&&y1<=b){
		if(flg[x1+1][y1]!=1&&x1+1<=a) func(x1+1,y1);
		if(flg[x1][y1+1]!=1&&y1+1<=b) func(x1,y1+1);
	}
}


Measured memory_bytes: 1976
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
const int mod=1e9+7;

int partition(int a[], int l, int r){
	int i = l-1;
	for(int j=0; j<r; j++){
		if(a[j] <= a[r]){
			i++;
			swap(a[j], a[i]);
		}
	}
	swap(a[r], a[i+1]);
	return i+1;
}

int main(){
	int n;
	cin >> n;
	int a[100000];
	for(int i=0; i<n; i++)
		cin >> a[i];
	int p = partition(a, 0, n-1);
	for(int i=0; i<p; i++){
		if(i)
			cout << ' ';
		cout << a[i];
	}
	cout << " [" << a[p] << ']';
	for(int i=p+1; i<n; i++)
		cout << ' ' << a[i];
	cout << endl;
	return 0;
}


Measured memory_bytes: 3396
#include<iostream>
#include<vector>
#include<iomanip>
using namespace std;
 
int main(){
  int N,K;
  cin>>N>>K;
  double p[N];
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  
  double ans=0;
  for(int i=0;i<K;i++){
    ans=ans+p[i];
  }
  double d=ans;
  for(int i=0;i<N-K;i++){
    d=d-p[i]+p[K+i];
    ans=max(ans,d);
  }
  ans=(ans+K)/2;
  cout<<fixed<<setprecision(2);
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

int dp[2][1005],fc[1005],in[1005];

int C(int n,int r){
	if(n<r){
		return 0;
	}
	return mul(mul(fc[n],in[r]),in[n-r]);
}

int calc(int count,int size){
	return mul(mul(fc[count*size],in[count]),powz(in[size],count));
}

void solve(){
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	dp[0][n]=1;
	for(int i=a;i<=b;i++){
		for(int set=c;set<=d;set++){
			if(set*i>n){
				break;
			}
			int cnst=calc(set,i);
			for(int last=n;last>=set*i;last--){
				add(dp[1][last-set*i],mul(mul(cnst,C(last,set*i)),dp[0][last]));
			}
		}
		for(int j=0;j<=n;j++){
			add(dp[0][j],dp[1][j]);
			dp[1][j]=0;
		}
	}
	cout<<dp[0][0];
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	fc[0]=1;
	for(int i=1;i<=1000;i++){
		fc[i]=mul(fc[i-1],i);
	}
	in[1000]=powz(fc[1000],mod-2);
	for(int i=999;i>=0;i--){
		in[i]=mul(in[i+1],i+1);
	}
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){

int A, B, C;
scanf("%d\n%d",&A , &B);
if(A==1&&B==2){
	printf("3");
} else if(A==2&&B==3){
	printf("1");
} else if(A==3&&B==1){
	printf("2");
} else if(A==2&&B==1){
	printf("3");
} else if(A==3&&B==2){
	printf("1");
} else if(A==3&&B==1){
	printf("2");
} else if(A==1&&B==3){
	printf("2");
}
return 0;

}

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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;


int suf[maxn][27];
int pre[27];
string s1,s2;


void solve(){
    mem(pre,-1);
    cin>>s1>>s2;
    int len1 = s1.length();
    int len2 = s2.length();
    for(int i=0;i<26;i++) suf[len1-1][i] = -1;
    for(int i=0;i<len1;i++){
        if(pre[s1[i] - 'a'] == -1){
            pre[s1[i] - 'a'] = i;
        }
    }
    for(int i=len1-2;i>=0;i--){
        for(int j=0;j<26;j++){
            if(s1[i+1]-'a' == j){
                 suf[i][j] = i+1;
            }else{
                suf[i][j] = suf[i+1][j];
            }
        }
    }
    long long res = 0;

    int p = 0,flag  = 1;
    while(p < len2){
        int x = pre[s2[p++]-'a'];
    //    printf("x = %d ,res = %lld\n", x,res);
        if(x == -1){
            flag = 0;break;
        }
        res += x+1;
     //   printf("!res = %lld\n",res );
        while(p<len2){
            int xx = x;
            x = suf[xx][s2[p]-'a'];
            if(~x){
                res += x-xx;
            }else{
                // printf("len1 = %d ,xx = %d\n",len1,xx );
                res += len1-1 - xx;
                break;
            }
            ++p;
            //printf("res = %lld\n",res );
        }
      //  ++p;
    }
    if(flag){
        printf("%lld\n",res );
    }else{
        printf("-1\n");
    }

    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
  //  printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Measured memory_bytes: 11136
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::pair;using std::set;using std::string;using std::vector;
using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;
#define ff first
#define ss second
#define pb emplace_back
template<typename T>void _dbg(const char*_s,T _h){cerr<<_s<<" = "<<_h<<"\n";}
template<typename T,typename...Ts>void _dbg(const char*_s,T _h,Ts..._t){int _b=0;while(((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',')cerr<<*_s++;cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);}
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...) 
#endif
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#endif
}}init;

const int MAXN = 2e5 + 1;
int a[MAXN], w[MAXN], c[MAXN];

int32_t main() {
    
    int n, mx = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        w[a[i]] = i;
        if (w[a[i] - 1]) 
            c[a[i]] = c[a[i] - 1] + 1;
        else
            c[a[i]] = 1;
        mx = max(mx, c[a[i]]);
    }

    cout << n - mx << '\n';
    

    return 0;
}


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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

#define rep(i,n) for(i=1;i<=n;i++)
#define Rep(i,n) for(i=0;i<n;i++)
#define For(i,a,b) for(i=a;i<=b;i++)

#define pb(x) push_back(x)
#define sz(x) x.size()

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define eps 1e-9

#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define ss(str) scanf("%s",str)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define piii(x,y,z) printf("%d %d %d",x,y,z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define plll(x,y,z) printf("%lld %lld %lld",x,y,z)
#define NL printf("\n")
#define Max 300005
#define INF 1e9
#define mod 1000000007
#define un(x) x.erase(unique( x.begin() , x.end() ), x.end())

#define FI freopen("in.txt","r",stdin)

#define D(x) cout << #x << " = " << x << endl
#define DD(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl
#define DDD(x,y,z) cout << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << endl

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

int setb(int n,int pos) { return n=n | (1 << pos); }
int resb(int n,int pos) { return n=n & ~(1 << pos); }
bool checkb(int n,int pos) { return (bool)(n & (1 << pos)); }

int n,ara[105];
vector <int> ans[2];
void solve1(int x)
{
	int i, idx;
	rep(i,n) if( ara[i] == x ) idx = i;
	rep(i,n) 
	{
		ara[i] += ara[idx];
		ans[0].pb(idx);
		ans[1].pb(i);
	}
	rep(i,n-1)
	{
		ara[i+1] += ara[i];
		ans[0].pb(i);
		ans[1].pb(i+1);
	}
	int len = sz(ans[0]);
	printf("%d\n",len);
	for(int i = 0; i < len; i++)
	{
		printf("%d %d\n",ans[0][i],ans[1][i]);
	}
}

void solve2(int x)
{
	int i, idx;
	rep(i,n) if( ara[i] == x ) idx = i;
	rep(i,n) 
	{
		ara[i] += ara[idx];
		ans[0].pb(idx);
		ans[1].pb(i);
	}
	for(int i = n; i > 1; i--)
	{
		ara[i-1] += ara[i];
		ans[0].pb(i);
		ans[1].pb(i-1);
	}
	int len = sz(ans[0]);
	printf("%d\n",len);
	for(int i = 0; i < len; i++)
	{
		printf("%d %d\n",ans[0][i],ans[1][i]);
	}
}

void show()
{
	int i;
	rep(i,n) printf("%d ",ara[i]);
	NL;
}

int main()
{
	int i,mn = 1e7, mx = -1e7;
	si(n);
	rep(i,n) si(ara[i]), mn = min(mn,ara[i]), mx = max(mx,ara[i]);
	if( abs(mx) >= abs(mn) ) solve1(mx);
	else solve2(mn);
	//show();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    deque<ll> b;

    for(ll i=0; i<n; i++){
        ll a; cin >> a;
        if(i%2 == 0) b.push_back(a);
        else b.push_front(a);
    }

    if(n%2 == 0) for(ll i=0; i<n; i++) cout << b[i] << ((i == n-1) ? endl : " ");
    else for(ll i=n-1; i>=0; i--) cout << b[i] << ((i == 0) ? endl : " ");
}

Measured memory_bytes: 3840
x,y = map(int,input().split())
l = [1,3,5,7,8,10,12]
m = [4,6,9,11]
if x==y:
    print('Yes')
    exit()
if x==2 or y==2:
    print('No')
    exit()
if x in l and y in l:
    print('Yes')
elif x in m and y in m:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
using namespace std;

bool isPrimeNum(int num){
    if(num!=2 && num%2==0)return false;
    for(int i=3;i<=sqrt(num);i+=2){
        if(num%i == 0)return false;
    }
    return true;
}

int n;

int main(){
    cin>>n;
    int num,counter=0;
    for(int i=0;i<n;++i){
        cin>>num;
        if(isPrimeNum(num))counter++;
    }
    cout<<counter<<endl;
    return 0;
}



Measured memory_bytes: 3104
import java.util.Scanner;

class Main {
public static void main(String[] args) {
 Scanner stdIn = new Scanner(System.in);
  int a = stdIn.nextInt();
  int b = stdIn.nextInt();
  if(a * b % 2 == 0) {
    System.out.println("Even");
  } else {
    System.out.println("Odd");
  }
}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
using namespace std;

typedef long long ll;

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

//--------------------

ll N;
ll A[100001];
ll c1, c2;

int main() {

  cin >> N;
  rep(i, N) {
    cin >> A[i];
    if(A[i]%4==0) ++c1;
    else if(A[i]%2==0) ++c2;
  }

  if(c1+(c2/2)>=N/2) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N = 2e5+5;
const int B = 13;
int cnt[55][55];
inline void read(){
	ll number=0;int P=0;
	int u=0;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c=='.'||(c>='0' && c<='9')){
		if(c=='.')u=1;
		else{
			if(u)++P;
			number=number*10ll+c-'0';
		}
		c=getchar();
	}
	int two=-P;
	while(number%2==0)two++,number/=2;
	int five=-P;
	while(number%5==0)number/=5,five++;
	two = min(two, 13),five = min(five, 13);
	cnt[B+two][B+five]++;
	// cout << two << ":" << five << endl;
}

int main()
{
	ll ans=0;
	int n;cin >> n;
	for(int i=1;i<=n;i++)read();
	for(int i=-10;i<=13;i++){
		for(int j=-10;j<=13;j++){
			for(int k=-10;k<=13;k++){
				for(int l=-10;l<=13;l++)if(pii(i,j) <= pii(k,l)){
					if(i+k>=0 && j+l>=0){
						if(pii(i,j)==pii(k,l)){
							ans+=1ll*cnt[B+i][B+j]*(cnt[B+i][B+j]-1)/2;
						}else{
							ans+=1ll*cnt[B+i][B+j]*cnt[B+k][B+l];
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>

using namespace std;

int main() {
    double a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    a *= 100;
    b *= 100;
    double dense = -1, tot = 0, totwat = 0, totsug = 0;
    for(int i=0;a*i<=f;i++) {
        for(int j=0;a*i+b*j<=f;j++) {
            for(int k=0;a*i+b*j+c*k<=f;k++) {
                for(int l=0;a*i+b*j+c*k+d*l<=f;l++) {
                    if((a*i+b*j)*e/100 < (c*k+d*l)) break;
                    double den = (c*k+d*l) / (a*i+b*j+c*k+d*l);
                    if(den > dense) {
                        dense = den;
                        tot = a*i+b*j+c*k+d*l;
                        totsug = c*k + d *l;
                    }
                }
            }
        }
    }
    cout << tot << " " << totsug << endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy
# sys.setrecursionlimit(1000000)

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(input())
    an = [int(input()) for i in range(n)]
    assert len(an) == n
    sublen = [0 for i in range(n + 1)]
    for i in range(n):
        a1 = an[i]
        sublen[a1] = sublen[a1 - 1] + 1
    res = max(sublen)
    print(n - res)

main()


Measured memory_bytes: 19472
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
signed main(){
    int n, m;
    cin >> n >> m;
    vi x(m);
    rep(i, m)
    {
        cin >> x[i];
    }
    if(n>=m){
        cout << 0 << endl;
    }else{
        sort(all(x));
        int alllength = 0;
        vi dis;
        rep(i, m - 1)
        {
            dis.pb(x[i + 1] - x[i]);
            alllength += x[i + 1] - x[i];
        }
        sort(dis.rbegin(), dis.rend());
        rep(i,n-1){
            alllength -= dis[i];
        }
        cout << alllength << endl;
    }
    return 0;
}

Measured memory_bytes: 2168
import math

n,d = map(int,input().split())
a = [[0 for i in range(d)] for j in range(n)]

for i in range(n):
     b = list(map(int,input().split()))
     for j in range(d):
          a[i][j] = b[j]
     b.clear()

cou = 0
ans = 0

for i in range(n):
     for j in range(i+1,n):
          for k in range(d):
               cou += abs(a[i][k]-a[j][k])**2
          if cou**(1/2)%1 == 0.0:
               ans += 1
          cou = 0
print(ans)




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

int main() {

  int N, K;
  cin >> N >> K;
  int l[N];
  for (int i = 0; i < N;i++)
  {
    cin >> l[i];
  }

  sort(l, l + N);
  for (int i = N - 2; i > N - 1 - K;i--)
  {
    l[N - 1] += l[i];
  }

  cout << l[N - 1] << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    char[] arr = sc.next().toCharArray();
    Set<Character> set = new TreeSet<>();
    for (char c : arr) {
      set.add(c);
    }

    for (int i = (int) 'a'; i <= (int) 'z'; i++) {
      if (!set.contains((char) i)) {
        System.out.println((char) i);
        return;
      }
    }
    System.out.println("None");
  }
}


Measured memory_bytes: 23908
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

struct Timer {
  Timer() { reset(); }
  void reset() { beg = chrono::high_resolution_clock::now(); }
  ll elapsed() const {
    chrono::high_resolution_clock::time_point en = chrono::high_resolution_clock::now();
    return chrono::duration_cast<chrono::milliseconds>(en - beg).count();
  }
private:
  chrono::high_resolution_clock::time_point beg;
} timer;

struct Xor128 {
  int rand() {
    unsigned t = x ^ (x << 11);
    x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
    return static_cast<int>(w);
  }
  int rand(int ub) {
    int res = rand() % ub;
    return res < 0 ? res + ub : res;
  }
  int rand(int lb, int ub) { return lb + rand(ub - lb); }
  ll randll() {
    unsigned long long res = static_cast<unsigned long long>(rand()) << 32;
    return static_cast<ll>(res | rand());
  }
  ll randll(ll ub) {
    ll res = randll() % ub;
    return res < 0 ? res + ub : res;
  }
  ll randll(ll lb, ll ub) { return lb + randll(ub - lb); }
private:
  unsigned x = 123456789, y = 362436069, z = 521288629, w = static_cast<unsigned>(time(nullptr));
} xor128;

const int D = 365, N = 26;
int c[N], s[D][N];

int calc_score(const vector<int> &t) {
  vector<int> last(N, -1);
  int score = 0;
  REP(d, D) {
    score += s[d][t[d]];
    last[t[d]] = d;
    REP(i, N) score -= c[i] * (d - last[i]);
    cout << score << '\n';
  }
  return max(score + 1000000, 0);
}

int main() {
  {int d; cin >> d;}
  REP(i, N) cin >> c[i];
  REP(i, D) REP(j, N) cin >> s[i][j];
  vector<int> t(D); REP(i, D) cin >> t[i], --t[i];
  calc_score(t);
  return 0;
}


Measured memory_bytes: 3704
X,Y = map(int, input().split())

result = 0
if X == 1:
    if Y == 1:
        result = 300000*2 + 400000
    elif Y == 2:
        result = 300000 + 200000
    elif Y == 3:
        result = 300000 + 100000
    else:
        result = 300000
elif X == 2:
    if Y == 1:
        result = 200000 + 300000
    elif Y == 2:
        result = 200000 + 200000
    elif Y == 3:
        result = 200000 + 100000
    else:
        result = 200000
elif X == 3:
    if Y == 1:
        result = 100000 + 300000
    elif Y == 2:
        result = 100000 + 200000
    elif Y == 3:
        result = 100000 + 100000
    else:
        result = 100000
else:
    if Y == 1:
        result = 300000
    elif Y == 2:
        result = 200000
    elif Y == 3:
        result = 100000
print(result)

Measured memory_bytes: 3064
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var x = int.Parse(line[2]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var r = a.Count(y => y > x);
        var L = a.Length - r;
        Console.WriteLine((Math.Min(r,L)));
    }
}


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

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n, x, ans;
  cin >> n >> x;
  ans = n;
  function<void(ll, ll)> solve = [&](ll x, ll y) {
    ans += 2LL * (y/x) * x; 
    if( !(y % x)) {
      ans -= x;
    } else {
      solve(y % x, x);
    }
  };
  solve(min(x, n - x), max(x, n - x));
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256