akhauriyash/Code-Regression huggingface dataset:
#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 main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int A, B;
    std::cin >> A >> B;

    if(A > B){
        std::swap(A, B);
    }

    if((A + B) % 2 == 0){
        int K = A + (B - A) / 2;
        std::cout << K << std::endl;
    }else{
        std::cout << "IMPOSSIBLE" << std::endl;
    }
}


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

typedef long long ll;
ll INF = 1LL << 60;
ll MAX = 100010;
ll MOD = 2019;

int
main() 
{
  string S; cin >> S;
  int one = 0;
  int zero = 0;

  rep(i, 0, S.size()){
    if(S[i] == '0') zero++;
    else one++;
  }

  cout << min(one, zero) * 2 << endl;

}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;

const int MN = 2e5+5;
const int MOD = 1e9+7;
const int INF = 1e9;

int N,A[MN],I[MN],cnt;
vector<int> G[MN];
pii P[MN<<2],E[MN];
priority_queue<pii,vector<pii>,greater<pii>> PQ;

pii cal(pii X, pii Y)
{
	pii P;
	P.va = A[X.va]<A[Y.va] ? X.va : Y.va;
	P.vb = A[X.vb]<A[Y.vb] ? X.vb : Y.vb;
	return P;
}

void init(int s, int e, int i)
{
	if(s==e){
		if(s%2) P[i].va = s;
		else P[i].vb = s;
		return;
	}
	int m = (s+e)/2;
	init(s,m,i<<1);
	init(m+1,e,i<<1|1);
	P[i] = cal(P[i<<1],P[i<<1|1]);
}

pii get(int s, int e, int x, int y, int i)
{
	if(e<x||y<s) return pii(0,0);
	if(x<=s&&e<=y) return P[i];
	int m = (s+e)/2;
	return cal(get(s,m,x,y,i<<1),get(m+1,e,x,y,i<<1|1));
}


int solve(int s, int e)
{
	if(s>e) return 0;
	int l,r,a,b,c;
	if(s%2){
		l = get(1,N,s,e-1,1).va;
		r = get(1,N,l+1,e,1).vb;
	}
	else{
		l = get(1,N,s,e-1,1).vb;
		r = get(1,N,l+1,e,1).va;	
	}
	E[++cnt] = pii(A[l],A[r]);
	int x = cnt;
	a = solve(s,l-1);
	b = solve(l+1,r-1);
	c = solve(r+1,e);
	if(a) G[x].push_back(a);
	if(b) G[x].push_back(b);
	if(c) G[x].push_back(c);
	I[a]++;
	I[b]++;
	I[c]++;
	return x;
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> N;
    A[0] = MN;
    for(int i=1; i<=N; i++){
    	cin >> A[i];
    }
    init(1,N,1);
    int x = solve(1,N);
    PQ.emplace(E[x].va,x);
    while(PQ.size()){
    	x = PQ.top().vb;
    	PQ.pop();
    	for(int v:G[x]){
    		I[v]--;
    		if(!I[v]) PQ.emplace(E[v].va,v);
    	}
    	cout << E[x].va << ' ' << E[x].vb << ' ';
    }
}

Measured memory_bytes: 23808
h,w,k=map(int,input().split())
c=[list(input()) for _ in range(h)]

from itertools import product
h_bits=list(product([0,1], repeat=h))
w_bits=list(product([0,1], repeat=w))

ans=0
for h_bit in h_bits:
    for w_bit in w_bits:
        tmp_cnt=0
        for i, h_b in enumerate(h_bit):
            for j, w_b in enumerate(w_bit):
                if h_b==0 and w_b==0 and c[i][j]=="#":
                    tmp_cnt+=1
        if tmp_cnt==k:
            ans+=1
print(ans)


Measured memory_bytes: 9200
#include<cstdio>
#include<algorithm>
using namespace std;
char s[300003];
int f[300003],n,minn=2e9;
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	for (int i=1;i<=n;i++)
	{
		if (s[i]=='E') f[i]=f[i-1]+1;
		else f[i]=f[i-1];
	}
	for (int i=1;i<=n;i++) minn=min(minn,i-f[i-1]-1+f[n]-f[i]);
	printf("%d",minn);
	return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, k;
  cin >> n >> k;
  ll ans = 1;
  REP(i, n) {
    ans *= max(0, k - i);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3104
import numpy as np
h, w = map(int, input().split())
arr = np.array([list(input()) for _ in range(h)]) == "."
# print(arr)
l = np.zeros((h, w), dtype=int)
r = np.zeros((h, w), dtype=int)
u = np.zeros((h, w), dtype=int)
d = np.zeros((h, w), dtype=int)

for i in range(h):
    u[i] = (u[i - 1] + 1) * arr[i] #arrがFalseだと0になる
    d[- i - 1] = (d[- i] + 1) * arr[- i - 1]

for j in range(w):
    l[:, j] = (l[:, j-1] + 1) * arr[:, j]
    r[:, - j - 1] = (r[:, - j] + 1) * arr[:, - j - 1]
# print(u)
print(np.max(u + d + l + r) - 3)


Measured memory_bytes: 219796
#include<bits/stdc++.h>
#define ST first
#define ND second
#define ll long long
#define ld long double
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;

const ll  INF = 1e9 + 9;
const ll  MOD = 1e9 + 7;
const long long LINF = (ll)1e18 + 3;
 
// secik.insert({x, t++});
// secik.erase(secik.lower_bound({x,-1}));
// *secik.find_by_order(x)).first << "\n";
// secik.order_of_key(x)
 
//random_device device;
//mt19937 gener(device());
//uniform_int_distribution<ll > gen(0,n-1);
//gen(gener); // generate random number

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

	ll x; cin >> x;
	cout << x + x*x + x*x*x;


















	
}

Measured memory_bytes: 3636
n = int(input())
s = []
t = []
for i in range(n):
  x,y = (input().split())
  y = int(y)
  s.append(x)
  t.append(y)
X = input()
l = 0
for i in range(n):
  if s[i] == X:
    l = i
    break
ans = sum(t[l+1:])
print(ans)

Measured memory_bytes: 3064
import java.util.*;	
		
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int num =sc.nextInt();
				 boolean ans=false;
				 for(int i=1;i<=3;i++){
					 if(num%10==7)
						 ans=true;
					 num=num/10;
				 }
				 if(ans){
					 System.out.print("Yes");
				 }else{
					 System.out.print("No");
				 }
  }
}


Measured memory_bytes: 35720
n = int(input())
A = [int(input()) - 1 for _ in range(n)]
pushed = [False] * n
q = [0]
ans = 0
while q:
    b = q.pop()
    ans += 1
    pushed[b] = True
    if pushed[A[b]]:
        ans = -1
        break
    if A[b] == 1:
        break
    q.append(A[b])
print(ans)

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

int main() {
  int N;
  cin >> N;
  int64_t ans = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      ans += i;
    }
  }
  cout << ans << endl;
}
  

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

int main() {
	// your code goes here
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b && a!=c) || (a==c && a!=b) ||(b==c && b!=a))
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))
#define N 32
#define INF (1e8)
const char dx[]={0,1,0,-1},dy[]={1,0,-1,0};

pii dp[N+1][N+1][N+1][N+1];
int h,w,s,sum,l;
int u[N][N];

pii add(pii a,pii b){
	pii r = make_pair(a.first+b.first,min(a.second,b.second));
	return r;
}

pii dfs(int x0,int y0,int x1,int y1){
	if(dp[x0][y0][x1][y1].first > 0)return dp[x0][y0][x1][y1];
	pii r;
	int p=0;
	for(int i=x0;i<x1;i++)for(int j=y0;j<y1;j++)p+=u[i][j];
	r = make_pair(1,p);
	for(int i=x0+1;i<x1;i++){
		pii t = add( dfs(x0,y0,i,y1), dfs(i,y0,x1,y1) );
		if(t.second >= l) r = max(r,t);
	}
	for(int i=y0+1;i<y1;i++){
		pii t = add( dfs(x0,y0,x1,i), dfs(x0,i,x1,y1) );
		if(t.second >= l) r = max(r,t);
	}
	return dp[x0][y0][x1][y1] = r;
}

int main(){
	for(;;){
		scanf("%d%d%d",&h,&w,&s);
		if(!(h*w*s))break;
		sum = 0;
		memset(dp,-1,sizeof(dp));
		rep(i,h)rep(j,w){
			scanf("%d",u[i]+j);
			sum += u[i][j];
		}
		l = sum - s;
		pii ans = dfs(0,0,h,w);
		printf("%d %d\n",ans.first,ans.second - l);
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) cin >> a[i];

  sort(a.begin(), a.end());
  int x = a.back();
  int r = a[0], t = (x + 1) / 2;
  for (int i = 0; i < n - 1; i ++) {
    if (abs(a[i] - t) < abs(r - t)) r = a[i];
  }
  cout << x << " " << r << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
    float a,b,c,d,e,f,x,y;
    
    while (scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f)  != EOF) {
        y = (d * c - a * f) / (d * b - a * e);
        x = (-b * y + c) / a;
        printf("%.3lf %.3lf\n", x, y);
    }
    return 0;
}

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

int main()
{
    long long int N, D;
    int v = 0;
    long long int a[1000000][2];
    double Z;

    cin >> N >> D;

    for (int i = 0; i <= N - 1; i++)
    {
        for (int f = 0; f <= 1; f++)
        {
            cin >> a[i][f];
        }
    }

    for (int i = 0; i <= N - 1; i++)
    {
        Z = a[i][0] * a[i][0] + a[i][1] * a[i][1];
        if (Z <= D * D)
        {
            v++;
        }
    }

    cout << v << endl;
    return 0;
}

Measured memory_bytes: 6760
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,ans=1;

int A[maxn],vi[maxn],Is[maxn],ch[maxn],has[maxn],f[maxn],deg[maxn];

int calc(int x,int y){
	if(x<y)return 2;
	if(x>y)return 0;
	return 1;
}

void Work(){
	REP(i,1,n)if(deg[i]>2||(deg[i]==2&&!Is[i]))return void(puts("0"));
	REP(i,1,n)if(!deg[i]){
		int x=i,t=0;while(!Is[x])x=A[x],t++;
		ch[x]=t;
	}
	REP(i,1,n)if(Is[i]){
		int x=i;
		do x=A[x];while(!ch[x]&&x!=i);
		if(x==i&&!ch[x]){
			int t=0;
			do x=A[x],t++,Is[x]=0;while(x!=i);
			has[t]++;
			continue;
		}
		
		int j=x,now=1;x=A[x];
		
		for(;;){
			if(ch[x]){
				ans=1ll*ans*calc(ch[x],now)%mod;
				now=0;
			}
			if(x==j)break;
			now++;x=A[x];
		}
		
		while(Is[x])Is[x]=0,x=A[x];
	}
	REP(i,1,n)if(has[i]){
		int x=(i>1&&(i&1))+1;
		f[0]=1;
		REP(j,1,has[i]){
			f[j]=1ll*f[j-1]*x%mod;
			if(j>=2)f[j]=(1ll*f[j-2]*(j-1)%mod*i+f[j])%mod;
		}
		ans=1ll*ans*f[has[i]]%mod;
	}
	iout(ans);
}

void Init(){
	read(n);
	REP(i,1,n)read(A[i]);
	REP(i,1,n)deg[A[i]]++;
	REP(i,1,n)if(!vi[i]){
		int x=i;
		while(!vi[x])vi[x]=i,x=A[x];
		if(vi[x]==i){
			while(!Is[x])Is[x]=1,x=A[x];
		}
	}
}

int main(){
	Init();
	Work();
	return 0;
}


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

if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 9204
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  ll a = 1, b = 1, n;
  cin >> n;
  ll keta;
  if (n > 1000000) keta = 1000000;
  else keta = n;
  for (ll i = 1; i <= keta; i++) {
    if (n % i == 0 && i <= n / i) {
      a = i;
      b = n / i;
    }
  }
  int ans = 0;
  while (b) {
    ans++;
    b /= 10;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();//500
		int b=sc.nextInt();//100
		int c=sc.nextInt();//50
		int x=sc.nextInt()/50;//50~20000=1~400
		
		int ans=0;
		for(int i=0;i<=a;i++) {
			for(int j=0;j<=b;j++) {
				for(int k=0;k<=c;k++) {
					if(x==i*10+j*2+k) {
						ans++;
					}
				}
			}
		}
		
		System.out.println(ans);

		}
	}


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


long long int parent[100005];
long long ans[100005];
long long set_size[100005];


void makeSet(long long int n)
{
    parent[n]=n;
     set_size[n]=1;
}

long long int Find(long long int reprasentative)
{
    if (parent[reprasentative] == reprasentative)
    {
        return reprasentative;
    }
    return parent[reprasentative] = Find(parent[reprasentative]);
}

void Union(long long int a,long long int b)
{
    long long int u = Find(a);
    long long int v = Find(b);
    if(u == v)
    { 
        return ;

    }
    else{
        if(set_size[u]>set_size[v])
           swap(u,v);
        parent[u]=v;
        set_size[v]+=set_size[u];
        set_size[u]=1;
    }
}

int main()
{

    long long n,m;
    cin>>n>>m;

    long long f=n*(n-1);
    f=f/2;

    long long a[m],b[m];

    for(int i=1;i<=n;i++)
      makeSet(i);




    for(int i=0;i<m;i++)
        cin>>a[i]>>b[i];


    ans[m]=f;


    for(int i=m-1;i>=0;i--){


         long long k=0;

         long long int z=Find(a[i]);
         long long int x=Find(b[i]),xz;

         if(z!=x){
            z=set_size[z];
            x=set_size[x];

            xz=z+x;
            xz=xz*(xz-1);
            xz=xz/2;


            x=x*(x-1);
            x=x/2;

            z=z*(z-1);
            z=z/2;

            f=f+x+z-xz;



         }

         Union(a[i],b[i]);
         ans[i]=f;


    }

    for(int i=1;i<=m;i++)
        cout<<ans[i]<<endl;









    return 0;
}


Measured memory_bytes: 5248
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		boolean flag = false;
		int ans=0;
		Scanner input = new Scanner(System.in);
		int a= input.nextInt();
		int b= input.nextInt();
		
		for(int i =0;i<Math.max(a, b);i++) {
			if(Math.abs(a-i)==Math.abs(b-i)) {
				flag = true;
				ans = i;
			}
		}
		if(flag) {System.out.println(ans);}
		
		else {
			 System.out.println("IMPOSSIBLE");
			
		}
		
	
		

	}

}


Measured memory_bytes: 27428
import math
import numpy as np

n = 10**5 + 1
p = [False] * n
c = [0] * n

def main():
    # 2からnまでの数字をsearch_listに入れる
    search_list = list(range(2,n))
    while True:
        # search_listの先頭の値が√nの値を超えたら処理終了
        if search_list[0] > math.sqrt(n):
            # search_listの残りの素数フラグを立てる
            for num in search_list:
                p[num] = True
            break
        else:
            # search_listの先頭の素数フラグを立てる
            tmp = search_list[0]
            p[tmp] = True
            # search_listの先頭をpopする
            search_list.pop(0)
            # search_listの先頭の倍数を取り除く
            search_list = [num for num in search_list if num % tmp != 0]

    # 1以上i以下のN-like数の数をc[i]とする
    for i in range(1,n):
        if p[i] and p[(i+1)//2]:
            c[i] = c[i-1] + 1
        else:
            c[i] = c[i-1]


    Q = int(input())
    for i in range(Q):
        l, r = map(int, input().split())
        print(c[r] - c[l-1])
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 18248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string S,T;
    cin >> S >> T;

    int n = S.size();
    int m = T.size();
    int tmp_cnt=0;
    int cnt = 10e8;

    for(int i=0;i<=n-m;i++){    //先頭
        for(int j=i;j<i+m;j++){ //
            if(S[j]!=T[j-i]){
                tmp_cnt++;
            }
        }
        //最小値取り出し
        if(cnt>tmp_cnt){
            cnt = tmp_cnt;
        }
        tmp_cnt=0;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3600
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 20 17:36:04 2017

"""

N = int(input())
TList = list(map(int, input().split()))
M = int(input())

drinkList = []

for i in range(M):
    PMList = list(map(int, input().split()))
    drinkList.append((PMList[0], PMList[1]))

sumTime = sum(TList)

for d in drinkList:
    print(sumTime - TList[d[0]-1] + d[1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;


int main()
{
  int N, D;
  cin >> N >> D;
  vector<vector<int>> vec;
  REP(i, N) {
    vector<int> tmp(D);
    REP(j, D) {
      cin >> tmp[j];
    }
    vec.push_back(tmp);
  }  
  int res = 0;
  REP(i, N) {
    for (int j = i+1; j < N; j++) {
      if (i == j) {
        continue;
      }
      double ans = 0;
      REP(k, D) {
        int b = abs(vec[i][k] - vec[j][k]);
        ans += b*b;
      }
      ans = sqrt(ans);
      if(abs(ans - (int)ans)>0) {
        continue;
      }
      res++;
    }
  }
  cout << res << endl;
  return 0;
}

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

int main(void){
    string s;
    cin >> s;
    if(s == "A"){
        s = "T";
    }
    else if(s == "T"){
        s = "A";
    }
    else if(s == "C"){
        s = "G";
    }
    else{
        s = "C";
    }
    
    cout << s <<endl;
    
    return 0;
}


































Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        scanf("%d", &h[i]);
    }
    if(n <= k){
        cout << 0 << endl;
        return 0;
    }
    long long ans = 0;
    sort(h.begin(), h.end());
    for(int i = 0; i < n - k; i++){
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
	int W, H, N, a;
	int x, y;

	cin >> W >> H >> N;

	int x0 = 0;
	int y0 = 0;
	int x1 = W;
	int y1 = H;


	for (int i = 0;i < N;i++)
	{
		cin >> x >> y >> a;

		switch (a)
		{
		case 1:
			if (x > x0)
				x0 = x;
			break;
		case 2:
			if (x < x1)
				x1 = x;
			break;
		case 3:
			if (y > y0)
				y0 = y;
			break;
		case 4:
			if (y < y1)
				y1 = y;
			break;
		default:
			break;
		}
	}

	if ((x1 - x0) < 0 || (y1 - y0) < 0)
		cout << 0 << endl;
	else
		cout << (x1 - x0) * (y1 - y0) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,T,M,P,X,ans=0;
  cin>>N;
  vector<int> v(N);
  for(int i=0;i<N;i++){
    cin>>v.at(i);
    ans+=v.at(i);
  }
  cin>>M;
  for(int i=0;i<M;i++){
    cin>>P>>X;
    cout<<ans+(X-v.at(P-1))<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

map<int, int> values[300];
char str[1000];
int length[300];

int expression(const char *str) {
  if (isdigit(str[0])) { return atoi(str); }
  int name = str[0];
  int index = expression(str + 2);
  if (index > length[name] || !values[name].count(index)) { throw 0; }
  return values[name][index];
}

int main() {
  while (true) {
    REP(i, 300) { values[i].clear(); }
    MEMSET(length, -1);
    int bug = 0;
    int line = 0;
    while (fgets(str, 999, stdin), str[0] != '.') {
      line++;
      if (bug != 0) { continue; }
      if (strstr(str, "=") == NULL) {
        int name = (int)str[0];
        length[name] = atoi(str + 2);
      } else {
        try {
          int name = (int)str[0];
          int index = expression(str + 2);
          if (index >= length[name]) { throw 0; }
          int right = expression(strstr(str, "=") + 1);
          values[name][index] = right;
        } catch (...) {
          bug = line;
        }
      }
    }
    if (line == 0) { break; }
    printf("%d\n", bug);
  }
}

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

int main ()
{
    int i,j,n,temp=-1;
    cin>>i>>j;
    if(i>9 || i<1 || j>9 ||j<1)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<i*j<<endl;
    }

}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll D[55];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    memset(D, 0, sizeof(D));
    REP(i, N) {
        cin >> D[i];
    }
    sort(D, D + N);
    vector<ll> v;
    v.push_back(0);
    REP(i, N) {
        if (i % 2 == 0)
            v.push_back(D[i]);
        else
            v.push_back(24 - D[i]);
    }

    ll ans = INF;
    REP(i, v.size()) {
        FOR(j, v.size(), i + 1) {
            ll a = v[i];
            ll b = v[j];
            ll d = std::min(abs(a - b), 24 - abs(a - b));
            ans = std::min(ans, d);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a < b) {
			System.out.println("a < b");
		} else if (a > b) {
			System.out.println("a > b");
		} else {
			System.out.println("a == b");
		}
	}
}



Measured memory_bytes: 26116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const int MOD=1000000007;
ll dp[100010][13]={};
int main(){
    string s;cin >> s;
    int n=s.size();
    dp[0][0]=1;
    for(int i=0; i<n; i++){
        if(s[i]=='?'){
            for(int j=0; j<10; j++){
                for(int k=0; k<13; k++){
                    dp[i+1][(j+k*10)%13]+=dp[i][k];
                    dp[i+1][(j+k*10)%13]%=MOD;
                }
            }
        }
        else{
            int j=s[i]-'0';
            for(int k=0; k<13; k++) {
                dp[i+1][(j+k*10)%13]+=dp[i][k];
                dp[i+1][(j+k*10)%13]%=MOD;
            }
        }
    }
    cout << dp[n][5] << endl;
    return 0;
}

Measured memory_bytes: 10624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		  Scanner sc = new Scanner(System.in);
		  
		  String S = sc.nextLine();
		  char c [] = S.toCharArray();
		  
		  System.out.print(2018);
		 for(int i = 4; i <c.length;i++) {
			 System.out.print(c[i]);
		 }
		 

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;
int main(){
  int N;
  cin>>N;
  int64_t ans=0;
  for(int i=1;i<=N;i++){
    if(i%3!=0&&i%5!=0){ans+=i;}
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3588
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main(){
	(readln.chomp.to!int / 3).writeln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

ll lcm(ll a, ll b){
    return abs(a) / __gcd(a,b) * abs(b);
}

int main(void)
{
    ll a,b,c,d,x;
    cin>>a>>b>>c>>d;
    x = (b/c - (a-1)/c) + (b/d - (a-1)/d) - (b/(lcm(c,d)) - (a-1)/(lcm(c,d)));
    cout << b-a+1-x << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;
typedef long long ll;

int main(){
  string S;
  cin >> S;
  vector<ll> digits;
  for (ll i=0; i<S.size(); i++){
    digits.push_back(atoi(S.substr(i, 1).c_str()));
  }
  ll ans = 0;
  ll buf = 0;
  for (ll i=0; i<pow(2, S.size()-1); i++){
    vector<bool> flags;
    buf = 0;
    ll itmp = i;
    for (ll j=0; j<S.size()-1; j++){
      flags.push_back(itmp % 2 == 1);
      itmp = itmp / 2;
      cerr << flags.back() << " ";
    }
    cerr << endl;
    buf = digits[0];
    for (ll j=1; j<S.size(); j++){
      if (flags[j-1]){
        ans += buf;
        buf = digits[j];
      }
      else{
        buf = 10 * buf + digits[j];
      }
    }
    ans += buf;
    cerr << ans << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[][][] l = new int[4][3][10];

        for(int i = 0; i < a; i++) {
        	int tou = sc.nextInt();
        	int kai = sc.nextInt();
        	int heya = sc.nextInt();
        	int ninzu = sc.nextInt();

        	l[tou-1][kai-1][heya-1] += ninzu;
        }

        for(int i = 0; i < 4; i++) {
        	for(int j = 0; j < 3; j++) {
        		for(int k = 0; k < 10; k++) {
        			System.out.print(" " + l[i][j][k]);
        		}
        		System.out.println();
        	}

        	if(i != 3) System.out.println("####################");
        }
	}
}



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

# define F first    
# define S second
      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector

# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

typedef pair <int, int> pii; 
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;

inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
int a;

int main() 
{
  Read_rap (); 
	cin >> a;
	cout << 24-a + 24;
     

  return 0;
} 










// Coded by Z..

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;

int main(int argc, char *argv[])
{
    std::string A, B;
    std::cin >> A >> B;

    std::string atemp, btemp;
    atemp = A;
    btemp = B;

    int acount = 0;
    while (!atemp.empty()) {
        atemp.pop_back();
        acount++;
    }

    int bcount = 0;
    while (!btemp.empty()) {
        btemp.pop_back();
        bcount++;
    }

    if (acount > bcount) {
        std::cout << "GREATER" << std::endl;
    } else if (acount < bcount) {
        std::cout << "LESS"    << std::endl;
    } else {
        if (A > B) {
            std::cout << "GREATER" << std::endl;
        } else if (A < B) {
            std::cout << "LESS"    << std::endl;
        } else {
            std::cout << "EQUAL"   << std::endl;
        }
    }
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    int N = S.size();
    vector<bool> dp(N+1, false);
    dp[0] = true;
    for (int i = 1; i <= N; ++i) {
        if (i >= 5 && dp[i-5] && S.substr(i-5, 5) == "erase") dp[i] = true;
        if (i >= 6 && dp[i-6] && S.substr(i-6, 6) == "eraser") dp[i] = true;
        if (i >= 5 && dp[i-5] && S.substr(i-5, 5) == "dream") dp[i] = true;
        if (i >= 7 && dp[i-7] && S.substr(i-7, 7) == "dreamer") dp[i] = true;
    }
    if (dp[N]) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> to[100005];
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  queue<int> q;
  vector<int> dist(n, -1);
  vector<int> pre(n, -1);
  dist[0] = 0;
  q.push(0);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int u : to[v]) {
      if (dist[u] != -1) continue;
      dist[u] = dist[v] + 1;
      pre[u] = v;
      q.push(u);
    }
  }

  cout << "Yes" << endl;
  for (int i = 0; i < n; ++i) {
    if (i == 0) continue;
    int ans = pre[i];
    ++ans;
    cout << ans << endl;
  }
}

Measured memory_bytes: 10628
#include<bits/stdc++.h>
using namespace std;
int n,x;
long double ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		ans+=1.0/x;
	}
	printf("%.10Lf\n",1/ans);
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

from bisect import bisect_left
from bisect import bisect_right

a, b, q = map(int, input().split())

s = [0]* a
t = [0]* b
X = [0]* q
for i in range(a):
    s[i] = int(input())

for i in range(b):
    t[i] = int(input())

for i in range(q):
    X[i] = int(input())

INF = float('inf')

for x in X:
    index_ls = bisect_left(s,x)
    index_lt = bisect_left(t,x)
    index_rs = bisect_right(s,x)
    index_rt = bisect_right(t,x)
    ans = INF
    right_s = INF
    left_s = -INF
    right_t = INF
    left_t = -INF

    if index_ls < a: right_s = s[index_ls]
    if index_lt < b: right_t = t[index_lt]
    if index_rs > 0: left_s = s[index_rs-1]
    if index_rt > 0: left_t = t[index_rt-1]

    ans1 = max(right_s-x,right_t-x)
    ans2 = max(x-left_s,x-left_t)
    ans3 = right_s-x + right_s-left_t
    ans4 = right_t-x + right_t-left_s
    ans5 = x-left_t + right_s-left_t
    ans6 = x-left_s + right_t-left_s

    print(min(ans1,ans2,ans3,ans4,ans5,ans6))



Measured memory_bytes: 16128
#include <stdio.h>
int main(){
  int t=0;
  int r[3]={0,0,0};
  char s[3][101];
  scanf("%s%s%s",s[0],s[1],s[2]);
  while(1){
    if(s[t][r[t]]== 0){
      printf("%c",'A'+t);
      return 0;
    }
    else t=s[t][r[t]++]-'a';
  }
}

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

int main() {
  string s;
  cin >> s;
  if((s[0] == s[1] && s[0] == s[2]) || (s[1] == s[2] && s[1] == s[3])){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

typedef struct Point_Coordinates {
	int x, y;
} point;

queue<point> que;
void BFS(point n, vector<string> & mp, vector<vector<int>> & ans) {
	int x = n.x, y = n.y;
	if (x > 0 && mp[y][x - 1] == '.') {
		que.push({ x - 1, y });
		mp[y][x - 1] = '#';
		ans[y][x - 1] = ans[y][x] + 1;
	}
	if (y > 0 && mp[y - 1][x] == '.') {
		que.push({ x, y - 1 });
		mp[y - 1][x] = '#';
		ans[y - 1][x] = ans[y][x] + 1;
	}
	if (x < mp[0].size() - 1 && mp[y][x + 1] == '.') {
		que.push({ x + 1, y });
		mp[y][x + 1] = '#';
		ans[y][x + 1] = ans[y][x] + 1;
	}
	if (y < mp.size() - 1 && mp[y + 1][x] == '.') {
		que.push({ x, y + 1 });
		mp[y + 1][x] = '#';
		ans[y + 1][x] = ans[y][x] + 1;
	}
	if (que.empty())
		return;
	n = que.front();
	que.pop();
	BFS(n, mp, ans);
	return;
}

int main(void) {
	int num, i, j, h, w, a, b, ans = 0;
	cin >> h >> w;
	vector<string> s(h), buf(h);
	rep(i, h)
		cin >> s[i];
	rep(j, h) {
		rep(i, w) {
			if (s[j][i] == '.') {
				buf = s;
				vector<vector<int>> d(h, vector<int>(w, 0));
				buf[j][i] = '#';
				BFS({ i, j }, buf, d);
				rep(a, h) {
					rep(b, w) {
						chmax(ans, d[a][b]);
					}
				}
			}
		}
	}
	cout << ans << "\n";
	return 0;
}

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

using namespace std;
using ll = long long;

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

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

  vector<int> v;
  int now = 1;
  int cnt = 0;
  rep(i, n) {
    if (s[i] == (now + '0')) {
      ++cnt;
    } else {
      v.push_back(cnt);
      now = 1 - now;
      cnt = 1;
    }
  }
  if (cnt != 0) v.push_back(cnt);
  int V = v.size();
  if (V % 2 == 0) v.push_back(0);

  vector<int> a(V + 1);
  rep(i, V) a[i + 1] = a[i] + v[i];

  int ans = 0;
  for (int i = 0; i < V; i += 2) {
    int add = 2 * k + 1;
    int sum = a[min(i + add, V)] - a[i];
    ans = max(ans, sum);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4208
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y;
    cin >> x >> y;
    if(x % y != 0){
        print(x);
    }else{
        print(-1);
    }
}


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

/**
 * Card Game
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		final int[] cards = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);

			int c1, c2, c3, own;
			c1 = Integer.parseInt(st.nextToken());
			c2 = Integer.parseInt(st.nextToken());
			c3 = Integer.parseInt(st.nextToken());
			own = c1 + c2;

			boolean[] hands = new boolean[11];
			hands[c1] = hands[c2] = hands[c3] = true;

			int p = 0;
			for (int i = 1; i < 11; i++) {
				if (!hands[i] && cards[i] + own <= 20) {
					p++;
				}
			}

			// if (p / 7.0 >= 0.5) {
			if (p > 3) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}

	}

}

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

int main() {
  int n; cin >>n;
  vector<string>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  map<string,int>mp;
  for(string s:a){
    if(mp.count(s)){
      cout<<"No"<<endl;
      return 0;
    }else{
      mp[s]=1;
    }
  }
  if(a[0].size()==1&&a[1].size()==1){
    if(a[0].at(0)!=a[1].at(0)){
      cout<<"No"<<endl;
      return 0;
    }
  }
  for(int i=1;i<n-1;i++){
    //cout<<i<<" "<<a[i-1].at( a[i-1].size()-1)<<" "<<a[i].at(0)<<endl;
    if( a[i-1].at( a[i-1].size()-1 ) != a[i].at(0) ){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

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

string a, b, c;

int main() {
	cin >> a >> b >> c;
	char winner;
	char now = a[0];
	a.erase(a.begin());
	while (true) {
		if (now == 'a') {
			if (a[0] == '\0') {
				winner = 'A';
				break;
			} else {
				now = a[0];
				a.erase(a.begin());
			}
		} else if (now == 'b') {
			if (b[0] == '\0') {
				winner = 'B';
				break;
			} else {
				now = b[0];
				b.erase(b.begin());
			}
		} else {
			if (c[0] == '\0') {
				winner = 'C';
				break;
			} else {
				now = c[0];
				c.erase(c.begin());
			}
		}
	}
	cout << winner << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
    long double r1,r2,r3;
    cin >> r1 >> r2;
    r3=pow((pow(r1,-1)+pow(r2,-1)),-1);
    cout <<fixed<<setprecision(10)<<r3;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N = 0;
    int K = 0;
    cin >> N >> K ;

    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A.at(i);
    }

    vector<int> count(N,0);
    for (int i = 0; i < N; ++i) {
        count.at(A.at(i)-1)++;
    }

    sort(count.begin(),count.end());

    //整数の種類数を数える
    int notzero = 0;
    for (int i = 0; i < N; ++i) {
        if(count.at(i) != 0) notzero++;
    }

    int result = 0;
    //ボールの数を書き換える回数を判定
    for (int i = 0; i < N; ++i) {
        //書き換えの必要なし
        if(notzero <= K){
            break;
        }
        if(count.at(i) > 0){
            result += count.at(i);
            notzero--;
        }
    }
    cout << result;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;
int main(int argc, char const *argv[]){
    int x, y;
    cin >> x >> y;
    rep(i,x+1){
        if(y==i*2+(x-i)*4){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 3608
def solve(N,K,R,S,P,T):
    check = [0]*N
    ans = 0
    for i in range(N):
        if i < K or T[i] != T[i-K] or not check[i-K]:
            ans += P if T[i] == 'r' else R if T[i] == 's' else S
            check[i] = 1
    print(ans)

def main():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = input()
    solve(N,K,R,S,P,T)

if __name__ == "__main__":
    main()

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

int main(void){
    int c,r;
    cin>>c>>r;
    vector<vector<int> > a(110,vector<int>(110));
    
    for(int i=0;i<c;i++){
        for(int j=0;j<r;j++){
            cin>>a.at(i).at(j);
        }
    }
    
    for(int i=0;i<c;i++){
        for(int j=0;j<r;j++){
            a.at(i).at(r)+=a.at(i).at(j);
        }
    }
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            a.at(c).at(i)+=a.at(j).at(i);
        }
    }    
    for(int i=0;i<r;i++){
        a.at(c).at(r)+=a.at(c).at(i);
    }
    
    for(int i=0;i<=c;i++){
        for(int j=0;j<=r;j++){
            if(j==r)cout<<a.at(i).at(j)<<endl;
            else cout<<a.at(i).at(j)<<" ";
        }
    }
}



Measured memory_bytes: 3180
n, m=gets.split.map &:to_i
a=(1..n).map{gets.split.map &:to_i}
b=(1..m).map{gets.split.map &:to_i}
a.each do |x, y|
	i=0
	p b.map{|s,t| [(x-s).abs+(y-t).abs, i+=1]}.min[1]
end

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
int f(int x){
  int sum =0;
  while (x>0)
  {
    sum+= x%10;
    x/=10;
  }
  return sum;
}
int main(int argc, char const *argv[])
{
  int N;
  cin>> N;
  int S =f(N);
  if (N%S==0)
  {
    cout<< "Yes"<<endl;
  }
  else
  {
    cout<<"No"<< endl;
  }
  
  
  
  return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()

ans = 0
if M > N:
    dist = []
    for i in range(1,M):
        dist.append(abs(X[i]-X[i-1]))
    dist.sort()
    for i in range(M-N):
        ans += dist[i]

print(ans)

Measured memory_bytes: 13960
N = int(input())
X = []
for _ in range(N):
    a, b = map(int, input().split())
    X.append((a, b))
mi = 1000
X = sorted(X)
for i in range(N):
    for j in range(i+1, N):
        p = X[j][0]-X[i][0]
        q = X[j][1]-X[i][1]
        if p == 0 and q == 0:
            continue
        if p < 0:
            p, q = -p, -q
        if p == 0 and q < 0:
            q = -q
        c = 0
        for k in range(N):
            for l in range(k):
                if X[l][0] == X[k][0] - p and X[l][1] == X[k][1] - q:
                    break
            else:
                c += 1
        mi = min(mi, c)
print(mi if mi < 1000 else 1)

Measured memory_bytes: 45292
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int n;
string s;

vector<char> func(vector<char> t){
    for(int i = 1; i < n; i++){
        if (s[i] == 'o'){
            if (t[i-1] == 'S' && t[i] == 'S') t.push_back('S');
            else if (t[i-1] == 'S' && t[i] == 'W') t.push_back('W');
            else if (t[i-1] == 'W' && t[i] == 'S') t.push_back('W');
            else if (t[i-1] == 'W' && t[i] == 'W') t.push_back('S');
        }
        else {
            if (t[i-1] == 'S' && t[i] == 'S') t.push_back('W');
            else if (t[i-1] == 'S' && t[i] == 'W') t.push_back('S');
            else if (t[i-1] == 'W' && t[i] == 'S') t.push_back('S');
            else if (t[i-1] == 'W' && t[i] == 'W') t.push_back('W');
        }
    }
    if (t[n] == t[0]){
        if (s[0] == 'o' && t[0] == 'S' && t[n-1] == t[1]) return t;
        else if (s[0] == 'o' && t[0] == 'W' && t[n-1] != t[1]) return t;
        else if (s[0] == 'x' && t[0] == 'S' && t[n-1] != t[1]) return t;
        else if (s[0] == 'x' && t[0] == 'W' && t[n-1] == t[1]) return t;
        else return {};
    }
    else return {};
}



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

    vector<vector<char>> vc;
    vc.push_back({'S','S'});
    vc.push_back({'S','W'});
    vc.push_back({'W','S'});
    vc.push_back({'W','W'});

    rep(i, 4) {
        vector<char> ret = func(vc[i]);
        if (ret.size() > 2){
            rep(j, n) cout << ret[j];
            cout << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int b1 = a - b;
    int b2 = c - b1;
    cout << max(0, b2) << endl;
    return 0;
}



Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        k: usize,
        mut s: chars
    }
    if n == 1 {
        if k % 2 == 1 {
            s[0] = flip_AB(&s[0]);
        }
        println!("{}", s[0]);
        return;
    }
    let mut f = false;
    let mut l = k;
    let mut i = 0;
    while l > 0 && i < n {
        if (s[i] == 'B') ^ f {
            l -= 1;
        } else if l > 1 {
            l -= 2;
        } else {
            s[i] = flip_AB(&s[i]);
            l -= 1;
            break;
        }
        f ^= true;
        i += 1;
    }
    for j in 0..i {
        if j % 2 == 0 {
            s.push('B');
        } else {
            s.push('A');
        }
    }
    if f {
        s = s.iter().map(flip_AB).collect();
    }
    if i == n && l % 2 == 1 {
        s[i] = 'B';
    }
    println!("{}", s[i..i + n].iter().cloned().collect::<String>());
}

fn flip_AB(c: &char) -> char {
    match *c {
        'A' => 'B',
        'B' => 'A',
        c => c
    }
}

Measured memory_bytes: 8444
A = []
A.append(list(map(int, input().split(" "))))
A.append(list(map(int, input().split(" "))))
A.append(list(map(int, input().split(" "))))

N = int(input())
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = -1


success = False
for i in range(3):
    if all([a == -1 for a in A[i]]):
        print("Yes")
        success = True
    elif all([a == -1 for a in [line[i] for line in A]]):
        print("Yes")
        success = True
    if success:
        break

if not(success) and A[0][0] == -1 and A[1][1] == -1 and A[2][2] == -1:
    print("Yes")
elif not(success) and A[2][0] == -1 and A[1][1] == -1 and A[0][2] == -1:
    print("Yes")
elif not(success):
    print("No")



Measured memory_bytes: 3064
n = int(input())
a = list(map(lambda x: int(x)-1,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = 0
ans += b[a[0]] 
for i in range(1,n):
    ans += b[a[i]]
    if a[i-1]+1 ==  a[i]:
        ans += c[a[i]-1]

print(ans)

Measured memory_bytes: 3064