akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    queue<string> song;
    string title;
    vector<int> time(n);
    for (int i = 0; i < n; i++)
    {
        cin >> title >> time[i];
        song.push(title);
    }
    string X;
    cin >> X;
    long ans = 0;
    int idx;
    for (int i = 0; i < n; i++)
    {
        title = song.front();
        if (title == X)
        {
            idx = i;
            break;
        }
        song.pop();
    }
    for (int i = idx + 1; i < n; i++)
    {
        ans += time[i];
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(int)n; i++)

//階乗
int frac(int n){
    if(n==0) return 1;
    else return n*frac(n-1);
}

int main(){
    int n; cin >> n;
    double x[n], y[n];
    rep(i, n) cin >> x[i] >> y[i];
    
    double dp[n][n];
    rep(i,n){
        rep(j,n){
            dp[i][j] = sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) );
        }
    }
    double sum = 0;
    rep(i, n){
        rep(j,n){
            if(i>j) {
                sum += dp[i][j];
            }
        }
    }
    cout << fixed << setprecision(10) << sum*2/n << endl; // C++
}


    


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long int k,n,q;
    cin>>n>>k>>q;
    long long int a[q+1],b[n+1]={0},c[n+1];
    for(int i=1;i<=q;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=q;i++)
    {
        b[a[i]]++;
    }
    for(int i=1;i<=n;i++)
    {
    c[i]=k-q+b[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(c[i]>0)
          cout<<"Yes";
          else
          cout<<"No";
          cout<<"\n";
    }

    return 0;
}


Measured memory_bytes: 2944
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,b) for(ll i=(b)-1, i>=a; --i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scanv(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#define square(x) x*x
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
string s;
void input(){
    cin>>s;
}
void src(){
    if(s=="keyence"){cout<<"YES"; return;}
    int er = s.length()-7;
    rep(i,s.length()-er+1){
        string s2=s;
        s2.erase(s2.begin()+i,s2.begin()+i+er);
        if(s2=="keyence"){cout<<"YES"; return;}
    }
    cout<<"NO";
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
}

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

int main(){
    int n;
    cin >> n;
    pair<pair<string,int>,int> p[110];
    map<string,int> memo;
    rep(i,n){
        int t;
        string m;
        cin >> m >> t;
        p[i] = make_pair(make_pair(m,-t),i);
    }
    sort(p,p+n);
    rep(i,n){
        cout << p[i].second +1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {

fast();

{
  int a,b;
  cin>>a>>b;
  if((a&1)&&(b&1))
  {
    cout<<"Odd"<<endl;
  }
  else
  {
    cout<<"Even"<<endl;
  }
  
  
  

}
return 0;
}


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

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

llint Q;
llint a, b;

llint get(llint x)
{
	llint ub = 1e9+7, lb = 0, mid;
	while(ub-lb>1){
		mid = (ub+lb)/2;
		if(mid*mid <= x) lb = mid;
		else ub = mid;
	}
	return lb;
}

int main(void)
{
	cin >> Q;
	for(int i = 1; i <= Q; i++){
		cin >> a >> b;
		llint r = get(a*b-1), ans = 2*r;
		if(r*(r+1) > a*b-1) ans--;
		if(min(a, b) <= r) ans--;
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n,m;
  cin >> n >> m;
  vector<int>a(m);
  int sum=0;
  for(int i=0;i<m;i++){
    cin >> a.at(i);
    sum+=a.at(i);
    }
  int ans=n-sum;
  if(sum>n) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
  }

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main ( void ) {
    char input[8][8];
    int i,t,n[8],cnt=0;
    for(i=0;i<8;i++){//入力
        scanf("%s",input[i]);
        n[cnt]=strlen(input[i]);
        cnt++;
    }
    puts("90");
    for(i=0;i<8;i++){
        for(t=7;t>=0;t--){
            printf("%c",input[t][i]);
        }
        puts("");
    } 
    puts("180");
    for(i=7;i>=0;i--){
        for(t=7;t>=0;t--){
            printf("%c",input[i][t]);
        }
        puts("");
    }
    puts("270");
    for(i=7;i>=0;i--){
        for(t=0;t<8;t++){
            printf("%c",input[t][i]);
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 948
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

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

    ll cnt1=0, cnt2=0;
    REP(i, 0, s.size()){
        if((i%2==0 && s[i]=='1') || (i%2==1 && s[i]=='0')) cnt1++;
    }

    REP(i, 0, s.size()){
        if((i%2==0 && s[i]=='0') || (i%2==1 && s[i]=='1')) cnt2++;
    }

    cout<<min(cnt1, cnt2)<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int N;
  cin >> N;
  vector<int> C(N - 1), S(N - 1), F(N - 1);
  rep(i, N - 1) cin >> C[i] >> S[i] >> F[i];

  rep(i, N) {
    int time = 0;
    repp(j, i, N - 2) {
      chmax(time, S[j]);
      time = ((time + F[j] - 1) / F[j]) * F[j];
      time += C[j];
    }
    cout << time << endl;
  }
}

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

int main()
{
    int W;
    vector<int> a(2);

    cin >> W >> a[0] >> a[1];
    sort(a.begin(),a.end());
    if (a[1]<=a[0]+W) {
        cout << "0" << endl;
    } else {
        cout << abs(a[0]+W-a[1]) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define MOD 10000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const ull B=100000007;
const int INF=1e9;
int rec(int a,int b){
      int k=1,t=b;
      while(t>k)k*=10;
      return a*k+b;
}
int main(){
      int n,k;
      cin>>n;
      int a[5];
      if(n==3){
            k=3;
            cin>>a[0]>>a[1]>>a[2];
            sort(a,a+3);
      }else{
            k=4;
            cin>>a[0]>>a[1]>>a[2]>>a[3];
            REP(i,n-3){
                  cin>>a[4];
                  sort(a,a+5);
            }
      }
      vector<int> ans;
      REP(i,k)REP(j,k)if(i!=j)ans.PB(rec(a[i],a[j]));
      sort(ans.begin(),ans.end());
      cout<<ans[2]<<endl;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define x1 jfkljfewlkjfwekl
#define x2 jkfwejklfwej
#define y1 kfewfe
#define y2 jfwekj3w3e
 
int bomb[50][50];
 
 
int a[4][4] = {
	{0,0,0,0},
	{0,0,0,0},
	{1,1,0,0},
	{1,1,0,0},
};
int myquery(int x1,int x2,int y1,int y2){
	int sum = 0;
	for(int i = y1 ; i <= y2 ; i++)
		for(int j = x1 ; j <= x2 ; j++)
			sum += a[i][j];
	return sum;
}
int query(int x1,int x2,int y1,int y2){
	cout << "? " << y1 << " " << x1 << " " << y2 << " " << x2 << endl;
	//return myquery(x1,x2,y1,y2);
	int sum;
	cin >> sum;
	return sum;
}
int dfs(int x1,int x2,int y1,int y2,int prv){
	if( x1 > x2 or y1 > y2 ) return 0;
	if( x1 == x2 and y1 == y2 ){
		if( prv == -1 ){
			bomb[y1][x1] = query(x1,x2,y1,y2);	
		}else{
			bomb[y1][x1] = prv;
		}
		return bomb[y1][x1];
	}else{
	
		int ask = prv == -1 ? query(x1,x2,y1,y2) : prv;
		
		if(!ask) return 0;
		int X = (x1+x2) / 2;
		int Y = (y1+y2) / 2;
		int a = dfs(x1,X,y1,Y,-1);
		int b = dfs(X+1,x2,y1,Y,-1);
		int c = dfs(x1,X,Y+1,y2,-1);
		int d = dfs(X+1,x2,Y+1,y2,ask-a-b-c);
		return ask;
	}
	
}
signed main(){
	int H,W,N,K;
	cin >> H >> W >> N >> K;
	dfs(0,W-1,0,H-1,-1);
	long long ans = 0;
	long long w = 1;
	for(int i = 0 ; i < H ; i++){
		for(int j = 0 ; j < W ; j++){
			ans += w * bomb[i][j];
			ans %= K;
			w *= 2;
			w %= K;
		}
	}
	cout << "!" << " " << ans << endl;
}

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

int main()
{
    ios::sync_with_stdio(false);
    string s;
    string s1,s2;
    int now=0;
    cin>>s;
    int q;
    cin>>q;
    for(int i=1;i<=q;i++){
        int f;
        cin>>f;
        if(f==1)now^=1;
        else{
            int a;
            char c;
            cin>>a>>c;
            if(a==1){
                if(now==0)s1+=c;
                else s2+=c;
            }else {
                if(now==0)s2+=c;
                else s1+=c;
            }
        }
    }
    reverse(s1.begin(),s1.end());
    s1+=s;
    s1+=s2;
    if(now)reverse(s1.begin(),s1.end());
    cout<<s1<<endl;
    return 0;
}


Measured memory_bytes: 1300
N=int(input())
ds=[]
for _ in range(N):
  d={}
  for s in input():d[s]=d.get(s,0)+1
  ds+=[d]
r=ds[0]
for d in ds:
  for k,v in r.items():
    r[k]=min(v,d.get(k,0))
ans=''
for k in sorted(r.keys()):
  ans+=k*r[k]
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
  int a[110],n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  for(i=0;i<n;i++)
    if(a[i]%2==0)
      if((a[i]%3!=0)&&(a[i]%5!=0)){
        printf("DENIED\n");
        return 0;
      }
  printf("APPROVED\n");
  return 0;
}

Measured memory_bytes: 128
///in the name of ALLAH
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   vector<ll>ans;
   ll x,y;
   x=max(a,b);
   y=max(c,d);
   ans.push_back(x*y);

       x=min(a,b);

   y=min(c,d);
   ans.push_back(x*y);


    x=min(a,b);
     y=max(c,d);
    ans.push_back(x*y);

   x=max(a,b);
    y=min(c,d);
    ans.push_back(x*y);

   sort(ans.begin(),ans.end());
   cout<<ans[ans.size()-1]<<endl;
}



Measured memory_bytes: 3640
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string.h>

using namespace std;

int sx[5] = {0, 1,  0, -1, 0};
int sy[5] = {0, 0, -1,  0, 1};

int mx[9] = {0, 1,  1,  0, -1, -1, -1, 0, 1};
int my[9] = {0, 0, -1, -1, -1,  0,  1, 1, 1};

int lx[13] = {0, 1,  1,  0, -1, -1, -1, 0, 1, 2,  0, -2, 0};
int ly[13] = {0, 0, -1, -1, -1,  0,  1, 1, 1, 0, -2,  0, 2};

int maze[10][10];

int i, j, xi, xj;

bool isValid(int a, int b) {
    return a >= 0 && b >= 0 && a < 10 && b < 10;
}

vector<string> split(string source, string pattern) {
    unsigned i, base = 0;
    vector<string> ret;
    string buff;

    for(i = 0; i < source.size(); i++) {
        if(source.substr(i, pattern.size()) == pattern) {
            ret.push_back(buff);
            i += pattern.size() - 1;
            buff.clear();
        } else {
            buff += source[i];
        }
    }
    ret.push_back(buff);
    return ret;
}

int main(void) {
    memset(maze, 0, sizeof(maze));

    int ai, aj, s;
    string p;
    vector<string> ok;

    while(getline(cin, p)) {
        ok.clear();
        ok = split(p, ",");

        aj = ok[1].size() > 1 ? 10 : ok[1][0] - '0';
        ai = ok[0].size() > 1 ? 10 : ok[0][0] - '0';
        s = ok[2].size() > 1 ? 10 : ok[2][0] - '0';

        if(s == 1) {
            for(i = 0; i < 5; i++) {
                xi = ai + sx[i];
                xj = aj + sy[i];

                if(isValid(xi, xj)) {
                    maze[xi][xj] += 1;
                }
            }
        } else if(s == 2) {
            for(i = 0; i < 9; i++) {
                xi = ai + mx[i];
                xj = aj + my[i];

                if(isValid(xi, xj)) {
                    maze[xi][xj] += 1;
                }
            }
        } else {
            for(i = 0; i < 13; i++) {
                xi = ai + lx[i];
                xj = aj + ly[i];

                if(isValid(xi, xj)) {
                    maze[xi][xj] += 1;
                }
            }
        }
    }

    int mx = 0, ct = 0;

    for(i = 0; i < 10; i++) {
        for(j = 0; j < 10; j++) {
            if(maze[i][j] == 0) ct += 1;
            mx = max(mx, maze[i][j]);
        }
    }
    cout << ct << endl << mx << endl;
    return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
)

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	if y <= 1 {
		fmt.Println("No")
		return
	}
	if y%2 != 0 {
		fmt.Println("No")
		return
	}
	if y <= 4*x && y >= 2*x {
		fmt.Println("Yes")
		return
	} else {
		fmt.Println("No")
		return
	}
}


Measured memory_bytes: 1816
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    if N % 2 == 1:
        return 0

    n = N // 2
    i = 5
    ans = 0
    while i <= n:
        ans += n // i
        i *= 5
    return ans


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


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

const int INF = 1e9;

using Edge = pair<int, int>;
vector<vector<Edge> > g;

int ans[(int)1e5];

void dfs(int cur, int parent, int color) {
  ans[cur] = color;
  for (auto edge: g[cur]) {
    if (edge.first == parent) {
      continue;
    }
    if ((color + edge.second) % 2 == 0) {
      dfs(edge.first, cur, 0);
    } else {
      dfs(edge.first, cur, 1);
    }
  }
}


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

  g.assign(n, vector<Edge>());

  for (int i=0; i<n-1; i++) {
    int u, v, w;
    cin>>u>>v>>w;
    g[u-1].push_back(make_pair(v-1, w));
    g[v-1].push_back(make_pair(u-1, w));
  }
  dfs(0, -1, 0);
  for (int i=0; i<n; i++) {
    cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int t=b;
    b=c;
    c=t;
    //cout<<b<<" "<<c;
    int t1=a;
    a=b;
    b=t1;
    cout<<a<<" "<<b<<" "<<c;
}


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

char c[55][55]; int H, W, cnt=0;

int main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) 
	{
		for (int j = 1; j <= W; j++) cin >> c[i][j];
	}
	for (int i = 1; i <= H; i++) 
	{
		for (int j = 1; j <= W; j++) 
		{
			if (c[i][j] == '#' && c[i][j - 1] != '#' && c[i - 1][j] != '#' && c[i][j + 1] != '#' && c[i + 1][j] != '#') cnt++;
		}
	}
	if (cnt == 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
		return 0;
}


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

void dfs(vector<int> &a,vector<vector<int>> &swi,vector<int> &p,int n,int m,int &ans){
    if(a.size() == n){
        bool ok = true;
        for(int i = 0;i < m;i++){
            int on = 0;
            for(int j = 0;j < swi[i].size();j++){
                if(a[swi[i][j]] == 1)on++;
            }
            if((on % 2) != p[i])ok = false;
        }
        if(ok)++ans;
        return;
    }
    for(int v = 0; v < 2;v++){
        a.push_back(v);
        dfs(a,swi,p,n,m,ans);
        a.pop_back();
    }

}

int main(){
    int n,m,k,s,ans = 0;
    cin >> n >> m;
    vector<vector<int>> switches(m);
    vector<int> p(m);
    for(int i = 0;i < m;i++){
        cin >> k;
        for(int j = 0;j < k;j++){
            cin >> s;
            switches[i].push_back(s - 1);
        }
    }
    for(int i = 0;i < m;i++){
        cin >> p[i];
    }
    vector<int> a;
    dfs(a,switches,p,n,m,ans);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

static const int N = 1000;

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

int main(){
  int n, i, j;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);


  /*
  * Insert sort
  */
  // trace(A, n);
  // for ( i = 2; i < n+1 ; i++) {
  //   int key = A[i];
  //   int j = i-1;
  //   while (j >= 1 && A[j] > key) {
  //     A[j+1] = A[j];
  //     j--;
  //   }
  //   A[j+1] = key;
  //   trace(A, n);
  //    /* code */
  // }

  /*
  * Bubble sort
  */
  int count = 0;
  for (i =1; i< n+1; i++){
    for ( j = n; j >= i+1; j--) {
      if (A[j] < A[j-1]){
        count += 1;
        int tmp = A[j];
        A[j] = A[j-1];
        A[j-1] = tmp;
      }
      /* code */
    }
  }
  trace(A,n);
  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 608
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
int x[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",x+i);
	long long ret=1;
	int at=0;
	for(int i=0;i<a;i++){
		while(at<a&&x[i]<i*2+1-at*2){
			ret=(ret*(i+1-at))%mod;
			at++;
		}
	}
	while(at<a){
		ret=(ret*(a-at))%mod;
		at++; 
	}
	printf("%lld\n",ret);
}


Measured memory_bytes: 512
//lib
function readInt(str){
    return parseInt(str, 10);
}
//main
function Main(raw) {
    const input = raw.split("\n");
    const [N, M] = input[0].split(" ").map(readInt);
    let K=[];
    let A=[];
    for(let i=0;i<N;i++){
        const[k, ...a] = input[i+1].split(" ").map(readInt);
        K.push(k);
        A.push(a.map(item=>item-1));
    }
    const count=new Array(M).fill(0);
    for(let i=0;i<N;i++){
        A[i].forEach(a => {
            count[a]++;
        });
    }
    const ans=count.filter(each=>each==N).length
    
    //出力
    console.log("%d", ans);
}
  
//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (1e9)

int main() {
  bool isrev = false;
  vector<string> before, after;
  int q, query;
  string s, add; cin >> s;
  cin >> q;

  for(int i = 0; i < q; i++) {
    cin >> query;
    if(query == 1) isrev = !isrev; 
    else {
      cin >> query >> add;
      if(query == 1) {
        (isrev ? after : before).push_back(add);
      } else {
        (isrev ? before : after).push_back(add);
      }
    }
  }

  if(isrev == false) {
    for(int i = before.size() - 1; i >= 0; i--) cout << before[i];
    cout << s;
    for(int i = 0; i < after.size(); i++) cout << after[i];
  } else {
    for(int i = after.size() - 1; i >= 0; i--) cout << after[i];
    for(int i = s.length() - 1; i >= 0; i--) cout << s[i];
    for(int i = 0; i < before.size(); i++) cout << before[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 11760
// Here is the top-down approach of 
#include <bits/stdc++.h>
#define int int64_t 
using namespace std; 

const int N = 1e5 + 1; 
vector<vector<int>> dp(N,vector<int>(101));
vector<int> v,w;


int solve(int W,int n){
    int &ans = dp[W][n];
    if(W ==0 or n == 0 )
        return 0;
    
    if(w[n-1] > W)
        return solve(W,n-1);
    if(dp[W][n] != -1) return ans;
    
    ans = max(v[n-1]+solve(W-w[n-1],n-1) , solve(W,n-1));
    
    return ans;
  
}
signed main() 
{ 
    int n,W;
    cin>>n>>W;
    int x,y;
    for(int i=0;i<=W;i++)
        for(int j=0;j<=n;j++)
            dp[i][j] = -1;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        w.push_back(x);
        v.push_back(y);
    }
    
    cout<<solve(W,n);
    
} 


Measured memory_bytes: 82304
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll a, b;
    cin >> a >> b;

    ll cnt(0);
    rep(i,a,b+1)
    {
        string s (to_string(i));
        ll n (s.size());
           if (s[0]==s[4] && s[1]==s[3])
            ++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<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
 
int main() {
    int n,m;
    cin >> n >> m;
    int ans = 0;
    ans += (m*(m-1))/(2);
    ans += (n*(n-1))/(2);
    cout << ans << '\n';

}

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

const int mn=2e5+8;
int a[mn],n,k;

int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i) scanf("%d",a+i);
    for(int i=k+1;i<=n;++i) {
        if(a[i]>a[i-k]) puts("Yes");
        else puts("No");
    }
}

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

int main() {
    string s, t, tem;
  	int c = 0, ans = 10000; 
  	cin>>s>>t;
  	for (int i = 0; i <= (s.size()-t.size()); i++)
    {
      c = 0;
      tem = s.substr(i,t.size());
      for (int j = 0; j < t.size(); j++)
        if (tem[j] != t[j])
          c++;
      ans = min(ans,c);
    }
  	cout<<ans;
    return 0;
}


Measured memory_bytes: 3612
#include<algorithm>
#include<string>
#include<vector>
#include<iostream>
#define rep(i,x,y) for(int i=x;i<y;i++)

using namespace std;
int main(){
  int n; cin>>n;
  vector<int>a(n); 
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int q; cin>>q;
  rep(i,0,q){
    int b,e,t;
    cin>>b>>e>>t;
    rep(j,0,e-b){
      swap(a[b+j],a[t+j]);
    }
  }
  rep(i,0,n-1){
    cout<<a[i]<<" ";
  }
  cout<<a[n-1]<<endl;
}


Measured memory_bytes: 3104
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    String c = sc.next();
    String s = (a.substring(0,1) + b.substring(0,1) + c.substring(0,1));
    System.out.println(s.toUpperCase());
  }
}

Measured memory_bytes: 21588
import math
N, D = map(int, input().split(' '))
X_ls = []
cnt = 0

for i in range(N):
    X_ls.append(list(map(int, input().split(' '))))

for i in range(N - 1):
    for j in range(i+1, N):
        dist_squared, dist = 0, 0
        for y, z in zip(X_ls[i], X_ls[j]):
            dist_squared += (y - z) ** 2
        dist = math.sqrt(dist_squared)
        if dist - math.floor(dist) == 0:
            cnt += 1
print(cnt)

Measured memory_bytes: 9116
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Register Phase
public class Main{
	Scanner sc=new Scanner(System.in);

	String s;

	void run(){
		s=sc.nextLine();
		solve();
	}

	void solve(){
		boolean f1=false, f2=false, f3=false;
		for(char c : s.toCharArray()){
			f1|=Character.isDigit(c);
			f2|=Character.isLowerCase(c);
			f3|=Character.isUpperCase(c);
		}
		println(f1&&f2&&f3&&s.length()>=6?"VALID":"INVALID");
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 17328
package main

import (
	"fmt"
	"math"
)

func powInt(a int, b int) (res int) {
	res = int(math.Pow(float64(a), float64(b)))
	return
}

func main() {
	var x int
	fmt.Scan(&x)

	max := 0
	for i := 0; true; i++ {
		if powInt(i, 5)-powInt(i-1, 5) > 1e9 {
			max = i
			break
		}
	}

	for a := 0; a < max; a++ {
		for b := 0; b < max; b++ {
			if powInt(a, 5)-powInt(b, 5) == x {
				fmt.Printf("%d %d\n", a, b)
				return
			}
			if powInt(a, 5)-powInt(-b, 5) == x {
				fmt.Printf("%d %d\n", a, -b)
				return
			}
		}
	}
}

Measured memory_bytes: 1824
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        if i % 2 == 0:
            print("#."*(W//2)+"#"*(W%2))
        else:
            print(".#"*(W//2)+"."*(W%2))
    print()

Measured memory_bytes: 7584
// AOJ 2011: Gather the Maps!
// 2017.11.1 bal4u@uu

#include <stdio.h>
#include <string.h>

char tbl[52][32];
long long f[52][32];

char buf[100], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, i, j, ans;
	long long goal, s;

	while (fgets(p=buf, 10, stdin) && *buf != '0') {
		n = getint();
		memset(f, 0, sizeof(f));
		memset(tbl, 0, sizeof(tbl));
		goal = (1LL << n) - 1;
		ans = 0;
		for (i = 0; i < n; i++) {
			fgets(p=buf, 100, stdin);
			j = getint(), p++;
			if (!j) ans = -1;
			if (!ans) while (j--) tbl[i][getint()] = 1, p++;
		}

		if (!ans) {
			ans = -1;
			for (j = 1; j <= 30; j++) {
				s = 0;
				for (i = 0; i < n; i++) if (tbl[i][j]) s |= f[i][j-1] | (1LL << i);
				if (s == goal) { ans = j; break; }
				for (i = 0; i < n; i++) {
					if (tbl[i][j]) f[i][j] = s;
					else f[i][j] = f[i][j-1];
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1668
import bisect
import sys
from itertools import accumulate

input = sys.stdin.readline


def main():
    N, M, K = map(int, input().split())
    A = tuple(map(int, input().split()))
    B = tuple(map(int, input().split()))

    B_cumsum = tuple(accumulate(B))
    ans = 0
    time = 0
    for i in range(N + 1):
        if time > K:
            break
        j = bisect.bisect_right(B_cumsum, K - time)
        ans = max(ans, i + j)

        if i < N:
            time += A[i]

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 42268
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int x1 = sc.nextInt();
			int y1 = sc.nextInt();
			int x2 = sc.nextInt();
			int y2 = sc.nextInt();
			int x = x2 - x1;
			int y = y2 - y1;
			int x3 = x2 - y;
			int y3 = y2 + x;
			int x4 = x1 - y;
			int y4 = y1 + x;

			System.out.println(String.format("%d %d %d %d", x3, y3, x4, y4));
		}
	}
}


Measured memory_bytes: 35704
#include <bits/stdc++.h>
using namespace std;
 
int main()
{

    string s,t;
    cin>>s>>t;
    int f=1;
    for(int i=0;i<s.length();i++)
    {
		if(s[i]!=t[i])
           {
				f=0;
             break;
           }
    }
    if(f)cout<<"Yes";
    else cout<<"No\n";
           
    
}

Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
    int a,b,c;
     int d,e;
   
    scanf("%d %d %d",&a,&b,&c);
    d=a-b;
    e=c-d;
    if(e>0)
        printf("%d",e);
    else
        printf("0");

}


Measured memory_bytes: 1724
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int f[2020];
int32_t main()
{
	string s;
	cin>>s;int n=s.length();
	int ans=0;f[0]++;
	int rem=0;int mul=1;reverse(s.begin(),s.end());
	for(int i=0;i<n;i++)
	{
		rem+=((s[i]-'0')*mul)%2019;
		mul*=10;mul%=2019;
		rem%=2019;
		ans+=f[rem];
		f[rem]++;
	}
	cout<<ans;
	
}

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

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

using namespace std;
using lint=long long;

const long long INF=1LL<<61;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n+1);
	rep(d,n+1) scanf("%d",&a[d]);

	lint f=1;
	rep(d,n+1){
		if(f-a[d]<0){
			return puts("-1"),0;
		}
		f=2*(f-a[d]);
		f=min(f,INF);
	}

	lint sum=0;
	rep(d,n+1) sum+=a[d];

	lint ans=0;
	f=1;
	rep(d,n+1){
		f-=a[d];
		sum-=a[d];
		ans+=a[d];
		ans+=f;
		f=min(2*f,sum);
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll x;
  R x;
  if(x<1200) pr("ABC");
  else pr("ARC");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999;
	
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var set = new HashSet<long>();
		var sa = Input();
		for(int i = 0; i < n; i++)
		{
			var k = sa[i].ToLong();
			if(set.Contains(k))
			{
				Console.WriteLine("NO");
				return;
			}
			set.Add(k);
		}
		Console.WriteLine("YES");
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


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

sortedL = sorted(list(map(int, input().split())))

accum = [0] * (2*10**3)

prev_ind = 0
count = 0
for elm in sortedL:
    if prev_ind < elm:
        for i in range(prev_ind+1, elm):
            accum[i] = count
        count += 1
        accum[elm] = count
    else:
        count += 1
        accum[elm] = count
    prev_ind = elm

for i in range(prev_ind, 2*10**3):
    accum[i] = count

ans = 0
for i in range(n):
    for j in range(i+1, n):
        a, b = sortedL[i], sortedL[j]
        left = abs(a - b)
        right = a + b
        tmp = accum[right-1] - accum[left]
        if left < a < right:
            tmp -= 1
        if left < b < right:
            tmp -= 1
        
        ans += tmp

print(ans // 3)

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

const int N = 2e5 + 5;
typedef long long ll;

int n, k;
ll sum[N], ans, mod = 1e9 + 7;

int main() {
	cin>>n>>k;
	for(int i = 1; i <= n; i++) sum[i] = (sum[i - 1] + i)%mod;
	for(int i = k; i <= n + 1; i++) 
		ans = (ans + sum[n] - sum[n - i] - sum[i - 1] + 1 + mod)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5144
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;


int main() {
	string s; cin >> s;
	int k; cin >> k;
	vector<string> v;
	for (int i = 0; i < (int)s.size(); i++) {
		v.push_back(s.substr(i, s.size() - i));
	}
	sort(v.begin(), v.end());
	int cnt = 0;
	for (int i = 0; i < (int)v.size(); i++) {
		int pos = 0;
		while (i > 0 && v[i][pos] == v[i - 1][pos]) pos++;
		for (int j = pos; j < (int)v[i].size(); j++) {
			cnt++;
			if (cnt == k) {
				cout << v[i].substr(0, j + 1) << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 16128
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define mod 1000000007
#define pb push_back
 
typedef long long ll;

using namespace std;

int main(){
  string x,y,ans="";
  cin >> x >> y ;
  for (int i=0; i<x.size(); ++i){
    ans+=x[i];
    if(i>=y.size()) break;
    else ans+=y[i];
  }
  cout << ans << endl;
  return 0;
}

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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n, k; read(n, k);

	vector<ll> a(n);
	rep(i, 0, n) read(a[i]);

	rep (i, 0, k) {
		vector<ll> b(n);
		rep(i, 0, n) {
			b[max(0ll, i - a[i])]++;
			if (i + a[i] + 1 < n)
				b[i + a[i] + 1]--;
		}
		vector<ll> a2(n);
		rep(i, 0, n)
			a2[i] = (i ? a2[i - 1] : 0) + b[i];
		a = a2;
		bool alln = true;
		rep(i, 0, n) {
			if (a[i] != n) alln = false;
		}
		if (alln) break;
	}


	rep(i, 0, n) cout << a[i] << " ";
	cout << endl;
}


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

int main() {
    int N, cnt = 0, tmp = 0;
    cin >> N;

    vector<int> Button(N);
    for (int i = 0; i < N; i++) {
        int z;
        cin >> z;
        z--;
        Button.at(i) = z;
    }
    
    //入力層終わり

    for (;;) {
        
        if (tmp == 1) {
            cout << cnt << endl;
            break;
        }

        if (cnt >= N) {
            cout << "-1" << endl;
            break;
        }
        tmp = Button.at(tmp);
        cnt++;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()


ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
int main(){
    vector<ll>num(3);
    ll k;
    rep(i,3) cin >> num[i];
    cin >> k;
    ll ans=0;
    rep(i,3){
        if(i==0){
            ans+=min(num[i],k);
            k-=num[i];
        }
        else if(i==1){
            k-=num[i];
        }
        else{
            ans-=min(num[i],k);
        }
        if(k<=0) break;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3600
from itertools import product
X, Y, Z, K = map(int, input().split())
AB = []
for ab in product(map(int, input().split()), map(int, input().split())):
    AB.append(ab[0] + ab[1])
AB.sort(reverse=True)
AB = AB[:min(K,X*Y)]
ABC = []
for abc in product(AB, map(int, input().split())):
    ABC.append(abc[0]+abc[1])
ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])


Measured memory_bytes: 233572
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int n[] = {0,0,2,0,1,0,1,0,0,1,0,1,0};
	int a,b,c;
	//string s="error";
	cin >> a; cin >> b; //cin >> c;
	//a[0]==a[2]?cout << "Yes"<< endl: cout << "No" << endl;
	if (n[a]==n[b])cout << "Yes" << endl;
	else cout << "No" << endl;
	
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		pr.println(n - (k - 1));
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int n, s[10009], q, t[509], c = 0;

int main(){
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	cin >> q;
	for(int i=0;i<q;i++){
		cin >> t[i];
	}

	for(int i=0;i<q;i++){
		int key = t[i];
		s[n] = key;
		int j = 0;
		while(s[j] != key){
			j++;
		}
		if(j != n) c++;
	}
	cout << c << endl;
}

Measured memory_bytes: 1200
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

const int INF = INT_MAX / 2;

int main(void) {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int ans = INF;
    for (int num_c = 0; num_c <= 200000; num_c += 2) {
        int num_a = max(0, X - num_c / 2);
        int num_b = max(0, Y - num_c / 2);
        int cand = num_a * A + num_b * B + C * num_c;
        chmin(ans, cand);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3584
using System;

namespace AizuOnline
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inp = Console.ReadLine().Split();
            int w = Int32.Parse(inp[0]);
            int h = Int32.Parse(inp[1]);
            int x = Int32.Parse(inp[2]);
            int y = Int32.Parse(inp[3]);
            int r = Int32.Parse(inp[4]);
            string arranged = "Yes";

            if (x < r || x > w-r)
            {
               arranged = "No";
            }
            if (y < r || y > h-r)
            {
               arranged = "No";
            }
            //Console.WriteLine("w={0} h={1} x={2} y={3} r={4}", w, h, x, y, r);
            Console.WriteLine(arranged);
        }
    }
}


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

int n;
map <string, bool> mp;

void brute(string &s) {
	if (mp.find(s) != mp.end()) return;
	mp[s] = true;

	for (int i = 0; i < n - 1; ++i) {
		if (s[i] != s[i + 1]) {
			int a = s[i] - '0';
			int b = s[i + 1] - '0';
			int c;
			for (c = 0; c < 3; ++c) {
				if ((c + c) % 3 == (a + b) % 3) break;
			}
			string nw = s;
			nw[i] = (char)(c + '0');
			nw[i + 1] = (char)(c + '0');
			brute(nw);
		}
	}
}
// --------------------------------------------------

const int N = 200005;
const int mod = 998244353;

int dp[N][3][3][2];

void add(int &x, int y) {
	x += y;
	while(x >= mod) x -= mod;
	while(x < 0) x += mod;
}

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

	string s; cin >> s;
	n = s.size();
	for (int i = 0; i < n; ++i) {
		s[i] = s[i] - 'a' + '0';
	}

	// corner cases
	if (n <= 3) {
		brute(s);
		cout << mp.size() << endl;
		return 0;
	}
	bool equal_all = true;
	for (int i = 0; i < n; ++i) {
		equal_all &= (s[i] == s[0]);
	}
	if (equal_all) {
		cout << 1 << endl;
		return 0;
	}

	// dp
	int t = 0;
	bool adj = false;
	for (int i = 0; i < n; ++i) {
		t = (t + s[i] - '0') % 3;
		if (i > 0) adj |= (s[i] == s[i - 1]);
	}

	dp[0][0][0][0] = 1; // dp[pos][mod3][last][any_equal_adjacent_pairs?]
	for (int i = 0; i < n; ++i) {
		for (int sum = 0; sum < 3; ++sum) {
			for (int last = 0; last < 3; ++last) {
				for (int have = 0; have < 2; ++have) {
					if (!dp[i][sum][last][have]) continue;

					for (int nxt = 0; nxt < 3; ++nxt) {
						bool new_have = have;
						if (i != 0 && nxt == last) new_have = 1;
						add(dp[i + 1][(sum + nxt) % 3][nxt][new_have], dp[i][sum][last][have]);
					}
				}
			}
		}
	}

	int res = 1; // s itself
	for (int last = 0; last < 3; ++last) {
		add(res, dp[n][t][last][1]);
	}

	if (adj) add(res, -1); // s is repeatly computed

	cout << res << endl;
}

Measured memory_bytes: 14612
#include<stdio.h>
#include<math.h>
int main()
{
	int n,m,i,j,a[5],b[5],c[4]={0},t,s=0,flag=0;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
	}
	if(m==0)
	{
		if(n==1)
		printf("0");
		else
		printf("%.0lf",pow(10,n-1));
	}
	else
	{
		for(i=1;i<m;i++)
		{
			for(j=0;j<m-i;j++)
			{
				if(a[j]>a[j+1])
				{
					t=a[j];
					a[j]=a[j+1];
					a[j+1]=t;
					t=b[j];
					b[j]=b[j+1];
					b[j+1]=t;
				}
			}
		}
	for(i=0;i<m-1;i++)
	{
		if((a[i]==a[i+1])&&(b[i]!=b[i+1]))
		{
			printf("-1");
			return 0;
		}
		if(((a[i]==1)&&(b[i]==0))||((a[i+1]==1)&&(b[i+1]==0)))
		{
			flag=1;
		}
		c[a[i]]=b[i];
	}
	if(a[0]==1&&b[0]==0&&flag==0)
	{
		flag=1;
	}
	c[a[m-1]]=b[m-1];
	if(c[1]==0)
	{
		if(n==1)
		{
			printf("0");
			return 0;
		}
		if(flag==1)
		{
			printf("-1");
			return 0;
		}
		c[1]=1;
	}
	for(i=1;i<=n;i++)
	s=10*s+c[i];
	printf("%d",s);
	}
	return 0;
}


Measured memory_bytes: 128
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
n = int(input())

div = make_divisors(n)
if len(div)%2 == 0:
    print(div[len(div)//2 - 1]+div[(len(div)//2)]-2)
else:
    print(div[(len(div)//2)]*2-2)

Measured memory_bytes: 3268
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	vector<long long int>x(n),y(n),z(n),w(n);
	rep(i,n)cin>>x[i]>>y[i]>>z[i];
	long long int sum,max = -1;

	rep(i,8){
		if((i&1)==0){
			rep(j,n)w[j]=x[j];
		}else{
			rep(j,n)w[j]=-x[j];
		}
		if((i&2)==0){
			rep(j,n)w[j]+=y[j];
		}else{
			rep(j,n)w[j]-=y[j];
		}
		if((i&4)==0){
			rep(j,n)w[j]+=z[j];
		}else{
			rep(j,n)w[j]-=z[j];
		}
		sort(w.begin(),w.end());
		//rep(j,n)cout<<w[j]<<" ";
		//cout<<endl;
		sum=0;
		rep(j,m){
			sum+=w[n-j-1];
		}
		if(max<sum)max=sum;
	}
	cout<<max<<endl;



	return 0;
}


Measured memory_bytes: 3656
I0 = lambda :map(int,input().split())
I1 = lambda :int(input())
I2 = lambda :list(map(int,input().split()))
#####################################################
 
 
from sys import stdin,setrecursionlimit
#from copy import deepcopy
 
setrecursionlimit(10**6)
input=stdin.readline
 
def dfs(p,father=-1):
    for i in tree[p]:
        if i == father:
            continue
        counter[i]+=counter[p]
        dfs(i,p)
 
n ,q = I0()
counter = [0]*n
tree = [[] for i in range(n)]
for i in range(n-1):
    a,b=I0()
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
 
for i in range(q):
    p,x = I0()
    counter[p-1]+=x
    
 
dfs(0)
 
print(*counter)
 

Measured memory_bytes: 269096
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input1 = Console.ReadLine();
            string input2 = Console.ReadLine();
            char[] kisu = input1.ToCharArray();
            char[] gusu = input2.ToCharArray();
            string pw = "";
            for (int i =0; i< input2.Length;i++)
            {
                pw = pw + kisu[i] + gusu[i];
            }
            if (input1.Length>input2.Length)
            {
                pw = pw + kisu[input1.Length - 1];
            }
            Console.WriteLine(pw);
        }
    }
}



Measured memory_bytes: 11092