akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> x;
    rep(i,n){
        ll a, b;
        cin >> a >> b;
        x.push_back(make_pair(a, b));
    }
    sort(x.begin(), x.end());
    ll tmp = 0;
    rep(i,n){
        if(k<=x[i].second){
            cout << x[i].first << endl;
            break;
        }
        k -= x[i].second;
    }
    return 0;
}

Measured memory_bytes: 2420
/** Author: Nicklaus **/
 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
#define PI 3.14159265358979324

int main(){
	string s;
	cin>>s;
	int m= (s[5]-48)*10 + s[6]-48;
	int d= (s[8]-48)*10 + s[9]-48;
	
	if(m<=4 && d<=30) cout<<"Heisei"<<endl;
	else cout<<"TBD"<<endl;
	return 0;
}

Measured memory_bytes: 256
n, k= map(int, input().split())
lis = list(map(int, input().split()))

mod = 10**9 + 7

ans = 0
right = 0
zenbu = 0

for i in range(n-1):
    for j in range(i,n):
        if lis[i] > lis[j]:
            right += 1
for i in range(n):
    for j in range(n):
        if lis[i] > lis[j]:
            zenbu += 1
    
t = (k-1)*k
ans += right*k
ans +=(t//2)*zenbu
ans %= mod

print(ans)

Measured memory_bytes: 9084
#include <iostream>

using namespace std;

int main(){
    long long int a,b,k,x;
    cin >> a;
    cin >> b;
    cin >> k;
    x=0;
    for(int i=0;i<k;i++){
        if(x==0){
            if(int m = a % 2){
                a = (a - 1)/2;
                b = a + b;
            }else{
                a = a / 2;
                b = b + a;
            }
        }
        if(x==1){
            if(int m = b % 2){
                b = (b - 1)/2;
                a = b + a;
        }else{
            b = b / 2;
            a = a + b;
        }
        }
        if(x==0){x=1;}else{x=0;}
    }
    cout << a << " " << b ;
}

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();
		int[] a = new int[N];
		for(int i = 0; i < N; i++) a[i] = sc.nextInt();
		int[] ball = new int[N];

		for(int k = N; k >= 1; k--) {
			int cnt = 0;
			for(int i = k; i <= N; i += k) cnt += ball[i - 1];
			if(cnt % 2 == a[k - 1]) continue;
			else ball[k - 1]++;
		}

		int num = 0;
		for(int i = 0; i < N; i++) if(ball[i] == 1) num++;
		System.out.println(num);
		for(int i = 0; i < N; i++) if(ball[i] == 1) System.out.println(i + 1);
	}
}


Measured memory_bytes: 95516
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,k,sum=0,a,b,c;
    cin>>n;
    b=n;
    while(n!=0)
    {
        a=n%10;
        sum+=a;
        n=n/10;
    }
    if(b%sum==0)
        cout<< "Yes" << endl;
    else
        cout<< "No" << endl;
    return 0;
}

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

int main()
{
  int N,M;cin>>N>>M;
  vector<int> A(M);
  int sum=0;
  for(int i=0;i<M;i++)
  {
    cin>>A[i];
    sum += A[i];
  }
  
  if(sum > N)
  {
    cout<<-1<<endl;
    return (0);
  }
  
  cout<< N - sum<<endl;

}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int N;
	cin >> N;
	int t;
	int min = 1000000;
	int counter = 0;
	vector<int>  P;
	for (int i = 0; i < N; i++) {
		cin >> t;
		if (t < min) {
			counter++;
			min = t;
		}
	}
    cout << counter;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H, W;
    cin >> H >> W;
  
    vector <vector<char> >data(H, vector<char>(W));
  
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> data.at(i).at(j);
        }
    }
  
    for(int i = 0; i < H; i++) {
        int cnt = 0; 
        for(int j = 0; j < W; j++) {
             if(data.at(i).at(j) == '.') {
                cnt++;
            }
        }
        if(cnt == W) {
            for(int j = 0; j < W; j++) {
                data.at(i).at(j) = '*';
            }
        }
    }
    
    for(int j = 0; j < W; j++) {
        if(data.at(0).at(j) != '#') {
            int cnt = 0;
            for(int k = 0; k < H; k++) {
                if(data.at(k).at(j) != '#') {
                    cnt++;
                }
            }
            if(cnt == H) {
                for(int k = 0; k < H; k++) {
                    data.at(k).at(j) = '*';
                }   
            }
        }     
    }
    
    for(int i = 0; i < H; i++) {
        int cnt = 0;
        for(int j = 0; j < W; j++) {
            if(data.at(i).at(j) != '*') {
                cout << data.at(i).at(j);
            }else {
                cnt++;
            }
        }
        if(cnt != W) {
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
#include <limits>
using namespace std;
typedef long long ll;

float inf = std::numeric_limits<float>::infinity();

/* 二次元配列の宣言
  vector<vector<int>> tb;
  tb.resize(H);
  for (size_t i = 0; i < H; i++) {
    tb[i].resize(W);
  }
*/
/*
  A.resize(N);
  for (int i = 0; i < N; i++) {scanf("%d",&A[i]);}
*/

int main(void) {
  ll H,W;
  string str;
  cin >> H >> W;

  for (int y = 0; y < H; y++) {
    cin >> str;
    cout << str << '\n' << str << '\n';
  }





}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,num=1;
  int x[10],y[10];
  double ans=0;
  vector<int> vec;

  cin>>n;
  for(int i=0;i<n;i++){ vec.push_back(i+1); cin>>x[i+1]>>y[i+1]; }

  do {
    for(int i=0;i<n-1;i++){
      ans+=sqrt((x[vec[i]]-x[vec[i+1]])*(x[vec[i]]-x[vec[i+1]])+(y[vec[i]]-y[vec[i+1]])*(y[vec[i]]-y[vec[i+1]]));
    }
    } while (next_permutation(vec.begin(), vec.end()));

  for(int i=1;i<=n;i++) num*=i;
  printf("%.10lf\n",ans/num);
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/*
 public class abc084a {

 }

 */
public class Main {
  public void solve() throws FileNotFoundException {
    InputStream inputStream = System.in;

    InputHelper in = new InputHelper(inputStream);

    // actual solution
    int m = in.readInteger();

    System.out.println((24 - m) + 24);


    // end here
  }

  public static void main(String[] args) throws FileNotFoundException {
    (new Main()).solve();
  }

  class InputHelper {
    StringTokenizer tokenizer = null;
    private BufferedReader bufferedReader;

    public InputHelper(InputStream inputStream) {
      InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
      bufferedReader = new BufferedReader(inputStreamReader, 16384);
    }

    public String read() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          String line = bufferedReader.readLine();
          if (line == null) {
            return null;
          }
          tokenizer = new StringTokenizer(line);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }

      return tokenizer.nextToken();
    }

    public Integer readInteger() {
      return Integer.parseInt(read());
    }

    public Long readLong() {
      return Long.parseLong(read());
    }
  }
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;
    
    vector<int> C(n-1), S(n-1), F(n-1);
    for(int i = 0; i < n-1; i++) {
        cin >> C[i] >> S[i] >> F[i];
    }

    for (int i = 0; i < n; i++) {
        
        int t = 0;
        for (int j = i; j < n-1; j++) {
            
            if (t < S[j]) t = S[j];
            else if (t % F[j] == 0);
            else t = t + F[j] - t % F[j];
            t += C[j];
        }
        cout << t << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int tot=26+26+10;
inline void read (int &x) {
	char ch = getchar(); x = 0;
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} 
char ch[tot];
char enc(int t){
	if(t<10)return '0'+t;
	t-=10;
	if(t<26)return 'a'+t;
	t-=26;
	return 'A'+t;
}
 
string s[tot];
int sum=tot;
int ttm=0;
inline int query (string str){
	if (str.size() > 128) return 1e9;
	cout << '?' << ' ' << str << '\n';
	fflush(stdout); int ans = 0; read (ans); return ans;
}
 
 
int len=0x3f3f3f3f;
int q[tot];
 
string merge(string a,string b){
	int i=0,j=0;
	int la=a.length(),lb=b.length();
	string fir=string();
	while(i<la&&j<lb){
		string qr=fir;
		qr+=a[i];
		for(int k=j;k<lb;k++){
			qr+=b[k];
		}
		if(query(qr)+qr.length()==len){
			fir+=a[i++];
		}else {
			fir+=b[j++];
		}
	}
	while(i<la)fir+=a[i++];
	while(j<lb)fir+=b[j++];
	return fir;
}
 
int main()
{
	int n = 0;
	for (int i = 0; i < 10; ++i) ch[n++] = '0' + i;
	for (int i = 0; i < 26; ++i) ch[n++] = 'a' + i;
	for (int i = 0; i < 26; ++i) ch[n++] = 'A' + i;
//	for (int i = 0; i < tot; ++i) cout << ch[i] << ' '; puts ("");
//	for (int i = 0; i < tot; ++i) ch[i] = enc (i);
	for(int i=0;i<tot;i++){
		s[i]+=ch[i];
		q[i]=query(s[i])+1;
		len=min(len,q[i]);
	}
	for(int i=0;i<tot;i++){
		if(q[i]==len){
			while(query(s[i]+ch[i])+s[i].length()+1==len)s[i]+=ch[i];
		}else s[i]=string();
	}
	while(1){
    	for(int i=0;i<tot;i++)for(int j=i+1;j<tot;j++)if(s[i].length()>s[j].length())swap(s[i],s[j]);
		int t=0;
		while(!s[t].length())++t;
		if(t+1==tot)break ;
		s[t+1]=merge(s[t],s[t+1]); s[t]=string();
	}
	assert(query(s[tot-1])==0);
	cout << "! "<< s[tot-1] << endl;
	fflush(stdout);
}


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

int main() {
 int H,W;
  cin>>H>>W;
  for(int i=0;i<W+1;i++){
  cout<<'#';
  }
  cout<<'#'<<endl;
  for(int i=0;i<H;i++){
    string s;
    cin>>s;
    cout<<'#'+s+'#'<<endl;
  }
   for(int i=0;i<W+2;i++){
  cout<<'#';
   }
}
  


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = (int)(2e5) + 5;
const int mod = 1e9 + 7;
const int inv = 500000004;
int p2[N];
vi g[N];
deque < pair < pii , int > > D[N];
pair < pii , int > add(pair < pii , int > a,pair < pii , int > b)
{
    return mp(mp(1ll * a.fi.fi * b.fi.fi % mod,(1ll * a.fi.fi * b.fi.se + 1ll * b.fi.fi * a.fi.se) % mod),((1ll * (a.fi.se + a.se) * (b.fi.se + b.se) % mod) + 1ll * a.fi.fi * b.se + 1ll * b.fi.fi * a.se) % mod);
}
int Merge(int & a,int & b)
{
    if (D[a].size() < D[b].size())
        swap(a,b);
    int sz = D[b].size();
    for (int i = 0;i < sz;++i)
        D[a][i] = add(D[a][i],D[b][i]);
    D[b].clear();
    return sz;
}
int cnt[N];
int dfs(int node,int dep)
{
    ++cnt[dep];
    int sz = 0;
    int d = node;
    int SZ = 0;
    for (auto it : g[node])
    {
        int nxt = dfs(it,dep + 1);
        smax(SZ,Merge(d,nxt));
    }
    for (int i = 0;i < SZ;++i)
        D[d][i].fi.fi += D[d][i].se,D[d][i].se = 0;
    D[d].push_front(mp(mp(inv,inv),0));
    return d;
}
int main(void)
{
    srand(time(0));
    int n;
    cin>>n;
    for (int i = 1;i <= n;++i)
    {
        int p;
        cin>>p;
        g[p].pb(i);
    }
    auto d = D[dfs(0,0)];
    int ans = 0;
    while (!d.empty())
        (ans += d.front().fi.se) %= mod,d.pop_front();
    for (int i = 1;i <= n + 1;++i)
        ans = (ans + ans) % mod;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 163712
#include<stdio.h>
int main(void)
{
	int h,r,a,b,c;
	scanf("%d %d",&h,&r);
	if(h==0) a=h+r;
	if(h<0){
		a=h+r;
		if(0<a) a=0;
	}
	if(h>0) a=h+r;
	if(a<0) a=-1;
	if(a>0) a=1;
	if(a==0) a=0;
	printf("%d\n",a);
	return 0;
}


Measured memory_bytes: 2148
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    vector<pair<int, int>> P(N);
    int ans = 0;
    for (int i = 0; i < N; ++i) cin >> P[i].first;
    for (int i = 0; i < N; ++i) cin >> P[i].second;
    for (int i = 0; i < N; ++i) {
        int tmp = P[i].first - P[i].second;
        if (tmp >= 0) ans += tmp;
    }
    printf("%d\n", ans);
}


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

using namespace std;

const int INF = 1e9 + 3;
const int N = 1e3 + 3;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

const double PI = acos(-1);

int n, m, sr, sc, er, ec, d[N][N];
char a[N][N];
int dd[4][2] = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};
deque<pair<int, int>> deq;

auto valid = [](int r, int c) { return r >= 1 && r <= n && c >= 1 && c <= m && a[r][c] != '#'; };


void update(int r, int c, int dx, int dy, int cost) {
    int rt = r + dx, ct = c + dy;
    if (!valid(rt, ct))
        return;
    if (d[rt][ct] > d[r][c] + cost) {
        d[rt][ct] = d[r][c] + cost;
        if (cost)
            deq.push_back({rt, ct});
        else
            deq.push_front({rt, ct});
    }
}

void bfs() {
    deq.push_back({sr, sc});
    d[sr][sc] = 0;
    while (!deq.empty()) {
        int r = deq.front().first, c = deq.front().second;
        deq.pop_front();
        for (int k = 0; k < 4; k++) {
            update(r, c, dd[k][0], dd[k][1], 0);
        }
        for (int dx = -2; dx <= 2; dx++)
            for (int dy = -2; dy <= 2; dy++)
                update(r, c, dx, dy, 1);
    }
}

void solve() {
    cin >> n >> m >> sr >> sc >> er >> ec;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
            d[i][j] = INF;
        }
    }
    bfs();
    if (d[er][ec] == INF)
        cout << -1;
    else
        cout << d[er][ec];
}


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int t;
    t = 1;
    while (t--) {
        solve();
    }
}

Measured memory_bytes: 8476
from sys import stdin, stdout  
import math
def main(): 
	a, b, c, d = [int(x) for x in stdin.readline().split()] 
	# h s h s
	if math.ceil(c / b) <= math.ceil(a / d):
		stdout.write('Yes \n')
	else:
		stdout.write('No \n')
if __name__ == "__main__": 
	main()


Measured memory_bytes: 9160
a,b,c = [int(i) for i in input().split()]

import math

root_a = math.sqrt(a)
root_b = math.sqrt(b)
root_c = math.sqrt(c)

if 4*a*b< (c - b -a)**2 and c - a - b >0:
  print('Yes')
else:
  print('No')

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

#define MAX 1000

void initialize();
int isEmpty();
int isFull();
void  push(int x);
int pop();

int top;
int S[1000];

int main()
{
  int i,n,ans,n1,n2,n3;
  char c[1000];

  initialize();

  while(1){
    if(scanf("%s",c)==EOF) break;

    if(c[0]=='+' || c[0]=='-' ||c[0]=='*'){
      n1 = pop();
      n2 = pop();
      if(c[0]=='+') n3 = n1 + n2;
      if(c[0]=='-') n3 = n2 - n1;
      if(c[0]=='*') n3 = n1 * n2;
      push(n3);
    }
      else{
	n = atoi(c);
	push(n);
      }
    }

    printf("%d\n",pop());
    return 0;
  }

  void initialize(){
    top = 0;
  }

  int isEmpty(){
    return top == 0;
  }

  int isFull(){
    return top >= MAX - 1;
  }

  void  push(int x){
    if (isFull()) fprintf(stderr,"overflow\n");
    top++;
    S[top] = x;
  }

  int pop(){
    if (isEmpty()) fprintf(stderr,"underflow\n");
    top--;
    return S[top+1];
  }

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

int main(){
    int N, M;
    int klst[10] = {0};
    int slst[10][10];
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            slst[i][j] = 0;
        }
    }
    int plst[10] = {0};
    cin >> N >> M;
    for(int i=0; i<M; i++){
        cin >>klst[i];
        for(int j=0; j<klst[i]; j++){
            cin >> slst[i][j];
        }
    }
    for(int i=0;i<M;i++){
        cin >> plst[i];
    }

    int cnt = 0;
    int m = (1 << N);
    for(int i=0;i<m;i++){
        int on_switch_num[10] = {0};
        for(int j=0;j<N;j++){
            if(((i >> j) & 1) == 1){
                for(int k=0; k<M; k++){
                    for(int l=0; l<klst[k]; l++){
                        if(slst[k][l] == j+1){
                            on_switch_num[k]++;
                        }
                    }
                }
            }
        }
        bool flg = true;
        for(int i=0;i<M;i++){
            if(on_switch_num[i]%2 != plst[i]){
                flg = false;
                break;
            }
        }
        if(flg){
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {

	int H, W, cnt, cnt2, flg, i, j, k;
	string a[100];
	string b[100];
	char c[100][101] = {0};

	cin >> H >> W;

	for (i = 0; i < H; i++) {
		cin >> a[i];
	}

	cnt = 0;
	for (i = 0; i < H; i++) {
		flg = 0;
		for (j = 0; j < W; j++) {
			if (a[i][j] == '#') {
				flg = 1;
				break;
			}
		}
		if (flg) {
			b[cnt] = a[i];
			cnt++;
		}
	}

	cnt2 = 0;
	for (j = 0; j < W; j++) {
		flg = 0;
		for (i = 0; i < cnt; i++) {
			if (b[i][j] == '#') {
				flg = 1;
				break;
			}
		}
		if (flg) {
			for (i = 0; i < cnt; i++) {
				c[i][cnt2] = b[i][j];
			}
			cnt2++;
		}
		else {

		}
	}

	for (i = 0; i < cnt; i++) {
		cout << c[i] << endl;
	}

	return 0;

}


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

int main() {
	char S[4];
	string T;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> S[0];
	if (S[0] == 'a'|| S[0] == 'i'|| S[0] == 'u'|| S[0] == 'e'|| S[0] == 'o') {
		cout << "vowel";
	}
	else {
		cout << "consonant";
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL n;
    LL d;
    LL e;
    cin >> n;
    bool is_ok=false;
    LL sum=0;
    for(LL i=0; i<n; i++){
        cin >> d >> e;
        if(d==e){
            sum++;
        }else{
            sum=0;
        }
        if(sum==3){
            is_ok=true;
        }
    }

    if(is_ok==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
S, T = list(zip(*[sys.stdin.buffer.readline().decode().rstrip().split() for _ in range(N)]))
X = sys.stdin.buffer.readline().decode().rstrip()
T = list(map(int, T))

i = S.index(X)
ans = sum(T[i + 1:], 0)
print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
using namespace std;
const int mod = 1000000007;


int main(){
 int N,a,b;
  cin>>N>>a>>b;
  //vector<int> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int>> A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  for(int i=a; i<=b; i++){
    if(i%N==0){cout<<"OK"<<endl;break;}
    if(i==b)cout << "NG" << endl;
  }
  
}


Measured memory_bytes: 3624
import itertools,math,bisect,pprint,sys
a, b = map(int, raw_input().split())
if a > 0:
    print "Positive"
    sys.exit()
if b >= 0:
    print "Zero"
else:
    if -(b-a)%2 == 0:
        print "Negative"
    else:
        print "Positive"

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


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

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


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

    ll dp[2][110000];
    dp[0][0] = 2;
    dp[1][0] = 1;
    for(int i = 1; i < s.length(); i++){
        if(s[i] == '1'){
            dp[0][i] = mul(dp[0][i-1], 2);
            dp[1][i] = add(mul(dp[1][i-1], 3), dp[0][i-1]);
        }
        else{
            dp[0][i] = dp[0][i-1];
            dp[1][i] = mul(dp[1][i-1], 3);
        }
    }

    cout << add(dp[0][s.length()-1], dp[1][s.length()-1]) << endl;


    return 0;
}


Measured memory_bytes: 2048
use whiteread::parse_line;

fn main() {
    let (h, w): (u64, u64) = parse_line().unwrap();
    let cnt: u64;
    // h = 1 or w = 1の時
    if h == 1 || w == 1 {
        cnt = 1;
    } else {
        // テストケースの図を見ると，全部のマスの半分が塗られることが分かる
        cnt = (h * w) / 2 + (h * w) % 2;
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2120
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=a/500;
        int c=a%500;
        int d=c/5;
        System.out.println(b*1000+d*5);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

ll f(ll a)
{
	ll ans = 1;
	REP(i, a)
	{
		ans %= MOD;
		ans *= (i + 1);
	}
	ans %= MOD;
	return ans;
}


int main()
{
	cin >> n >> m;
	if (abs(n - m) > 1) {
		cout << 0 << endl;
		return 0;
	}
	ll a = f(n) % MOD;
	ll b = f(m) % MOD;
	ans = a*b%MOD;

	if (n == m) {
		ans *= 2;
	} 

	cout << ans%MOD << endl;
}

Measured memory_bytes: 256
@nums = gets.strip.split('').map(&:to_i)

@ops = [nil, nil, nil]
[:+, :-].each do |op1|
    [:+, :-].each do |op2|
        [:+, :-].each do |op3|
            calc = @nums[0].send(op1, @nums[1]).send(op2, @nums[2]).send(op3, @nums[3])
            if calc == 7
                @ops = [op1, op2, op3]
            end
        end
    end
end

puts "#{@nums[0]}#{@ops[0]}#{@nums[1]}#{@ops[1]}#{@nums[2]}#{@ops[2]}#{@nums[3]}=7"

Measured memory_bytes: 1788
#include <cmath>
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, char>> cond;
  for (size_t m = 0; m < M; ++m) {
    int s;
    char c;
    cin >> s >> c;
    cond.push_back(make_pair(s-1, c));
  }
  string maximum(N, '9');
  int res = -1;
  for (int i = N != 1 ? pow(10, N-1) : 0, end = stoi(maximum); i <= end; ++i) {
    string str = to_string(i);
    bool ok = true;
    for (pair<int, char> p : cond) {
      if (str[p.first] != p.second) {
        ok = false;
        break;
      }
    }
    if (ok) {
      int num = stoi(str);
      res = res != -1 ? min(res, num) : num;
    }
  }
  if (to_string(res).size() != N) {
    cout << "-1" << endl;
  } else {
    cout << res << endl;
  }
  return 0; 
}


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

int main(){

  string S;
  bool flag=false;
  cin>>S;

  for(unsigned int i=0;i<S.length();i++){
    for(unsigned int j=i+1;j<S.length();j++){
      if(S.at(i)==S.at(j))
	flag=true;
    }
  }

  if(flag)cout<<"no"<<endl;
  else cout<<"yes"<<endl;
  
  return 0;
}

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

def isPrime(n):
  if n < 2:
    return False
  if n == 2:
    return True
  if n % 2 == 0:
    # ２ではない偶数は素数ではない
    return False
  for p in range(3, n, 2): # 奇数だけ計算する
      if n % p == 0:
        return False
  return True

def main(x):
    res = isPrime(x)
    if res == True:
        print(x)
        return

    if res == False:
        main(x+1)

main(x)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());

    vector<string> a = {
        "dream",
        "dreamer",
        "erase",
        "eraser",
    };
    rep(i, a.size()) {
        reverse(a[i].begin(), a[i].end());
    }

    int i = 0;
    bool allok = true;
    while (i < S.size()) {
        int ans_j = -1;
        rep(j, a.size()) {
            bool ok = true;

            rep(k, a[j].size()) {
                if (S[i + k] != a[j][k]) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                ans_j = j;
                break;
            }
        }
        if (ans_j == -1) {
            allok = false;
            break;
        }
        i += a[ans_j].size();
    }

    if (allok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

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

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

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

int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	
	int n=sz(s), ans = 0;
	rep(i, n-1){
		ans += s[i] != s[i+1];
	}
	cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;

class Main{
	static ArrayList<Path>[] graph;
	static int count = 0;
	static int N;
	static int M;
	static boolean flg;
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		N = saori.saori_hayami();
		M = saori.saori_hayami();
		graph = new ArrayList[N + 1];
		boolean[] seen  = new boolean[N + 1];
		for (int i = 1; i <= N; i++) {
		    graph[i] = new ArrayList<Path>();
		}
		for (int i = 0; i < M; i++) {
		    int a = saori.saori_hayami();
		    int b = saori.saori_hayami();
		    graph[a].add(new Path(b));
		    graph[b].add(new Path(a));
		}
		dfs(1,seen);
		System.out.println(count);
		saori.close();
		 
	}
	
	static void dfs(int n,boolean[] seen){
		if(seen[n]){
			return;
		}
		seen[n] = true;
		flg = true;
		for(int i = 1; i < N + 1 && flg; i++){
			flg = seen[i];
		}
		if(flg){
			count++;
			seen[n] = false;
			return;
		}
		for (Path x : graph[n]) {
	        dfs(x.to,seen);
		}
		seen[n] = false;
	}
}

class Path{
	int to;
	public Path(int to){
		this.to = to;
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22740
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class ERemOfSumIsNum {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N, K;
        in>>N>>K;
        vc<int> A(N), pref(N+1, 0);
        REP(i, N) in>>A[i], pref[i+1] = (pref[i]+A[i]) % K;
        map<int, int> M;
        lint ans = 0;
        REP(i, N+1){
            if(i>=K){
                int j = i - K;
                M[((pref[j]-j)%K+K)%K]--;
            }
            int key = ((pref[i]-i)%K+K) % K;
            ans += M[key];
            M[key]++;
        }
        out<<ans<<'\n';
    }
};


int main() {
	ERemOfSumIsNum solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 14188
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
int n,m;
char op;
signed main()
{
	scanf("%d %c %d",&n,&op,&m);
	printf("%d",((!(op-'+'))?(n+m):(n-m)));
	return putchar(10),0;
}

Measured memory_bytes: 256
n = int(input())
a = list(input())
b = list(input())
c = list(input())

count = 0

for i in range(n):
    if a[i] == b[i] and b[i] == c[i]:
        continue
    elif a[i] == b[i] or b[i] == c[i] or a[i] == c[i]:
        count += 1
    else:
        count += 2

print(count)

Measured memory_bytes: 3064
using System;

class MainClass
    {
        public static void Main(string[] args)
        {
            // 入力
            var num = Console.ReadLine();

            // 答え
            var ans = 0;

            for (int n = 0; n < num.Length; n++){
                if (num.Substring(n, 1) == "1")
		    ans += 1;            
            }

            Console.WriteLine(ans);
        }
    }

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

string s;
string t;

main(){
	cin >> s >> t;

	vector< vector<int> > m;
	m.resize(s.size()+1, vector<int>(t.size()+1));

	for(int i=1; i<=s.size(); i++){
		for(int j=1; j<=t.size(); j++){
			if(s[i-1] == t[j-1]){
				m[i][j] = 1 + m[i-1][j-1];
			}
			else{
				m[i][j] = max(m[i-1][j], m[i][j-1]);
			}
		}
	}

	// for(int i=0; i<=s.size(); i++){
	// 	for(int j=0; j<=t.size(); j++){
	// 		cout << m[i][j] << " ";
	// 	}
	// 	cout << "\n";
	// }

	int a = s.size();
	int b = t.size();
	int len = m[a][b];
	string sol = "";
	while(a>0 && b>0){
		if(s[a-1]==t[b-1]){
			sol = s[a-1] + sol;
			a--;
			b--;
		}
		else if(m[a-1][b] > m[a][b-1]){
			a--;
		}
		else{
			b--;
		}
		len = m[a][b];
	}
	
	cout << sol << "\n";
}

Measured memory_bytes: 70784
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String input = br.readLine();
		if(input.contains("9")){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 22996
#include <stdio.h>
#include <math.h>
#define Max 100
#define min(a, b) (a < b ? a : b)
int i, j, k, l, n, m[Max][Max], p[Max];
int INF = (int)INFINITY;

int mcm(int *P) {
  for ( i = 0; i <= n; ++i ) m[i][i] = 0;
  for ( l = 2; l <= n; ++l ) {
    for ( i = 1; i <= n - l + 1; ++i ) {
      j = i + l - 1;
      m[i][j] = INF;
      for ( k = i; k <= j - 1; ++k ) {
        m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + P[i - 1] * P[k] * P[j]);
      }
    }
  }
  return m[1][n];
}

int main(void) {
  int r, c;
  scanf("%d", &n);
  for ( i = 0; i < n; ++i ) {
    scanf("%d %d", &r, &c);
    p[i] = r; p[i + 1] = c;
  }
  printf("%d\n", mcm(p));
}



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

#define rep(i,begin,end) for(int i=begin; i<end; i++)

int main(){
    int w, h, n;
    scanf("%d %d %d", &w, &h, &n);
    int t[w][h];
    rep(i, 0, w){
        rep(j, 0, h){
            t[i][j] = 1;
        }
    }
    rep(i, 0, n){
        int x, y, a;
        scanf("%d %d %d", &x, &y, &a);
        if(a == 1){
            rep(j, 0, x){
                rep(k, 0, h){
                    t[j][k] = 0;
                }
            }
        }else if(a == 2){
            rep(j, x, w){
                rep(k, 0, h){
                    t[j][k] = 0;
                }
            }
        }else if(a == 3){
            rep(j, 0, w){
                rep(k, 0, y){
                    t[j][k] = 0;
                }
            }
        }else{
            rep(j, 0, w){
                rep(k, y, h){
                    t[j][k] = 0;
                }
            }
        }
    }
    int ans = 0;
    rep(i, 0, w){
        rep(j, 0, h){
            if(t[i][j]){
                ans++;
            }
        }
    }
    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
	int n;
	while(cin >> n){
		if(n==-1)
			break;
		vector<int> ans(0);
		do{
			ans.insert(ans.begin(),n%4);
			n=n/4;
		}
		while(n!=0);
		for(int i=0;i<ans.size();i++)
			cout << ans[i];
		cout << endl;
	}
}

Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,f;
int main(){
	cin>>n;
	while(n--){
		cin>>a>>b;
		if(a==b) c++;
		else c=0;
		if(c>=3) f=1;
	}
	if(f==1) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 3636
#include <iostream>
int main(){
	std::string m[3];
	while(std::cin >> m[0], m[0][0] != '0'){
		for(int i=1;i<3;i++)std::cin >> m[i];
		std::string w = "NA";
		for(int i=0;i<3;i++){
			if(!(m[i][0] + m[i][1] - m[i][2] * 2))
				if(m[i][0] != '+')w = m[i][0];
			if(!(m[0][i] + m[1][i] - m[2][i] * 2))
				if(m[0][i] != '+')w = m[0][i];
		}
		if(!(m[0][0] + m[1][1] - m[2][2] * 2))
			if(m[0][0] != '+')w = m[0][0];
		if(!(m[0][2] + m[1][1] - m[2][0] * 2))
			if(m[0][2] != '+')w = m[0][2];
		
		std::cout << w << std::endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
struct Edge {
    long long from;
    long long to;
    long long cost;
};
bool comp(Edge A, Edge B) {
    return A.cost < B.cost;
}
struct Union_Find { //Union-Find木

	//Parent[i] : i の親の番号　例）Parent[3] = 2 のとき、3 の親の番号は 2.
	vector<int>Parent;
    Union_Find() {}
	//最初は全てが根であるとして初期化します.
	Union_Find(int N) : Parent(N) {
		for (int i = 0; i < N; i++) Parent.at(i) = i;
	}

	//ノードnodeが属する木の根の番号を再起関数により得る. root(node) = { node の木の根 }.
	int root(int node) {
		if (Parent.at(node) == node) return node;
		else return Parent.at(node) = root(Parent.at(node));
	}

	//Union-Find木の操作① xとyの木を併合させる. 但し、root(x) != root(y).
	//Union-Find木は、併合はできるが、分割ができないことに注意.
	void unite(int x, int y) {
		int root_x = root(x); //root_x : xの木の根の番号
		int root_y = root(y); //root_y : yの木の根の番号
		//併合させる2つの木の根が異なる場合のみ、2つの木を併合させることができるので、
		//2つの木の根が同じ場合はそのままで返す.
		if (root_x == root_y) return;
		//2つの木の根が異なる場合は、x の木の根 root_x を、y の木の根 root_y につける.
		Parent.at(root_x) = root_y;
	}

	//Union-Find木の操作② xとyの属する木が同じかどうかを調べる.
	//すなわち、xとyの属する木の根が同じかどうかを調べる.
	bool same(int x, int y) {
		int root_x = root(x);
		int root_y = root(y);
		return root_x == root_y;
	}
};
Union_Find U;
long long Kruskal(vector<Edge>&edges, long long V) {
    sort(edges.begin(), edges.end(), comp);
    U = Union_Find(V);
    long long sum = 0;
    for (long long i = 0; i < edges.size(); i++) {
        if (!U.same(edges.at(i).from, edges.at(i).to)) {
            U.unite(edges.at(i).from, edges.at(i).to);
            sum += edges.at(i).cost;
        }
    }
    return sum;
}
int main() {
    long long V, E;
    cin >> V >> E;
    vector<Edge>edges(E);
    for (long long i = 0; i < E; i++) {
        cin >> edges.at(i).to >> edges.at(i).from >> edges.at(i).cost;
    }
    long long ans = Kruskal(edges, V);
    cout << ans << endl;
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

bool comp(int a, int b){
    return (a<b);
}

int main(){
    int n; cin >> n;
    vector<int> a(n);
    REP(i,0,n)cin >> a[i];
    int cnt = 0;
    REP(i,0,n-2){
        if(a[i]<a[i+1] && a[i+1]<a[i+2]) cnt++;
        else if(a[i]>a[i+1] && a[i+1]>a[i+2]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(), (c).end());
const long long MOD = 10e9 + 7;
typedef long long ll;

int main(){
	int a;
	string s;
	cin >> a >> s;
	if(a < 3200)cout << "red" << endl;
	else cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int r,c;
  cin >> r >> c;

  int a[101][101]={{}};

  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      cin >> a[i][j];
      a[i][c] += a[i][j];
      a[r][j] += a[i][j];
      a[r][c] += a[i][j];
    }
  }

  for(int i=0;i<=r;i++){
    for(int j=0;j<=c;j++){
      cout << a[i][j];
      if(j!=c) cout << " " ;
      else cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3128
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int S = sc.nextInt();
      int W = sc.nextInt();
      if(S<=W){
        System.out.println("unsafe");
      }else{
        System.out.println("safe");
      }
    }
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
std::string S;

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

  std::cin >> N >> S;

  for(char &c : S){
      c = 'A' + ((c - 'A') + N) % 26;
  }

  std::cout << S << std::endl;
}


Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def cmb(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


def main():
    N, K = MI()

    for i in range(K):
        if i < N - K + 1:
            # print(K, N - K + 1)
            # print(N - K + 1, i+1, '-', K - 1, i)
            a = cmb(N - K + 1, i+1) % MOD
            b = cmb(K - 1, i) % MOD
            print((a * b) % MOD)
        else:
            print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49752
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

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

	int N;

	string S;

	cin >> N >> S;

	for(int i = 0; i < S.length(); i++) {
		char s = S[i];
		s += N;
		if(s > 'Z') {
			s -= 26;
		}
		cout << s;
	}
			
}


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

int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  for (int i=0; i<K; i++) {
    if (A >= B) {
      B *= 2;
    } else if (B >= C) {
      C *= 2;
    }
  }
  if (A < B && B < C) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3672