akhauriyash/Code-Regression huggingface dataset:
# https://atcoder.jp/contests/abc157/tasks/abc157_b


Ass = Array.new(3) { gets.split.map(&:to_i) }
N = gets.to_i
bs = Array.new(N) { gets.to_i }

cond = Array.new(3) {Array.new(3) {false}}


N.times do |k|
  3.times do |i|
    3.times do |j|
      cond[i][j] = true if bs[k] == Ass[i][j]
    end
  end
end

def checkBingo(cond)
  ans = false
  3.times do |i|
    ans ||= (cond[i][0] && cond[i][1] && cond[i][2])
    ans ||= (cond[0][i] && cond[1][i] && cond[2][i])
  end

  ans ||= (cond[0][0] && cond[1][1] && cond[2][2])
  ans ||= (cond[0][2] && cond[1][1] && cond[2][0])
end

ans = checkBingo(cond)

puts ans ? 'Yes' : 'No'


Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

string S, T;
int len;
bool finish;

void dfs(int v) {
  if (len == v) {
    cout << S << endl;
    finish = true;
    return;
  }

  if (S[v] == '?') {
    for (int i = 0; i < 26; i++) {
      S[v] = 'a' + i;
      dfs(v + 1);
      S[v] = '?';
      if (finish) return;
    }
  } else {
    dfs(v + 1);
  }
}

int main(int argc, char *argv[])
{
  cin >> S;
  cin >> T;
  len = S.size();

  for (int i = len-T.size(); i >= 0 ;i--) {
    bool ok = false;
    for (int j = 0; j < T.size(); j++) {
      if (S[i + j] == T[j] || S[i + j] == '?') {
        ok = true;
      } else {
        ok = false;
        break;
      }
    }

    if (ok == true) {
      for (int j = 0; j < T.size() ; j++) {
        swap(S[i + j], T[j]);
      }
      dfs(0);
      return 0;
    }
  }

  cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
inline void add(int &x,int y){(x+=y)>=mod?x-=mod:0;}
int n,a[610],b[610],cnt,ans,dp[2][310][310];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n;i+=2)
	{
		scanf("%d %d",&a[i],&a[i+1]);
		if(a[i]!=-1)
		{
			if(a[i+1]!=-1)b[a[i]]=b[a[i+1]]=1;
			else b[a[i]]=2;
		}
		else
		{
			if(a[i+1]!=-1)b[a[i+1]]=2;
			else ++cnt;
		}
	}
	int t=0;
	dp[0][0][0]=1;
	for(int i=2*n;i;--i)
		if(b[i]!=1)
		{
			t^=1;
			memset(dp[t],0,sizeof(dp[t]));
			if(b[i]==2)
			{
				for(int j=0;j<=n;++j)
					for(int k=0;k<=n;++k)
						if(dp[t^1][j][k])
						{
							add(dp[t][j][k-1],dp[t^1][j][k]);
							add(dp[t][j+1][k],dp[t^1][j][k]);
						}
			}
			else
			{
				for(int j=0;j<=n;++j)
					for(int k=0;k<=n;++k)
						if(dp[t^1][j][k])
						{
							if(j)add(dp[t][j-1][k],1ll*j*dp[t^1][j][k]%mod);
							if(k)add(dp[t][j][k-1],dp[t^1][j][k]);
							add(dp[t][j][k+1],dp[t^1][j][k]);
						}
			}
		/*	for(int j=0;j<=n;++j)
			{
				for(int k=0;k<=n;++k)printf("%d ",dp[t][j][k]);
				printf("\n");
			}
			printf("\n");*/
		}
	ans=dp[t][0][0];
	for(int i=2;i<=cnt;++i)ans=1ll*ans*i%mod;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll p=1e9+7;
ll n,i,sum,f[1000010];
int main(){
	scanf("%lld",&n);
	f[n]=n;f[n-1]=n*n%p;
	for(i=n-2;i>=1;i--){
		sum=(sum+f[i+3])%p;
		f[i]=(f[i+1]+(n-1)*(n-1)%p+sum+i+1)%p;
	}
	printf("%lld",f[1]);
}

Measured memory_bytes: 8064
N = int(input())
t = [0] * (N + 1)
x = [0] * (N + 1)
y = [0] * (N + 1)

for i in range(N):
    t[i+1], x[i+1], y[i+1] = map(int, input().split())

f = True
for i in range(N):
    dt = t[i+1] - t[i]
    dictlist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    
    if dt < dictlist:
        f = False
    if dictlist % 2 != dt % 2:
        f = False

print("Yes" if f else "No")


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

int d,ans[365],c[26],s[365][26],last[26],tlast[26],S[365][26];
const int INF=1e9;

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

void FIN(int a){
  if(a){
    ofstream fout("output.txt");
    REP(i,d)fout<<ans[i]<<"\n";
    fout.close();
    return;
  }
  REP(i,d)cout<<ans[i]<<"\n";
  return;
}

int score(){
  int res=0;
  memset(tlast,-1,sizeof(tlast));
  REP(day,d){
    res+=S[day][ans[day]-1];
    tlast[ans[day]-1]=day;
    REP(i,26)res-=c[i]*(day-tlast[i]);
  }
  return res;
}

signed main(){
  memset(last,-1,sizeof(last));
  cin>>d;
  REP(i,26)cin>>c[i];
  REP(i,d)REP(j,26)cin>>s[i][j];
  REP(i,d)REP(j,26)S[i][j]=s[i][j];
  REP(j,26){
    int now=-INF;
    for(int i=364;i>=0;i--){
      if(s[i][j]<now)s[i][j]-=(now-s[i][j])/20;
      else now=s[i][j];
      now-=c[j];
    }
  }
  REP(day,d){
    vector<int> minus(26);
    REP(j,26)minus[j]=c[j]*(day-last[j]);
    int A=-INF,idx=0;
    REP(j,26){
      int tmp=s[day][j]+minus[j];
      if(A<tmp)A=tmp,idx=j;
    }
    ans[day]=idx+1;
    last[idx]=day;
  }
  REP(_,450){
    int day1=rand()%365,day2=rand()%365;
    if(day1==day2)day2++;if(day2==365)day2=0;
    int Sc=-INF,now1=ans[day1],now2=ans[day2];
    REP(i,26){
      REP(j,26){
        ans[day1]=i+1;
        ans[day2]=j+1;
        int R=score();
        if(Sc<R)Sc=R,now1=i+1,now2=j+1;
        else ans[day1]=now1,ans[day2]=now2;
      }
    }
  }
  FIN(0);
}


Measured memory_bytes: 3688
#include<stdio.h>
#include<string.h>
int main(void)

{
    char a[11],b[11],c[11];
    int g,o,l;
    scanf("%s%s%s",a,b,c);

   g= strlen(a); o=strlen(b); l=strlen(c);

   if ((a[g-1]==b[0])&&(b[o-1]==c[0]))
      printf("YES\n");
   else printf("NO\n");

return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main()
{
    long long n,num;
    int k,r=0,i,count=0;
    scanf("%lld%d",&n,&k);
    for(i=0; n!=0; i++)
    {
        r=n%k;
        n=n/k;
        num=(r*pow(10,i))+num;
        count++;
        num/=num;
   }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <algorithm>
#include <functional>
#include <limits.h>
#include <bitset>

#include <tuple>
#include <unordered_map>

#define mp       make_pair
#define mt       make_tuple
#define pb       push_back
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int N;
vector<int> pre;
map<int, int> in;
vector<int> ans;
int pos;
void rec(int l, int r){
	if (l >= r){
		return ;
	}
	int node = pre[pos++];
	int index = in[node];
	rec(l, index);
	rec(index + 1, r);
	ans.push_back(node);
}

int main(){
	cin >> N;
	pre.resize(N);
	pos = 0;
	for (int i = 0; i < N; i++){
		cin >> pre[i];
	}
	for (int i = 0; i < N; i++){
		int x;
		cin >> x;
		in[x] = i;
	}
	rec(0, N);
	for (int i = 0; i < ans.size(); i++){
		if (i != ans.size() - 1){
			cout << ans[i] << " ";
		}else{
			cout << ans[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1216
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl;
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 
int main(){
  ll N;
  cin >> N; 
  vector<ll> A(N);
  for(int i=0; i<N; i++) cin >> A[i];

  //const ll MAX_A = 1e6;
  ll MAX_A = 0;
  for(int i=0; i<N; i++){
    MAX_A = max(MAX_A, A[i]);
  }
  vector<ll> vec(MAX_A+5, 0);
  for(ll a: A){
      for(ll j=1; a*j <= MAX_A; j++){
        vec[a*j]++;
      }
  }

  ll ans = 0;
  for(ll a: A){
    if(vec[a] == 1) ans++;
  }

  cout << ans << endl;

}


Measured memory_bytes: 12756
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue (P x) {
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue() {
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min (int a, int b) {
    return a < b ? a : b;
    // 以下のプログラムと同値   
    // if (a < b) {
    //     return a;
    // } else if (a > b) {
    //     return b;
    // }
}

int main () {
    int elaps = 0, c;       // elaps: カウント変数, c: 消費時間
    int i, q;

    P u;

    char str[64];

    scanf("%d %d", &n, &q);  // n = 命令数, q = 1回の処理時間
    for (i = 1; i <= n; i++) {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1;       // 
    tail = n + 1;   // Q[tail] = null

    while (head != tail) {
        u = dequeue();      // type(u) => type P
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if (u.t > 0) {      // まだ終わっていなければ、uをenqueueし直す
            enqueue(u);
        } else {            // 終わっていれば、プロセス名と終了時間を出力する
            printf("%s %d\n", u.name, elaps);
        }
    }
    return 0;
}


Measured memory_bytes: 12716
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define Graph vector<vector<int>>;
#define iterG(next_v, G, v) for(auto next_v : G[v]
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int r, ans;
    ans = 0;
    r = 0;
    rep(l, s.size()){
        while(r < s.size() && s[r] == 'A' || s[r] == 'C' || s[r] == 'G' || s[r] == 'T'){
            r++;
            ans = max(ans, r - l);
        }
        if (l == r) r++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
static const int MAX = 500;
static const int INFTY = (1<<21);
int main(void){
  int n, i, j, e, sum;
  int tmp;
  int M[MAX][MAX];
  int p[MAX];
  int d[MAX];
  int v[MAX];
  int x;

  scanf("%d", &n);
  for ( i=0; i<n; i++ ){
    for ( j=0; j<n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }
  for( i=0; i<n; i++ ){
	  p[i]=-1;    //PI
	  d[i]=INFTY; //key
	  v[i]=0;	  //d
  }
  d[0]=0;
  while(1){
	tmp=INFTY;
	x=-1;
	for( i=0; i<n; i++ ){
		if( tmp>d[i]&&(v[i]==0)){
			x=i;
			tmp=d[i];
		}
	}
	if(x==-1)break;
	v[x]=1;
	for( i=0; i<n; i++ ){
		if(d[i]>=M[x][i]&&(v[i]==0)){
			p[i]=x;
			d[i]=M[x][i];
		}
	}
  }
  sum = 0;
  for ( i = 0; i < n; i++ ) if ( p[i] != -1 ) sum += M[i][p[i]];
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 804
a = []
for i in range(5):
  a.append(int(input()))

total = 0
l = 100
for i in range(5):
  total += (a[i] + 9) // 10 * 10
  d = a[i] % 10
  if d > 0 and d < l:
    l = d

ll = 0 if l == 100 else 10 - l

print(total-ll)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
    int n, m, l;
    cin >> n;
    cin >> m;
    cin >> l;
    long matA[n][m];
    long matB[m][l];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> matA[i][j];
        }
    }

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < l; j++) {
            cin >> matB[i][j];
        }
    }


    long matC[n][l];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            matC[i][j] = 0;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            for (int k = 0; k < m; k++) {
                matC[i][j] += matA[i][k] * matB[k][j];
            }
        }
    }


    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            cout << matC[i][j];
            if (j == l - 1) {
                break;
            }
            cout << " ";
        }
        cout << endl;
    }


}

Measured memory_bytes: 3324
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

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

    double n, k;
    cin >> n >> k;
    vector< pair< double, int > > pw;
    double e = 1.0;
    int cnt = 0;
    while( e < 100005 ) {
        pw.pb( MP( e, cnt ) );
        e *= 2.0;
        ++cnt;

    }
    pw.pb( MP( e, cnt ) );

    int pos = n;
    int it = 0;
    double res = 0;
    while( pos >= 1 ) {
        while( pos * pw[it].F < k ) {
            ++it;

        }
        double tmp = 1.0 / pow( 2.0, (double)pw[it].S );
        res += tmp * ( 1 / n );
        --pos;
    }
    printf( "%.9lf\n", res );
    return 0;
}


Measured memory_bytes: 384
using namespace std;
#include <bits/stdc++.h>
#define frr(i, r, l) for(int i = r; i >= l; --i)
#define fr(i, l, r) for(int i = l; i < r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
typedef pair<ll, ll> iPair; 
priority_queue< ll, vector <ll> , greater<ll>>pq1,pq2;
#define maxN 1000000000000000000
ll power(ll a,ll b){ll res=1;while(b>0){res*=a;b--;}return res;}
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s1,s2;
    cin>>s1>>s2;
    ll l1=s1.length();
    ll l2=s2.length();

    ll ans=maxN;
    fr(i,0,l1-l2+1)
    {
        ll k=i,cnt=0;
        fr(j,0,l2)
        {
            if(s1[k]!=s2[j])
            cnt++;

            k++;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;
import java.util.stream.IntStream;

class Main {
    public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt();
		
		boolean isPrimeNum = false;
		while (!isPrimeNum) {
			int num = k;
			isPrimeNum = IntStream.range(2, num).allMatch(c -> num % c != 0);
			if (isPrimeNum) System.out.println(num);
			k++;
		}
	}
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> A(N + 2);
  for (ll i = 1; i <= N; i++) {
    cin >> A[i];
  }
  ll sum = 0;
  for (ll i = 0; i <= N; i++) sum += abs(A[i + 1] - A[i]);
  for (ll i = 1; i <= N; i++) {
    ll dist = sum - abs(A[i + 1] - A[i]) - abs(A[i] - A[i - 1])
      + abs(A[i+1] - A[i-1]);
    cout << dist << "\n";
  }

  return 0;
}



Measured memory_bytes: 3992
#include <iostream>
#include <cstdio>
#include <math.h>

using namespace std;

int main(void){
    double v;
    
    while (cin>>v)
    {
        double n,k;
        n = (4.9*(v/9.8)*(v/9.8)+5)/5;
        k=n-(int)n;
        if(0==k);
        else {n++;}
        cout<<(int)n<<endl;
    }
    return 0;
}

Measured memory_bytes: 1224
import sys
from collections import deque

input = sys.stdin.readline

class Bellman_Ford:
    def __init__(self, v=None, e=None, lis=None, start=None, end=None, inf=float('inf')):
        self.V = v
        self.E = e
        self.lis = lis
        self.start = start if start else 0
        self.end = end if end else self.V-1
        self.inf = inf
        self.close_minus = False
    
    def getlist(self, lis):
        self.lis = lis
    
    def def_start(self, s):
        self.start = s
    
    def def_end(self, e):
        self.end = e

    def def_inf(self, inf):
        self.inf = inf
    
    def def_vertice(self, v):
        self.V = v
    
    def def_edge(self, e):
        self.E = e

    def prepare(self):
        self.cost = [self.inf]*self.V # 各頂点への最小コスト
        self.cost[self.start] = 0 # 自身への距離は0

    def search(self):
        for i in range(self.V):
            update = False # 更新が行われたか
            for x, y, z in self.lis:
                if self.cost[y] > self.cost[x] + z:
                    self.cost[y] = self.cost[x] + z
                    update = True
            if not update:
                break
            # 負閉路が存在
            if i == self.V - 1:
                self.close_minus = True
                return False
        return True

    def main(self):
        self.prepare()
        self.search()
    
    def cost_all(self):
        return self.cost

def main():
    n, m, p = map(int, input().split())
    
    graph = [None]*m
    tree_forth = [[] for _ in range(n)]
    tree_back = [[] for _ in range(n)]
    
    for i in range(m):
        a, b, c =map(int, input().split())
        tree_forth[a-1].append(b-1)
        tree_back[b-1].append(a-1)
        c = p-c
        graph[i] = (a-1, b-1, c)
    
    already1, already2 = [True]*n, [True]*n
    for already, tree, start in zip([already1, already2], [tree_forth, tree_back], [0, n-1]):
        not_yet = deque([start])
        already[start] = False
        while not_yet:
            key = not_yet.pop()
            for v in tree[key]:
                if already[v] == False:
                    continue
                already[v] = False
                not_yet.append(v)
    
    graph_new = []
    for i in range(m):
        a, b, c = graph[i]
        if already1[a] or already1[b] or already2[a] or already2[b]:
            continue
        graph_new.append((a, b, c))
       
    bf = Bellman_Ford(v=n, e=m, lis=graph_new)
    bf.main()
    if bf.close_minus:
        print(-1)
    else:
        print(max(0, -bf.cost[n-1]))
    
    
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 77184
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN=1e5+10;
    class Edge{
    public:
        int r,d;
        Edge(){}
        Edge(int rr,int dd):r(rr),d(dd){}
    };
    int N,M;
    vector<Edge>G[MAXN];
    int vis[MAXN];
    int pos[MAXN];
    void dfs(int root,int p){
        if(vis[root])return;
        pos[root]=p;
        vis[root]=true;
        for(auto e:G[root]){
            dfs(e.r,p+e.d);
        }
    }
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>N>>M;
        for(int u=0;u<M;u++){
            int l,r,d;
            cin>>l>>r>>d;
            G[l].push_back(Edge(r,d));
            G[r].push_back(Edge(l,-d));
        }
        for(int r=1;r<=N;r++){
            if(!vis[r])dfs(r,0);
        }
        for(int l=1;l<=N;l++){
            for(auto e:G[l]){
                if(e.d>=0){
                    if(pos[e.r]-pos[l]!=e.d){
                        cout<<"No";
                        return ;
                    }
                }
            }
        }
        cout<<"Yes";
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
char a,b,c;
int main(){
  scanf("%c%c%c",&a,&b,&c);
  if(a=='R'&&b=='R'&&c=='R')puts("3");
  else if(a=='R'&&b=='R')puts("2");
  else if(b=='R'&&c=='R')puts("2");
  else if(a=='R'||b=='R'||c=='R')puts("1");
  else puts("0");
  return 0; 
}

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

int main(){
    int H, W;
    while (true){
        cin>>H>>W;
        if(H==0&&W==0){
            break;
        }
        else{
            rep(i, H){
                rep(j, W){
                    if((i+j)%2==0){
                        cout<<"#";
                    }
                    else{
                        cout<<".";
                    }
                }
                cout<<""<<endl;
            }
            cout<<""<<endl;
        }
    }
}


Measured memory_bytes: 3100
#include<stdio.h>
int main(){
	int N,M;
	int A;
	int cnt=0;
	scanf("%d",&N);
	scanf("%d",&M);
	for(int i=0;i<M;i++){
		scanf("%d",&A);	
		cnt+=A;		
	}
	if(cnt>N)N=cnt-1;
			N-=cnt;
	printf("%d",N);
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	int s=0;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]!=b[i])
		s++;
	}
	cout<<s;
	return 0;
 } 

Measured memory_bytes: 3832
#include<cmath>
#include<cstdio>

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

using namespace std;

int main(){
	for(double r;scanf("%lf",&r),r!=0.0;){
		for(int de=1;;de++){
			int nu=(int)(M_PI*de);
			int nu2=nu+1;
			if(abs(1.*nu2/de-M_PI)<abs(1.*nu/de-M_PI))	nu=nu2;
			if(abs(1.*nu/de-M_PI)<r){
				printf("%d/%d\n",nu,de);
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
n = int(input())
a = tuple(list(map(int, input().split())))
#aをtupleにしておかないとb = aとしたときにb変更するとa変更されてしまう リストーのコピー
def puramai(a):
    b = list(a)
    hikaku = 0
    ans = 0
    for i in range(n):
        if i % 2 == 0 and hikaku + b[i] <= 0:
            b[i] = -hikaku+1
            ans += abs(b[i]-a[i])
        
        elif i % 2 != 0 and hikaku + b[i] >= 0:
            b[i] = -hikaku-1
            ans += abs(b[i]-a[i])
        
        hikaku += b[i]
    return ans

def maipura(a):
    b = list(a)
    hikaku = 0
    ans = 0
    for i in range(n):
        if i % 2 == 0 and hikaku + b[i] >= 0:
            b[i] = -hikaku-1
            ans += abs(b[i]-a[i])
        
        elif i % 2 != 0 and hikaku + b[i] <= 0:
            b[i] = -hikaku+1
            ans += abs(b[i]-a[i])
        
        hikaku += b[i]
    return ans
print(min(maipura(a), puramai(a)))

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

using namespace std;

int get_digit(long long val)
{
  int dig = 0;
  while(val > 0){
    val /= 10;
    dig++;
  }
  return dig;
}

int main()
{
  long long n;
  cin >> n;
  
  int min_dig = INT_MAX;
  for(long long a=1; a*a<=n; a++){
    long long b=n/a;
    if(b*a == n){
      min_dig = (min_dig, get_digit(max(a, b)));
    }
  }
  
  cout << min_dig << endl;
  
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int ma = 0;
  bool res = true;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    if (ma - a >= 2) res = false;
    ma = max(ma, a);
  }
  if (res) puts("Yes");
  else puts("No");
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    cout << (N + 1) * N / 2 << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
s=[i for i in input()]
t=[j for j in input()]
s.sort()
t.sort()
flag=0
count=0

if len(s)<len(t):
  for i in range(len(s)):
    if s[i]==t[i]:
      count+=1
  else:
    if count==len(s):
      flag=1

t.sort(reverse=True)

if s[0]<t[0]:
    flag=1

if flag==1:
  print("Yes")
else:
  print("No")
      

Measured memory_bytes: 3064
#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=1;i<=n;i++)
typedef long long ll;

int main(){
	string s;
	cin >> s;
	if(s <= "2019/04/30"){
		cout << "Heisei" << endl;
	}else{
		cout << "TBD" << endl;
	}
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

a = int(input())
b = list(map(int,input().split()))
inf=float("inf")
b_min = [inf for _ in range(a)]
b_min[0] = b[0]
for i in range(1,a):
    b_min[i] = min(b_min[i-1],b[i])
ret = 0
for i,j in zip(b,b_min):
    if i == j:
        ret+=1
print(ret)

Measured memory_bytes: 24428
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

vector<int> primes;
void init(int n) {
  primes.push_back(2);
  bool is_prime[n + 1];
  fill(is_prime, is_prime + n + 1, true);
  for (long long p = 3; p <= n; p += 2)
    if (is_prime[p]) {
      primes.push_back(p);
      for (long long i = p * p; i <= n; i += p) is_prime[i] = false;
    }
}

template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) { return *this *= p.inverse(); }
  ModInt operator-() const { return ModInt() - *this; }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b) t = a / b, swap(a -= t * b, b), swap(u -= t * v, v);
    return ModInt(u);
  }
  ModInt pow(int64_t e) const {
    ModInt ret(1);
    for (ModInt b = *this; e; e >>= 1, b *= b)
      if (e & 1) ret *= b;
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int modulo() { return mod; }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  using Mint = ModInt<int(1e9 + 7)>;
  int N;
  cin >> N;
  init(N);
  Mint ans = 1;
  for (auto p : primes) {
    if (p > N) break;
    int cnt = 0;
    int ppw = p;
    while (ppw <= N) cnt += N / ppw, ppw *= p;
    ans *= Mint(cnt + 1);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3640
//C++14 (Clang 3.8.0)
     
    #include <vector>
    #include <list>
    #include <map>
    #include <set>
    #include <queue>
    #include <deque>
    #include <stack>
    #include <bitset>
    #include <algorithm>
    #include <functional>
    #include <numeric>
    #include <utility>
    #include <sstream>
    #include <iostream>
    #include <iomanip>
    #include <cstdio>
    #include <cmath>
    #include <cstdlib>
    #include <ctime>
    #include <string>
     
    typedef long long ll;
    using namespace std;
    const int MAX_N=1e5+1;
    const int MAX_Q=1e5+1;
    ll MAX_q=1e18+1;
    ll a[MAX_N];
    ll t[MAX_N];
     
    int binsearch(vector<ll> x,ll y,int z){
        int l=-1,r=z,mid;
        while(r-l>1){
            mid=(l+r) / 2;
            if(y >= x[mid]) l=mid;
            else  r = mid;
        }
        return r;
    }
     
    int main(){
        int N;
        int Q;
        cin>>N>>Q;
        vector<ll> q;
        q.push_back(N);
        for(int i =0;i<Q;i++) {
            ll x;
            cin>>x;
            while(!q.empty() && q.back() >= x) q.pop_back();
            q.push_back(x);
        }
     
        int L = q.size() - 1;
        t[L] = 1;
     
        for(int i = L;i >0;i--){
            ll k=q[i];
            while(k>q[0]){
                int ind=lower_bound(q.begin(),q.begin()+i,k)-q.begin()-1;
                t[ind]+=t[i]*(k/q[ind]);
                k=k%q[ind];
            }
            a[k-1]+=t[i];
        }
        a[q[0]-1] += t[0];
        for(int i=N-1;i>=0;i--) a[i]+=a[i+1];
        for(int i=0;i<N;i++) cout<<a[i]<<endl;    
        return 0;
    };


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

using namespace std;

using int64 = long long;
const int INF = 1 << 30;

template< class T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret = max(ret, data[k]);
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] = max(data[k], x);
  }
};

int main() {
  int N;
  string S;

  cin >> N;
  cin >> S;
  vector< int > latte, malta;
  for(int i = 0; i < 2 * N; i++) {
    if(S[i] == 'a') latte.push_back(i);
    else malta.push_back(i);
  }
  int type = 0, pre = 0;
  vector< string > myon;

  auto get_beet = [&](int l, int r) {

/*
    cout << l << " " << r << endl;
    for(int i = l; i < r; i++) {
      cout << latte[i] << " " << malta[i] << endl;
    }
    cout << "---" << endl;
*/
    if(latte[l] < malta[l]) {
      BinaryIndexedTree< int > bit(2 * N);
      for(int i = l; i < r; i++) {
        bit.add(malta[i], bit.sum(latte[i]) + 1);
      }
      int ans = bit.sum(2 * N - 1);
      string s;
      for(int i = 0; i < ans; i++) s += "ab";
      return s;
    } else {
      string s;
      for(int i = l; i < r; i++) {
        vector< int > vx;
        for(int j = i; j < r; j++) {
          vx.push_back(latte[j]);
          vx.push_back(malta[j]);
        }
        sort(begin(vx), end(vx));
        string t;
        for(int j = 0; j < vx.size(); j++) t += S[vx[j]];
        s = max(s, t);
      }
      return s;
    }
  };
  vector< int > ev;
  int sum = 0;
  ev.push_back(0);
  for(int i = 0; i < 2 * N; i++) {
    if(S[i] == 'a') ++sum;
    else --sum;
    if(sum == 0) ev.push_back(i + 1);
  }
  for(int i = 1; i < ev.size(); i++) {
    int l = -1, r = -1;
    for(int j = 0; j < N; j++) {
      if(latte[j] == ev[i - 1] || malta[j] == ev[i - 1]) l = j;
      if(latte[j] + 1 == ev[i] || malta[j] + 1 == ev[i]) r = j;
    }
    myon.push_back(get_beet(l, r + 1));
  }
  vector< string > dp(myon.size());

  for(int i = 0; i < myon.size(); i++) {
    dp[i] = max(dp[i], myon[i]);
    for(int j = 0; j < i; j++) {
      dp[i] = max(dp[i], dp[j] + myon[i]);
    }
  }
  cout << *max_element(begin(dp), end(dp)) << endl;
}

Measured memory_bytes: 14208
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <map>
#include <math.h>
using namespace std;

int main()
{  int i,j;
  char a[10][10];
  for(int i=1;i<=2;i++)
  {
      for(int j=1;j<=3;j++)
      {
          scanf("%c",&a[i][j]);
      }
      getchar();
  }
  if(a[1][1]==a[2][3])
  {
      if(a[2][2]==a[1][2])
      {
          if(a[1][3]==a[2][1])
          {
              printf("YES\n");
          }
          else
          {
              printf("NO\n");
          }
      }
      else
      {
          printf("NO\n");
      }
  }
  else
  {
      printf("NO\n");
  }

    return 0;
}


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

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

  if (N % 1111 == 0) {
    cout << "Yes" << endl;
  }
  else if ( (N % 1000) % 111 == 0 ){
  	cout << "Yes" << endl;
  }
  else if ( (N - N % 10) % 111 == 0){
  	cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp;
use std::collections::*;
use std::io::*;
use std::mem::swap;
#[allow(dead_code)]
struct Io<'a> {
    r: BufReader<StdinLock<'a>>,
    w: BufWriter<StdoutLock<'a>>,
    buf: VecDeque<String>,
    buf_str: String,
}
#[allow(dead_code)]
impl<'a> Io<'a> {
    fn r<T: std::str::FromStr>(&mut self) -> T {
        if self.buf.len() == 0 {
            self.r.read_line(&mut self.buf_str).unwrap();
            for w in self.buf_str.split_whitespace() {
                self.buf.push_back(w.to_owned());
            }
            self.buf_str.clear();
        }
        self.buf
            .pop_front()
            .unwrap()
            .parse()
            .unwrap_or_else(|_| panic!())
    }
    fn r_s(&mut self) -> String {
        if self.buf.len() == 0 {
            self.r.read_line(&mut self.buf_str).unwrap();
            for w in self.buf_str.split_whitespace() {
                self.buf.push_back(w.to_owned());
            }
            self.buf_str.clear();
        }
        self.buf.pop_front().unwrap()
    }
    fn w<T: std::fmt::Display>(&mut self, v: T) {
        write!(self.w, "{}", v).unwrap();
    }
    fn wl<T: std::fmt::Display>(&mut self, v: T) {
        writeln!(self.w, "{}", v).unwrap();
    }
    fn iter<'b, T: std::str::FromStr>(&'b mut self) -> IoIter<'a, 'b, T> {
        IoIter {
            io: self,
            p: std::marker::PhantomData,
        }
    }
}
#[allow(dead_code)]
struct IoIter<'a: 'b, 'b, T: std::str::FromStr> {
    io: &'b mut Io<'a>,
    p: std::marker::PhantomData<T>,
}
#[allow(dead_code)]
impl<'a, 'b, T: std::str::FromStr> Iterator for IoIter<'a, 'b, T> {
    type Item = T;
    fn next(&mut self) -> Option<T> {
        Some(self.io.r())
    }
}
fn main() {
    let stdin = stdin();
    let stdout = stdout();
    let r = BufReader::new(stdin.lock());
    let w = BufWriter::new(stdout.lock());
    let mut io = Io {
        r,
        w,
        buf: VecDeque::new(),
        buf_str: String::new(),
    };
    problem(&mut io);
}

fn problem(io: &mut Io) {
    let n: usize = io.r();
    let set: HashSet<String> = io.iter().take(n).collect();
    io.wl(set.len());
}


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

int main()
{
	int x,y,n,z;
	cin >> x;
	n = x / 3600;
	y = x % 3600;
	z = y / 60;
	x = y % 60;
	cout << n << ":" << z << ":" << x <<endl;
	return 0;
}

Measured memory_bytes: 3084
N, K = map(int, input().split())
P = list(map(int, input().split()))

V = [0] * (N + 1)
S = [0] * (1010)
for i in range(1009):
    S[i + 1] = S[i] + (i + 1)
# print(S)

for i in range(N):
    p = P[i]
    V[i + 1] = V[i] + S[p] / p

# print(V)

res = 0
for i in range(N + 1 - K):
    res = max(res, V[i + K] - V[i])

print(res)

Measured memory_bytes: 71792
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
//#include <random>
#include <map>
//#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <time.h>
//#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
//#include <type_traits>
#define rep(i,n) for(ll 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 ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
double pi = 3.141592653589793;
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

int main() {

	int x, n;
	cin >> x >> n;
	vector<int> p(n);
	rep(i, n) {
		cin >> p[i];
	}

	vector<int> z(105);
	rep(i, n) {
		z[p[i]] = 1;
	}

	if (z[x] == 0) {
		cout << x << endl;
		return 0;
	}

	int d = x;
	int u = x;

	while (1) {
		d--;
		if (z[d] == 0) {
			cout << d << endl;
			return 0;
		}
		u++;
		if (z[u] == 0) {
			cout << u << endl;
			return 0;
		}
	}

}






Measured memory_bytes: 3724
import sys
input = sys.stdin.readline

n, d = map(int, input().split())
x = []
cnt = 0
ans = 0
for i in range(n):
    x_memo = list(map(int, input().split()))
    x.append(x_memo)

for i in range(n - 1):
    for j in range(i + 1, n):
        cnt = 0
        for k in range(d):
            cnt += abs(x[i][k] - x[j][k]) ** 2
        cnt = cnt ** 0.5
        if cnt.is_integer():
            ans += 1

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> v(n, 0);
    REP(i, 0, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        v[a]++;
        v[b]++;
    }
    for (int i = 0; i < n; i++) {
        cout << v[i] << endl;
    }
}


Measured memory_bytes: 256
a = []
for i in range(3):
    aa = list(map(int, input().split()))
    a.append(aa)
n = int(input())
flag = []
for i in range(3):
    flag.append([0, 0, 0])
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                flag[j][k] = 1
ans = False
for j in range(3):
    if flag[0][j] == 1 and flag [1][j] == 1 and flag[2][j] == 1:
        ans = True
for i in range(3):
    if flag[i][0] == 1 and flag [i][1] == 1 and flag[i][2] == 1:
        ans = True
if flag[0][0] == 1 and flag [1][1] == 1 and flag[2][2] == 1:
        ans = True
if flag[2][0] == 1 and flag [1][1] == 1 and flag[0][2] == 1:
        ans = True
if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <list>
#include <math.h>
using namespace std;

typedef pair<int, int> P;
#define ll long long
#define int ll


signed main(){

	string S;
	cin >> S;
	int n,s,e,w;
	if (S.find("N") != string::npos) n = 1; else n = 0;
	if (S.find("S") != string::npos) s = 1; else s = 0;
	if (S.find("E") != string::npos) e = 1; else e = 0;
	if (S.find("W") != string::npos) w = 1; else w = 0;


	if ((n-s)%2==0 && (e-w)%2==0) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;

int main(){
    
    int n,q;
    cin >> n >> q;
    vector<vector<int>> v;
    vector<int> cost;
    vector<bool> traversed;

    vector<int> tmpv;    
    rep(i,n+1){
        v.pback(tmpv);
        cost.pback(0);
        traversed.pback(false);
    }

    rep(i,n-1){
        int tmpa,tmpb;
        cin >> tmpa >> tmpb;

        v[tmpa].pback(tmpb);
        v[tmpb].pback(tmpa);

    }

    rep(i,q){
        int tmpp,tmpx;
        cin >> tmpp >> tmpx;

        cost[tmpp] = cost[tmpp] + tmpx;
    }

    //BFSをして前のノードのcostを足していく

    //行き先とコストを表すペアの入れるキュー
    queue<pair<int,int>> qu;
    qu.push(mpair(1,0));

    while(!qu.empty()){
        int tmpnode = qu.front().first;
        int tmpcost = qu.front().second;

        cost[tmpnode] = cost[tmpnode] + tmpcost;
        tmpcost = cost[tmpnode];
        traversed[tmpnode] = true;

        rep(i,v[tmpnode].size()){
            int next = v[tmpnode][i];
            if(!traversed[next]){
                qu.push(mpair(next,tmpcost));
            }
        }

        qu.pop();
    }

    rep(i,n){
        cout << cost[i + 1] << " ";
    }
    cout << endl;
    return 0;
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int main() {
    ll n;
    cin >> n;
    string s;
    while (n > 0) {
        int t = n % 26;
        if (t == 0)
            t = 26;
        s += t - 1 + 'a';
        n -= t;
        n /= 26;
    }
    reverse(all(s));
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
        int a;
        cin >> a;
        if(a==111){
            cout << 3 << endl;
        }else if(a==101||a==110||a==11){
            cout << 2 << endl;
        }else if(a==100||a==10 ||a==1){
            cout << 1 << endl;
        }else if(a==0){
            cout << 0 << endl;
        }
    }

Measured memory_bytes: 256
n = int(input())

list = [1,2,3,4,5,6,7,8,9,
2,4,6,8,10,12,14,16,18,
3,6,9,12,15,18,21,24,27,
4,8,12,16,20,24,28,32,36,
5,10,15,20,25,30,35,40,45,
6,12,18,24,30,36,42,48,54,
7,14,21,28,35,42,49,56,63,
8,16,24,32,40,48,56,64,72,
9,18,27,36,45,54,63,72,81]

if list.count(n) > 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
# 2020/03/07
# AtCoder Beginner Contest 158 - C

# Input
a, b = map(int,input().split())

ep = list()
tp = list()

# Calc
e_st = -1
e_ed = -1
t_st = -1
t_ed = -1

for i in range(1010):
    ep.append(int(i * 0.08))
    tp.append(int(i * 0.1))
    
    if e_st == -1 and ep[i] == a:
        e_st = i
    elif e_ed == -1 and e_st != -1 and ep[i] != ep[i-1]:
        e_ed = i - 1

    if t_st == -1 and tp[i] == b:
        t_st = i
    elif t_ed == -1 and t_st != -1 and tp[i] != tp[i-1]:
        t_ed = i - 1

ans = 0
if (e_ed < t_st and e_st < t_ed) or (t_ed < e_st and t_st < e_ed):
    ans = -1
else:
    ans = max(e_st, t_st)

# Output
print(ans)


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

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


    int n,d;
    cin >> n >> d;
    
    int ans = n/(2*d+1);
    if(n % (2*d+1) !=0) ans +=1;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
using namespace std;
long long i[10000][10000];
long long u[1111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e=1,f=0;
  string s;
  cin >>a>>b>>c>>d;
  a+=b,c+=d;
  if(a>c) cout <<"Left\n";
  else{
    if(a<c) cout <<"Right\n";
    else cout <<"Balanced\n";
  }
  return (0);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean ok = false;
        int sum = 0;
        loop: for (int i = 0; i <= N / 4; i++) {
            for (int j = 0; j <= N / 7; j++) {

                if (4 * i + 7 * j == N) {
                    ok = true;
                    break loop;
                }
            }
        }
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  i64 N;
  cin >> N;
  vector<pair<i64, i64>> vec;
  for(i64 i: ran(N)) {
    i64 a, b;
    cin >> a >> b;
    vec.push_back({b, a});
  }
  sort(all(vec));
  i64 before = 0;
  i64 remain = 0;
  for(auto p: vec) {
    i64 b = p.first;
    i64 a = p.second;
    remain += b - before;
    before = b;
    if(remain - a < 0) {
      cout << "No" << endl;
      return 0;
    }
    remain -= a;
  }
  cout << "Yes" << endl;

}


Measured memory_bytes: 6384
/**
 * Created by hiramekun at 20:43 on 2019-12-08.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    vl a(3);
    cin >> a;
    if (accumulate(all(a), 0LL) >= 22) {
        cout << "bust" << '\n';
    } else {
        cout << "win" << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#import<iostream>
#import<atcoder/all>
using namespace std;long N,Q,i,a;main(){cin>>N>>Q;atcoder::fenwick_tree<long>b(N);for(;i++<N;b.add(i-1,a))cin>>a;while(Q--){cin>>i>>a>>N;if(i)cout<<b.sum(a,N)<<endl;else b.add(a,N);}}

Measured memory_bytes: 8220