akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for(auto v:(V))cout<<v<<" "<<endl
inline int GCD(int a, int b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;

void mmod(ll &x, ll &y)
{
    x = (x + MOD - y) % MOD;
}

int main()
{
    int N;
    cin >> N;
    vvvll ans(4, vvll(4, vll(4, 1)));
    vvvll ansprev(4, vvll(4, vll(4, 1)));
    ans[0][1][2] = ans[1][0][2] = ans[0][2][1] = 0;
    ansprev = ans;
    repb(s, 4, N+1)
    {
        rep(i, 4)
        {
            rep(j, 4)
            {
                rep(k, 4)
                {
                    ans[i][j][k] = (ansprev[0][i][j] + ansprev[1][i][j] + ansprev[2][i][j] + ansprev[3][i][j]) % MOD;
                }
            }
        }
        ans[0][1][2] = 0;
        ans[0][2][1] = 0;
        ans[1][0][2] = 0;
        mmod(ans[1][2][0], ansprev[0][1][2]);
        mmod(ans[1][2][1], ansprev[0][1][2]);
        mmod(ans[1][2][2], ansprev[0][1][2]);
        mmod(ans[1][2][3], ansprev[0][1][2]);
        mmod(ans[1][1][2], ansprev[0][1][1]);
        mmod(ans[2][1][2], ansprev[0][2][1]);
        mmod(ans[3][1][2], ansprev[0][3][1]);
        mmod(ans[1][3][2], ansprev[0][1][3]);
        mmod(ans[2][1][0], ansprev[0][2][1]);
        mmod(ans[2][1][1], ansprev[0][2][1]);
        mmod(ans[2][1][3], ansprev[0][2][1]);
        mmod(ans[0][2][0], ansprev[1][0][2]);
        mmod(ans[0][2][2], ansprev[1][0][2]);
        mmod(ans[0][2][3], ansprev[1][0][2]);
        ansprev = ans;
    }
    ll anssum = 0;
    rep(i, 4)
    {
        rep(j, 4)
        {
            rep(k, 4)
            {
                anssum = (anssum + ans[i][j][k]) % MOD;
                //cout << i << " " << j << " " << k << " " << ans[i][j][k] << endl;
            }
        }
    }
    cout << anssum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int count=0;
    int min=2000000;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    
    for (int i = 0; i < N; i++) {
    if(min>=vec.at(i)){
        min=vec.at(i);
        count++;
    }
    
    }
    cout <<count;
    
}

Measured memory_bytes: 1024
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n, m, q = input_a
a, b, c, d = q.times.map { gets.split.map(&:to_i) }.transpose
base_array = (1..m).to_a
sum = 0
array = base_array.repeated_combination(n).to_a
array.each do |ar|
  tmp = 0
  q.times.each do |i|
    if (ar[b[i]-1] - ar[a[i]-1]) == c[i]
      tmp += d[i]
    end
  end
  if tmp >=sum
    sum = tmp
  end
end
puts sum


Measured memory_bytes: 37544
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#define nmax_def 220000
#define Cmax_def 2200
#define mod 1000000007
using namespace std;
typedef long long ll;

int main() {
	ll i, j;
	ll N, K, A[nmax_def];
	vector<vector<ll>> sA;
	vector<ll> sAnum;
	vector<ll> Anext;
	cin >> N >> K;
	sA.resize(nmax_def);
	sAnum.resize(nmax_def);
	Anext.resize(N);
	for (i = 0; i < nmax_def; i++)
		sAnum[i] = 0;
	for (i = 0; i < N; i++)
	{
		cin >> A[i];
		sA[A[i]].push_back(i);
		sAnum[A[i]]++;
	}
	for (i = 0; i < nmax_def; i++)
	{
		ll sAnumtmp = sAnum[i];
		//cout << i << " " << sAnumtmp << endl;
		for (j = 0; j < sAnumtmp; j++)
		{
			ll jnext = (j + 1) % sAnumtmp;
			//if (i < 10)
				//cout << sA[i][j] << " " << j << " " << jnext << endl;
			Anext[sA[i][j]] = sA[i][jnext];
		}
	}
	j = 1;
	ll sta_tmp = 0;
	//for (i = 0; i < N; i++)
		//cout << Anext[i] << endl;
	//cout << endl;
	while (1)
	{
		ll sta_tmp_tmp = Anext[sta_tmp];
		if (sta_tmp_tmp <= sta_tmp)
			j++; // loop
		sta_tmp = sta_tmp_tmp + 1;
		//cout << sta_tmp << endl;
		if (sta_tmp == N)
			break;
	}
	//cout << j << endl;
	sta_tmp = 0;
	K %= j;
	j = 1;
	if (K == 0)
		sta_tmp = N; // stmpは空
	else
	{
		while (1)
		{
			if (j >= K)
				break;
			ll sta_tmp_tmp = Anext[sta_tmp];
			if (sta_tmp_tmp <= sta_tmp)
				j++;
			sta_tmp = sta_tmp_tmp + 1;
		}
	}
	ll slen_tmp = N - sta_tmp;
	ll stmp[nmax_def];
	for (i = 0; i < N - sta_tmp; i++)
		stmp[i] = A[i + sta_tmp];
	bool s_use[nmax_def];
	bool A_in[nmax_def];
	for (i = 0; i < slen_tmp; i++)
	{
		s_use[i] = 1;
	}
	for (i = 0; i < nmax_def; i++)
	{
		A_in[i] = 0;
	}
	for (i = 0; i < slen_tmp; i++)
	{
		ll stmptmp = stmp[i];
		if (A_in[stmptmp] == 0)
		{
			A_in[stmptmp] = 1;
		}
		else
		{
			//cout << i << endl;
			j = i;
			s_use[j] = 0;
			while (1)
			{
				A_in[stmp[j]] = 0;
				if (s_use[j] && stmp[j] == stmptmp)
				{
					s_use[j] = 0;
					break;
				}
				s_use[j] = 0;
				j--;
			}
			A_in[stmptmp] = 0;
		}
	}

	for (i = 0; i < slen_tmp; i++)
	{
		if (s_use[i])
			cout << stmp[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 19840
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int a, p;
  a = N;
  p = 0;
  while (a > 0) {
    p += a % 10;
      a /= 10;
  }
  if (N % p == 0) {
  cout << "Yes" << endl;
  }
  else {
  cout << "No" << endl;
  }
  }


Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
string s;
char dp[4][100010];
int main(){
	cin>>N>>s;
	dp[0][0]='W';
	dp[0][1]='W';
	dp[1][0]='W';
	dp[1][1]='S';
	dp[2][0]='S';
	dp[2][1]='W';
	dp[3][0]='S';
	dp[3][1]='S';

	for(int i=1;i<N+2;i++){
		for(int j=0;j<4;j++){
			if(dp[j][i]=='S'){
				if(s[i%N]=='o'){
					if(dp[j][i-1]=='S')dp[j][i+1]='S';
					if(dp[j][i-1]=='W')dp[j][i+1]='W';
				}else{
					if(dp[j][i-1]=='S')dp[j][i+1]='W';
					if(dp[j][i-1]=='W')dp[j][i+1]='S';

				}
			}else{
				if(s[i%N]=='o'){
					if(dp[j][i-1]=='S')dp[j][i+1]='W';
					if(dp[j][i-1]=='W')dp[j][i+1]='S';
				}else{
					if(dp[j][i-1]=='S')dp[j][i+1]='S';
					if(dp[j][i-1]=='W')dp[j][i+1]='W';

				}
			}
		}
	}

	for(int i=0;i<4;i++){
		if(dp[i][0]==dp[i][N] && dp[i][1]==dp[i][N+1]){
			for(int j=0;j<N;j++){
				cout<<dp[i][j];
			}
			return 0;
		}

	}
	cout<<-1<<endl;


	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <math.h>
#include <string>
#include <string.h> 
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cassert>
using namespace std;
#define MAX 200000
#define rep(i, n) for(int i = 0;i < n;i++)
#define IN(n) scanf("%d",&n);
#define OUT(n) printf("%d\n",n);
#define IN2(n,k) scanf("%d%d",&n,&k);
#define OUT2(n,k) printf("%d%d\n",n,k);
#define IN3(n,k,s) scanf("%d%d%d",&n,&k,&s);
#define OUT3(n,k,s) printf("%d%d%d\n",n,k,s);

int main(){
    int a,b,c,sum=0;
    IN3(a,b,c);
    for(int i=0;i<101;i++){
        if((b*i+c)%a==0){
            cout<<"YES"<<endl;
            return 0;
        }        
    }
    cout<<"NO"<<endl;
    return 0;
}

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

typedef long long ll;
ll A[100005] = { 0 };
int N, sum_4, sum_2;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		if (A[i] % 4 == 0) {
			sum_4++;
		}
		else if (A[i] % 2 == 0) sum_2++;
	}
	if (sum_4 >= N / 2) {
		cout << "Yes" << endl; 
	}
	else if (sum_2 + sum_4 * 2 >= N){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
}

Measured memory_bytes: 1024
def max(a,b):
    if a > b:
        return a
    else:
        return b
n, k = [int(i) for i in input().split()]
ans = 0


for b in range(1,n+1):
    p = n // b
    r = n % b
    ans += p * max(0,b-k)+max(0,r-k+1)
if k == 0:
    ans -= n
    
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ll x;
    cin>>x;
    for(int i=1;i<=130;i++)
    {
        for(int j=-130;j<=130;j++)
        {
            if(pow(i,5)-pow(j,5)==x)
            {
                cout<<i<<" "<<j;
                return 0;
            }
        }
    }
}


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

typedef pair<int, int> P;
const int INF = 1000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
    int H, W;
    char field[1000][1000];
    int dist[1000][1000];
    int max_dist = 0;
    cin >> H >> W;

    queue<P> que;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> field[i][j];
            if(field[i][j] == '#'){
                que.push(P(i, j));
                dist[i][j] = 0;
            }else{
                dist[i][j] = INF;
            }
        }
    }

    while(que.size()){
        P p = que.front();
        que.pop();

        for(int i=0; i<4; i++){
            int nx = p.first + dx[i], ny = p.second + dy[i];

            if(0 <= nx && nx < H && 0 <= ny && ny < W && dist[nx][ny] == INF){
                dist[nx][ny] = dist[p.first][p.second] + 1;
                que.push(P(nx, ny));
                max_dist = max(max_dist, dist[nx][ny]);
            }
        }
    }

    cout << max_dist << endl;
    return 0;
}


Measured memory_bytes: 16216
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}


signed main() {
  int a, b, c;
  cin >> a >> b >> c;

  if (c - a - b <= 0) {
    cout << "No\n";
  } else {
    int lhs = 4 * a * b;
    int rhs = (c - a - b) * (c - a - b);

    if (lhs < rhs)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
ans = "-1 -1 -1"
for a in range(N+1):
	for b in range(N+1-a):
		if  1000 * (N-(a+b)) + 5000*b + 10000*a == Y:
			ans = str(a)+ " " + str(b) + " " + str(N-a-b)
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <bitset>
#include <map>

#define rep(i, l, r) for(int i=l; i<=r; i++)
#define dow(i, l, r) for(int i=l; i>=r; i--)
#define clr(x, c) memset(x, c, sizeof(x))
#define travel(x) for(edge *p=fir[x]; p; p=p->n)
#define all(x) (x).begin,(x).end
#define pb push_back
#define fi first
#define se second
#define l(x) Left[x]
#define r(x) Right[x]
#define lowbit(x) (x&-x)

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,int> Pli;
typedef long double ld;
typedef unsigned long long ull;

inline int read()
{
	int x=0; bool f=0; char ch=getchar();
	while (ch<'0' || '9'<ch) f|=ch=='-', ch=getchar();
	while ('0'<=ch && ch<='9') x=x*10+ch-'0', ch=getchar();
	return f?-x:x;
}

/* struct num
{
	int L, a[maxn];
	void input()
	{
		char s[maxn]; clr(s,0); scanf("%s", s);
		L=strlen(s);
		rep(i, 0, L-1) a[i]=s[L-1-i]-'0';
	}
	void output()
	{
		char s[maxn]; clr(s,0);
		rep(i, 0, L-1) s[i]=a[L-1-i]+'0';
		printf("%s", s);
	}
	void dec1()
	{
		a[0]--; 
		rep(i, 0, L-1) if (a[i]<0) a[i]+=10, a[i+1]--;
		if (a[L-1]==0) L--;
	}
	void div2()
	{
		dow(i, L-1, 1) a[i-1]+=(a[i]%2?10:0), a[i]/=2; a[0]/=2;
		if (a[L-1]==0) L--;
	}
	void mult2()
	{
		rep(i, 0, L-1) a[i]*=2;
		rep(i, 0, L-1) if (a[i]>9) a[i]-=10, a[i+1]++;
		if (a[L]) L++;
	}
}; */



/* int p[maxn], a[maxn];
	p[0]=p[1]=1;
	rep(i, 2, n+1) p[i]=Q-1LL*(Q/i)*p[Q%i]%Q;
	rep(i, 2, n+1) p[i]=1LL*p[i]*p[i-1]%Q;
	a[0]=a[1]=1;
	rep(i, 2, n+1) a[i]=1LL*a[i-1]*i%Q;
inline int C(int x, int y){return 1LL*a[x]*p[y]%Q*p[x-y]%Q;} */



#define maxn 200009

int n, m, a[maxn], s[maxn], t[maxn];
ll g[maxn], g2[maxn], b[maxn], All;

int main()
{
	n=read(); m=read();
	rep(i, 1, n) a[i]=read()-1;
	rep(i, 1, n-1) All+=(a[i+1]-a[i]+m)%m;
	rep(i, 1, n-1) if (a[i]>a[i+1]) 
		s[a[i]+1]++, t[a[i+1]+m]++, g[a[i+1]+m]+=a[i+1]-a[i]+m-1;
	else
		s[a[i]+1]++, t[a[i+1]]++, g[a[i+1]]+=a[i+1]-a[i]-1;
	
	int tmp=0; ll now=0; 
	rep(i, 0, (m-1)*2)
	{
		now+=tmp; b[i%m]+=now;
		tmp+=s[i]; tmp-=t[i]; now-=g[i];
	}
	int Ans=0; rep(i, 1, m-1) if (b[i]>b[Ans]) Ans=i;
	printf("%lld\n", All-b[Ans]);
	return 0;
}

Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		double R = sc.nextInt();
		double s = 2*R*Math.PI;
		System.out.println(s);
	}
}

Measured memory_bytes: 35972
#include <iostream>
using namespace std;
int main(void){
  int n,x;
  int l[100];
  int sum=0;
  int count=1;
  
  cin>>n>>x;
  for(int i=0;i<n;i++){
    cin>>l[i];
  }
  
  
  for(int i=0;i<n;i++){
    sum+=l[i];
    if(sum<=x) count++;
    else break;

  }
  cout<<count;
  
  
    return 0;
}

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

int main() {
	string s; cin >> s;

	int pre, post;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			pre = i;
			break;
		}
	}
	for (int i = s.size() - 1; i > 0; i--) {
		if (s[i] == 'Z') {
			post = i;
			break;
		}
	}
	cout << post - pre+1 << endl;

	return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
const ll MAX_V = 210;

int main() {
    ll n;
    cin >> n;

    vvl dist1(MAX_V, vl(MAX_V));  // dist1[u][v] : 頂点uと頂点vの最短距離
    rep(i, n) {
        rep(j, n) {
            if(i != j) {
                dist1[i][j] = INF;
            }
        }
    }
    
    vvl G(n);  // 辺の重みがすべて1のグラフ
    rep(i, n) {
        string s;
        cin >> s;
        rep(j, n) {
            if(s[j] == '1') {
                G[i].pb(j);
                if(dist1[i][j] > 1) {
                    dist1[i][j] = dist1[j][i] = 1;
                }
            }
        }
    }

    // ワーシャルフロイド法。計算量はO(V^3)
    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                dist1[i][j] = min(dist1[i][j], dist1[i][k] + dist1[k][j]);
            }
        }
    }
    
    bool nibuGraph = true;
    // BFS。計算量はO(V+E)
    vl dist2(n, -1);  // dist2[v] : 頂点svから頂点vへの最短距離(-1のとき未訪問)
    queue<ll> Q;
    rep(V, n) {
        if(dist2[V] == -1) {
            dist2[V] = 0;
            Q.push(V);
            while(!Q.empty()) {
                ll v = Q.front();
                Q.pop();
                for(auto u : G[v]) {
                    if(dist2[u] == -1) {
                        dist2[u] = dist2[v] + 1;
                        Q.push(u);
                    }
                    else if(dist2[v] == dist2[u]) {
                        nibuGraph = false;
                    }
                }
            }
        }
    }
    
    if(nibuGraph) {
        ll ans = 0;
        rep(i, n) {
            rep(j, n) {
                if(dist1[i][j] != INF) {
                    chmax(ans, dist1[i][j]);
                }
            }
        }
        ans++;
        out(ans);
    }
    else {
        out(-1);
    }

    re0;
}

Measured memory_bytes: 1024
[A, B, C, D] = input().split(' ')
A = int(A)  # health
B = int(B)  # strength
C = int(C)  # health
D = int(D)  # strength

turn = 0
while True:
    if A <= 0:
        print('No')
        break
    if C <= 0:
        print('Yes')
        break

    if turn == 0:
        C = C - B
        turn = 1
    else:
        A = A - D
        turn = 0


Measured memory_bytes: 9188
def check(s, t):
    flag = True
    for i in range(len(s)):
        if s[i] != t[i] and s[i] != "?":
            flag = False
    return flag


S = str(input())
T = str(input())

ans = ""
for i in reversed(range(len(S)-len(T)+1)):
    # S[i:i+len(T)]で対象の範囲を取れる
    if check(S[i:i+len(T)], T):
        num = 0
        while num != len(S):
            if num == i:
                ans += T
                num += len(T)
            else:
                if S[num] == "?":
                    ans += "a"
                else:
                    ans += S[num]
                num += 1
        break

if ans == "":
    print("UNRESTORABLE")
else:
    print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll res = max(0ll, (B - A) * (N - 2) + 1);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import collections
from math import gcd
from functools import reduce

from random import randint

def lcm(a, b):
    return abs(a*b) // gcd(a, b)

def find_gcd(list):
    x = reduce(gcd, list)
    return x

def find_lcm(list):
    x = reduce(lambda a,b: lcm(a,b)% MOD, list)
    return x

D = [None for _ in range(10**6)]
MOD = 10**9 + 7
def solve(N: int, A: "List[int]"):

    q1 = reduce(gcd, A) == 1

    def SieveOfEratosthenes(n): 
        prime = [i for i in range(n + 1)] 
        p = 2
        while (p * p <= n): 
            if (prime[p] == p): 
                for i in range(p * 2, n + 1, p): 
                    prime[i] = p
            p += 1
        prime[0]= 0
        prime[1]= 1
        return prime

    D = SieveOfEratosthenes(10**6)
    s = set([])
    q2 = True
    for a in A:
        facs = set([])
        while True:            
            facs.add(D[a])
            a = a // D[a]
            if D[a] == a:
                facs.add(D[a])
                break

        for fac in facs:
            if fac in s:
                if fac != 1 and fac != 0:
                    q2 = False
            s.add(fac)


    if q1 and q2:
        print('pairwise coprime')
    elif q1:
        print('setwise coprime')
    else:
        print('not coprime')
    return


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

    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 236324
#include <iostream>
#include <string>
#include <cctype>
#include <vector>

using namespace std;
const int counter_size = 'z' - 'a' + 1;

int main(){
    string line;
    vector<int> counter(counter_size, 0);
    while(getline(cin, line)){
        for(auto c : line){
            if(isalpha(c)){
                ++counter[tolower(c)-'a'];
            }
        }
    }
    char label = 'a';
    for(auto n : counter){
        cout << label++ << " : " << n << endl;
    }
}

Measured memory_bytes: 1184
while True:
    x = raw_input()
    if x == ".":break
    a = ""
    for s in x:
        if s in ["(",")","[","]"]:
            a += s
    while True:
        if "()" in a or "[]" in a:
            a = a.replace('[]', '')
            a = a.replace('()', '')
        else:
            break
    if a =="":
        print "yes"
    else:
        print "no"



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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<ll> enum_prime(ll N){
	deque<bool> is_prime(N+1,true);
	vector<ll> P;
	for(ll i=2;i<=N;i++){
		if(is_prime[i]){
			for(ll j=i*i;j<=N;j+=i){
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

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

	auto P=enum_prime(1000000);
	vector<ll> H(2000000,0),S(2000001,0);
	for(auto& x:P) H[x]=1;
	for(int i=0;i<2000000;i++){
		S[i+1]=S[i]+H[i];
	}

	while(true){
		ll N=in();
		if(!N) break;

		ll sum=0;
		REP(i,N){
			ll A=in(),B=in();
			ll L=max(A-B,1LL),R=A+B;
			sum += (S[R+1]-S[L])?S[R+1]-S[L]-1:-1;
		}
		out(sum);
	}
	
	return 0;
}



Measured memory_bytes: 34664
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n; cin >> n; std::vector<std::pair<int, int>> vec;
	for(int i = 0; i < n; i++){
		int a; cin >> a;
		
		vec.push_back({a, 0});
	}
	for(int i = 0; i < n; i++){
		int a; cin >> a;
		
		vec.push_back({a, 1});
	}
	sort(begin(vec), end(vec));
	
	const int MOD = 1e9 + 7;
	long A[2] = {}, ans = 1;
	for(int i = 0; i < 2 * n; i++){
		if(A[1 - vec[i].second]) {
			ans *= A[1 - vec[i].second];
			A[1 - vec[i].second]--;
			ans %= MOD;
		}else{
			A[vec[i].second]++;
		}
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2420
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] dp = new int[3];
        for(int day=0;day<n;day++){
            int[] newdp = new int[3];
            int[] c = new int[3];
            for(int i=0;i<3;i++){
                c[i] = scan.nextInt();
            }

            for(int i=0;i<3;i++){
                for(int j=0;j<3;j++){
                    if(i!=j){
                        newdp[j] = Math.max(newdp[j],dp[i] + c[j]);
                    }
                }
            }
            dp[0] = newdp[0];
            dp[1] = newdp[1];
            dp[2] = newdp[2];
        }
        System.out.println(Math.max(dp[0],Math.max(dp[1],dp[2])));
        scan.close();
        
}
}


Measured memory_bytes: 88368
#include <unistd.h>
#include <stdlib.h>

void    get_nums(int *array, char *s, int count)
{
	int num;
	int i;

	i = 0;
	while (s[i] && s[i] != 10)
	{
	    if (s[i] != 32)
	    {
	        num = 0;
	        while ('0' <= s[i] && s[i] <= '9')
	            num = num * 10 + s[i++] - '0';
	        array[count++] = num;
	        continue;
	    }
	    i++;
	}
}

char    *get_string(char *tmp, int pass_flag)
{
	int     i;
	int     j;
	int     k;
	int     count;
	char    *new_arr;

    count = 0;
	i = 0;
	while (count++ < pass_flag)
		while (tmp[i++] != 10)
			;
	j = 0;
	while (31 < tmp[i + j] && tmp[i + j] < 127)
		j++;
	if (!(new_arr = (char*)malloc(j + 1)))
	    return (0);
	k = -1;
	while (++k < j)
		new_arr[k] = tmp[i + k];
	new_arr[k] = 0;
	return (new_arr);
}

char    **get_strings(char *tmp, int pass_flag, int size)
{
	int     i;
	int     j;
	int     count;
	char    **new_arr;

	if (!(new_arr = (char**)malloc(sizeof(char*) * (size + 1))))
	    return (0);
	count = 0;
	i = 0;
	while (count++ < pass_flag)
		while (tmp[i++] != 10)
			;
	j = -1;
	while (++j < size)
		if(!(new_arr[j] = get_string(&tmp[i], j)))
		    return (0);
	new_arr[j] = 0;
	return (new_arr);
}

void get_ans(int *nums, char **arr, int i, int *y)
{
    int x[nums[0]];
    int j;

    while (++i < nums[0] && !(x[i] = 0))
    {
        j = -1;
        while (++j < nums[1])
            if (arr[i][j] == '.')
                arr[i][j] == '.' ? x[i]++, y[j]++ : 0;
    }
    i = -1;
    while (++i < nums[0])
    {
        if (x[i] == nums[1])
            continue;
        j = -1;
        while (++j < nums[1])
        {
            if (y[j] == nums[0])
                continue;
            write(1, &arr[i][j], 1);
        }
        write(1, "\n", 1);
    }
}

int     main(void)
{
	char    s[10200];
	int     nums[2];
	char    **arr;
	int     i;
	int     *y;
	
	if ((i = read(0, s, 10200)) == -1)
	    return (-1);
	s[i] = 0;
	get_nums(nums, s, 0);
	arr = get_strings(s, 1, nums[0]);
	if (!(y = (int*) malloc(sizeof(int) * nums[1])))
	    return (-1);
	i = -1;
	while (++i < nums[1])
        y[i] = 0;
	get_ans(nums, arr, -1 , y);
	i = -1;
	while (++i < nums[0])
	    free(arr[i]);
	free(arr);
	free(y);
	return (0);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    int sum;
    sum = a1+a2+a3;
    if(sum>=22){
        cout << "bust" << endl;
    }else if( sum <= 21){
        cout << "win" << endl;
    }

}




Measured memory_bytes: 256
p = list(map(int, input().split()))

x1 = p[0]
y1 = p[1]
x2 = p[2]
y2 = p[3]

X = int(x2 - x1)
Y = int(y2 - y1)

x3 = x2 - Y
y3 = y2 + X

x4 = x1 - Y
y4 = y1 + X

print(x3,y3,x4,y4)


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

# define C continue;
# define R return

#define int long long
# define D double
# define I insert
# define ld long double
# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) v.begin() , v.end()
# define allcomp(v) v.begin() , v.end() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

#define PQ(type) priority_queue<type>
#define PQD(type) priority_queue<type, vector<type>, greater<type>>

#define mii map<int, int>
#define mll map<ll, ll>
#define mci map<char, int>
#define msi map<string, int>
#define mis map<int, string>
#define mib map<int, bool>
#define mcb map<char,bool>

#define umii unordered_map<int, int>
#define umll unordered_map<ll, ll>
#define umci unordered_map<char, int>
#define umsi unordered_map<string, int>
#define umis unordered_map<int, string>

#define init(arr,val) memset(arr,val,sizeof(arr))
#define REP(i,a,b) for(int i=a; i<b; i++)
#define distance(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define nl "\n"
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = { -1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = { -2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

const int dx[] = { -1 , 0 , 1 , 0 } ;
const int dy[] = { 0 , 1 , 0 , -1 } ;

const ld pie = 3.1415926535897932384626 ;
const int mod = 1e9 + 7 ;
#define test int t; cin>>t;
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .
void a_b_c()
{
    #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
}
int cti(char c)
{
    R c-'0';
}
void solve()
{
 string str;
 cin>>str;
 int sum=0;
 REP(i,0,str.length())
 {
     sum+=cti(str[i]);
 }
 if(sum%9==0) cout<<"Yes";
 else cout<<"No";
}
int32_t main()
{	fast
    int t=1;
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    //int t;  cin>>t;
    for(int i=1; i<=t; i++) solve();

}



Measured memory_bytes: 3740
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

struct obs {
    int s;
    int t;
    int x;
};

vector<struct obs> obss;
vector<int> D;

vector<vector<int>> bs;
vector<vector<int>> es;

int main(void) {
    int N, Q;
    cin >> N >> Q;

    obss.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> obss[i].s >> obss[i].t >> obss[i].x;
    }
    // sort(obss.begin(), obss.end(), [](const struct obs &a, const struct obs &b) {
    //         return a.x < b.x;
    //         });

    D.resize(Q);
    for (int i = 0; i < Q; i++) {
        cin >> D[i];
    }

    bs.resize(Q);
    es.resize(Q);
    for (auto &obs : obss) {
        auto it_b = lower_bound(D.begin(), D.end(), obs.s - obs.x);
        auto it_e = lower_bound(D.begin(), D.end(), obs.t - obs.x);
        if (it_b == it_e) {
            continue;
            // it_e++;
        }
        // printf("[%ld, %ld)\n", it_b - D.begin(), it_e - D.begin());
        if (it_b != D.end()) {
            int pos = it_b - D.begin();
            bs[pos].push_back(obs.x);
        }
        if (it_e != D.end()) {
            int pos = it_e - D.begin();
            es[pos].push_back(obs.x);
        }
    }

    // printf("bs: \n");
    // for (int i = 0; i < Q; i++) {
    //     for (auto &b: bs[i]) {
    //         cout << b << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;

    // printf("es: \n");
    // for (int i = 0; i < Q; i++) {
    //     for (auto &e: es[i]) {
    //         cout << e << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;

    set<int> se;
    for (int i = 0; i < Q; i++) {
        for (auto &e : es[i]) {
            se.erase(e);
        }
        for (auto &b : bs[i]) {
            se.insert(b);
        }

        int ans = se.empty() ? -1 : *se.begin();
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 30196
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MOD2 100000000
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(v) v.begin(),v.end()
ll mod=MOD;
using namespace std;
long long int fast_exp(long long int base,long long int ex) {
    long long int res=1;
    while(ex>0) {
       if(ex%2==1) res=(res*base)%mod;
       base=(base*base)%mod;
       ex/=2;
    }
    return res%mod;
}
long long int gcd(long long int a, long long int b)
{
    if(b==0)return a;
     return gcd(b,a%b);
}
 ll dp[100001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,w;
    cin>>n>>w;
   ll a[n]; ll b[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];


        for(int j=0;j<=100000;j++)
        dp[j]=1e18;
    dp[b[0]]=a[0];
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        for(int j=100000;j>-1;j--)
          {
              if(j>=b[i]&&dp[j-b[i]]!=1e18)
                dp[j]=min(dp[j],dp[j-b[i]]+a[i]);
          }
    }
    ll ans=0;
            for(ll i=0;i<=100000;i++)
                if(dp[i]<=w)
                    ans=i;
        cout<<ans<<"\n";
    return 0;
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    int t, x, y;
    int x_pre = 0;
    int y_pre = 0;
    int t_pre = 0;
    bool ans = true;
    for(int i=0; i<N; i++){
        cin >> t >> x >> y;
        int mrg = t - t_pre - (abs(x - x_pre) + abs(y - y_pre));
        if(mrg >= 0 && mrg % 2 == 0){
            ;
        }
        else{
            ans = false;
        }
        t_pre = t;
        x_pre = x;
        y_pre = y;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int N, L;
	cin >> N >> L;
	
	int R = L + N - 1;
	int ans = (R + L) * (R - L + 1) / 2;
	
	if( R <= 0 ) ans -= R;
	else if( L >= 0 ) ans -= L;
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
def div2cnt(n):
    res = 0
    while n % 2 == 0:
        res += 1
        n //= 2
    return res


def main():
    n = int(input())
    aa = map(int, input().split())
    res = sum(map(div2cnt, aa))
    print(res)


if __name__ == '__main__':
    main()


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

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

using namespace std;

const double PI=acos(-1);

int main(){
	int n;
	double L,theta[3000]; cin>>n>>L;
	rep(i,n) cin>>theta[i], theta[i]*=2*PI/L;

	double xans=0,yans=0;
	rep(j,n) rep(i,j) {
		double phi=(theta[i]+theta[j])/2;
		xans+=(n-j+i-1)*cos(phi)+(j-i-1)*cos(phi+PI);
		yans+=(n-j+i-1)*sin(phi)+(j-i-1)*sin(phi+PI);
	}
	xans/=n*(n-1.)*(n-2)/6;
	yans/=n*(n-1.)*(n-2)/6;

	cout<<setprecision(10)<<xans<<' '<<yans<<endl;

	return 0;
}


Measured memory_bytes: 512
N = int(input())
h = list(map(int, input().split()))
#print([i for i, x in enumerate(l_dup) if x == 'x'])
ans = 0
#for i in range(-1):
    #print("unko")
while True:
    i_of_minus = [i for i, x in enumerate(h) if x <= 0]
    c = len(i_of_minus)
    #print(h)
    if c >= N:
        break
    if c == 0:
        ans += 1
        h = list(map(lambda x: x-1, h))
    else:
        if i_of_minus[0] != 0:
            ans += 1
        if i_of_minus[-1] != N - 1:
            ans += 1
        for j in range(1, c):
            if i_of_minus[j] - i_of_minus[j-1] > 1:
                ans += 1
        h = list(map(lambda x: x - 1, h))
print(ans)

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<ll,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int h, w, k;
	cin >>h >>w >>k;
	vector<string> s(h);
	rep(i, h) cin >>s[i];
	vector<VI> ba(h, VI(w));
	rep(i,h) rep(j,w) ba[i][j] = s[i][j] -'0';
	int res = 1<<28;
	rep(i,1<<(h-1)){
		int sm = 0;
		VI cv(h);
		rep(j, h){ cv[j] = sm; if((i>>j)& 1) sm++; }
		if(sm >= res) continue;
		VI cdy(sm+1,0);
		rep(x, w){
			bool addsw=false;
			VI now1(sm+1,0);
			rep(y, h){
				now1[cv[y]] += ba[y][x];
				if(now1[cv[y]] > k) goto lastlp;
				cdy[cv[y]] += ba[y][x];
				if(cdy[cv[y]] > k) addsw=true;
			}
			if(addsw){
				sm++;
				if(sm>=res) goto lastlp;
				cdy = now1;
			}
		}
		res = min(res, sm);
		lastlp: ;
	}
	cout << res <<"\n";
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
//计算指数 e可以分解几个组合
int solve(int e)
{
	int now=1,res=0;
	while(now<=e)
	{
		e-=now;
		now++;
		res++;
	}
	return res;
}
int main()
{
	ll n;
	int ans=0;
	cin>>n;
	ll m=sqrt(n);
	//遍历到 sqrt(n)即可
	for(ll i=2;i<=m;i++)
	{
		//能进 if 的 i 必定是素数
		if(n%i==0)
		{
			int cnt=0;//统计以 i 为底的指数个数
			while(n%i==0)
			{
				n/=i;
				cnt++;
			}
			ans+=solve(cnt);
		}
	}
	if(n!=1) 
		ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3664
#include <bitset>
#include <cmath>
#include <cstdio>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <set>
#include <iterator>
#include <climits>
#include <stack>
#include <cassert>
#include <list>
#include <cstring>
using namespace std;

#define ll long long int
#define dd double
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vi vector<ll>
#define mii map<ll,ll>
#define mod 1000000007
#define matrix vector<vector<ll>>
#define fast_io ios_base :: sync_with_stdio(false),cin.tie(NULL);

matrix multiply(matrix A, matrix B) {
    matrix C(5);
    for (int i = 0; i < 5; ++i) {
        for (int j = 0; j < 5; ++j) {
            for (int x = 0; x < 5; ++x) {
                C[i][j] = (C[i][j]+(A[i][x] * B[x][j]) % mod) % mod;
            }
        }
    }
    return C;
}

matrix power(matrix T, ll n) {
    if (n == 1)
        return T;

    if (n & 1)
        return multiply(T, power(T, n - 1));

    matrix X = power(T, n >> 1);
    return multiply(X, X);
}

signed main(void) {

    fast_io;
    ll a,b;
    
    cin >> a >> b;
    if(a >= 10 || b >= 10)
        cout << -1 << endl;
    else
        cout << b*a << endl;
    return 0;
}


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

int main(){
  int n,x;
  cin >> n;
  
  for(int i=3;i<=n;++i){
    if(i%3==0){
      cout << " " << i;
    }
    else{
        x=i;
        do{
            if(x%10==3){
                cout << " " << i;
                break;
            }
            x/=10;
        }while(x);
        
    }
  }
  cout << endl;
}



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

using namespace std;

int main(){
	string S; cin >> S;
	bool alphabet[26];
	fill(alphabet, alphabet + 26, false);
	for(int i = 0; i < S.size(); ++i){
		alphabet[S[i]-97] = true;
	}
	for(int i = 0; i < 26; ++i){
		if(alphabet[i] == false){
			cout << (char)(i+97) << endl;
			return 0;
		}
	}
	cout << "None" << endl;
}

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

using namespace std;

int main(){


    int a, b, x;
    cin >> a >> b >> x;

    if (a == x) {
        cout << "YES" << endl;
    } 
    else if (a > x){
        cout << "NO" << endl;
    }
    else {
        if (a + b >= x){ 
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }





    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back 
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;


int main()
{ fast;
string s;
cin>>s;

string cur,prev;

ll k=1,n=s.size();

prev.pb(s[0]);


for(ll i=1;i<n;i++)
{
cur.pb(s[i]);

if(cur!=prev)
{
    prev=cur;
    cur.clear();
    k++;
}

}

cout<<k;

}


Measured memory_bytes: 720
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main(){
    double s,c,h,a,b,deg;
  	cin >> a >> b >> deg;
  
  	c = (double)(sqrt(pow(a,2) + pow(b,2) - 2*a*b*cos((deg / 180) * M_PI) ));
  	s = (double)(0.5*a*b*sin((deg / 180)*M_PI));
    h = (double)(s/a*2);
  

  	cout << setprecision(20) << (double)s << endl;
  	cout << setprecision(20) << (double)a+b+c << endl;
  	cout << setprecision(20) << (double)h << endl;
  	
  	
    return 0;
}


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

int n, m;
bool AC[100100];
int pen[100100];
int task;
char ver[10];

int main(){
	scanf("%d%d", &n, &m);
	rep(i, m){
		scanf("%d%s", &task, ver);
		task--;
		if(ver[0] == 'W'){
			if(!AC[task]) pen[task]++;
		} else {
			AC[task] = 1;
		}
	}
	int count_AC = 0, count_pen = 0;
	rep(i, n){
		if(AC[i]){
			count_AC++;
			count_pen += pen[i];
		}
	}
	printf("%d %d\n", count_AC, count_pen);
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int K;
    cin >> K;
    string S = "11121215221512111515221122541411";
    if (K == 16)
    {
        cout << 14 << endl;
    }
    else if (K == 24)
    {
        cout << 15 << endl;
    }
    else if (K == 32)
    {
        cout << 51 << endl;
    }
    else
    {
        cout << S.at(K - 1) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <unistd.h>
#include <bits/stdc++.h>

#define pii pair<int,int>
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;

using Graph = vector<vector<int>>;

typedef long long ll;
static const ll INF = 1000000000000000000LL;
static const ll MOD = 1000000007;

Graph G;

int main()
{
    int N,M;
    cin >> N >> M;
    G.assign(N, vector<int>());
    REP(i,M)
    {
        int v,u;
        cin >> v >> u;
        --v;--u;
        G[v].push_back(u);
        //G[u].push_back(v);
    }

    int s, t;
    cin >> s >> t;
    --s;--t;

    vector <vector < ll > > d(N, vector<ll>(3, -1)); 
    d[s][0] = 0;

    queue<pair<int,int>> que;
    que.push({s,0});
    while(!que.empty())
    {
        pair<int, int> cur = que.front();
        que.pop();

        int v = cur.first;
        int parity = cur.second;//(0,1,2)

        for(auto nv: G[v])
        {
            int np = (parity + 1) % 3;
            if(d[nv][np] == -1)
            {
                d[nv][np] = d[v][parity] + 1;
                que.push({nv,np});
            }
        }
    }


    int res;
    res = d[t][0] / 3;
    if(d[t][0] == -1)res = -1;

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void app() {
  int t;
  cin>>t;

  rep(t_,t){
    lint n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    lint ans=-1;

    map<lint,lint> dp;
    using state=pair<lint,lint>;
    priority_queue<state,vector<state>,greater<state>> q;
    dp[n]=9e18;
    q.emplace(0,n);
    while(!q.empty()){
      auto up=q.top();
      q.pop();
      lint ucost=up.first;
      lint u=up.second;
      //cout<<ucost<<u<<endl;

      if(u==0){
        ans=ucost;
        break;
      }
      if(u<0) continue;

      vector<pair<lint,lint>> g;
      if(u<=5){
        g.emplace_back(ucost+d*u,0);
      }
      g.emplace_back(ucost+a+u%2*d,u/2);
      g.emplace_back(ucost+b+u%3*d,u/3);
      g.emplace_back(ucost+c+u%5*d,u/5);
      g.emplace_back(ucost+a+(2-u%2)*d,u/2+1);
      g.emplace_back(ucost+b+(3-u%3)*d,u/3+1);
      g.emplace_back(ucost+c+(5-u%5)*d,u/5+1);
      if(u-u/2<(9e18-ucost)/d){
        g.emplace_back(ucost+(u-u/2)*d,u/2);
      }
      if(u-u/3<(9e18-ucost)/d){
        g.emplace_back(ucost+(u-u/3)*d,u/3);
      }
      if(u-u/5<(9e18-ucost)/d){
        g.emplace_back(ucost+(u-u/5)*d,u/5);
      }
      for(auto p:g){
        lint v=p.second;
        if(v>2e18||v<0) continue;
        if(dp[v]==0) dp[v]=9e18;
        if(chmin(dp[v],p.first)) q.push(p);
      }
    }
    cout<<ans<<endl;
  }
}

int main(){app();return 0;}


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

int main() {
  ll h, w;
  cin >> h >> w;
  if ((h==1) || (w==1)) {
    cout << 1 << endl;
  } else {
    h *= w;   
    cout << (h+1)/2 << endl;
  }
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}

void solve()
{
   string s;
    cin >> s;
    
    if(s.back() != 's') s.pb('s');
    else s += "es";
    
    cout << s;
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 3628