akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("trapv")
#define I inline void 
#define S struct 
#define vi vector<int> 

using namespace std ; 
using ll = long long ; 
using ld = long double ; 

const int N = 1e6 + 7 , mod = 1e9 + 7 ; 
int n ; 

// How interesting!

int occ[N] ; 
bool p[N] ; 
vector<int> prm[N] ; 

int main(){
	ios_base::sync_with_stdio(0) ; 
	cin.tie(0) ;
	//freopen("in.in" , "r" , stdin) ; 
	cin >> n ; 
	ll gc = 0 ; 

	for(int i = 2; i < N ;i++){
		if(p[i])continue ; 
		prm[i].push_back(i) ; 
		for(int j = i + i ;j < N ;j+=i){
			p[j] = 1; 
			prm[j].push_back(i) ; 
		}
	}
	bool bad = 0 ; 

	for(int i = 0 ;i < n ;i++){
		ll x; 
		cin >> x ; 
		gc = __gcd(gc , x) ; 
		if(bad)continue ; 
		for(auto u : prm[x]){
			occ[u] ++ ; 
			if(occ[u] > 1){
				bad = 1; 
			}
		}
	}

	bool ok = 1; 
	for(int i = 1 ; i<N ;i++){
		if(occ[i] > 1){
			ok = 0 ;
		}
	}
	if(ok){
		cout<<"pairwise coprime" ; 
	}
	else if(gc == 1){
		cout <<"setwise coprime" ; 
	}
	else cout<<"not coprime" ; 
	return 0 ; 
}


Measured memory_bytes: 63924
#include <stdio.h>
#include <string.h>

int main() {
	int n, lst = 0, nxt, sum = 0;
	bool add[25];
	scanf("%d", &n);
	memset(add, false, sizeof add);
	for (int i = 0; i < n; i++) {
		scanf("%d", &nxt);
		if (lst == nxt - 1)
			add[lst] = true;
		lst = nxt;
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &nxt);
		sum += nxt;
	}
	for (int i = 1; i < n; i++) {
		scanf("%d", &nxt);
		if (add[i])
			sum += nxt;
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128
//Author: Abitnav
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){

ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//string s;
	int n,m,c=0,t=1,i=0,j,k,sum=0,ans,f=0,x,y;
	//cin>>t;
		//vector<int> v;
		map<int,int> mp;
		cin>>n;
		rep(i,n-1) {
			cin>>x;
			mp[x]++;
			
		}
		for(int i=1;i<=n;i++) cout<<mp[i]<<endl;
	return 0;
}













Measured memory_bytes: 16128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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() {
    int a[3];
    rep(i, 3) cin >> a[i];
    int sum = 0;
    rep(i, 3) sum += a[i];
    if (sum >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

min_diff_t = 10e6
ans = 0

for i, e in enumerate(h):
    ti = t - 0.006 * e
    d = abs(a - ti)

    if d < min_diff_t:
        min_diff_t = d
        ans = i + 1

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <limits.h>

int main(){
    long int A;
    long int B;
    
    long int a;
    long int b;
    int z=1;
    
    long int ans;
    
    scanf("%ld",&A);
    scanf("%ld",&B);
    
    if(A>B){
        a = A;
        b = B;
    }else{
        a = B;
        b = A;
    }
    
    while(z != 0){
        z = a%b;
        a = b;
        if(z==0){
            break;
        }
        b = z;
    }
        
    ans = (A/b)*B;    
        
    printf("%ld\n",ans);
    
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    long long int mn;
    cin>>mn;
    long long int n;
    cin>>n;
    long long int count=0;
    long long int arr[mn];
    long long int i=0;
    for(i=0;i<mn;i++){
        cin>>arr[i];
    }
    sort(arr,arr+mn);
    for(i=0;i<mn-n;i++){
        count=count+arr[i];
    }
    cout<<count<<endl;

return 0;
}


Measured memory_bytes: 1792
import math
 
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
 
p_sort = sorted(p)
q_sort = sorted(q)
 
p_number = 1
q_number = 1
 
k = 0
for i in p:
  k += 1
  i_index = p_sort.index(i)
  p_number += i_index * math.factorial(n-k)
  p_sort.remove(i)
k = 0
for i in q:
  k += 1
  i_index = q_sort.index(i)
  q_number += i_index * math.factorial(n-k)
  q_sort.remove(i)
answer = abs(p_number - q_number)
print(answer)

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

int main() {
    int n;
    cin >> n;
    vector<ll> x(n);
    vector<ll> sort_x(n);
    for(int i=0; i<n; i++){
        cin >> x[i];
        sort_x[i] = x[i];
    }

    sort(sort_x.begin(), sort_x.end());
    ll min_x = sort_x[n/2-1];
    ll max_x = sort_x[n/2];

    for(int i=0; i<n; i++){
        if(x[i]<max_x){
            cout << max_x << endl;
        }else{
            cout << min_x << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5376
num, bricks, count, smash = int(input()), [int(x) for x in input().split(" ")], 1, 0
for x in bricks:
    if count == x: count += 1
    else: smash += 1
print(smash if smash != len(bricks) else 0 if len(bricks) == 1 else -1)

Measured memory_bytes: 25768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

	

int main() {
	int n,a,b; cin >> n >> a >> b;

	cout << min(a*n,b) << endl;
}

Measured memory_bytes: 384
while true
        input = STDIN.gets.split(' ')

        m = input[0].to_i
        f = input[1].to_i
        r = input[2].to_i

        break if m == -1 && f == -1 && r == -1

        grade = ''
        if m == -1 || f == -1 then
                grade = 'F'
        elsif (m + f) >= 80 then
                grade = 'A'
        elsif (m + f) >= 65 then
                grade = 'B'
        elsif (m + f) >= 50 then
                grade = 'C'
        elsif (m + f) >= 30 then
                grade = 'C' if r >= 50
                grade = 'D' if r < 50
        else
                grade = 'F'
        end
        puts grade
end

Measured memory_bytes: 6096
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
char s[N];
int a[N], op[N], tot[N];

int main() {
	int n, k, cnt = 0, sum = 0; cin >> n >> k;
	scanf("%s", s+1);
	for(int i = 1; i <= n + 1; ++i) {
		if(s[i] != s[i - 1] && i - 1) {
			a[++cnt] = sum;
			op[cnt] = s[i - 1] - '0';
			sum = 0;
		}
		++sum;
	}
	memset(tot, 0, sizeof(tot));
	for(int i = 1; i <= cnt; ++i) {
		if(!op[i]) tot[i] = tot[i - 1] + 1; else tot[i] = tot[i - 1];
		a[i] += a[i - 1];
	}
	int ans = 0;
	for(int l = 0, r = 1; r <= cnt; ++r) {
		while(l < r && tot[r] - tot[l - 1] > k) ++l;
		ans = max(ans, a[r] - a[l - 1]);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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 n, a[200010];

int main() {
    cin >> n;
    rep(i, n) cin >> a[i];
    sort(a, a+n);

    bool ok = true;
    rep(i, n-1) if (a[i] == a[i+1]) ok = false;
    if (ok) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 100
#define INFTY 100000000
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BRACK 2

void prim();


int n,total;
int A[MAX][MAX];
int d[MAX];
int p[MAX];
int visit[MAX];
 
int main(){
    int i,j;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            scanf("%d",&A[i][j]);
            if(A[i][j]==-1) A[i][j]=INFTY;
        }
        visit[i]=WHITE;
        d[i]=INFTY;
    }

    prim();

    for(i=0;i<n;i++) {
        if(p[i]!=NIL){
            total+=A[i][p[i]];
        }
    }
    printf("%d\n",total);
    return 0;
}


void prim(){
    int i,u,v,mincost;

    d[0]=0;
    p[0]=NIL;

   while(1){
       mincost=INFTY;
       for(i=0;i<n;i++){
           if(visit[i]!=BRACK && d[i] < mincost){
               mincost = d[i];
               u = i;
           }
       }

       if(mincost == INFTY) break;
       visit[u] = BRACK;

       for(v=0;v<n;v++){
           if(visit[v]!=BRACK && A[u][v]!=INFTY){
               if(A[u][v] < d[v]){
                   d[v] = A[u][v];
                   p[v] = u; //親
                   visit[v]=GRAY;
               }
           }
       }
   }

}


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

int main()
{
	string s;
	cin >> s;
	string t;
	for (auto c : s) {
		if (c == 'B') {
			if (!t.empty())
				t.pop_back();
		}
		else {
			t.push_back(c);
		}
	}
	cout << t << endl;
	return 0;
}

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

void solve(long long N){
ll s[87];
s[0]=2;
s[1]=1;
for(int i=2; i<=N; i++){
    s[i]=s[i-1]+s[i-2];
}
cout<< s[N] <<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
using namespace std;
#define ul unsigned long long


int main() {
	string s;
	cin >> s;
	int n = 27;
	vector<int> c = vector<int>(n);
	for (int i = 0; i < s.length(); i++) {
		c[s[i] - 'a']++;

	}
	bool no = false;
	for (int i = 0; i < c.size(); i++) {
		if (c[i] > 1) no = true;
	}
	if (no) cout << "no"<<endl;
	else cout << "yes" << endl;



	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#define long long int int
using namespace std;

const int maxk = 18;

class edge{
public:
  int t,c,l;

  edge(int to, int color, int length) : t(to),c(color),l(length) {}
};

int depth[100005];
int parent[maxk + 1][100005];
vector<edge> g[100005];
int dist[100005];
int num[100005];
int dist2[100005];

void dfs(int v, int prev, int d, int de,int n) {
  depth[v] = d;
  parent[0][v] = prev;
  dist[v] = de;
  num[v] = n;
  for(int i = 0; i < g[v].size(); i++) {
    int u = g[v][i].t;
    if(u != prev) {
      n++;
      dfs(u,v,d+1,de+g[v][i].l,n);
    }
  }
  
  return;
}

  

void init(int V) {
  dfs(0,-1,0,0,0);
  
  for(int k = 0; k < maxk; k++) {
    for(int i = 0; i < V; i++) {
      if(parent[k][i] < 0) parent[k+1][i] = -1;
      else parent[k+1][i] = parent[k][parent[k][i]];
    }
  }
  return;
}

int lca(int u, int v) {
  if(depth[u] > depth[v]) swap(u,v);
  for(int k = 0; k < maxk; k++) {
    if((depth[v] - depth[u]) >> k & 1) {
      v = parent[k][v];
    }
  }
  if(u == v) return u;
  for(int k = maxk - 1; k >= 0; k--) {
    if(parent[k][u] != parent[k][v]) {
      u = parent[k][u];
      v = parent[k][v];
    }
  }
  return parent[0][u];
}


int n,q;

typedef pair<int,int> P;
map<int,P> s[100005];

int C[100005];
int D[100005];


void dfs2(int v, int prev, int n) {

  
  for(auto itr = s[v].begin(); itr != s[v].end(); ++itr) {
    int u = itr->first;
    itr->second.first = C[u];
    itr->second.second = D[u];
    
  }

  for(int i = 0; i < g[v].size(); i++) {
    int u = g[v][i].t;
    if(u != prev) {
      C[g[v][i].c]++;
      D[g[v][i].c] += g[v][i].l;
      n++;
      dist2[u] = dist2[v] + g[v][i].l;
      dfs2(u,v,n);
      C[g[v][i].c]--;
      D[g[v][i].c] -= g[v][i].l;
    }
  }
  
}

int x[100005];
int y[100005];
int u[100005];
int v[100005];

signed main() {
  cin >> n >> q;



  for(int i = 0; i < n - 1; i++) {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    a--,b--;
    g[a].push_back(edge(b,c,d));
    g[b].push_back(edge(a,c,d));
  }

    init(n);
 
  for(int i = 0; i < q; i++) {
    cin >> x[i] >> y[i] >> u[i] >> v[i];
    u[i]--,v[i]--;
   
    s[u[i]][x[i]] = P(0,0);
    s[v[i]][x[i]] = P(0,0);
    int t = lca(u[i],v[i]);
    s[t][x[i]] = P(0,0);
  }
  dfs2(0,-1,0);

  for(int i = 0; i < n; i++) if(dist[i] != dist2[i]) cout << "Ijijijiji"<<endl;

  for(int i = 0; i < q; i++) {
    int tmp = s[u[i]][x[i]].first * y[i];
    int tmp2 = s[v[i]][x[i]].first * y[i];
    int tmp3 = s[lca(u[i],v[i])][x[i]].first * y[i];

    int tmp4 = s[u[i]][x[i]].second;
    int tmp5 = s[v[i]][x[i]].second;
    int tmp6 = s[lca(u[i],v[i])][x[i]].second;
    
    int di = dist[u[i]] + dist[v[i]] - 2 * dist[lca(u[i],v[i])];
    int di2 = tmp4 + tmp5 - 2 * tmp6;
    int di3 = tmp + tmp2 - 2 * tmp3;
    
    
    cout << di - di2 + di3 << endl;
    
  }
}
			      


Measured memory_bytes: 41656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a * b < c * d)
    {
        cout << c * d << endl;
    }
    else
    {
        cout << a * b << endl;
    }
    return 0;
}


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


void solve(long long a, long long b, long long c, long long d, long long e, long long k){
    vector<ll> vec;
    vec.push_back(a);
    vec.push_back(b);
    vec.push_back(c);
    vec.push_back(d);
    vec.push_back(e);
    sort(vec.begin(), vec.end());
    ll diff = vec[4] - vec[0];

    if(diff > k){
        printf(":(");
    } else {
        printf("Yay!");
    }
}

int main(){

    //FILE* fp_in = freopen("/Users/kokinakamura/atcoder-workspace/abc123/B/in_1.txt", "r", stdin);

    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    long long d;
    scanf("%lld",&d);
    long long e;
    scanf("%lld",&e);
    long long k;
    scanf("%lld",&k);
    solve(a, b, c, d, e, k);

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
vector<int> enum_div(int n)//nの約数を列挙
{
	vector<int> ret;
	for(int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 0;
    for(int i = 2; i * i <= N; i++) {
        int num = N;
        while (num % i == 0) num /= i;
        if(num % i == 1) ans++;
    }
    N--;
    vector<int> v = enum_div(N);
    cout << ans + v.size()/2 + 1 << endl;

    return 0;
}


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

int main(){
long long N,A,B; cin >> N >> A >> B;
  if( A > B){ cout << 0 << endl;}
  else if ( A == B){ cout << 1 << endl;}
  else{ // A < Bの時
    if( N == 1){ cout << 0 << endl;}
    else if( N == 2){ cout << 1 << endl;}
    else if( N == 3){ cout << 2 << endl;}
    else{  cout << ( N - 2) * ( B - A ) + 1<< endl;}
  }
  
  return 0;}
      

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

const int N = 5e5+1;
int n, m;
long fact[N], ifact[N];

long POW(long x, long n){
  if (n == 0) return 1;
  long y = POW(x, n / 2);
  y = y * y % MOD;
  if (n % 2) return x * y % MOD;
  else return y;
}

int main()
{
  fastio;
  cin >> n >> m;
  fact[0] = 1;
  for (int i = 1; i <= m; i++) fact[i] = fact[i - 1] * i % MOD;
  ifact[m] = POW(fact[m], MOD - 2); ifact[0] = 1;
  for (int i = m - 1; i > 0; i--) ifact[i] = ifact[i + 1] * (i + 1) % MOD;
  auto A = [&](int k, int n){
    return fact[n] * ifact[n - k] % MOD;
  };
  auto C = [&](int k, int n){
    return (fact[n] * ifact[k] % MOD) * ifact[n - k] % MOD;
  };
  long res = 0;
  for (int i = 0; i <= n; i++){
    long x = A(n - i, m - i); x = x * x % MOD;
    long cur = A(i, m) * C(i, n) % MOD;
    cur = cur * x % MOD;
    if (i % 2) res -= cur;
    else res += cur;  
    res %= MOD;
  }
  cout << (res + MOD) % MOD;
  return 0;
}

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

using namespace std;


int main()
{
	int h,w,k;
	cin >> h >> w >> k;
	vector<string> arr(h);
	for(int i = 0; i < h; i++) cin >> arr[i];
	int ans = 0;
	for(int i = 0; i < (1<<h); i++){
		for(int j = 0; j < (1<<w); j++){
			int cnt = 0;
			map<pair<int,int>,bool> chosen;
			for(int m = 0; m < h; m++){
				if(i&(1<<m)) continue;
				for(int col = 0; col < w; col++){
					if(j&(1<<col)) continue;
					if(chosen[{m,col}]) continue;
					if(arr[m][col] == '#'){
						cnt++;
					}
					chosen[{m,col}] = 1;
				}
			}
			/*for(int m = 0; m < w; m++){
				if(j&(1<<m)) continue;
				for(int row = 0; row < h; row++){
					if(chosen[{row,m}]) continue;
					if(arr[row][m] == '#'){
						cnt++;
					}
					chosen[{row,m}] = 1;
				}
			}*/
			ans += cnt == k;
		}
	}
	cout << ans;
}


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

int i,j,W,H;

while(1){
scanf("%d %d",&H,&W);
if(H==0&&W==0)break;
for(i=0;i<H;i++){
for(j=0;j<W;j++){
if((i+j)%2==0){
printf("#");
}else if((i+j)%2!=0){
printf(".");
}
}
printf("\n");
}
printf("\n");
}
return 0;
}


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

using std::cout;
using std::cin;
using std::endl;

int main(){
    int N,K,i,d,tmp,count=0;
    int *a;
    cin >> N >> K;
    a = new int[N];
    for(i=0;i<N;i++){
        a[i] = 0;  //REPの使い方を調べる
    }
    for(i=0;i<K;i++){
        cin >> d;
        for(int j=0;j<d;j++){
            cin >> tmp;
            a[tmp-1]++;
        }
    }
    for(i=0;i<N;i++){
        if(a[i] == 0) count++;
    }
    cout << count;
}

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

int main(){
  long n,i;
  cin >> n;
  vector<long> d(n);
  for(i=0; i<n; i++){
    cin >> d[i];
  }
  sort(d.begin(),d.end());
  cout << d[n/2]-d[n/2-1];
}

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

using namespace std;

int main(){
    int a;
    int b;
    int c;
    int d;
    int e;
    int f;
    int g;
    int h;
    cin >> a >> b >> c >> d;
    cin >> e >> f >> g >> h;
    int result = max(a + b + c + d, e + f + g + h);
    cout << result << endl;
}


Measured memory_bytes: 3120
from math import *

n=int(input())
ans=[]
while n>0:
	x=n%26
	if x==0:
		x=26
		n-=1
	ans.append(x)
	n=n//26

ans.reverse()
f=''
for i in ans:
	f=f+chr(96+i)

print(f)

Measured memory_bytes: 9120
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

int main(){
	int n, k;
	std::string s;
	std::cin >> n >> s >> k;
	char s1 = s[k-1];
	for(int i=0; i<n; i++){
		if(s[i]!=s1) s[i] = '*';
		std::cout << s[i];
	}
	std::cout <<std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int test;
	//cin>>test;
	test=1;
	while(test--){
		int n;
		cin>>n;
		map<int,string> m;
		m[0]=m[1]=m[6]=m[8]="pon";
		m[3]="bon";
		m[2]=m[4]=m[5]=m[7]=m[9]="hon";
		cout<<m[n%10]<<endl;
		
	}
		
}
	



Measured memory_bytes: 3652
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a)
	fmt.Scan(&b)
	var ans string
	switch {
	case a == b:
		ans = "a == b"
	case a < b:
		ans = "a < b"
	case a > b:
		ans = "a > b"
	}
	fmt.Println(ans)
}



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

int main(){
	int N;
	cin >> N;
	double sum = 0;
	vector<double> A(N);
	rep(i, N){
		cin >> A[i];
		sum += (1 / A[i]);
	}
	sum = 1 / sum;
	cout << sum << endl;
}

Measured memory_bytes: 256
let n, k = Scanf.scanf " %d %d" @@ fun a b -> a, b
let cs = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ fun h -> if h >= k then 1 else 0
let _ = Printf.printf "%d\n" @@ Array.fold_left (fun s b -> s + b) 0 cs

Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=100010;

ll a,b,c,d;

int main(){
  cin>>a>>b>>c>>d;
  ll ans=min(a,b);
  ans+=min(c,d);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int a, p;
  cin >> a >> p;
  int pcs = a * 3 + p;
  int ans = pcs / 2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
N, K = list(map(int,input().split()))
h = list(map(int, input().split()))

score = [sys.maxsize for i in range(N)]

score[0] = 0
score[1] = score[0] + abs(h[1]-h[0])
for i in range(2, N):
    for j in range(max(i-K, 0), i):
        score[i] = min(score[i], score[j] + abs(h[i]-h[j]))

print(score[-1])


Measured memory_bytes: 56544
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC147A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);

            if (a + b + c <= 21)
                Console.WriteLine("win");
            else if (a + b + c >= 22)
                Console.WriteLine("bust");

            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
int main()
{
  char S[5];
   scanf("%s", S);
  if(S[0]==S[1])
    puts("Bad");
  else if(S[1]==S[2])
    puts("Bad");
  else if(S[2]==S[3])
    puts("Bad");
  else if(S[3]==S[4])
    puts("Bad");
  else
    puts("Good");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>

using namespace std;

int main()
{
  int n;
  deque<int64_t> a;

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

  reverse(a.begin(), a.end());

  cout << a.front();
  a.pop_front();

  for (auto &&i : a) {
    cout << " " << i;
  }

  cout << endl;

  return 0;
}



Measured memory_bytes: 3084
(stdin => {
  // Define Function
  const lessThen = (a, b) => a < b
  const range = f => (a, b, c) => f(a, b) && f(b, c)
  // Declare Variable
  const inputs = stdin.toString().trim().split('\n')
  const [a, b, c] = Array.from(inputs[0].split(' '), Number)
  // display
  console.log(range(lessThen)(a, b, c) ? 'Yes' : 'No')
  
})(require('fs').readFileSync('/dev/stdin', 'utf8'))



Measured memory_bytes: 15136
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */

public class Main {
    public static void main(String[] args) {
        InputStream    inputStream    = System.in;
        OutputStream outputStream = System.out;
        InputReader    in                      = new InputReader(inputStream);
        PrintWriter      out                    = new PrintWriter(outputStream);
        Task                 solver               = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
    	public void solve(int testNumber, InputReader in, PrintWriter out) {
    		int D = in.nextInt();
    		int N = in.nextInt();
     
    		if (N == 100) {
    			N++;
    		}
    		if (D == 0) {
    			System.out.println(N);
    		} else if (D == 1) {
    			System.out.println(N * 100);
    		} else if (D == 2) {
    			System.out.println(N * 10000);
    		}
    		
    	}
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 24532
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b;
    char op;
    
    while(1){
        scanf("%d %c %d",&a, &op, &b);
        if(op == '?'){
            break;
        }
        else{
            if(op == '+'){
                printf("%d\n", a + b);
            }
            else if(op == '-'){
                printf("%d\n", a - b);
            }
            else if (op == '*'){
                printf("%d\n", a * b);
            }
            else if(op == '/'){
                printf("%d\n", a / b);
            }
            else{
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int lcm(int a, int b) { return a / __gcd(a, b) * b; }
int dp[100001];
int n,k;
int a[100001];

int solve(int in){
     
    if(in>=n-1){
        return 0;
    }
    if(dp[in] !=-1){
        return dp[in];
    }
    int ans = 1e18;
     
    for (int i = 1; i<=k;i++)
      if(in+i<n)
       ans = min(ans, abs(a[in] - a[in + i]) + solve(in + i));
     
    return dp[in]=ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    memset(dp, -1, sizeof(dp));
    //cin >> tc;
    while (tc--)
    {

        cin >> n>>k;
        for(int i=0;i<n;i++){
            cin >> a[i];
        }
        a[n] = a[n - 1];
        int f = solve(0);
        cout << f << endl;
    }

    return 0;
}

Measured memory_bytes: 6528
import heapq
n, k = list(map(int, input().split()))
li = []
for _ in range(n):
    li.append(tuple(map(int, input().split())))

li.sort()
cnt = 0
for a, b in li:
    cnt += b
    if cnt >= k:
        ans = a
        break

print(ans)

Measured memory_bytes: 17104
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
int cnt;
int ans;
struct Edge{
	int v,nxt;
}e[200010];int tot=1;
int first[100010],deg[100010];
void build(int u,int v)
{
	e[++tot]=(Edge){v,first[u]};
	first[u]=tot;
	deg[u]++;
	return ;
}
bool book[100010];
bool flag;
void dfs1(int u)
{
	if(deg[u]!=2)flag=true;
	book[u]=true;
	for(int i=first[u];i;i=e[i].nxt)
		if(!book[e[i].v])dfs1(e[i].v);
	return ;
}

vector<int>to[100010];
bool vis[200010];

int C[200010];
void link(int u,int fr)
{
	if(deg[u]==4){
		if(u==fr)C[u]++;
		else{
			to[u].push_back(fr);
			to[fr].push_back(u);
		}
		return ;
	}
	for(int& i=first[u];i;i=e[i].nxt)
		if(!vis[i])
		{
			vis[i]=vis[i^1]=true;
			link(e[i].v,fr);
		}
	return ;
}
bool book2[200010];
void dfs2(int u)
{
	book2[u]=true;
	for(int i=0;i<to[u].size();i++)
		if(!book2[to[u][i]])
			dfs2(to[u][i]);
	return ;
}


int main()
{
//	freopen("test_04.txt","r",stdin);
//	freopen("qwq.out","w",stdout);
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		build(u,v);
		build(v,u);
	}
	//check1
	for(int i=1;i<=n;i++)
		if(deg[i]&1){
			printf("No\n");
			return 0;
		}
	//check2
	for(int i=1;i<=n;i++)
		if(!book[i]&&first[i])
		{
			flag=false;
			cnt++;dfs1(i);
			ans+=1-flag;
		}
//	printf("cnt=%d\nans=%d\n",cnt,ans);
	if(cnt>3){
		printf("No\n");
		return 0;
	}
	//check3
	for(int i=1;i<=n;i++)
		if(deg[i]>=6){
			printf("Yes\n");
			return 0;
		}
	int hahaha=0;
	for(int i=1;i<=n;i++)
		if(deg[i]==4)hahaha++;
	if(hahaha>=3){
		printf("Yes\n");
		return 0;
	}
	//link edges
	for(int i=1;i<=n;i++)
		if(deg[i]==4)
		{
			for(int j=first[i];j;j=e[j].nxt)
				if(!vis[j]){
					vis[j]=vis[j^1]=true;
					link(e[j].v,i);
				}
		}
	bool flg=false;
	for(int i=1;i<=n;i++)
		if(deg[i]==4&&C[i]){
			ans+=C[i];
			flg=true;
		}
	if(hahaha==2){
		if(ans)printf("Yes\n");
		else printf("No\n");
	}
	else if(ans>=3)
		printf("Yes\n");
	else printf("No\n");
//	fclose(stdin);fclose(stdout);
	return 0;
}


Measured memory_bytes: 6784
#include <iostream>

using namespace std;

#define MAXN 105
#define MAXW 100005

#define int int64_t //xdxdxdxdxd

int ww[MAXN];
int v[MAXN];

int dp[MAXN][MAXW];

int32_t main(){

    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
    
    int n,w;cin>>n>>w;
    for(int i=1;i<=n;i++){

        cin>>ww[i]>>v[i];

    }
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=w;j++){
            if(j>=ww[i])dp[i][j] = max(dp[i-1][j-ww[i]]+v[i],dp[i-1][j]);
            else dp[i][j] = dp[i-1][j];
        }
    }
    cout<<dp[n][w]<<endl;

#ifdef NOTINAIR
    for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++)
            cerr<<dp[i][j]<<' ';
        cerr<<endl;    
    }   
#endif
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_mset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fr(i,a,b) for (int i=(a); i<(b);++i)
#define frr(i,a,b) for(ll i=(a-1);i>=(b);--i)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define F first
#define S second
#define pii pair<int,int> 
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.begin(),a.end(),greater<int>())
#define sz(a) (int)a.size()
#define endl '\n'
#define po(a,b) (ll)(pow(a,b)+0.5)
#define print(a) for(auto x:a)cout<<x<<" ";cout<<endl;
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
const ll M=1e9+7;
const int MX=1e5+5;

int n,k;
int dp[MX];
int val[MX];
int a[101];int mn;
int solve(int num)
{
   if(val[num])return 1;
   if(num<a[0])return 0;
   if(dp[k]!=-1)return dp[k];
   int c=0;
    fr(i,0,n)
    {
    if(a[i]<num)
    {  
      if(dp[num-a[i]]!=-1){if(c==0)c=1-dp[num-a[i]];}
      else if(solve(num-a[i])==0)c=1;
    }
    else break;
  }
    return dp[num]=c;
}

int main()
{ 
    Fast
      cin>>n>>k;
      memset(dp,-1,sizeof dp);
      memset(val,0,sizeof val);
   
      fr(i,0,n){cin>>a[i];val[a[i]]=1;}
       if(solve(k))cout<<"First";
       else cout<<"Second";
    
}



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

typedef pair<int,int> P;
const int INF = 500000000;

int main(){
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Fri Apr  5 16:48:09 2019

@author: adachi-lab
"""

input_code = input()
L1 = len(input_code)
list_3 = []
list_4 = []
list_5 = []

for w in range(L1):
    list_3.append(0)
    list_4.append(0)


for i in range(L1):
    code = input_code[i]
    if code == 'A' or code == 'C' or code == 'G' or code == 'T':
        list_3[i] = 1
        
c = 0

for n,m in zip(list_3,list_4):
    
    if n == m:
        c = 0
        list_5.append(c)
        
    else:
        c += 1
        list_5.append(c)
        
print(max(list_5))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int output = 0;
		for(int i = 0;i<x;i++) {
			int temp = sc.nextInt();
			if(temp>=y)output++;
		}
		System.out.println(output);

	}

}


Measured memory_bytes: 47912
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {
	ll a[114514] = {}; int n; cin >> n;
	for (int i = 0; i < n; i++) 
		cin >> a[i];
	sort(a, a + n);
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == a[i + 1])i += 1;
		else cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1152
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), c
  cout << fixed << setprecision(15);

  ll h, w;
  cin >> h >> w;

  vP ops;
  ll add = 0;
  vll lcs(h);
  rep(i, h) {
    add = 0;
    rep(j, w) {
      ll a;
      cin >> a;
      if(j == w-1) {
        lcs[i] = (a + add) & 1;
        continue;
      };
      a += add;
      if (a & 1) {
        ops.emplace_back(i, j);
        add = 1;
      } else {
        add = 0;
      }
    }
  }

  vP ops2;
  add = 0;
  rep(i, h-1){
    ll a = lcs[i] + add;
    if(a & 1){
      ops2.emplace_back(i, w-1);
      add = 1;
    } else {
      add = 0;
    }
  }

  ll n1 = ops.size();
  ll n2 = ops2.size();
  cout << n1 + n2 << endl;
  rep(i, n1){
    ll y, x;
    tie(y, x) = ops[i];
    printf("%lld %lld %lld %lld\n", y+1, x+1, y+1, x+2);
  }
  rep(i, n2){
    ll y, x;
    tie(y, x) = ops2[i];
    printf("%lld %lld %lld %lld\n", y+1, x+1, y+2, x+1);
  }


  return 0;
}


Measured memory_bytes: 5372
require 'pp'

s = gets.chomp!.chars
index_f = -1

if s[0] != "A"
    puts "WA"
    exit 0
end

count = 0
2.upto(s.length - 2) do |i|
    if s[i] == "C"
        count += 1
        index_f = i
    end
end

if count != 1
    puts "WA"
    exit 0
end

ok = true
s.each_with_index do |ch, index|
    next if index == 0 || index_f == index
    
    unless ('a'..'z').include?(ch)
        puts "WA"
        exit 0
    end
end

puts "AC"
    

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
using ll = long long;
int main() {
    int n;
    scanf("%d", &n);
    
    ll sum = 0;
    rep(i, n) {
        ll a; scanf("%lld", &a);
        sum += a;
    }

    // a-1を足してけばいい = 合計からaの合計個数nを引いてる
    printf("%lld", sum - n);
    return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll int>
#define vs vector<string>
#define v vector<int>
#define mi map<int,int>
#define mc map<char,int>

//ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

int main(){
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     int n;
     cin>>n;
     v A(n),B;
     for(auto &x:A)cin>>x;
     for(int i=0;i<n;i++){
		 if(A[i]%2==0){
			 B.push_back(A[i]);
			 }
		 }
		 int m=B.size(),c=0;
		 for(int j=0;j<m;j++){
			 if(B[j]%3==0 || B[j]%5==0){c++;}
			 else{continue;}
			 }
			 if(c==m){cout<<"APPROVED" <<"\n";}
			 else{cout<<"DENIED" <<"\n";}
}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define llong long long
#define ullong unsigned llong
#define fn fill_n
typedef pair<int, int> P;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

int a, b, c, d;
int A[10000], B[10000], C[10000];
string s, t, r;


int main(){
	cin >> A[0] >> A[1] >> A[2];
	cin >> a;
	sort(A, A+3);
	for(int i = 0; i < a; i++) A[2]*= 2;
	cout << A[0]+A[1]+A[2] << endl;
	return 0;
}

Measured memory_bytes: 256
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr <<"at line "<< __LINE__<<": [" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

void solve()
{
	int n;
	cin>>n;
	
	map<int,int>fre[2];
	
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		
		fre[i%2][x]++;
	}
	
	vector<pii>even,odd;
	
	for(auto it: fre[0]) even.push_back({it.second,it.first});
	for(auto it: fre[1]) odd.push_back({it.second,it.first});
	
	sort(even.rbegin(),even.rend());
	sort(odd.rbegin(),odd.rend());
	
	int ans=n;
	
	for(int i=0;i<min(1000,(int)even.size());i++)
	{
		for(int j=0;j<min(1000,(int)odd.size());j++)
		{
			if(even[i].second!=odd[j].second) ans=min(ans,n-even[i].first-odd[j].first);
			else ans=min(ans,min(n/2-even[i].first+n/2,n/2-odd[j].first+n/2));
		}
	}
	
	
	cout<<ans;
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


Measured memory_bytes: 8880
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#define ll long long
using namespace std;
int ans=0,sum=0,j;
int main(){
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	for(int i=1;i<=n;i++){
		if(i<10){
			if(i>=a&&i<=b){ans+=i;}
			continue;
		}
		sum=0;
		j=i;
		while(j>=10){
			sum+=j%10;
			j/=10;
		}
		sum+=j;
		if(sum>=a&&sum<=b){
			ans+=i;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define CHECK cout << "*" << endl
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint h, w;
char c[2005][2005];
bool valid[2005][2005];
llint len[2005][2005];
llint l[2005], r[2005];
stack<llint> stk;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> h >> w;
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			cin >> c[x][y];
		}
	}
	
	for(int y = 1; y <= h-1; y++){
		for(int x = 1; x <= w-1; x++){
			llint cnt = 0;
			if(c[x][y] == '#') cnt++;
			if(c[x+1][y] == '#') cnt++;
			if(c[x][y+1] == '#') cnt++;
			if(c[x+1][y+1] == '#') cnt++;
			valid[x][y] = (cnt%2==0);
		}
	}
	h--, w--;
	
	for(int x = 0; x <= w+1; x++){
		for(int y = 0; y <= h+1; y++){
			len[x][y] = -1;
		}
	}
	for(int y = 1; y <= h; y++){
		llint cnt = 0;
		for(int x = 1; x <= w; x++){
			if(valid[x][y]) cnt++;
			else cnt = 0;
			len[x][y] = cnt;
		}
	}
	
	llint ans = max(h+1, w+1);
	for(int x = 1; x <= w; x++){
		while(stk.size()) stk.pop();
		stk.push(0);
		for(int y = 1; y <= h; y++){
			while(len[x][stk.top()] >= len[x][y]) stk.pop();
			l[y] = stk.top();
			stk.push(y);
		}
		while(stk.size()) stk.pop();
		stk.push(h+1);
		for(int y = h; y >= 1; y--){
			while(len[x][stk.top()] >= len[x][y]) stk.pop();
			r[y] = stk.top();
			stk.push(y);
		}
		for(int y = 1; y <= h; y++){
			ans = max(ans, (len[x][y]+1) * (r[y]-l[y]));
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	int i,j;
	int tmp;
	int now=1;
	int answer;
	int counter=0;
	double ave;
	vector<int> given;

	cin >> N;

	for(i=0;i<N;i++){
		cin >> tmp;
		given.push_back(tmp);
	}

	for(i=0;i<N;i++){
		if(given[i]==now){
			now++;
		}else{
			counter++;
		}
	}

	if(now==1){
		cout << -1 << endl;
	}else{
		answer=counter;
		cout << answer << endl;
	}

	return 0;
}



Measured memory_bytes: 1400
#include <cstdio>
#include <list>
#include <set>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

set<int> able;

bool valid(int num) {
	int Nf = num;
	int digit = 0;
	while (Nf >= 1)
	{
		Nf /= 10;
		digit++;
	}

	bool res = true;
	for (int i = 0; i < digit; i++)
	{
		res = res && able.find((num / int(pow(10, i)) % 10)) != able.end();
	}
	return res;
}


int main(int argc, char const *argv[]) {
	int N, K;
	scanf("%d %d", &N, &K);

	for (int i = 0; i < 10; i++)
	{
		able.insert(i);
	}

	for (int i = 0; i < K; i++)
	{
		int temp;
		scanf("%d", &temp);
		able.erase(temp);
	}

	int ans = N;
	while (!valid(ans))
	{
		ans++;
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
s = list(input())
f = True
for index, i in enumerate(s):
    if(index % 2 == 0):
        if(i == 'L'):
            f = False
            break
    if(index % 2 == 1):
        if(i == 'R'):
            f = False
            break
if(f):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
ll= lambda : list(map(int,input().split()))
testcases=1
# testcases=int(input())
for testcase in range(testcases):
    [n]=ll()
    a=[0]+ll()
    b=[0]+ll()
    ans=0
    # print(a,b)
    for i in range(1,n+1):
        if b[i] >= (a[i]+a[i+1]):
            ans+=(a[i]+a[i+1])
            a[i]=0
            a[i+1]=0
            
        elif(b[i]>=a[i]):
            ans+=b[i]
            b[i]-=a[i]
            a[i]=0
            
            a[i+1]-=b[i]
        elif(b[i]<a[i]):
            ans+=b[i]
            a[i]-=b[i]
        # print(ans,i,a,b)
    print(ans)
            

Measured memory_bytes: 82916