akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
#include <fstream>
#include <stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
//const ll INF = 100000000000010000;
//const ull B = 998244353;
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

vector<ll> dx = { 0, 1, 0, -1, 1, -1, 1, -1, 0};
vector<ll> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0};

void chmin(ll& x, ll y) {
	x = min(x, y);
}

void chmax(ll& x, ll y) {
	x = max(x, y);
}

ll pow_long(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y % 2 == 1) res *= x;
		x *= x;
		y /= 2;
	}
	return res;
}

void test() {
	cout << "888888888888888888888888" << endl;
}

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

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 1000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

ll n, k;
ll d, A;
ll b[110];
ll ans;
void solve() {
	cin >> n >> k;
	rep(i, k) {
		cin >> d;
		rep(j, d) {
			cin >> A;
			b[A]++;
		}
	}
	for (ll i = 1; i <= n; i++) if (b[i] == 0) ans++;
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll T = 1;
	//cin >> T;
	rep(i, T) solve();
}


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

using namespace std;

int a[105][105];

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, d, ans = 0;
    cin >> n >> d;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= d; ++j) cin >> a[i][j];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            int s = 0;
            for (int w = 1; w <= d; ++w) s += (a[i][w] - a[j][w]) * (a[i][w] - a[j][w]);
            int f = sqrtl(s);
            for (int d = max(0, f - 1); d <= f + 1; ++d) {
                if (d * d == s) ans++;
            }
        }
    }
    cout << ans;
    return 0;
}



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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

#define fi first
#define se second
#define all(A) A.begin(),A.end()

using namespace std;
using namespace atcoder;

/////////////////////////////////////////////////////
#define vv vector

ll N;
pll xy[202020];
ll ytoi[202020];
ll mk[202020];
ll i, j, k;
int main(){
    scanf("%lld", &N);
    vv<pll> xi(N);
    dsu d(N + 3);

    rep(i,0,N){
        ll x, y;
        scanf("%lld%lld", &x, &y);
        xy[i] = {x,y};
        ytoi[y] = i;
        xi[i] = {x, i};
    }
    sort(all(xi));

    map<ll,ll> mp;
    ll xmx = 0, ymn = N+1;
    rep(i,0,N){
        ll ii = xi[i].se;
        ll x = xy[ii].fi;
        ll y = xy[ii].se;

        if(y>ymn)
            continue;
        if(x<xmx)
            d.merge(ii, ytoi[ymn]);
        rep(j,y,ymn){
            //printf("%llda", ytoi[j]);
            d.merge(ii, ytoi[j]);
            xmx = max(xmx, xy[ytoi[j]].fi);
        }
        ymn = y;
    }
    rep(i,0,N){
        printf("%lld\n", d.size(i));
    }

    return 0;
}

Measured memory_bytes: 12024
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    long long N, M, s[10], c[10], i, j, judge=1, ans;

    cin >> N >> M;

    vector<pair<long long, long long>> p(M);

    for(i=0; i<M; i++){
        cin >> s[i] >> c[i];

        p[i].first = s[i];
        p[i].second = c[i];
    }

    sort(p.begin(), p.end());

    if(M >= 2){
        for(i=0; i<M-1; i++){
            if(p[i].first==p[i+1].first && p[i].second!=p[i+1].second){
                judge = 0;
            }       
        }
    }

    for(i=0; i<M; i++){
        if(p[i].first==1 && p[i].second==0 && N>1){
            judge = 0;
        }
    }         


    ans = 0;

    if(judge == 1){
        for(i=1; i<=N; i++){
            for(j=0; j<M; j++){
                if(j<M-1){
                    while(p[j].first == p[j+1].first){
                        j++;
                    }
                }
                
                if(i == p[j].first){
                    ans += pow(10, N-p[j].first) * p[j].second;
                }
            }
        }

        if(N>=2 && ans < pow(10, N-1)) ans += pow(10, N-1);

        cout << ans << endl;
    }

    else{
        cout << -1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
std::vector<int> PRIMES;

void init_primes(int max)
{
  if (max < 2) return;
  std::set<int> candidate;
  PRIMES.push_back(2);
  for (int i = 3; i < max; i+=2) {
    candidate.insert(i);
  }
  for (int i = 3; i < sqrt(max); i+=2) {
    std::set<int>::iterator it = candidate.find(i);
    if (it != candidate.end()) {
      PRIMES.push_back(i);
      int del_num = i;
      while (del_num < max) {
        it = candidate.find(del_num);
        if (it != candidate.end()) candidate.erase(it);
        del_num += i;
      }
    }
  }
  for (std::set<int>::iterator it = candidate.begin();
       it != candidate.end(); ++it) {
    PRIMES.push_back(*it);
  }
}

int main()
{
  const int max = 1000000;
  init_primes(max);
  int i;
  while (std::cin >> i) {
    std::vector<int>::iterator it = PRIMES.begin();
    int n = 0;
    while (*it <= i && it != PRIMES.end()) {
      n++;
      it++;
    }
    std::cout << n << std::endl;
  }
  return 0;
}

Measured memory_bytes: 25024
N, M = map(int, input().split())
A = []
for i in range(N):
  a, b = map(int, input().split())
  A.append([a, b])
B = []
for i in range(M):
  c, d = map(int, input().split())
  B.append([c, d])
M = [[[abs(b[0] - a[0]) + abs(b[1] - a[1]), i] for i, b in enumerate(B)] for a in A]
for m in M:
  print(sorted(m, key=lambda x:x[0])[0][1] + 1)


Measured memory_bytes: 3316
#include <iostream>
#include <math.h>

using namespace std;
int main(void){
   
   int n,m ; cin >> n>>m;
   int *a;
   a= new int[m];
   int sum=0;
   for(int i=0;i<m;i++){
       cin >> a[i];
       sum += a[i];
   }
   int ans = n- sum;
   if(ans >=0) cout << ans ;
   else cout << -1;

}


Measured memory_bytes: 3632
#include <iostream>
#include<string>

using namespace std;

int main()
{    string s;
    cin>>s;
    if(s[0]=='S')
        cout<<"Cloudy"<<endl;
    else if(s[0]=='C')
        cout<<"Rainy"<<endl;
    else
        cout<<"Sunny"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt=0;
  int tim;
  cin>>n>>tim;
  vector<int> x(n);
  
  for(int i=0; i<n; ++i){
    cin>>x[i];
    if(i != 0){
      if(x[i] - x[i-1] > tim){
        cnt += tim;
      }else{
        cnt += x[i] - x[i-1];
      }
    }
  }
  
  cnt += tim;
  
  cout<<cnt<<'\n';
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
//#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    string N;
    cin >> N;
    cout << "ABC" << N << endl;
}


Measured memory_bytes: 256
N=int(input())
if N%10==0 :
  print("pon")
elif N%10==1 :
  print("pon")
elif N%10==6 :
  print("pon")
elif N%10==8 :
  print("pon")
elif N%10==3 :
  print("bon")
else :
  print("hon")

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m,s,t; cin>>n>>m>>s>>t;
  s--,t--;
  vector<vpll> G(n*2);
  rep(i,m){
    ll u,v,a,b; cin>>u>>v>>a>>b;
    u--,v--;
    G[u].emplace_back(v,a);
    G[v].emplace_back(u,a);
    G[u+n].emplace_back(v+n,b);
    G[v+n].emplace_back(u+n,b);
  }
  
  vll dist(n*2,LINF);
  dist[s]=0;
  dist[n+t]=0;
  priority_queue<pll, vector<pll>, greater<pll>> q;
  q.emplace(0,s);
  q.emplace(0,t+n);
  while(!q.empty()){
    pll p=q.top(); q.pop();
    ll v=p.second, c=p.first;
    if(dist[v]<c) continue;
    for(auto np: G[v]){
      ll nv=np.first, nc=np.second;
      if(chmin(dist[nv],dist[v]+nc)) q.emplace(dist[nv], nv);
    }
  }
  vll ans;
  ll base=1e15;
  ll max=0;
  rrep(i,n){
    ll val=base-(dist[i]+dist[i+n]);
    chmax(max,val);
    ans.push_back(max);
  }
  rrep(i,ans.size()) cout<<ans[i]<<endl;
}

Measured memory_bytes: 19960
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s >= 0;s--)

int main()
{
	ll n;
	string s,ans;
	bool flag = false;

	cin >> s;

	if (s[s.size()-1] == '3')
		ans = "bon";
	else if (s[s.size() - 1] == '0'||s[s.size() - 1] == '1' || s[s.size() - 1] == '6' || s[s.size() - 1] == '8')
		ans = "pon";
	else
		ans = "hon";

	
	cout << ans;

}


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

int main()
{
	int a, b;
	cin >> a >> b;
	// a+b a-b a*b
	int m = a+b;
	if( m < a-b) m = a-b;
	if( m < a*b) m = a*b;
	cout << m << endl;
}


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

int main(){
  long n,m,p[1001];
  while(cin>>n>>m,n||m){
    for(int i=1;i<=n;++i) cin>>p[i];
    p[0]=0;
    vector<long> s(0);
    for(int i=0;i<=n;++i){
      for(int j=0;j<=n;++j) s.push_back(p[i]+p[j]);
    }
    sort(s.begin(),s.end());
    long a=0;
    for(vector<long>::iterator it=s.begin();it!=s.end();++it){
      if(*it>m/2) break;
      a=max(a,*it+*(upper_bound(s.begin(),s.end(),m-*it)-1));
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 17524
import sys
import math
N = int(sys.stdin.readline().rstrip())

# def create_money(i):
#     money = []
#     tmp = 1
#     for _ in range(math.floor(math.log(N, i))):
#         tmp *= i
#         money.append(tmp)
    
#     return money

# money = [1]
# money += create_money(6)
# money += create_money(9)

money = [1]
for i in range(20):
    if 100000 >= 6**i:
        money.append(6**i)
    if 100000 >= 9**i:
        money.append(9**i)

money = sorted(money)[::-1]


dp = [[10**18] * (N + 1) for _ in range(len(money) + 1)]
dp[0][0] = 0

for i in range(1, len(money) + 1):
    m = money[i - 1]
    for j in range(N + 1):
        if j - m >= 0:
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - m] + 1, dp[i][j - m] + 1)
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[len(money)][N])

Measured memory_bytes: 52336
k, x = map(int, input().split())
li = []
li1 = []
li2 = []
for i in range(k):
    li.append(x-i)
for i in range(k):
    li1.append(x+i)
li2 = li + li1
li2 = set(li2)
li2 = sorted(li2)
for i in range(len(li2)):
    print(li2[i], end=' ')


Measured memory_bytes: 3060
from collections import Counter
import sys
sys.setrecursionlimit(1000000)
N, M = map(int, input().split())
mod = 10**9+7

factor = []
tmp = M
i = 2
while i**2 <= M:
    while tmp % i == 0:
        factor.append(i)
        tmp //= i
    i += 1
if tmp != 1:
    factor.append(tmp)

arr = Counter(factor).values()


dp = [-1 for _ in range(200001)]


def factorize(n):
    if dp[n] != -1:
        return dp[n]
    if n == 1:
        return 1
    return n*factorize(n-1)


def combination(n, k):
    i = n
    res = 1
    while i > n-k:
        res *= i
        i -= 1
    return res//factorize(k)

ans = 1
for elem in arr:
    ans *= combination(elem+N-1, elem)
    ans %= mod

print(ans)


Measured memory_bytes: 5040
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, a[1000], i, ans=0, tmp;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
        ans+=a[i];
    }
    tmp=ans;
    sort(a, a+n);
    i=0;
    while(ans%10==0){
        if(a[i]%10!=0) ans-=a[i];
        i++;
        if(i==n) break;
    }
    if(ans%10==0) ans=0;
    cout << ans <<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int sum=0,piece=0,n,m,count=0;
	while(scanf("%d,%d",&m,&n)!=EOF){
		count++;
		sum=sum+m*n;
		piece+=n;
	}
	printf("%d\n",sum);
	n=piece*10/count;
	if(n%10>=5)printf("%d\n",n/10+1);
	else printf("%d\n",n/10);
	return 0;
}

Measured memory_bytes: 0
// package app;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

    // フィールド
    static char[][] field;
    // 最小反転回数
    static int retMinCnt = Integer.MAX_VALUE;

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        System.out.println(N % 2 == 0 ? N : N * 2);

    }
}

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

using namespace std;

int main(void) {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n*a, b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const long long c = 1e18;
const int maxn = 1e5 + 10;
int n;
long long a[maxn];
int main()
{
	cin>>n;
	bool flag = false;
	for(int i = 0; i < n; i++)
	{
		cin>>a[i];
		if(a[i] == 0)
		flag = true;
	}
	if(flag)
	{
		cout<<0<<endl;
		return 0;
	}
	long long ans = 1ll;
	for(int i = 0; i < n; i++)
	{
		if(c / ans < a[i])
		{
			cout<<-1<<endl;
			return 0;
		}
		ans *= a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000000;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  int n,m;
  cin >> n >> m;
  ll g[n][n];
  rep(i,n) {
    rep(j,n) {
      g[i][j]=(ll)MAX*(ll)MAX;
      if(i==j) g[i][j]=0;
    }
  }
  rep(i,m) {
    int x,y,z;
    cin >> x >> y >> z;
    g[x][y]=z;
  }
  rep(k,n) {
    rep(i,n) {
      rep(j,n) {
	if(g[i][k]!=(ll)MAX*(ll)MAX && g[k][j]!=(ll)MAX*(ll)MAX) g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
      }
    }
  }
  bool neg=false;
  rep(i,n) {
    if(g[i][i]<0) neg=true;
  }
  if(neg) pr("NEGATIVE CYCLE");
  else {
    rep(i,n) {
      rep(j,n) {
	if(j) cout << " ";
	if(g[i][j]==(ll)MAX*(ll)MAX) cout << "INF";
	else cout << g[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ABC054B - Template Matching
  // 縦N行、横N列に画素が並んだ画像A
  // 縦M行、横M列に画素が並んだ画像B
  // '.'は白色の画素、'＃'は黒色の画素
  int N, M; cin >> N >> M;
  vector<string> A(N);
  vector<string> B(M);
  REP(i, N) cin >> A[i];
  REP(i, M) cin >> B[i];
  bool flag = false; // 一致しないする
  REP(i, N - M + 1){ // 縦にずらす
    REP(j, N - M + 1){ // 横にずらす
      int cnt = 0; // 縦横の探索が終わってこの数がM*Mになったらflagをtrueにする
      REP(k, M){ // Mの中を探索（縦）
        REP(l, M){ // Mの中を探索（横）
          if(B[k][l] == A[i+k][j+l]) cnt++;
        }
      }
      if(cnt == M * M){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


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

long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}

int main(){
  int K; cin >> K;
  long long ans = 0;
  rep1(a, K) rep1(b, K) rep1(c, K) ans += gcd(gcd(a, b), c);
  cout << ans << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000;

//main関数
int main() {
    
    //入力
    long N;
    cin>>N;
    vector<long> a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }
    
    
    //計算
    
    long ans=0;
    for(int i=0;i<N;i++){
        while(a.at(i)%2==0){
            ans++;
            a.at(i)/=2;
        }
    }
    
    //出力
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < 3; i++){
        cout << s[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;

int main()
{
    string s;
    cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);

int n;
vi vec = {'3', '5', '7'};
int ans = 0;

void dfs(string x){
    if (x.size() && stoll(x) > n) return;
    bool flag = true;
    if (x.find('3') == string::npos) flag = false;
    if (x.find('5') == string::npos) flag = false;
    if (x.find('7') == string::npos) flag = false;
    if (flag) ans++;

    for (char v: vec){
        dfs(x + v);
    }
    return;
}

int main() {
    cin >> n;
    dfs("");
    cout << ans << endl;

}


Measured memory_bytes: 3632
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

ll MOD = pow(10,9)+7;

int main(){
    int N;cin>>N;
    ll ans = 1;
    FOR(i, 1, N+1) ans = (ans*i) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  Vi c(26,0);
  string s;
  cin >> s;
  rep(i,0,s.size()){
    c[s[i] - 'a']++;
  }
  
  bool ok = true;
  rep(i,0,26){
    if(c[i]%2==1) ok = false;
  }
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
K,*as=$<.read.split.map(&:to_i)

ret = 0

(1..K).each do |i|
  (i..K).each do |j|
    (j..K).each do |k|
      n = i.gcd(j).gcd(k)
      if i == j && i == k
        ret += n
      elsif i != j && j != k
        ret += n*6
      else
        ret += n*3
      end
    end
  end
end

puts ret


Measured memory_bytes: 14380
n = int(input())
a = [int(_) for _ in input().split()]
left = [0] * (n//2)
right = [0] * (n//2)
if n % 2 == 0:
    left = a[n:0:-2]
    right = a[0:n:2]
    ans = left + right
else:
    left  = a[n:1:-2]
    right = a[1:n:2]
    ans = left + [a[0]] + right
for i in ans:
    print(i, end=" ")

Measured memory_bytes: 26180
#include<stdio.h>
#include<iostream>

#define MAX_N 100000
#define MAX_Q 50000

using namespace std;

int S[MAX_N], T[MAX_Q];

int main()
{
    int N,Q;
    scanf("%d", &N);
    for(int i=0; i<N; i++)
        scanf("%d", S+i);
    scanf("%d", &Q);
    for(int i=0; i<Q; i++)
        scanf("%d", T+i);
    int cnt=0;
    for(int curq=0; curq<Q; curq++){
        int target=T[curq];
        int l=0, r=N-1, targetIdx=-1;
        while(l<=r){
            int mid=(l+r)/2;
            if(S[mid]==target){
                targetIdx=mid;
                break;
            }
            else if(S[mid]<target){
                l=mid+1;
            }
            else if(S[mid]>target){
                r=mid-1;
            }
        }
        if(targetIdx!=-1)
            cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}



Measured memory_bytes: 3764
import heapq
from collections import defaultdict
N=int(input())
X=[]
Y=[]
dic_x=defaultdict(list)
dic_y=defaultdict(list)
for i in range(N):
  x,y=map(int,input().split())
  dic_x[x].append(i)
  dic_y[y].append(i)
  X.append(x)
  Y.append(y)
X=sorted(X)
Y=sorted(Y)
V=N
E=(V-1)*2
G=[]
for i in range(N-1):
  heapq.heappush(G,(X[i+1]-X[i],dic_x[X[i]].pop(),dic_x[X[i+1]][0]))
  heapq.heappush(G,(Y[i+1]-Y[i],dic_y[Y[i]].pop(),dic_y[Y[i+1]][0]))
 
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.p = [e for e in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def same(self, u, v):
        return self.find_set(u) == self.find_set(v)

    def unite(self, u, v):
        u = self.find_set(u)
        v = self.find_set(v)

        if u == v:
            return

        if self.rank[u] > self.rank[v]:
            self.p[v] = u
            self.size[u] += self.size[v]
        else:
            self.p[u] = v
            self.size[v] += self.size[u]
            if self.rank[u] == self.rank[v]:
                self.rank[v] += 1

    def find_set(self, u):
        if u != self.p[u]:
            self.p[u] = self.find_set(self.p[u])

        return self.p[u]

    def update_p(self):
        for u in range(self.n):
            self.find_set(u)

    def get_size(self, u):
        return self.size[self.find_set(u)]

def Minmum_Spanning_Tree(G,V,E):
  uf=UnionFind(V)
  cnt=0
  tot_weight=0
  while cnt!=V-1:
    w,u,v=heapq.heappop(G)
    if uf.same(u-1,v-1)==False:
      uf.unite(u-1,v-1)
      tot_weight+=w
      cnt+=1
  return tot_weight

weight=Minmum_Spanning_Tree(G,V,E)
print(weight)

Measured memory_bytes: 77772
N = int(input())

if N == 3:
    print('2 5 63')
else:
    A2 = [a for a in range(2, 30001, 2) if a % 6 != 0]
    A3 = [a for a in range(3, 30001, 6)]
    A6 = [a for a in range(6, 30001, 6)]

    a2 = min(10000, (N - 2) // 2 * 2)
    N -= a2
    a3 = min(5000, N // 2 * 2)
    a6 = N - a3

    ans = A2[: a2] + A3[: a3] + A6[: a6]
    print(*ans)

Measured memory_bytes: 4744
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    string S;
    cin >> S;
    int ans = 0;
    for(int i=1; i<S.size(); i++){
      if(i*2 < int(S.size())){
        string a = S.substr(0,i);
        string b = S.substr(i,i);
        if(a == b){
            ans = i*2;
        }
      }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<stdio.h>
#include<vector> // 可変長配列
using namespace std;
static const int MAX = 1000000;


void printLine(int A[], int N) {
    for (int i = 0; i < N; i++) {
        if (i > 0) {
            printf(" ");
        }
        printf("%d", A[i]);
    }
    printf("\n");
}

int insertionSort(int A[], int N, int g) {
    int cnt = 0;
    for (int i = g; i < N;i++) {
        int seq = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > seq) {
            A[j + g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j + g] = seq;
    }
    return cnt;
}

int shellSort(int A[], int N) {
    // 可変長配列でshell sortの幅を生成
    // この段階では昇順[1, 3, 9...]
    vector<int> vec; 
    vec.push_back(1); // append
    for (int i = 1;;) {
        i = i * 3;
        if (i > N) {
            break;
        }
        vec.push_back(i); // append
    }
    
    // 幅リストのサイズ
    int s = vec.size();
    printf("%d\n", s);
    
    int cnt = 0;
    // 降順に評価
    
    for (int i = s - 1;i >= 0;i--) {
        if (i < s - 1) {
            printf(" ");
        }
        printf("%d", vec[i]);
        cnt += insertionSort(A, N, vec[i]);
    }
    printf("\n");
    return cnt;
}

int main() {
    int N;
    scanf("%d", &N);
    
    int A[MAX];
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    
    //insertionSort(A, N, 1);
    int cnt = shellSort(A, N);
    printf("%d\n", cnt);
    for (int i = 0; i < N; i++) {
        printf("%d\n", A[i]);
    }
     
    return 0;
}



Measured memory_bytes: 7148
#include <bits/stdc++.h>
#include <set>
#include <queue>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define reps(i, s, n) for (int i = s; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define repsl(i, s, n) for (ll i = s; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl
#define readVarll(nam) ll nam; cin >> nam
#define INF 99999999999
#define PLL pair<ll,ll>
#define TLLL tuple<ll,ll,ll>

string a[1001];
ll cnt[1001][1001];
ll h, w, ch, cw, dh, dw;
ll magicArea[5][5] = {{1,1,1,1,1},{1,1,0,1,1},{1,0,2,0,1},{1,1,0,1,1},{1,1,1,1,1}};

deque<TLLL> mydata;

void useMagic(ll nh, ll nw, ll hsub, ll wsub)
{
  if( nh+hsub >= 0 && nh +hsub < h
    && nw+wsub >= 0 && nw+wsub < w
    && a[nh + hsub][nw + wsub] == '.' && cnt[nh + hsub][nw + wsub] > cnt[nh][nw] + 1)
  {
    cnt[nh + hsub][nw + wsub] = cnt[nh][nw] + 1;
    mydata.push_back(TLLL(nh+hsub, nw+wsub, cnt[nh][nw]+1));
  }  
}

void walk(ll nh, ll nw, ll hsub, ll wsub)
{
  if( nh+hsub >= 0 && nh +hsub < h
    && nw+wsub >= 0 && nw+wsub < w
    && a[nh + hsub][nw + wsub] == '.' && cnt[nh + hsub][nw + wsub] > cnt[nh][nw])
  {
    cnt[nh + hsub][nw + wsub] = cnt[nh][nw];
    mydata.push_front(TLLL(nh+hsub, nw+wsub, cnt[nh][nw]));
  }
}

ll calc()
{
  while(!mydata.empty())
  {
    TLLL x = mydata.front();
    mydata.pop_front();
    ll nh = get<0>(x);
    ll nw = get<1>(x);
    ll np = get<2>(x);

    if(cnt[nh][nw] < np)
    {
      continue;
    }

    if(nh == dh && nw == dw)
    {
      return cnt[nh][nw];
    }

    repsl(i, -2, 3)
    {
      repsl(j, -2, 3)
      {
        if(magicArea[i+2][j+2] == 0)
        {
          walk(nh, nw, i, j);
        }
        else if(magicArea[i+2][j+2] == 1)
        {
          useMagic(nh, nw, i, j);
        }
      }
    }
  }

  return cnt[dh][dw];
}

int main()
{
  
  cin >> h >> w >> ch >> cw >> dh >> dw;
  ch--;
  cw--;
  dh--;
  dw--;
  repl(i, h)
  {
    cin >> a[i];
    repl(j, w)
    {
      cnt[i][j] = INF;
    }
  }

  cnt[ch][cw] = 0;
  mydata.push_front(TLLL(ch, cw, 0));
  ll ans = calc();
  if(ans == INF) ans = -1;
  cout << fixed << ans << endl;

  return 0;
}


Measured memory_bytes: 13608
#include <bits/stdc++.h>
#include <iostream>
#include <string>

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define REP(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  u64 x[5];

  REP(i, 5) {
    cin >> x[i]; 
    if (x[i]==0) {
        cout << i+1;
        return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
int main(void) {
int i, j, m, n, a, max=0;
int mem[21]={0};
scanf("%d%d",&m,&n);
for(i=0;i<m;i++) {
for(j=0;j<n;j++){
scanf("%d",&a);
mem[i]+=a;
}
if(max<mem[i]) max=mem[i];
}
printf("%d\n",max);
return(0);
}

Measured memory_bytes: 600
#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() {
    ll N;
    string S, T;
    cin >> N >> S >> T;
    rep(i, N) { cout << S[i] << T[i]; }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
  
int main () {
  int n, q, count;
  cin >> n;
  int s[n];
  REP(i, n) {
    cin >> s[i];
  }
  cin >> q;
  int t[q];
   REP(i, q) {
    cin >> t[i];
  }

  count = 0;
  REP(i, q) {
    REP(j, n) {
      if (s[j] == t[i]) {
        count++;
        break;
      }
    }
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3100
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
m = map(int,read().split())
LR = list(zip(m,m))

if N==2:
    L1,R1 = LR[0]
    L2,R2 = LR[1]
    answer = (R1-L1+1) + (R2-L2+1)
    print(answer)
    exit()

# 片方に集める場合
max_width = max(R-L+1 for L,R in LR)

LR.sort()

INF=10**18
# Rが最小のもの
i = -1
opt_R = INF
for n,(L,R) in enumerate(LR):
    if opt_R>=R:
        opt_R=R
        i=n
j = -1
opt_L = -INF
for n,(L,R) in enumerate(LR):
    if opt_L<=L:
        opt_L=L
        j=n

if i==j:
    L,R = LR[i]
    answer = max_width + (R-L+1)
    print(answer)
    exit()

L1,R1 = LR[i]; L2,R2 = LR[j]

LR = [(L,R) for n,(L,R) in enumerate(LR) if n != i and n != j]

LR.sort(key = lambda x: (x[0],-x[1]))

n = len(LR)
dpl = [(-INF,INF)]*(n+1)
dpr = [(-INF,INF)]*(n+1)

for i in range(n):
    a,b = dpl[i]
    L,R = LR[i]
    dpl[i+1] = (max(a,L),min(b,R))
for i in range(n,0,-1):
    a,b = dpr[i]
    L,R = LR[i-1]
    dpr[i-1] = (max(a,L),min(b,R))

answer = 0
for (a,b),(c,d) in zip(dpl,dpr):
    l1 = max(L1,a); r1 = min(R1,b)
    l2 = max(L2,c); r2 = min(R2,d)
    x = max(0,r1-l1+1) + max(0,r2-l2+1)
    if answer < x:
        answer = x

x = max_width + max(0,min(R1,R2)-max(L1,L2)+1)
if answer < x:
    answer = x

print(answer)

Measured memory_bytes: 72804
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, m, x, i, b, c1=0, c2=0;
	cin >> n >> m >> x;
	int a[n+1]={0};
	for (i=1; i<=m; i++)
	{
		cin >> b;
		a[b] = 1;
	}
	for (i=1; i<=x-1; i++)
		if (a[i]==1)
			c1++;
	for (i=x+1; i<=n-1; i++)
		if (a[i]==1)
			c2++;
	if (c1>c2)
		cout << c2 << endl;
	else
		cout << c1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl
#define P pair<lint,lint>

int main() {
	lint N;
	cin >> N;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	lint cnt = 0;
	rep(i, N) {
		if ((i + 1) % 2 == 1 && A[i] % 2 == 1) {
			cnt++;
		}
	}
	cout << cnt << enld;
}

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

main() {
    string divide[4]={"dream","dreamer","erase","eraser"};
    string S; cin >> S;
    queue<int> BFS;
    bool can=false;
    BFS.push(0);
    while(!BFS.empty()){
        int t=BFS.front();
        BFS.pop();
        if(t==S.size()){
            can=true;
            break;
        }
        for(string s:divide){
            if(S.substr(t,s.size())==s){
                BFS.push(t+s.size());
            }
        }
    }
    cout << (can ? "YES":"NO") << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
struct point{
    long double x;
    long double y;
};
int main(){
    int n;
    point a[4];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<4;j++){
            scanf("%Lf%Lf",&a[j].x,&a[j].y);
        }
        if((a[1].x-a[0].x)*(a[3].y-a[2].y)==(a[3].x-a[2].x)*(a[1].y-a[0].y))printf("YES\n");
        else printf("NO\n");
    }
}

Measured memory_bytes: 2700
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int n;
int m;
pii a[10];
int b[10];
int cnt = 1;
int gao(int x)
{
    MS0(b);
    if (!x)
    {
        return 1;
    }
    int res = 0;
    cnt = 1;
    while (x)
    {
        res++;
        b[cnt++] = x % 10;
        x /= 10;
    }
    return res;
}
int main()
{
    //freopen("D:\\code\\text\\input.txt","r",stdin);
    //freopen("D:\\code\\text\\output.txt","w",stdout);
    n = readint();
    m = readint();
    repd(i, 1, m)
    {
        a[i].fi = readint();
        a[i].se = readint();
    }
    int ans = -1;
    repd(i, 0, 999)
    {
        if (gao(i) == n)
        {
            // chu(i);
            int flag = 1;
            repd(j, 1, m)
            {
                if (b[n - a[j].fi + 1] != a[j].se)
                {
                    flag = 0;
                }
            }
            if (flag)
            {
                ans = i;
                break;
            }
        }
    }
    printf("%d\n", ans );
    return 0;

}




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


//マクロ
#define FOR(i, a, b) for(int i = (a); i < (b), i++)
#define REP(i, n) FOR(i, 0, n);
#define ALL(a) (a).begin(),(a).end()

// 最長共通部分列問題
// 入力
// S T

// dp[i + 1][j + 1] := Sのi文字目までと、Tのj文字目までのLCSの長さ
// 計算量 O(|S||T|)

int main(){

    //入力
    string S, T; cin >> S >> T;
    vector<vector<string> > dp(2, vector<string> (T.size() + 1, ""));

    //dp初期条件
    
    int now = 0;
    int next = 1;
    for(int i = 0; i < S.size(); i++){
        for(int j = 0; j < T.size(); j++){
            if(S[i] == T[j] && dp[next][j + 1].size() < dp[now][j].size() + 1) dp[next][j + 1] = dp[now][j] + S[i];
            if(dp[next][j + 1].size() < dp[next][j].size()) dp[next][j + 1] = dp[next][j];
            if(dp[next][j + 1].size() < dp[now][j + 1].size()) dp[next][j + 1] = dp[now][j + 1];
        }

        swap(now, next);
    }

    cout << dp[now][T.size()] << endl;
    return 0;
}

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

using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
 
#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;


//debug func
template<typename T>
void vecprint(vector<T> v) {
    for(auto x : v) {
        cout << x << " ";
    }
    cout << endl;
}

template<typename T>
void vecvecprint(vector<vector<T>> v) {
    for(auto x :v) {
        REP(i, x.size()-1) {
            cout << x[i] << " ";
        }
        cout << x[x.size()-1] <<endl;
    }
}

template<typename T>
void pqprint(priority_queue<T> q) {
    while(!q.empty()) {
        cout << q.top() << " ";
        q.pop();
    }
    cout << endl;
}

template<typename T>
void qprint(queue<T> q) {
    while(!q.empty()) {
        cout << q.front() << " ";
        q.pop();
    }
    cout << endl;
}

template<typename T>
void vecqprint(vector<queue<T>> v) {
    for(int i = 0; i < v.size(); i++) {
        qprint(v[i]);
    }
}

template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

int main(void) {
    int a, b;
    cin >> a >> b;
    int ans = a - 2 * b;
    if(ans < 0) ans = 0;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;


int main(){

	int E,Y;
	scanf("%d %d",&E,&Y);

	switch(E){
	case 0:
		if(Y <= 1911){
			printf("M%d\n",Y-1867);
		}else if(Y <= 1925){
			printf("T%d\n",Y-1911);
		}else if(Y <= 1988){
			printf("S%d\n",Y-1925);
		}else{
			printf("H%d\n",Y-1988);
		}
		break;
	case 1:
		printf("%d\n",Y+1867);
		break;
	case 2:
		printf("%d\n",Y+1911);
		break;
	case 3:
		printf("%d\n",Y+1925);
		break;
	case 4:
		printf("%d\n",Y+1988);
		break;
	}

    return 0;
}

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


int main()
{
	int n;
	cin >> n;
	char* s, * t;
	s = new char[n];
	t = new char[n];
	cin >> s >> t;
	for (int i = 0; i < n; i++) {
		cout << s[i] << t[i];
	}
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,a=1,b=1,ans=1e10;
    cin >> n;
    ll u=sqrt(n);
    for(int i = 1;i <= u;i ++){
        if(n%i==0) {
            a=n/i;
            b=i;
        }
        if(max(int(log10(a)),int(log10(b)))+1<ans)ans=max(int(log10(a)),int(log10(b)))+1;
    }
    cout << ans << endl;
    return 0;
}

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

namespace zyt
{
	typedef long long ll;
	const int N = 19;
	const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
	ll f[1 << 17 | 13][N][N];
	int n, arr[N];
	bool vis[1 << 17 | 13][N][N];
	ll dfs(const int rot, const int l, const int r, const int u, const int v)
	{
		if (l > r)
			return 0;
		if (vis[rot][l][r])
			return f[rot][l][r];
		vis[rot][l][r] = true;
		ll &ans = f[rot][l][r];
		ans = LINF;
		for (int i = l; i <= r; i++)
			ans = min(ans, dfs(rot << 1, l, i - 1, u, u + v) 
				+ dfs(rot << 1 | 1, i + 1, r, u + v, v) 
				+ arr[i] * ll(u + v));
		return ans;
	}
	int work()
	{
		scanf("%d", &n);
		for (int i = 1; i <= n; i++)
			scanf("%d", &arr[i]);
		printf("%lld", dfs(1, 2, n - 1, 1, 1) + arr[1] + arr[n]);
		return 0;
	}
}
int main()
{
	return zyt::work(); 
}

Measured memory_bytes: 209648
while True:
    a, op, b = input().split()      
    a =int(a)                  
    b = int(b)        

    if op=="?":
        break
    else:   
        if op=='+':
            print(a + b)
        elif op=='-':
            print(a - b)
        elif op=='*':
            print(a * b)
        elif op=='/':
            print(a//b)


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

int par[51];
int ranks[51];

void init(int n){
  for(int i = 0; i < n; i++) par[i] = i, ranks[i] = 0;
}

int find(int x){
  if(par[x] == x){
    return x;
  } else{
    int r = find(par[x]);
    return par[x] = r;
  }
}

void unite(int x, int y){
  x = find(x); y = find(y);
  if (x == y) return;
  if (ranks[x] < ranks[y]) swap(x, y);
  if (ranks[x] == ranks[y]) ranks[x]++;
  par[y] = x;
}

bool same(int x, int y){
  return find(x) == find(y);
}


int main(){
  int n, m;
  cin >> n >> m;
  int a[m], b[m];
  rep(i, m) cin >> a[i] >> b[i];
  int ans = 0;
  rep(i, m){
    init(n+1);
    rep(j, m){
      if(j != i) unite(a[j], b[j]);
    }
    if(!same(a[i],b[i])) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD= 1E9+7;
int main(void)
{
    unsigned long long n;
    cin>>n;
    unsigned long long ans=1;
    for(int i=2;i<=n;i++)
    {
        ans=(ans*i)%MOD;
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256