akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {
	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char[] S1 = sc.next().toCharArray();
		char[] S2 = sc.next().toCharArray();

		long sum = S1[0] == S2[0] ? 3 : 6;
		int start = S1[0] == S2[0] ? 1 : 2;
		boolean prev = S1[0] == S2[0]; // 縦なら true, 横なら false
		for (int i = start; i < N; i++) {
			int pow;
			if (prev) {
				pow = 2;
			} else {
				if (S1[i] == S2[i]) {
					pow = 1;
				} else {
					pow = 3;
				}
			}
			sum = ((sum % MOD) * pow) % MOD;
			// debug(sum, pow, S1[i], S2[i]);

			if (S1[i] != S2[i]) {
				i++;
			}
			prev = S1[i] == S2[i];
		}
		System.out.println(sum);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

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

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

int main(void) {
    const int INF = 1 << 30;
    int n, a[100], max_a = INF * (-1), min_a = INF;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n) {
        cin >> a[i];
        max_a = max(max_a, a[i]);
        min_a = min(min_a, a[i]);
    }
    
    cout << max_a - min_a << "\n";
    return 0;
}

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

int a[100000];
int cnt[200000];

int main(){
	int n,k;scanf("%d%d",&n,&k);
	rep(i,n)scanf("%d",&a[i]);
	int g=0;
	set<int>se;
	int ans=INT_MAX;
	rep(i,n){
		while(g<n&&se.size()<k){
			if(a[g]>k){g++;continue;}
			cnt[a[g]]++;
			se.insert(a[g++]);
		}
		if(se.size()<k)break;
		ans=min(ans,g-i);
		if(a[i]<=k){
			cnt[a[i]]--;
			if(!cnt[a[i]])se.erase(a[i]);
		}
	}
	if(ans==
	INT_MAX)puts("0");
	else cout<<ans<<endl;
}

Measured memory_bytes: 8668
#include<stdio.h>

int main()
{
  //input
  int N, v, j;
  scanf("%d", &N);
  int A[N];
  for(int i=0; i<N; i++) scanf("%d", &A[i]);
  //calc
  for(int i=1; i<N+1; i++)
    {
      for(int k=0; k<N; k++)
	{
	  printf("%d", A[k]);
	  if(k<N-1) printf(" ");
	}
      printf("\n");
      v = A[i];
      j = i - 1;
      while(j >= 0 && A[j] > v)
	{
	  A[j+1] = A[j];
	  j--;
	  A[j+1] = v;
	}
    }
  return 0;
  }



Measured memory_bytes: 2128
#include "bits/stdc++.h"
#define rep(i,N) for (int (i) = 0; (i) < (N); (i)++)

int main() {

	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
	
	std::string S; std::cin >> S;
	std::cout << "2018";
	for (int i = 4; i < S.size(); i++) {
		std::cout << S[i];
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N;
  cin >> N;
  while (N > 1000) N -= 1000;
  cout << 1000 - N << endl;
  return 0;
}

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

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

using namespace std;

const int MAX_V = 3000;
const int IINF = INT_MAX;
typedef pair<int,int> ii;

map<ii,int> mp; /////////

struct Edge{ int to,cap,rev; bool isRev; };

vector<Edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
  G[from].push_back((Edge){to,cap,G[to].size(),false});
  G[to].push_back((Edge){from,0,G[from].size()-1,true});
}

int dfs(int v,int t,int f){
  if( v == t ) return f;
  used[v] = true;
  for(int i=0;i<G[v].size();i++){
    Edge &e = G[v][i];
    if( !used[e.to] && e.cap > 0 ){
      int d = dfs(e.to,t,min(f,e.cap));
      if( d > 0 ){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s,t,IINF);
    if( f == 0 ) return flow;
    flow += f;
  }
}

vector<int> G2[MAX_V],rG2[MAX_V];
bool visited[2][MAX_V];

void init(int _size=MAX_V){ rep(i,_size) G[i].clear(), G2[i].clear(), rG2[i].clear(); }

int V,E;

void icompute(int s,bool used[MAX_V],int type){
  used[s] = true;
  deque<int> deq;
  deq.push_back(s);
  while( !deq.empty() ){
    int cur = deq.front(); deq.pop_front();
    rep(i,(int)(type?G2[cur].size():rG2[cur].size())){
      int next = type?G2[cur][i]:rG2[cur][i];
      if( !used[next] ) {
	used[next] = true;
	deq.push_back(next);
      }
    }
  }
}

void compute(int let,int go){
  int maxi = max_flow(let,go);
  rep(i,V) {
    int s = i;
    rep(j,(int)G[i].size()) if( G[i][j].cap ) {
      int t = G[i][j].to, c = G[i][j].cap;
      G2[s].push_back(t), rG2[t].push_back(s);
    }
  }

  memset(visited,false,sizeof(visited));
  icompute(let,visited[0],1);
  icompute(go ,visited[1],0);
  /*
  rep(i,V) {
    cout << i+1 << "-th : " << visited[0][i] << " ";
  } cout << endl << endl;

  rep(i,V) {
    cout << i+1 << "-th : " << visited[1][i] << " ";
  } cout << endl << endl;
  */
  int cnt = 0;
  rep(i,V) rep(j,(int)G[i].size()) if( G[i][j].cap && !G[i][j].isRev ) {
    if( visited[0][G[i][j].to] && visited[1][i] ) ++cnt;
  }
  cout << maxi + ( cnt > 0 ) << " " << cnt << endl;
}

int main(){
  int s,t;
  while( cin >> V >> E >> s >> t, V|E|s|t ) {
    --s, --t;
    init(V);
    set<ii> S;
    rep(i,E) {
      int a,b;
      scanf("%d %d",&a,&b);
      --a, --b;
      add_edge(a,b,1);
    }
    compute(s,t);
  }
  return 0;
}

Measured memory_bytes: 2400
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,K,S,k=1;
  cin>>N>>K>>S;
  if(S==1000000000)
    k=-1;
  for(int i=0;i<N;i++){
    if(i<K)
      cout<<S;
    else
      cout<<S+k;
    if(i!=N-1)
      cout<<' ';
    else
      cout<<endl;
  }
}

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

int main()
{
  int n;
  cin >> n;
  int ans = 1;
  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    if (a % 2 == 0)
    {
      if (a % 3 == 0 || a % 5 == 0)
      {
        continue;
      }
      ans = 0;
    }
  }
  if (ans)
  {
    cout << "APPROVED" << endl;
  }
  else
  {
    cout << "DENIED" << endl;
  }
}


Measured memory_bytes: 3648
/*  -*- coding: utf-8 -*-
 *
 * 2709.cc: Dark Room
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

typedef vector<int> vi;
typedef queue<vi> qvi;
typedef map<vi,int> mvii;

/* global variables */

bool dks[MAX_N];
int vs[MAX_N][MAX_N];
mvii dists;

/* subroutines */

/* main */

int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);

  vi st;
  for (int i = 0; i < m; i++) {
    int di;
    scanf("%d", &di);
    di--;
    st.push_back(di);
    dks[di] = true;
  }

  for (int i = 0; i < n; i++)
    for (int j = 0; j < k; j++)
      scanf("%d", &vs[i][j]), vs[i][j]--;

  qvi q;
  q.push(st);
  dists[st] = 0;
  int mind = -1;

  while (! q.empty()) {
    vi u = q.front(); q.pop();
    int un = u.size(), vd = dists[u] + 1;

    for (int i = 0; i < k; i++) {
      vi v;
      for (int j = 0; j < un; j++) {
	int &vj = vs[u[j]][i];
	if (dks[vj]) v.push_back(vj);
      }

      if (v.empty()) {
	printf("%d\n", vd);
	return 0;
      }
      sort(v.begin(), v.end());
      v.erase(unique(v.begin(), v.end()), v.end());

      if (dists.find(v) == dists.end()) {
	dists[v] = vd;
	q.push(v);
      }
    }
  }

  return 0;
}

Measured memory_bytes: 12024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    long long N, T;
    cin >> N >> T;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    long long m = A[0], M = 0;
    long long res = 0;
    long long cnt = 1;
    for(int i = 0; i < N; i++){
        if(m > A[i]){
            if(res < M - m){
                res = M - m;
                cnt = 1;
            }
            else if(res == M - m) cnt++;
            m = A[i];
            M = 0;
        }
        if(M < A[i] && m != A[i]) M = A[i];
    }
    if(res == M - m) cnt++;
    cout << cnt << endl;
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
    int b1, b2, b3;
    string ans;
    cin >> b1 >> b2 >> b3;
    
    if(b1 == 1 && b2 == 1 && b3 == 0){
    ans = "Open";
    }else if(b1 == 0 && b2 == 0 && b3 == 1){
      ans = "Open";
      }else{
        ans = "Close";
      }
      cout << ans << endl;
     return 0;
}



Measured memory_bytes: 3116
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        String str = sc.next();
        String s[] = new String[n];

        for (int i = 0; i < n; i++) {
            s[i] = str.substring(i, i+1);
        }
        s[k-1] = s[k-1].toLowerCase();

        for (int i = 0; i < n; i++) {
            System.out.print(s[i]);
        }
        System.out.println();
	}
}

Measured memory_bytes: 19028
import string
import itertools


def main():
    n = int(input())
    s = input()

    front = [set()]
    for c in s:
        x = front[-1] | set([c])
        front.append(x)
        
    back = [set()]
    for c in reversed(s):
        x = back[0] | set([c])
        back.insert(0, x)
    
    m = 0
    for f, b in zip(front, back):
        x = f & b
        m = max(m, len(x))
    
    print(m)

main()

Measured memory_bytes: 3828
#include<stdio.h>
#include<string.h>
int main(){
   char S[100];
   int K;
   scanf("%d",&K);
   scanf("%s",S);
   int i;
   if(strlen(S)>K){
      for(i=0;i<K;i++){
         printf("%c",S[i]);
      }
      printf("...");
   }else{
      printf("%s",S);
   }
   return 0;
}


Measured memory_bytes: 1696
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll par[1000000];

ll find(ll a);
void combine(int a,int b);
bool same(int a,int b);
main(){
    vector<pair<pair<ll,ll>,ll>> E;//グラフの情報を保持している
    ll n,a,b,c,ans=0;
    cin>>n;
    pair<pair<ll,ll>,ll>v[n];
    for(int i=0;i<n;i++){
        cin>>v[i].first.first>>v[i].first.second;
        v[i].second=i;
    }

    sort(v, v+n, [](pair<pair<int, int>,int>p, pair<pair<int,int>,int>q){
  return p.first.first < q.first.first;
});
    for(int i=1;i<n;i++){
        a=v[i-1].second;
        b=v[i].second;
        c=fmin(abs(v[i-1].first.first-v[i].first.first),abs(v[i-1].first.second-v[i].first.second));
        E.push_back({{a,b},c});
    }

    sort(v, v+n, [](pair<pair<int, int>,int>p, pair<pair<int,int>,int>q){
    return p.first.second < q.first.second;
    });
    for(int i=1;i<n;i++){
        a=v[i-1].second;
        b=v[i].second;
        c=fmin(abs(v[i-1].first.first-v[i].first.first),abs(v[i-1].first.second-v[i].first.second));
        E.push_back({{a,b},c});
    }

    sort(E.begin(),E.end(), [](pair<pair<int, int>,int>p, pair<pair<int,int>,int>q){
      return p.second < q.second;
    });

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

for(int i=0;i<E.size();i++){
if(!same(E[i].first.first,E[i].first.second)){
    combine(E[i].first.first,E[i].first.second);
    ans+=E[i].second;
}
}

cout<<ans<<endl;
}

int find(int a){
int k;
k=a;
while(par[a]!=a){
a=par[a];
}
par[k]=a;
return a;
}
 
void combine(int a,int b){
int a1,b1;
a1=find(a);
b1=find(b);
if(a1!=b1){
par[b1]=a1;
}
}

bool same(int a,int b){
  if(find(a)==find(b))return true;
  return false;
}


Measured memory_bytes: 10864
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char fmt_buf[256];
int prev_fmt = 0;

char *mkfmt(int n) {
    if (n == prev_fmt) return fmt_buf;
    prev_fmt = n;
    memset(fmt_buf, 0, sizeof(typeof(fmt_buf)));
    int c = 0;
    for (int i = 0; i < n - 1; i++) {
        memcpy(fmt_buf + c, "%lld ", 5);
        c += 5;
    }
    memcpy(fmt_buf + c, "%lld", 4);
    return fmt_buf;
}

int cmp(const void *const a, const void *const b) {
    long long aa = *(long long *) a;
    long long bb = *(long long *) b;
    return aa == bb ? 0 : (aa > bb ? 1 : -1);
}

long long read(long long *t, long long n) {
    long long r = 0;
    while (n > 0) {
        r += t[n];
        n -= (n & -n);
    }
    return r;
}

void update(long long *t, long long s, long long n, long long d) {
    while (n < s) {
        t[n] += d;
        n += (n & -n);
    }
}

int main() {
    long long n, k, *a, *b, *c, *d, r = 0;
    scanf(mkfmt(2), &n, &k);
    a = malloc(sizeof(*a) * n);
    b = malloc(sizeof(*b) * (n + 1));
    c = malloc(sizeof(*c) * (n + 1));
    d = malloc(sizeof(*d) * (n + 2));
    for (int i = 0; i < n; i++) scanf(mkfmt(1), &a[i]);
    for (int i = 0; i < n; i++)a[i] -= k;
    b[0] = 0;
    for (int i = 0; i < n; i++)b[i + 1] = b[i] + a[i];
    memcpy(c, b, sizeof(*b) * (n + 1));
    qsort(b, n + 1, sizeof(*b), cmp);
    for (int i = 0; i < n + 1; i++) c[i] = ((long long *) bsearch(&c[i], b, n + 1, sizeof(*b), cmp) - b) + 1;
    memset(d, 0, sizeof(*d) * (n + 2));
    for (int i = 0; i <= n; i++) {
        r += read(d, c[i]);
        update(d, n + 2, c[i], 1);
    }
    printf(mkfmt(1), r);
}

Measured memory_bytes: 6496
// C - Train Ticket
#include <bits/stdc++.h>
using namespace std;

int main(){
    string str;
    cin >> str;
    int A,B,C,D;
    A = int(str.at(0) - '0');
    B = int(str.at(1) - '0');
    C = int(str.at(2) - '0');
    D = int(str.at(3) - '0');

    //cout << A << " " << B << " " << C << " " << D <<  endl;   
    if (A + B + C + D  == 7){
        cout << A << "+" << B << "+" << C << "+" << D << "=7" <<  endl;   
    }else if (A + B + C - D  == 7){
        cout << A << "+" << B << "+" << C << "-" << D << "=7" <<  endl;       
    }else if (A + B - C + D  == 7){
        cout << A << "+" << B << "-" << C << "+" << D << "=7" <<  endl;       
    }else if (A + B - C - D  == 7){
        cout << A << "+" << B << "-" << C << "-" << D << "=7" <<  endl;       
    }else if (A - B + C + D  == 7){
        cout << A << "-" << B << "+" << C << "+" << D << "=7" <<  endl;       
    }else if (A - B + C - D  == 7){
        cout << A << "-" << B << "+" << C << "-" << D << "=7" <<  endl;       
    }else if (A - B - C + D  == 7){
        cout << A << "-" << B << "-" << C << "+" << D << "=7" <<  endl;       
    }else if (A - B - C - D  == 7){
        cout << A << "-" << B << "-" << C << "-" << D << "=7" <<  endl;       
    }else{
      ;
    }
  
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,k;cin >> a >> b >> k;
	rep(i,k){
		if(i%2==0){
			a/=2;
			b+=a;
		}
		else{
			b/=2;
			a+=b;
		}
	}
	cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	int result;
	
	// http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1154186366
	// 階乗のなかで、０が増えるのは、２と５を約数にもった数を
	// 掛けたときです。特に２と５の２つを比べると
	// 圧倒的に５が少ないですから、５の倍数を調べて５の約数の数を
	// 見つけるのです。そして５の約数の数だけ０が増えていくのです。
	while(scanf("%d\n", &n) == 1) {
		if(n==0) break;
		result = 0;
		while(n!=0) {
			n /= 5;
			result += n;
		}
		printf("%d\n", result);
	}
	
	return 0;
}

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

/*方針*/
//文字列が十分に小さいから、全探索→s[i]とs[i+1]の間に+を入れるかどうかで全探索(dfs)

/*
➀divというbool型配列にs[i],s[i+1]の間に入れるかどうかの判定
　を持たせる(s[i],s[i+1]の間の判定はdiv[i]に入れる)

➁div[n-2]までdfsで判定を入れる(div[n-1]には、番兵としてtrueを入れる)

➂➁を元にして、そのときの値をansに足す
*/
ll ans=0;
string s;

void dfs(vector<bool> &div,ll num,bool divide){
    //divに入れ終わったら計算する
    if(num==s.size()-1){
        ll a=0,b=0;
        while(a!=num+1){
            if(div[a]){//+で分割するときの最後の桁  　　　　s: 1 2 3 4 5 6 7 8 
                ans+=(10*b+(ll)(s[a]-'0'));           //div: 0 0 0 1 0 1 0 1 (1が+を入れる判定) 
                b=0;                                  //このときは　1234+56+78となる。最後のdivは番兵として入れないと、78を足せない
            }else{//+で分割されていない部分
                b=10*b+(ll)(s[a]-'0');
            }
            a++;
        }
        return;
    }


    div[num]=divide;

    dfs(div,num+1,true);//s[num+1] s[num+2]の間に+を入れる
    dfs(div,num+1,false);//入れない

    return;
}

int main(){
    cin>>s;

    vector<bool> div(s.size());
    div[s.size()-1]=true;//番兵
    
    dfs(div,0,true);
    dfs(div,0,false);
    
    cout<<ans/2<<endl;//最後のdfsのとき、div[s.size()-1]はtrueなのに、2回数えられてしまっているので半分にして調整
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)

int
main(int argc, const char *argv[])
{
  int w, a, b;
  scanf("%d %d %d", &w, &a, &b);

  if ((a <= b && b <= a + w) || (a <= b + w && b + w <= a + w))
    printf("0\n");
  else
    printf("%d\n", Min(abs(a - b), Min(abs(a + w - b), abs(a - (b + w)))));

  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
using namespace std;

int N;
vector < pair<int, int> > adj[100000];
int v1, v2, dist;
queue<int> q;
int d[100000];

int main() {
	scanf("%d", &N);

	for (int i = 0; i < N - 1; i++) {
		scanf("%d %d %d", &v1, &v2, &dist);
		adj[v1 - 1].push_back(make_pair(v2 - 1, dist%2));
		adj[v2 - 1].push_back(make_pair(v1 - 1, dist%2));
	}

	for (int i = 0; i < N; i++) {
		d[i] = -1;
	}
    q.push(0);
    d[0] = 0;
    
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(int j=0;j<adj[v].size();j++){
            int u = adj[v][j].first;
            if(d[u] == -1){
                q.push(u);
                d[u] = (d[v] + adj[v][j].second)%2;
            }
        }
    }
    
    for(int i=0;i<N;i++){
        printf("%d\n", d[i]%2);
    }
}

Measured memory_bytes: 6784
import collections, math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N, P = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    A[i] = A[i] % 2
c = collections.Counter(A)
zero = c[0]
one = c[1]

ans = 0
if P == 0:
    for i in range(0, one + 1, 2):
        ans += (2 ** zero) * (combinations_count(one, i) )
else:
    for i in range(1, one + 1, 2):
        ans += (2 ** zero) * (combinations_count(one, i) )
print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
    long int n,d;
    int b=0;
    long long c;
    long int x[200000],y[200000];
    cin >> n >> d;
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }
    for(int f=0;f<n;f++){
        c=(x[f]*x[f]+y[f]*y[f]);
        if(c<=d*d){
            b++;
        }
    }
    cout << b;
    return 0;
}

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

int main(){
  int k;
  string s;
  cin >> s;
  k = s.size();
  if(k < 8){
    cout << "YES";
  }else{
    int c;
    for(int i = 0; i < k; i++){
      if(s.at(i) == 'o'){
        c++;
      }
    }
    if(15-k >= 8-c){
      cout << "YES";
    }else{
      cout << "NO";
    }
  } 
}

Measured memory_bytes: 256
num = int(input())
for j in range(num):
    house,gen = map(int,input().split())
    
    point = list(map(int,input().split()))
    
    if house ==1 and gen >=1:
        print(0)
    elif house == 2 and gen == 1:
        print(point[-1])
    elif house == 2 and gen >= 2:
        print(0)
    elif house <= gen:
        print(0)
    elif house >=3 and gen ==1:
        print(max(point)-min(point))
    
    elif house >= 3:

        length = []
        for i in range(1,house):
            length.append(point[i]-point[i-1])
        length.sort()

        print(sum(length[:-1*(gen-1)]))


Measured memory_bytes: 21632
<?php
fscanf(STDIN, '%d %d %d', $r, $d, $first);
$ans = 0;
$tmp = $first;
for($i = 1; $i <=10; $i++) {
    $ans = $r * $tmp - $d;
    echo $ans, PHP_EOL;
    $tmp = $ans;
}

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

const int N = 1e5 + 5;

int n;
string s;
int carry[N], a[N];

bool check(int k) {
	for (int i = 1; i <= n; ++i) a[i] = (s[i] != s[i - 1]);
	for (int i = 1; i <= n; ++i) if (i - k < 1 && i + k > n + 1) {
		if (a[i] == 1) return false;
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> s;
	n = s.size();
	s = '0' + s;

	int l = 0, r = n;
	while(l < r) {
		int mid = ((l + r + 1) >> 1);
		if (check(mid)) l = mid; else r = mid - 1;
	}
	cout << l << endl;
}

Measured memory_bytes: 748
N, M = map(int, input().split())
stores = []
for i in range(N):
    stores.append(list(map(int, input().split())))
stores.sort()
answer = 0
for store in stores:
    yasui = min(M, store[1])
    M -= yasui
    answer += store[0] * yasui
    if M == 0:
        break
print(answer)


Measured memory_bytes: 27760
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, a;

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a;
		if (a % 2 == 0) {
			if (a % 3 != 0 && a % 5 != 0) {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <tuple>
#include <queue>
using namespace std;

typedef long long ll;

#define INF 100000000;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define eps 1.0e-14;

using Graph = vector<vector<int>>;

vector<bool> seen;

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

	Graph G(N);
	for (int i = 0; i < M; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	vector<int> dist(N, -1);
	queue<int> que;

	dist[0] = 0;
	que.push(0);

	while(!que.empty()){
		int v = que.front();
		que.pop();

		for (int nv : G[v]) {
			if (dist[nv] != -1) continue;
			dist[nv] = dist[v] + 1;
			que.push(nv);
		}
	}
	cout << "Yes" << endl;
	for(int i = 1; i < N; i++){
		//cout << dist[i] << endl;
		for (int jk : G[i]){
			if (dist[jk] == dist[i] - 1){
				cout << jk + 1 << endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 10228
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#define MV 51
#define MX 101
#define MX2 202
#define MOD 1000000007

using namespace std;

typedef long long ll;

template <typename T> void read(T& x)
{
	x = 0; char c = getchar();
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
}

int fst[MV], nxt[MX2], u[MX2], v[MX2], lnum;
ll fac[MX2], faci[MX2];

void addeg(int nu, int nv)
{
	nxt[++lnum] = fst[nu];
	fst[nu] = lnum;
	u[lnum] = nu;
	v[lnum] = nv;
}

int low[MV], dfn[MV], stk[MX], bel[MX], top, scc, dfc;
int n, m, k;

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

ll qpow(ll x, ll t)
{
	ll ans = 1;
	while(t)
	{
		if(t & 1) ans = ans*x%MOD;
		x = x*x%MOD;
		t >>= 1;
	}
	return ans;
}

ll binom(int x)
{
	return fac[x+k-1] * faci[k-1] % MOD * faci[x] % MOD;
}

ll polya(int x)
{
	ll ret = 0;
	for(int i=0; i<x; i++)
		ret = (ret + qpow(k, gcd(i, x))) % MOD;
	return ret * qpow(x, MOD-2) % MOD;
}

void init()
{
	fac[0] = 1;
	for(int i=1; i<MX2; i++) fac[i] = fac[i-1] * i%MOD;
	faci[MX2-1] = qpow(fac[MX2-1], MOD-2);
	for(int i=MX2-1; i>=1; i--) faci[i-1] = faci[i] * i % MOD;
	lnum = 0;
}

void input()
{
	int a, b;
	read(n); read(m); read(k);
	for(int i=1; i<=m; i++)
	{
		read(a); read(b);
		addeg(a, b);
		addeg(b, a);
	}
}

ll ans = 1;

void tarjan(int x, int f)
{
	dfn[x] = low[x] = ++dfc;
	for(int i=fst[x]; i; i=nxt[i])
	{
		int y = v[i];
		if(!dfn[y])
		{
			stk[++top] = i;
			tarjan(y, x);
			low[x] = min(low[x], low[y]);
			if(low[y] >= dfn[x])
			{
				scc++;
				int pcnt = 0, ecnt = 0;
				while(1)
				{
					int now = stk[top--];
					ecnt++;
					if(bel[u[now]] != scc) bel[u[now]] = scc, pcnt++;
					if(bel[v[now]] != scc) bel[v[now]] = scc, pcnt++;
					if(now == i) break;
				}
				if(pcnt < ecnt) ans = ans * binom(ecnt) % MOD;
				else if(pcnt == ecnt) ans = ans * polya(ecnt) % MOD;
				else ans = ans * k % MOD;
			}
		}
		else if(dfn[y]<dfn[x] && y!=f)
		{
			low[x] = min(low[x], dfn[y]);
			stk[++top] = i;
		}
	}
}

int main()
{
	init();
	input();
	for(int i=1; i<=n; i++)
		if(!dfn[i])
			tarjan(i, 0);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
while 1:
    H, W = map(int ,raw_input().split())
    if H == 0 and W == 0:
        break
    else:
        for i in range(H):
            if i == 0:
                print ('#'*W)
            elif i == H-1:
                print ('#'*W + '\n')
            else:
                print ('#' + '.'*(W-2) + '#')

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

using namespace std;

int N, M, Q;
int a[100], b[100], c[100], d[100];
int ans;

void dfs(vector<int> &v) {
    if(v.size() == N+1) {
        int sum = 0;
        for(int i=0; i<Q; i++) {
            if(v[b[i]]-v[a[i]] == c[i]) sum += d[i];
        }
        ans = max(ans, sum);
    } else {
        for(int i=v.back(); i<=M; i++) {
            v.emplace_back(i);
            dfs(v);
            v.pop_back();
        }
    }
}

int main(void) {
    cin >> N >> M >> Q;
    for(int i=0; i<Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    vector<int> v = {1};
    dfs(v);

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC109.B
{
    class Program
    {
        static void Main()
        {
            var sc = new Scanner();
            var n = sc.Nextint();
            var w = Enumerable.Range(0, n).Select(i => sc.Next()).ToArray();
            var usedSet = new HashSet<string>();
            usedSet.Add(w[0]);
            for (int i = 1; i < n; i++)
            {
                if (usedSet.Contains(w[i]) || w[i - 1].Last() != w[i].First())
                {
                    Console.WriteLine("No");
                    return;
                }
                usedSet.Add(w[i]);
            }
            Console.WriteLine("Yes");
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int Nextint()
        {
            return int.Parse(Next());
        }
        public int[] Arrayint(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        public double[] ArrayDouble(long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}


Measured memory_bytes: 13524
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());//昇順ソート
#define usort(a) sort(a.rbegin(),a.rend());//降順ソート

using namespace::std;

int jo(ll int a, ll int b){//累乗
    ll int num=1;
    rep(i,0,b) num=num*a;
    return num;
}
char tobig(char s){//char大文字化
  return (s-0x20);
}
char tolow(char s){//char小文字化
  return (s+0x20);
}
int ctoi(char a){//char->int
  if('0'<=a&&a<='9') return (a-'0');
  return -1;
}

int gcd(ll int a,ll int b) {//最大公約数
  if(a<b) return gcd(b,a);
  int c;
  while ((c=a%b)) {
    a=b;
    b=c;
  }
  return b;
}
int lcm(ll int a,ll int b){//最小公倍数
 return (a*b)/gcd(a,b);
}


int main(){
  string S;cin>>S;
  rep(i,0,8) S.pop_back();
  cout<<S;
}




// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;
const ll inf2 = 0x3f3f3f3f3f3f3f3f;
inline void read(int &x){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    x = s*w;
}

char S[maxn],T[maxn];
int lens,lent;
void solve(){
    int ans = inf;
    for(int i = 1;i<=lens-lent+1;i++){
        int cnt = 0;
        for(int j = 1;j<=lent;j++){
            if(S[i + j-1] != T[j]){
                cnt++;
            }
        }
        ans = min(ans,cnt);
    }
    cout<<ans<<'\n';
}
int main(){
//    debug;
    ios;

    cin>>(S+1)>>(T+1);
    lens = strlen(S+1);
    lent = strlen(T+1);
    solve();


    return 0;
}

Measured memory_bytes: 3652
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end
N = gets_i

t = gets_i

(N-1).times do
  t = t.lcm(gets_i)
end

puts t

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, i,j;
  int x;
  int sum=100;
  cin >> N;
  for(i=1;i<=N;i++){
	cin >> A;
    int count=0;
	while(A%2!=1){
      A/=2;
      count +=1;    	
      /*      for(j=A;j==1;j/2){
		count +=1;    			
	  }
      */}
     if(sum>count){
    		 sum = count;
		   }   
  }
  cout << sum << endl;
}
   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  for(int i = 0; i < 12; i++){
    cout << s[i];
    if(i == 3) cout << " ";
  }
  cout << endl;  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>
#define MOD 1000000007
using namespace std;
typedef long long ll;
char s[100010];
ll dp[100010][13],a[100010];
int main(){
    int n;
    scanf("%s",s);
    n=strlen(s);
    dp[0][0]=1;
    a[n-1]=1;
    for(int i=n-2;i>=0;i--){
        a[i]=a[i+1]*10;
        a[i]%=13;
    }
    for(int i=0;i<n;i++){
        if(s[i]=='?'){
            for(int j=0;j<=9;j++){
                for(int k=0;k<13;k++){
                    dp[i+1][(j*a[i]+k)%13]+=dp[i][k];
                    dp[i+1][(j*a[i]+k)%13]%=MOD;
                }
            }
        }
        else{
            for(int j=0;j<13;j++){
                dp[i+1][((j+(s[i]-'0')*a[i]))%13]+=dp[i][j];
                dp[i+1][((j+(s[i]-'0')*a[i]))%13]%=MOD;
            }
        }
    }
    printf("%lld\n",dp[n][5]);
}

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

int main(){
	string s;cin>>s;
	string ans;
	rep(i,s.size()){
		if(i%2==0)ans+=s[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long int split(long long int h){
    
    if(h==1)
        return 1;
        
    else 
      return 1+2*split(floor(h/2));
       
}

int main(){
    long long int H;
    cin>>H;
   cout<<split(H);
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i, s, n) for(int i = s; i < n; i++)
#define ll long long

int main() {
    int n, k;
    cin >> n >> k;

    double gain = 0;

    rep(i, 1, n+1) {    
        double tmp = 1.0/n;
        double plus = i;
        while(plus < k) {
            plus *= 2;
            tmp /= 2;
        }
        gain += tmp;
    }

    //cout << gain << endl;
    printf("%.12f\n", gain);
}

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

using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

bool dp[100100];

int main () {
    int N;
    cin >> N;

    vector<int>w(N);
    rep(i,N){
        cin >> w[i];
    }

    int ans =100000;
    repr(i,0,N){
        int s1=0;
        int s2=0;

        rep(j,i+1){
            s1+= w[j];
        }
        repr(j,i+1,N){
            s2+= w[j];
        }
        ans =min(ans,abs(s1-s2));
    }

    cout << ans << endl;

}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(sys.getrecursionlimit())
N = int(input())
A = list(map(int,input().split(" ")))

def gcd (a: int,b: int) -> int:
    if a < b: a,b = b,a
    return a if b == 0 else gcd(b,a%b)
def lcm (a: int,b: int) -> int:
    return a // gcd(a,b) * b

gcdForward = [0] * N
gcdBackWard = [0] * N
gcdForward[0] =  A[0]
gcdBackWard[N-1] = A[-1]
for i in range(N-1):
    gcdForward[i+1] = gcd(gcdForward[i],A[i+1])
    gcdBackWard[N-i-2] = gcd(gcdBackWard[N-i-1],A[N-i-2])


if N == 2:
    print(max(A))
    exit(0)
else:
    ans = max(gcdBackWard[1],gcdForward[N-2])
    for i in range(1,N-1):
        ans = max(ans,gcd(gcdForward[i-1],gcdBackWard[i+1]))
    print(ans)

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

int main(){
  int N,K;
  cin >>N>>K;
  int a[N];
  map <int,int> mp;
  for (int i=0;i<N;i++){
    cin>>a[i];
    mp[a[i]]++;
  }
  int num=mp.size();
  int col[num];
  auto itr=mp.begin();
  for (int i=0;i<num;i++){
    col[i]=itr->second;
    //cout<<i<<" "<<itr->first<<" "<<col[i]<<endl;
    itr++;
  }
  int ans=0;
  sort(col,col+num);
  int i=0;
  while(num>K){
    ans=ans+col[i];
    num--;
    i++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 11136
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <numeric>

using namespace std;

typedef long long int lo;
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9
#define N (lo)1e5 * 5
#define all(x) (x).begin(), (x).end()
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
#define si pair<string,lo>
#define vi vector <lo> 
#define vii vector <ii> 

int main() {
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0);
    lo x;
    cin >> x;
    lo c = 100;
    for(lo i = 1 ; i < 4000 ; i++){
	//cout << c << endl;
	c += (lo)((lo)c / (lo)100);
	if(c >= x){
	    cout << i << endl;
	    return 0;
	}
    }
    return 0;
}


Measured memory_bytes: 3652
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	string s, t;
	cin >> s >> t;

	for (int i = 0; i < N; i++) {
		cout << s[i] << t[i];
	}
	cout << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,k;
	char a[1001];
	while(1){
		k=0;
		scanf("%s",a);
		if(a[0]=='0')break;
		for(i=0;a[i]!='\0';i++)k+=a[i]-'0';
		printf("%d\n",k);
	}
	return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -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;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };


int main() {
   ll K,A,B;
   cin >> K >> A >> B;
   if(B-A<=2 || K < A-1){
       fin(1+K);
   }else{
       //まずスタート一枚からAまで行く回数を出す
       //A枚まで増やす→B-A枚残りで増やし続けるにする
       
       
       ll sum=A;
       K-=A-1;
       
       if(K%2 == 1){
           //残りKが奇数回だったら
           sum++;
           K--;
       }
       sum += (B-A)*(K/2);
       fin(sum);
   }


}
    



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

using namespace std;

int main()
{
    long double W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << W*H/2 << " ";
    if (x == W/2 && y == H/2)
    {
        cout << 1;
    }
    else
    {
        cout << 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	int N;
	cin >> N;
	vl A(N), B(N);
	REP(i, N) {
		cin >> A[i];
	}
	REP(i, N) {
		cin >> B[i];
	}

	ll ans = 0, d = 0;
	vl m;
	REP(i, N) {
		if (A[i] < B[i]) {
			ans++;
			d += B[i] - A[i];
		}
		else if(A[i] > B[i]) {
			m.push_back(A[i] - B[i]);
		}
	}

	sort(RALL(m));
	int ms = m.size();
	bool ok = false;
	if (d == 0) {
		ok = true;
		
	}
	else {
		REP(i, ms) {
			ans++;
			d -= m[i];
			if (d <= 0) {
				ok = true;
				break;
			}
		}
	}

	if (ok) {
		cout << ans << endl;
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 2428
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 mod = 1000000007;

int n, k;

ll dfs(int v, int p, vector<vector<int>> &G){
	int col_num;
	if(p == -1) col_num = k-1;
	else col_num = k-2;
	if(k < G[v].size()) return 0;
	ll case_num = 1;
	for(auto nv : G[v]){
		if(nv == p) continue;
		case_num *= col_num;
		col_num--;
		case_num %= mod;
	}
	for(auto nv : G[v]){
		if(nv == p) continue;
		case_num *= dfs(nv, v, G);
		case_num %= mod;
	}
	return case_num;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
	vector<vector<int>> G(n);
    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
	ll ans = k * dfs(0, -1, G);
	ans %= mod;
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11648
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <algorithm>

using namespace std;
typedef long long ll;

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

	string s;
	cin >> s;

	vector<int> v(n, 0);
	int t=0, r=300010;

	for(int i=0; i<n; i++){
		v[i]=t;
		if(s[i]=='W') t++;
	}

	t=0;
	for(int i=n-1; 0<=i; i--){
		v[i]+=t;
		if(s[i]=='E') t++;
		r=min(r, v[i]);
	}

	cout << r << endl;

	return 0;

}



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

ans = 0
s = 0


def judge(x, y, z):
    width = y + 2 * z
    if width > x:
        return 0

    s = 1  # 上記条件を通過で1人は座れる
    rest = x - width

    width = y + z
    while width <= rest:
        s += 1
        width = y + z
        rest -= width
    return s


print(judge(X, Y, Z))


Measured memory_bytes: 3060