akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;

#define pb push_back
#define mp make_pair
#define N 400050
int outd[N];
vector<int> va[N],vb[N];
set<pair<int,int> > st;

int q[N];
int vis[N];
int ans[N],tmp[N];
int tim[N],ttp;
int rr[N],nxt[N],pls[N];
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int p2;scanf("%d",&p2);
		outd[p2]++;
		va[i].pb(p2);
		vb[p2].pb(i);
	}
	for(int i=1;i<=n;i++)
		ans[i]=-1;
	
	int l,r,p;l=1,r=0;
	for(int i=1;i<=n;i++)
		if(!outd[i]) q[++r]=i;
	if(r==0)
	{
		if(n&1) puts("IMPOSSIBLE");
		else puts("POSSIBLE");
		return 0;
	}
	while(l<=r)
	{
		p=q[l++];vis[p]=1;++ttp;
		for(int i=0;i<vb[p].size();i++)
		{
			int pt=ans[vb[p][i]];
			if(pt==-1) continue;
			if(tim[pt]<ttp) tim[pt]=ttp;
		}
		ans[p]=0;
		for(int i=0;tim[i]==ttp;i++)
			ans[p]++;
		for(int i=0;i<va[p].size();i++)
		{
			int pt=va[p][i];
			if(--outd[pt]==0)
				q[++r]=pt;
		}
	}
	
	int rnd=0,fst=0;
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			if(fst==0) fst=i;
			++ttp;++rnd;
			for(int j=0;j<vb[i].size();j++)
			{
				int pt=ans[vb[i][j]];
				if(pt==-1){nxt[i]=vb[i][j];continue;}
				if(tim[pt]<ttp) tim[pt]=ttp;
			}
			for(int j=0;tim[j]==ttp;j++)
				tmp[i]++;
		}
	for(int i=1;i<=n;i++)
		if(!vis[i]) ans[i]=tmp[i];
	rr[1]=fst;
	for(int i=nxt[fst],j=2;i!=fst;i=nxt[i],j++)
		rr[j]=i;
	rr[0]=rr[rnd];
	
	int res;
	while(1)
	{
		int ifok=1,iffail=0;
		for(int i=rnd;i>=1;i--)
		{
			if(!pls[rr[i-1]] && ans[rr[i-1]]==ans[rr[i]])
			{
				ifok=0;
				ans[rr[i-1]]++;
				pls[rr[i-1]]=1;
				if(st.find(mp(rr[i-1],ans[rr[i-1]]))!=st.end())
					iffail=1;
				else st.insert(mp(rr[i-1],ans[rr[i-1]]));
			}
			if(pls[rr[i-1]] && ans[rr[i-1]]!=ans[rr[i]]+1)
			{
				ifok=0;
				ans[rr[i-1]]--;
				pls[rr[i-1]]=0;
				if(st.find(mp(rr[i-1],ans[rr[i-1]]))!=st.end())
					iffail=1;
				else st.insert(mp(rr[i-1],ans[rr[i-1]]));
			}
			
		}
		if(iffail || ifok) {res=ifok? 1:0;break;}
	}
	res? puts("POSSIBLE"): puts("IMPOSSIBLE");
}


Measured memory_bytes: 47232
#include<stdio.h>
#include<string.h>
#define Max(x,y) ((x>y)?x:y)
typedef struct group{
	char name[20];
	char mem[30][30];
	int n;
}group;
group x[105];
char list[2000][30];
int f,n,ff[105];
int func(int i){
	int j,k,r=0;
	if(ff[i]==1)return 0;
	else ff[i]=1;
	for(j=0;j<x[i].n;j++){
		for(k=0;k<n;k++)if(strcmp(x[k].name,x[i].mem[j])==0)break;
		if(k==n){
			for(k=0;k<f;k++)if(strcmp(x[i].mem[j],list[k])==0)break;
			if(k==f)strcpy(list[f++],x[i].mem[j]),r++;
		}else{
			r+=func(k);
		}
	}
	return r;
}
int main(){
	int i,j,k,m,g,ans;
	char s[30],t[200];
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%s",t);
			m=strlen(t);
			memset(s,0,sizeof(s));
			f=g=0;
			for(j=0;j<m;j++){
				if('a'<=t[j] && t[j]<='z'){
					s[g++]=t[j];
				}else{
					if(f==0){
						strcpy(x[i].name,s);
						f++;g=0;
					}else{
						strcpy(x[i].mem[f-1],s);
						f++;g=0;
					}
					memset(s,0,sizeof(s));
					if(t[j]=='.')break;
				}
			}
			x[i].n=f-1;
			//printf("%s :",x[i].name);
			//for(j=0;j<x[i].n;j++)printf(" %s,",x[i].mem[j]);
			//printf("\n");
		}
		ans=0;
		f=0;
		memset(ff,0,sizeof(ff));
		//for(i=0;i<n;i++){
		//	g=func(i);
		//	ans=Max(ans,g);
			//ans+=func(i);
			//printf(" %d\n",func(i));
		//}
		//for(i=0;i<f;i++)printf("%s ",list[i]);
		printf("%d\n",func(0));
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	
	//aとbを昇順に
	if(b<a){
		int x=a;
		a=b;
		b=x;
	}
	//cをbと比較
	int ans;
	if(c<=b) ans=a+c;
	else ans=a+b;
	
	cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  long int n,m;
  scanf("%ld %ld",&n,&m);
 int a[m];
 int hw=0;
 int i;
for(i=0;i<m;i++){
  scanf("%d",&a[i]);
}
long int s=0;
for(i=0;i<m;i++){
  s=s+a[i];
}
if(n-s<0){
  printf("-1");
  return 0;
}

printf("%d",n-s);

  return 0;
  }

Measured memory_bytes: 1700
# DP

n = int(input())
A = list(map(int, input().split()))
dp = [[None] * 2 for _ in range(n + 1)]
dp[0][0] = 0
dp[0][1] = -float("inf")

for i in range(1, n + 1):
    dp[i][0] = max(dp[i - 1][0] + A[i - 1], dp[i - 1][1] - A[i - 1])
    dp[i][1] = max(dp[i - 1][0] - A[i - 1], dp[i - 1][1] + A[i - 1] )

print(dp[n][0])

Measured memory_bytes: 72608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx=1e5+100;
const int INF=1e9;
const int MOD=1e9+7;
vector<int> mapp[maxx];
int vis[maxx];
int n;
int ans[5];
void dfs(int x,int y)
{
    vis[x]=1;
    vis[y]=2;
    queue<int> q;
    q.push(x);
    q.push(y);
    while(!q.empty()){
        int p=q.front();
        ans[vis[p]]++;
        q.pop();
        for(int i=0; i<mapp[p].size(); i++){
            if(vis[mapp[p][i]])   continue;
            vis[mapp[p][i]]=vis[p];
            q.push(mapp[p][i]);
        }
    }
}
int main()
{
    cin>>n;
    int a,b;
    for(int i=1; i<n; i++){
        cin>>a>>b;
        mapp[a].push_back(b);
        mapp[b].push_back(a);
    }
    dfs(1,n);
    if(ans[1]>ans[2])  cout<<"Fennec"<<endl;
    else               cout<<"Snuke"<<endl;
    return 0;
}

 

Measured memory_bytes: 6272
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
L = [int(input()) for _ in range(N)]
d = {l: i % 2 for i, l in enumerate(L)}

sorted_L = sorted(L)
d_s = {l: i % 2 for i, l in enumerate(sorted_L)}

cnt = 0
for l in L:
    if d_s[l] == d[l]:
        continue
    else:
        cnt += 1
print(cnt//2)


Measured memory_bytes: 63704
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> aoeui, pair<int, int> boeui){return aoeui.se < boeui.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; i++)
#define foris(i, a, b) for(ll i = a; i < b; i++)
#define forise(i, a, b) for(ll i = a; i <= b; i++)
#define ford(i, n) for(ll i = n; i >= 0; i--)
#define fords(i, a, b) for(ll i = a; i >= b; i--)
#define fordse(i, a, b) for(ll i = a; i > b; i--)
#define forr(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

int main() {
  io();
  string inp;
  cin >> inp;
  
  int o = 0, z = 0;
  fori(i, inp.size()) {
    if(inp[i] == '0') {
      ++z;
    }
    else {
      ++o;
    }
  }
  
  cout << min(o, z)*2;
  
  return 0;
}

Measured memory_bytes: 512
from collections import deque
H,W=map(int,input().split())
Ch,Cw=map(int,input().split())
Dh,Dw=map(int,input().split())
maze=[]

for i in range(H):
  l=list(input())
  for j in range(len(l)):
    if l[j]=='.':l[j]=-1
    if l[j]=='#':l[j]=-2
  maze.append(l)

def isIn(h,w):
  if h<0 or h>=H or w<0 or w >=W:return False
  return True
l=[[Ch-1,Cw-1]]
l=deque(l)
maze[Ch-1][Cw-1]=0
l2=[[0]*W for i in range(H)]

cnt=0
while l:
  cnt+=1
  vectors=[[-1,0],[1,0],[0,1],[0,-1]]

  target=l[0]
  h,w=target
  l.popleft()
  if l2[h][w]:
    continue
  l2[h][w]=1
  for vector in vectors:
    if not isIn(h+vector[0],w+vector[1]):continue
    if maze[h+vector[0]][w+vector[1]]>maze[h][w] or maze[h+vector[0]][w+vector[1]]==-1:
      maze[h+vector[0]][w+vector[1]]=maze[h][w]
      l.appendleft([h+vector[0],w+vector[1]])
  for i in range(25):
    if not isIn(h+i//5-2,w+i%5-2):continue
    if maze[h+i//5-2][w+i%5-2]>maze[h][w] or maze[h+i//5-2][w+i%5-2]==-1:
      maze[h+i//5-2][w+i%5-2]=maze[h][w]+1
      l.append([h+i//5-2,w+i%5-2])
print(maze[Dh-1][Dw-1])


Measured memory_bytes: 173688
n= int(input())
from itertools import combinations
d=[0,0,0,0,0]

f={}
f['M']=0
f['A']=1
f['R']=2
f['C']=3
f['H']=4

e={}
e['M']=0
e['A']=0
e['R']=0
e['C']=0
e['H']=0


for _ in range(n):

    s = input()[0]
    if s in ['M','A','R','C','H']:
        e[s]=1
        d[f[s]]+=1


k = e['M']+e['A']+e['R']+e['C']+e['H']

cnt=0
if k>=3:
    c = list(combinations(d,3))

    for j in c:
        tmp=1
        for l in j:
            tmp*=l
        
        cnt+=tmp

print(cnt)


Measured memory_bytes: 3064
import java.util.Scanner;

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

		int len = scan.nextInt();
		scan.nextLine();
		String topic = scan.nextLine();

		if(topic.length() <= len){
			System.out.println(topic);
		}else{
			System.out.println(topic.substring(0, len) + "...");
		}
		scan.close();
	}
}

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

l = [int(i) for i in input().split()]
count = 0
for i in range(n - 2):
    tmp = []
    for j in range(i, i + 3):
        tmp.append(l[j])
    if tmp[1] == max(tmp) or tmp[1] == min(tmp):
        pass
    else:
        count += 1

print(count)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
	int A, B, temp;
	scanf("%d", &A);
	scanf("%d", &B);

	temp = A + B;
	if (temp < A - B)
		temp = A - B;
	if (temp < A * B)
		temp = A * B;

	printf("%d", temp);

	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
char s[110]; int len;
char st[110];
int main() {
	int i, j, k;
	st[0] = 'k'; st[1] = 'e'; st[2] = 'y'; st[3] = 'e'; st[4] = 'n'; st[5] = 'c'; st[6] = 'e';
	scanf("%s", s+1);
	len = strlen(s+1);
	int p = len-7;
	bool bk;
	for(i = 1; i <= 8; i++){
		k = 0; bk = true;
		for(j = 1; j < i; j++){
			if(s[j] != st[k]){ bk = false; break; }
			k++;
		}
		for(j = i+p; j <= len; j++){
			if(s[j] != st[k]){ bk = false; break; }
			k++;
		}
		if(bk == true) break;
	}
	if(bk == true) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
  int n, m, l, i, j, k;
  scanf("%d %d %d", &n, &m, &l);
  int A[n][m], B[m][l];
  long C[n][l];

  // array C initialize
  for (i = 0; i < n; i++)
    for (k = 0; k < l; k++)
      C[i][k] = 0;

  // determination A
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      scanf("%d", &A[i][j]);

  // determination B
  for (j = 0; j < m; j++)
    for (k = 0; k < l; k++)
      scanf("%d", &B[j][k]);

  // determination C
  for (i = 0; i < n; i++){
    for (k = 0; k < l; k++){
      for (j = 0; j < m; j++){
	C[i][k] += A[i][j] * B[j][k];
      }
      if (k)
	printf(" ");
      printf("%ld", C[i][k]);
    }
    printf("\n");
  }
      
  return 0;
}

Measured memory_bytes: 756
#include<stdio.h>

int main(){

int N,ans=0;
scanf("%d",&N);

int A[N],B[N-1];

for (int i = 0; i < N-1; i++){
    scanf("%d",&B[i]);
}

A[N-1] = B[N-2];
for (int i = N-2; 0 < i; i--)
{
  if (B[i] > B[i-1]){
    A[i]=B[i-1];
    ans +=A[i];
  }else{
    A[i]=B[i];
    ans +=A[i];
  }
}
A[0] = B[0];

printf("%d",ans+A[0]+A[N-1]);

return 0;
}

Measured memory_bytes: 1728
import numpy as np
N,M,C=map(int,input().split(' '))
B=np.array(list(map(int,input().split(' '))))
A=[list(map(int,input().split(' '))) for _ in range(N)]

print(sum(list(map(lambda a: int(sum(np.array(a)*B)+C>0),A))))



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

int main() {
    int dx[]={0,0,1,-1},dy[]={1,-1,0,0};
    int h,w;cin>>h>>w;
    string s[h];
    for (int i=0;i<h;i++)
        cin>>s[i];
    int mx=0;
    for (int i=0;i<h;i++)
        for (int j=0;j<w;j++)
            if (s[i][j]=='.') {
                int d[h][w];
                for (int k=0;k<h;k++)
                    for (int l=0;l<w;l++)
                        d[k][l]=-1;
                d[i][j]=0;
                queue<pair<int,int>> q;
                q.push({i,j});
                while (!q.empty()) {
                    auto p=q.front();
                    int y=p.first,x=p.second;
                    q.pop();
                    for (int k=0;k<4;k++) {
                        int ny=y+dy[k],nx=x+dx[k];
                        if (0<=ny&&ny<h&&0<=nx&&nx<w&&s[ny][nx]=='.'&&d[ny][nx]==-1) {
                            d[ny][nx]=d[y][x]+1;
                            mx=max(mx,d[ny][nx]);
                            q.push({ny,nx});
                        }
                    }
                }
            }
    cout<<mx<<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);
        String S = sc.next();
        String T = sc.next();

        int count = 0;
        for (int i = 0; i < 3; i++) {
            if (S.charAt(i) == T.charAt(i)) {
                count++;
            }
        }

        System.out.println(count);
        sc.close();
    }
}


Measured memory_bytes: 21716
n = int(input())
a = list(map(int, input().split()))
c4 = 0
c2 = 0
for i in range(n):
    if a[i] % 4 == 0:
        c4 += 1
    elif a[i] % 2 == 0:
        c2 += 1

d4 = n // 2
d2 = 0
if n % 2 == 0:
    if c4 >= n // 2:
        print("Yes")
        exit()
    else:
        for i in range(n // 2):
            if i == 0:
                d4 -= 1
                d2 += 2
            elif i == n // 2 - 1:
                d4 -= 1
                d2 += 2
            else:
                d4 -= 1
                d2 += 2
            if c4 >= d4 and c2 >= d2:
                print("Yes")
                exit()
else:
    if c4 >= n // 2:
        print("Yes")
        exit()
    else:
        for i in range(n // 2):
            if i == 0:
                d4 -= 1
                d2 += 3
            elif i == n // 2 - 1:
                d4 -= 1
                d2 += 2
            else:
                d4 -= 1
                d2 += 2
            if c4 >= d4 and c2 >= d2:
                print("Yes")
                exit()
print("No")

Measured memory_bytes: 14252
def main():
    import sys
    input = sys.stdin.readline
    import heapq

    n,m,s,t = map(int,input().split())
    edgesYen = [[]for _ in range(n+1)]
    edgesSnuuk = [[]for _ in range(n+1)]
    for _ in range(m):
        u,v,a,b = map(int,input().split())
        edgesYen[u].append((v,a))
        edgesSnuuk[u].append((v,b))
        edgesYen[v].append((u,a))
        edgesSnuuk[v].append((u,b))
    
    def dijkstra(edges,costDic,startPoint):
        que=[(0,startPoint)]
        heapq.heapify(que)
        while que:
            cost,now = heapq.heappop(que)
            if now not in costDic:
                costDic[now] = cost
                for nx,c in edges[now]:
                    if nx not in costDic:
                        heapq.heappush(que,(cost+c,nx))
    costDicYen = {}
    costDicSnuuk = {}
    dijkstra(edgesYen,costDicYen,s)
    dijkstra(edgesSnuuk,costDicSnuuk,t)

    costList = []
    for i in range(1,n+1):
        cost = costDicYen[i]+costDicSnuuk[i]
        costList.append((cost,i))
    heapq.heapify(costList)
    c,l = heapq.heappop(costList)
    for i in range(n):
        while l<=i:
            c,l = heapq.heappop(costList)
        print(10**15-c)
main()

Measured memory_bytes: 122672
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define ld          long double
#define endl        "\n"

const int mod = 1e9+7;

inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }

void solve() {
    string s; cin >> s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;
    //cin >> T;
    for(int tt=1; tt<=T; tt++) {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 256
a = str(input())

if a[0] == 'R' and a[1] == 'R' and a[2] == 'R':
  print(3)
elif a[1] == 'R' and a[2] == 'R' and a[0] != 'R':
  print(2)
elif a[0] == 'R' and a[1] == 'R' and a[2] != 'R':
  print(2)
elif 'R' not in a:
  print(0)
else:
  print(1)

Measured memory_bytes: 9020
#include <stdio.h>

int map[10010];
 
int main(void)
{
	int i, n, m;
	int dise, x, ans;
	
	while (1){
		
		scanf("%d %d", &n, &m);
		x = 0;
		ans = 0;
		
		if (n == 0 && m == 0){
			break;
		}
		
		for (i = 0; i < 10000; i++){
			map[i] = 0;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d", &map[i]);
		}
		for (i = 0; i < m; i++){
			scanf("%d", &dise);
			x += dise + map[dise + x];
			if (n - 1 <= x && ans == 0){
				ans = i + 1;
			}
		}
		printf("%d\n", ans);
	}
	return (0);
}
			

Measured memory_bytes: 632
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int a,b;
    cin >> a >> b;
    if (a>b) swap(a,b);
    rep(i,b) {
        cout << a;
    }
    cout << endl;
    return 0;
}
























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

int main() {
  int N;
  cin >> N;
  
  int X = N/1.08;
  for(int i = X; i<=N; i++){
    if(int(i*1.08)==N){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl; 
}

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

int main() {
  long N;
  long X;
  cin >> N;
  cin >> X;
  long L[N];
  for (long i = 0; i < N; i++) {
    cin >> L[i];
  }

  long D = 0;
  long cnt = 0;
  while (D <= X) {
    D = D + L[cnt];
    cnt++;
    if (cnt > N)
      break;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<set>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<string> v;
    string s;
    int m=0;
    int i,j;
    for(i=0;i<n;i++){
      cin>>s;
      string b;
      b+=s[0];
      for(j=1;j<s.size();j++){
	if(s[j-1]=='a'||s[j-1]=='i'||s[j-1]=='u'||
	   s[j-1]=='e'||s[j-1]=='o'){
	  b+=s[j];
	}
      }
      m=max(m,(int)b.size());
      v.push_back(b);
    }
    bool f=false;
    for(i=1;i<=m;i++){
      set<string> ss;
      for(j=0;j<n;j++){
	string sub=v[j];
	if(sub.size()>i) sub=v[j].substr(0,i);
	//cout << sub << endl;
	if(ss.find(sub)==ss.end()) ss.insert(sub);
	else break;
      }
      if(ss.size()==n){
	f=true;
	break;
      }
    }
    if(f) cout << i << endl;
    else cout << -1 << endl;
  }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
int sum(string &a)
{
	int s=0;
	for(int i=0;i<a.size();i++)
	{
		s+= a[i]-48;
	}
	return s;
}
int main()
{
	int n,mans=1000000000;
	cin>>n;
	for(int a=1;a<=(n-1);a++)
	{
		int b=n-a;
		string aa=to_string(a),bb=to_string(b);
		mans=min(mans,sum(aa)+sum(bb) ); 
	}
	cout<<mans<<endl;
	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	int ma = 0, cnt = 0;
	for (int i = 0; i < N; i++) {
		int H;
		cin >> H;
		ma = max(ma, H);
		cnt += ma == H;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
N = int(input().split()[0])
abc_list = []

for _ in range(N):
    a, b, c = list(map(int, input().split()))
    abc_list.append(dict(a=a, b=b, c=c))

dp_list = [dict(a=0, b=0, c=0) for _ in range(N + 1)]

for i in range(1, N + 1):
    # i日目の行動
    scores = abc_list[i - 1]
    # その日行動Aをとる場合の最適値
    dp_list[i]["a"] = scores["a"] + max(dp_list[i - 1]["b"], dp_list[i - 1]["c"])
    # その日行動Bをとる場合の最適値
    dp_list[i]["b"] = scores["b"] + max(dp_list[i - 1]["a"], dp_list[i - 1]["c"])
    # その日行動Cをとる場合の最適値
    dp_list[i]["c"] = scores["c"] + max(dp_list[i - 1]["a"], dp_list[i - 1]["b"])

ans = max(dp_list[-1].values())

print(ans)


Measured memory_bytes: 83184
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;
vector<vector<int> > ki;
vector<int> pat;
vector<int> p;

int pt(int now,int pa){
    if(!ki[now].size()){
        pat[now]=0;
        return 0;
    }
    int tmp=0;
    rep(i,ki[now].size()){
        if(ki[now][i]==pa) continue;
        p[ki[now][i]]=now;
        tmp=max(pt(ki[now][i],now)+1,tmp);
    }
    pat[now]=tmp;
    return pat[now];
}

int main(){
  	int n,u,v; cin >> n >> u >> v;
    u--; v--;
    ki.resize(n);
    pat.resize(n);
    p.resize(n);
    rep(i,n-1){
        int a,b; cin >> a >> b;
        a--; b--;
        ki[a].push_back(b);
        ki[b].push_back(a);
    }
    int d=pt(v,-1);
    int dis=0;
    int tmpu=u;
    while(tmpu!=v){
        tmpu=p[tmpu];
        dis++;
    }
    int md=0;
    tmpu=u;
    int nowdis=dis;
    rep(i,((dis-1)/2)+1){
        if(md<=pat[tmpu]+nowdis-1+i){
            md=pat[tmpu]+nowdis-1+i;
        }
        tmpu=p[tmpu];
        nowdis-=2;
    }
    cout << md << endl;
return 0;
}




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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a[10000000],b,c,cmp=0,cmpp=0,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

      cin >> n;
      rep(i,n)cin>>a[i];
       sort(a,a+n);
       reverse(a,a+n);
       rep(i,n){
           if(a[i]==a[i+1] && fl){
               cmp=max(cmp,a[i]);
               fl=false;
               i++;
           }
           else if(a[i]==a[i+1]){
               cmpp=max(cmpp,a[i]);
               break;
           }
       }
       Cout(cmp*cmpp);
return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    map<char,ll> M;
    rep(i,n){
        string s; cin>>s;
        M[s[0]]++;
    }
    ll ans=0;
    char a[]={'M','A','R','C','H'};
    rep(i,5){
        for(int j=i+1; j<5; j++){
            for(int k=j+1; k<5; k++){
                ans+=M[a[i]]*M[a[j]]*M[a[k]];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );

    int N; cin >> N; vector< int > s;

    for( int pos = 0; N != 0; pos++ )
    {
        int bit = ( N & 1 ); s.push_back( bit ); N >>= 1;

        if ( ( pos & 1 ) and bit )
            N++;
    }

    while( !s.empty() and s.back() == 0 )
        s.pop_back();

    if ( s.empty() )
        cout << 0;
    else
        while( !s.empty() )
            cout << s.back(), s.pop_back();
}

Measured memory_bytes: 256
solve xs n p
  | p == 0 && o == 0 = 2^e
  | p == 1 && o == 0 = 0
  | otherwise = 2 ^ (n-1)
  where
    (e,o) = foldl step (0,0) xs
    step (a,b) x  
      | even x = (a+1,b)
      | otherwise = (a,b+1)

main = do
  [n,p] <- map read . words <$> getLine :: IO [Int]
  xs <- map read . words <$> getLine :: IO [Int]
  print $ solve xs n p


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <bitset>
#include <queue>
#include <utility>
#include <functional>
#include <sstream>
using namespace std;
#define ll long long
 
int main(void){
    ll h, w;
    cin >> h >> w;
    string s[h];
    for(ll i = 0; i < h; i++)
            cin >> s[i];
    ll count = 0;
    for(ll i = 0; i < h; i++){
        for(ll j = 0; j < w; j++){
            if(s[i][j]=='#')
                count++;
        }
    }
    if(count == h+w-1)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
#define debug(x) (cout << "#x = " << (x) << endl)
#define lowbit(x) (x & -x)
#define Set(x, i) memset(x, i, sizeof x)
#define R register
#define For( i, j, k ) for(R int i = (j); i <= (k); ++i)
#define Rep( i, j, k ) for(R int i = (j); i >= (k); --i)
#define Cross( i, j, k ) for(R int i = (j); i; i = (k))
typedef long long ll;
using namespace std;
const ll N = 100011;
const ll INF = 5e16;

namespace IO {

	#define dd ch = getchar()
	inline ll read() {
		ll x = 0; bool f = 0; char dd;
		for (; !isdigit (ch); dd) f ^= (ch == '-');
		for (; isdigit (ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) putchar ('-'), x = -x;
		if (x > 9) write (x / 10); putchar (x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x); putchar (' '); }

	inline void wln ( ll x ) { write(x); putchar ('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x); wln (y); }

}

using namespace IO;

namespace Cesare {
	
	int main() {
		ll n = read(); 
		return wln(n * n * n), 0;
	}
	
}

int main()
{
	return Cesare :: main();
}

/*

*/



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

int main() {
  int N;
  cin >> N;
  int x = 0;
  int l, r;
  
  for (int i = 0; i < N; i++){
     cin >> l >> r; 
     x = x + r - l + 1;
   }
  cout << x << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(15);
vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	int x;
	cin >> x;
	if(x%2==1&&x!=1&&x!=9){
		cout << "YES" << endl;
	}else{
		cout <<"NO" << endl;
	}
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <numeric>
#include <limits>

const int INF = 1 << 30;
const int V = 10;
struct edge { int to, cost; };
std::vector<edge>v[100];
typedef std::pair<int, int>p;

int main() {
	std::string s, t;
	std::cin >> s >> t;
	int nSum = 0;
	for (int i = s.size()-1;i >=t.size()-1;i--) {
		int flag = 0;
		int k = t.size() - 1;
		for (int j = i;j >=i+1-t.size();j--) {
			if (s[j] == t[k] || s[j] == '?') {
				flag = 0;
			}
			else  {
				flag = 1;
				break;
			}
			k--;
			if (j == 0)break;
		}
		if (flag == 0) {
			int k = t.size() - 1;
			for (int j = i;j>=i+1-t.size();j--) {
				if ( s[j] == '?') {
					s[j] = t[k];
				}
				k--;
				if (j == 0)break;
			}
			nSum = 100;
			break;
		}
		else {
			nSum += 1;
		}
	}
	if (nSum ==100) {
		for (int i = 0;i < s.size();i++) {
			if (s[i] == '?') {
				s[i] = 'a';
			}
		}
		std::cout << s << std::endl;
	}
	else {
		std::cout << "UNRESTORABLE" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		long[] a = new long[200001];
		long[] b = new long[200001];
		int[] actual = new int[n];
		for(int i=0; i<n; i++) {
			int x = scanner.nextInt();
			a[x] += 1;
			actual[i] = x;
		}
		long total = 0;

		for(int i=0; i<200001; i++) {
			b[i] = (a[i]*(a[i]-1))/2;
			total += b[i];
		}

		for(int x : actual) {
			System.out.println(total - b[x] + ((a[x]-1) * (a[x]-2))/2);
		}
	}
}

Measured memory_bytes: 105832
n, m, c = gets.split.map &:to_i
bs = gets.split.map &:to_i
ass = n.times.map {gets.split.map &:to_i}
cnt = n.times.count do |i|
  m.times.sum { |j| ass[i][j] * bs[j] } + c > 0
end
p cnt

Measured memory_bytes: 14304
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,
        r: usize,
        s: usize,
        p: usize,
        t: chars
    }
    let mut ans = 0;
    for i in 0..k {
        let mut c = 0;
        let mut h = '?';
        let mut j = i;
        while j < n {
            if h == t[j] {
                c += 1;
            } else {
                let pt = if h == 'r' {
                    p
                } else if h == 's' {
                    r
                } else {
                    s
                };
                ans += (c + 1) / 2 * pt;
                c = 1;
                h = t[j];
            }
            j += k;
        }
        let pt = if h == 'r' {
            p
        } else if h == 's' {
            r
        } else {
            s
        };
        ans += (c + 1) / 2 * pt;
    }
    println!("{}", ans);
}


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

int main() {
    int N;
    cin >> N;
    vector<int>B(N);
    for (int i = 0; i < N-1; i++)
    {
        cin >> B.at(i);
    }
    
    int answer = B.at(0) + B.at(N-2);
    for (int i = 0; i < N-2; i++)
    {
        answer += min(B.at(i),B.at(i+1));
    }
    
    cout << answer << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define Int int64_t
using namespace std;

int N;
int64_t K;
int main()
{
    cin>>N;
    bool ok=false;
    
    for(int i=1;i<=9;++i){
        for(int j=1;j<=9;++j){
            if(i*j==N){
                ok=true;
            }
        }
    }
    cout<<(ok ? "Yes\n":"No\n");
   
}

Measured memory_bytes: 3584
S=input()
if S=="MON":
  print(6)
elif S=="TUE":
  print(5)
elif S=="WED":
  print(4)
elif S=="THU":
  print(3)
elif S=="FRI":
  print(2)
elif S=="SAT":
  print(1)
elif S=="SUN":
  print(7)
  

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

int main(){
	int N;
	cin >> N;
	if((N/1000==(N%1000)/100&&(N%1000)/100==(N%100)/10)||((N%1000)/100==(N%100)/10&&(N%100)/10==N%10)) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
int K;
int find(int i) {
   for (int j = 0; j <= 20; j++) {
      if (pow(2, j) * i < K && pow(2, j + 1) * i >= K) return j + 1;
   }
   return 0;
}

int main() {
   int N;
   cin >> N >> K;
   double ans = 0.;
   for (int i = 1; i <= N; i++) {
      // cout << "---" << endl;
      // cout << i << endl;
      double p = 1. / N;
      if (i < K) {
         int n = find(i);
         // cout << n << endl;
         // cout << (double)pow(2, n) << endl;
         p *= (double) 1. / pow(2, n);
      }
      ans += p;
      // cout << fixed << setprecision(10) << p << endl;
   }
   cout << fixed << setprecision(10) << ans << endl;
   return 0;
}


Measured memory_bytes: 256
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define int long long
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define copy(a, b) memcpy(b,a,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define rep1(i, n) for(int i=1;i<=(int)n;++i)
#define per1(i, n) for(int i=(int)n;i>=1;--i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef string str;
typedef long double db;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<db> vdb;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 1e18;
const db EPS = 1e-15;
const int MOD = 1e9 + 7;
const int N = 1e5 + 7;

//

int32_t main() {
  FAST_IO;
  int n;
  cin >> n;
  vi a(n + n);
  rep(i, n + n)
    cin >> a[i];
  sort(all(a));
  int ans = 0;
  rep(i, n + n) {
    ans += a[i];
    i++;
  }
  cout << ans << '\n';
  rtn 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X, Y;
  cin>>X>>Y;
  bool finished=false;
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      if(i+j==X && 2*i+4*j==Y){
        cout<<"Yes"<<endl;
        finished=true;
        break;
        
      }
      
      else if(i==99 && j==99){
        cout<<"No"<<endl;
      }  
    }
    if(finished){
      break;
    }
  }
     
}

Measured memory_bytes: 3616
N = int(input())
minimum = 100 
total = 0
for i in range(N):
    s = int(input())
    total += s 
    if s % 10 != 0:
        minimum = min(minimum,s)
if total % 10 != 0:
    print(total)
elif minimum == 100:
    print(0)
else:
    print(total - minimum)

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

using namespace std;

int n;
int a[200010];
int sum;
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum ^= a[i];
	}
	for(int i = 1; i <= n; i++)
	{
		printf("%d ", a[i] ^ sum);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 4432
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
//#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}

bool check(string &src, string &s)
{
    int len = src.size();
    bool isMatch = true;
    for(int i=0; i<len; i++){
        if(src[i] == '?') continue;
        if(src[i] != s[i]){
            isMatch = false;
        }
    }
    return isMatch;
}

void func(void)
{
//DEBUG_OUT("----\n");
    string ss;
    string T;
    cin >> ss;
    cin >> T;

    bool isMatch = false;
    for(int i=ss.size()-T.size(); i>=0; i--){
        string tmpS = ss.substr(i, T.size());
        if(check(tmpS, T)){
            for(int j=0; j<T.size(); j++){
                ss[j+i] = T[j];
            }
            isMatch = true;
            break;
        }
    }

    if(!isMatch){
        cout << "UNRESTORABLE" << endl;
        return;
    }

    for(int i=0; i<ss.size(); i++){
        if(ss[i] == '?') ss[i] = 'a';
    }

    cout << ss << endl;

    return;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, h, w; cin >> n >> h >> w;
	cout << (n - h + 1)*(n - w + 1) << endl;
	return 0;
}

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

using namespace std;

int ans;
int qtdS;

string s;

int main()
{
	cin >> s;

	for(int i = 0 ; i < s.size() ; i++)
	{
		if( s[i] == 'S' ) qtdS++, ans++;
		else
		{
			if( qtdS == 0 ) ans++;
			else qtdS--, ans--;
		}
	}

	printf("%d\n",ans);
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
int min(int a, int b)
{
  if(a <= b)
  return a;
  else
  return b;
}

void swap(int *p_from, int *p_to) {
    int tmp;
    tmp = *p_from;
    *p_from = *p_to;
    *p_to = tmp;
}

int main(void)
{
  int a[5];
  int i;
  int min, c, minp;
  c = 0;
  minp = 5;
  for(i = 0; i < 5; i++)
  scanf("%d", &a[i]);
  min = 9;
  for(i = 0; i < 5; i++){
    if(a[i] % 10 <= min && a[i] % 10 != 0){
    min = a[i] % 10;
    minp = i;
  }
  }
  for(i = 0; i < 5; i++){
    if(a[i] % 10 != 0 && i != minp)
    c += (a[i] / 10)*10 +10;
    else
    c += a[i];
  }
  printf("%d\n", c);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int H=1,W=1,i,j;

	while(H!=0&&W!=0)
	{
		scanf("%d %d",&H,&W);

		if(H!=0&&W!=0)
		{
		
			for(i=0;i<H;i++)
			{
				for(j=0;j<W;j++)
				{
					printf("#");
				}
				printf("\n");
			}
	
			printf("\n");
	  }
	  else
	  {
	  }

	}
	
	

	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
vector<int> heights;
int input;
 
int main(){
 while(cin >> input) heights.push_back(input);
 sort(heights.begin(), heights.end());
 auto itr = heights.end()-1;
 cout << *itr << "\n" << *(itr-1) << "\n" << *(itr-2) << endl;
 
 return 0;
}

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

using namespace std;

int main()
{
    int n,m,total=0;;
    cin >>n >> m;
    int arr[n];
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
        total += arr[i];
    }


    //cout << total << endl;
    sort(arr,arr+n);

    int count = 0;
    double val = 1.0/(4*m);
    double test = total * val;

    //cout <<"thr: "<< test;
    for(int i=0; i<n; i++)
    {
        if(arr[i]<test)
        {
            count++;
        }
    }

    if((n-count) < m)
        cout << "No";
    else
        cout << "Yes";
    return 0;
}


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

using namespace std;

int main() {
    
    int n, k;
    
    scanf("%d%d", &n, &k);
    vector<int>a(n);
    for(int& i: a){
        scanf("%d", &i);
    }
    
    vector<bool>dp(k+1);
    for(int i=0; i<=k; i++){
        for(int j: a){
            if(i>=j && !dp[i-j]){
                    dp[i] =1;
            }
        }
    }
    
    
    puts(dp[k]? "First":"Second");
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include<map>

inline int Abs(const int x) { return x >= 0 ? x : -x; }

int n, a[205], b[205], Mat[205], Ans;
bool G[205][205], Vis[205];
std::map<int, int> M;

bool Prime(int x)
{
	if (x < 2)return false;
	for (int i = 2; i * i <= x; ++i)
		if (x % i == 0)return false;
	return true;
}

bool DFS(int x)
{
	for (int y = 1; y <= n; ++y)
		if (!Vis[y] && G[x][y])
			if (Vis[y] = true, !Mat[y] || DFS(Mat[y]))
				return Mat[y] = x, true;
	return false;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1, x; i <= n; ++i)scanf("%d", &x), M[x] ^= 1, M[x + 1] ^= 1;
	for (auto i : M)if (i.second)(i.first & 1 ? a[++ * a] : b[++ * b]) = i.first;
	for (int i = 1; i <= *a; ++i)
		for (int j = 1; j <= *b; ++j)
			G[i][j] = Prime(Abs(a[i] - b[j]));
	for (int i = 1; i <= *a; ++i)memset(Vis, 0, sizeof Vis), Ans += DFS(i);
	printf("%d\n", Ans + (*a - Ans) / 2 * 2 + (*b - Ans) / 2 * 2 + (*a - Ans) % 2 * 3);
	
	return 0;
}


Measured memory_bytes: 256