akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

struct team_t{
    int point;
    int rank;
};

int main(){
    team_t teams[101];
    int flg[31];
    memset( flg, 0, sizeof(flg) );
    while(1){
        int n, p;
        scanf("%d,%d", &n, &p);
        if( !n && !p )  break;
        teams[n].point = p;
        flg[p]++;
    }
    int r = 1;
    for( int i=30; i>=0; i-- ){
        if( flg[i] ){
            for( int j=0; j<=100; j++ ){
                if( teams[j].point == i ){
                    teams[j].rank = r;
                }
            }
            r++;
        }
    }
    int k;
    while( scanf("%d", &k) == 1 ){
        printf("%d\n", teams[k].rank);
    }
    return 0;
}

Measured memory_bytes: 1188
#include<stdio.h>
int main(){

	while(1){

		int n,i,k,a[10000]={0},b[100]={0};
		
		scanf("%d",&n);

		if(n==0)break;

		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
			for(k=0;k<10;k++){
				if(k==a[i])
					b[k]++;
			}
		}


		for(i=0;i<10;i++){
			if(b[i]==0)
				printf("-");
			else
				for(k=0;k<b[i];k++){
					printf("*");
				}
			printf("\n");
		}
	}
return 0;
	
}

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

int main(){
  
  int a,b,c,d,e,aa,bb,cc,dd,ee;
  cin >>a>>b>>c>>d>>e;
  aa=(a-1)%10; bb=(b-1)%10; cc=(c-1)%10; dd=(d-1)%10; ee=(e-1)%10;
  int f=min(aa,min(bb,min(cc,min(dd,ee))));
  vector<int> g(5);
  if(f==9) cout << a+b+c+d+e << endl;

  else {
  	g[0]=aa; g[1]=bb; g[2]=cc; g[3]=dd; g[4]=ee;
    sort(g.begin(),g.end());
    cout << a+b+c+d+e-aa-bb-cc-dd-ee+g[0]+36 << endl;
  }
}

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

n, m = [int(x) for x in input().split()]
s = input().rstrip()
s_rev = s[::-1]

place = 0

ans = []

while place < n:
    flag = 1
    for i in range(min(m, n - place), 0, -1):
        if s_rev[place + i] == "0":
            ans.append(i)
            place += i
            flag = 0
            break
    if flag:
        print(-1)
        sys.exit()

print(*ans[::-1])


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

//AtCoder ABC 109 B-Shiritori
int main(){
  int N;
  bool f_shiritori = true;

  cin >> N;
  string str[N];
  for(int i = 0; i < N; i++){
    cin >> str[i];
  }
  for(int i = 0; i < N-1; i++){
    for(int j = i+1; j < N; j++){
      if( str[i] == str[j] ){
        f_shiritori = false;
        break;
      }
    }
  }
  if(f_shiritori){
    for(int i = 0; i < N-1; i++){
      if( str[i].back() != str[i+1].front() ){
        f_shiritori = false;
        break;
      }
    }
  }
  if(f_shiritori) { cout << "Yes\n";}
  else { cout << "No\n";}

	return 0;
}


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

from collections import deque

def bfs(sx, sy):  # 引数にはスタート地点を取る
    # 移動ベクトル
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    
    # 移動距離の記録
    d = [[-1]*w for _ in range(h)]
    d[sx][sy] = 0  # スタート地点を0に設定する
    
    # キュー
    que = deque([])
    que.append([sx, sy])  # スタート地点を追加する
    
    while que:
        # FIFO
        x, y = que.popleft()
        # 移動先
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            # 移動先がマップ内に収まっているか、
            # 壁ではないか、
            # 移動済みではないか、を確認する
            if (0 <= nx < h) and (0 <= ny < w) and \
                (field[nx][ny] != '#') and (d[nx][ny] == -1):
                # スタート地点からの距離を記録していく
                d[nx][ny] = d[x][y] + 1
                # 移動先をキューに追加する
                que.append([nx, ny])
                
    return d
  
  
import itertools

ans = 0
for i in range(h):
    for j in range(w):
        if field[i][j] == '#':
            continue
        d = bfs(i, j)
        ans = max(ans, max(itertools.chain(*d)))
        
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main() {

  int H, W;
  string s[105];
  cin>>H>>W;
  for(int i=0; i<H; i++){
    cin>>s[i];
  }

  for(int i=0; i<H; i++){
    cout<<s[i]<<endl;
    cout<<s[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split()))
vs = sorted(v,reverse=False)
last = 0
for i in range(1,n):
    if i == 1:
        last = (vs[i-1] + vs[i])/2
    else:
        last = (last + vs[i])/2

print(last)


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

int main()
{
    int K, S;
    cin >> K >> S;

    int cnt = 0;
    for (int x = 0; x < K + 1; x++)
    {
        for (int y = 0; y < K + 1; y++)
        {
            if ((0 <= S - x - y) && (S - x - y <= K))
            {
                cnt++;
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
d={}
for i in a:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
p=max(a)*2
chk=[pow(2,i) for i in range(1,32)]
ans=0
for i in a[::-1]:
    if d[i]>0:
        d[i]-=1
        for j in chk[::-1]:
            if j-i in d and d[j-i]>0:
                d[j-i]-=1
                ans+=1
                break
print(ans)

Measured memory_bytes: 109652
#include <stdio.h>

int partition(int*, int, int);

int main(){
  int i,j,n,A[100000],a;

  scanf("%d",&n);

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

  a = partition(A, i, n);

  for(i=1;i<a;i++) {
    printf("%d ",A[i]);
  }
  printf("[%d] ",A[a]);

  for(i=a+1;i<n;i++) {
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n]);

  return 0;
}

int partition(int* A,int p,int r){
  int data,suzi,i,henkan;
  
  data = A[r];
  suzi = p-1;
  for (i = p;i<=r-1;i++){
    if (A[i] <= data){
      suzi = suzi+1;
      henkan =A[suzi];
      A[suzi]= A[i];
      
      A[i] = henkan;
    }
  }
      
    henkan =A[suzi+1];
      A[suzi+1]=A[r];

   A[r]=henkan;
 
  return suzi+1;
}



Measured memory_bytes: 2144
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int A, B; cin >> A >> B;
  int result = (A+B)%24;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>

using namespace std;

const int MAX_N=1<<19;

int n,dat[2*MAX_N-1];
int num[MAX_N];

int at(int x,int k=0){
  if(k-(MAX_N-1)>=0)return k-(MAX_N-1);
  if(x<=dat[k*2+1])return at(x,k*2+1);
  return at(x-dat[k*2+1],k*2+2);
}

void update(int k,int a){
  k+=MAX_N-1;
  dat[k]=a;
  while(k>0){
    k=(k-1)/2;
    dat[k]=dat[k*2+1]+dat[k*2+2];
  }
}

int main(){
  for(int q,lim;cin>>q>>lim,q|lim;){
    fill(begin(dat),end(dat),0);
    int serial=0;
    int size=0;
    map<int,int> m;
    while(q--){
      int qi,x;
      cin>>qi>>x;
      if(qi==0){
	update(serial,1);
	num[serial]=x;
	m[x]=serial;
	serial++;
	size++;
	if(size>lim){
	  update(at(1),0);
	  size--;
	}
      }else if(qi==1){
	update(at(x),0);
	size--;
      }else if(qi==2){
	cout<<num[at(x)]<<endl;
      }else{
	update(m[x],0);
	size--;
      }
    }
    cout<<"end"<<endl;
  }
}

Measured memory_bytes: 25616
#include <bits/stdc++.h>
using namespace std;
typedef long long int l1;
#define pb push_back
#define input l1 t;cin>>t;while(t--)
l1 min(l1 a,l1 b){
    l1 ma=(a<b)?a:b;
    return ma;
}
l1 max(l1 a,l1 b){
    l1 ma=(a>b)?a:b;
    return ma;
}
l1 gcd(l1 a, l1 b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
# define pie 3.14159265358979323
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    l1 n,m,x;
    cin>>n>>m;
    vector<l1 >a;
    l1 s=0;
    for(l1 i=0;i<m;i++){
        cin>>x;
        s+=x;
    }
    if(s<=n){
        cout<<n-s;
    }
    else{
        cout<<-1;
    }
        
}
 

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

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

    int n;
    cin >> n;
    int cmin = n + 1;
    int ans = 0;
    for (int i = 0; i < n; i++) {
    	int x;
    	cin >> x;
    	if (cmin > x) {
    		ans++;
    		cmin = x;
    	}
    }
    cout << ans << endl;
}   


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		int r = input();
		int c = input();

		int[][] table = new int[r + 1][c + 1];

		for (int i = 0; i < r; i++) {

			for (int j = 0; j < c; j++) {

				table[i][j] = input();
				table[i][c] += table[i][j];
				table[r][j] += table[i][j];
				table[r][c] += table[i][j];

			}
		}

		for (int i = 0; i < r + 1; i++) {

			for (int j = 0; j < c + 1; j++) {

				if (i < r && j < c) {

					System.out.print(table[i][j]);

				}else if (i == r && j == c) {

					System.out.print(table[r][c]);

				} else if (i == r) {

					System.out.print(table[r][j]);

				} else if (j == c) {

					System.out.print(table[i][c]);

				}

				if (j != c) {

					System.out.print(" ");

				}
			}

			System.out.println("");

		}

		close();

	}

	public static int input() {

		return scanner.nextInt();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 43508
N = int(input())
C = []
for _ in range(N):
	x,l = map(int, input().split())
	C.append([x-l,x+l])

C.sort(key = lambda x: x[1])
ans = 0
a = -float("inf")
for i in range(N):
	if C[i][0] >= a:
		a = C[i][1]
	else:
		ans += 1

print(N-ans)

Measured memory_bytes: 21336
#include <stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
unsigned long int gcd(unsigned long int a,unsigned long int b)
{
 if(b==0)
 return a;
 else
 return gcd(b,a%b);

}
unsigned long int lcm(unsigned long int a,unsigned long int b)
{

 return a/gcd(a,b)*b;

}
int main() {
 unsigned long int a,b;

   while(cin>>a>>b)
   {
    

    cout<<gcd(a,b)<<" "<<lcm(a,b)<<"\n";
   }
    return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>

#define LIMIT 1000000007


void fact(int *fact_num, int a, int b)
{
    int i, j;
    int temp;
    
    
    for(i=a; i<=b; i++)
    {
        temp = i;
        j = 2;
        
        while(temp>1)
        {
            while(temp%j == 0)
            {
                fact_num[j]++;
                temp /= j;
            }
            
            j++;
        }
    }
}

void simpl_fact(int *fact_num, int a)
{
    int i, j;
    int temp;
    
    
    for(i=2; i<=a; i++)
    {
        temp = i;
        j = 2;
        
        while(temp>1)
        {
            while(temp%j == 0)
            {
                fact_num[j]--;
                temp /= j;
            }
            
            j++;
        }
    }
}

int main(void)
{
    int N, M;
    int i, j;
    int prime[150000];
    int prime_ctr;
    int prime_num[150000];
    int temp;
    long long p;
    
    int fact_num[150000];
    
    
    scanf("%d %d", &N, &M);
    
    /**/
    
    prime_ctr = 0;
    prime_num[0] = 0;
    temp = M;
    i = 2;
    
    
    while(temp>1)
    {
        if(temp%i == 0)
        {
            //printf("prime = %d\n", i);
            prime[prime_ctr] = i;
            
            do{
                prime_num[prime_ctr]++;
                temp /= i;
            }while(temp%i == 0);
            //printf("prime_num = %d\n", prime_num[prime_ctr]);
            
            prime_num[++prime_ctr] = 0;
        }
        
        i++;
    }
    //printf("prime_ctr = %d\n", prime_ctr);
    
    /**/
    
    for(i=0; i<150000; i++)
    {
        fact_num[i] = 0;
    }
    
    
    for(i=0; i<prime_ctr; i++)
    {
        fact(fact_num, N, prime_num[i]+N-1);
        simpl_fact(fact_num, prime_num[i]);
    }
    //system("pause");
    
    
    p = 1;
    
    
    for(i=2; i<150000; i++)
    {
        for(j=0; j<fact_num[i]; j++)
        {
            p = (p*i)%LIMIT;
        }
    }
    
    
    /**/

    printf("%lld\n", p);
    
    //system("pause");
    
    return 0;
}

Measured memory_bytes: 768
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    int c = a % 3;
    int d = b % 3;
    int e = ( a + b ) % 3;

    if ((c==0) || (d==0) || (e==0) ){
      System.out.println("Possible");
    }
    else {
      System.out.println("Impossible");
    }
  }
}

Measured memory_bytes: 21844
# -*- coding: utf-8 -*-


def main():
    a, b = map(int, input().split())
    s = input()

    if s[:a].isdigit() and s[a:a + 1] == '-' and s[a + 1:].isdigit():
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    vector<vector<int>> c(3,vector<int>(3));
    int x=0,y=0,z=0;
    rep(i,3){
        rep(j,3){
            cin>>c[i][j];
            if(j==i) x+=c[i][j];
            else if(j==i+1||(j==0&&i==2)) y+=c[i][j];
            else z+=c[i][j];
        }
    }
    if(x==y&&y==z) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3584
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    N, M = map(int, readline().split())
    edge = list(list(map(int, readline().split())) for _ in range(M))
    bridge = 0
    for i in range(M):
        uf = UnionFind(N)
        for j in range(M):
            if i==j:
                continue
            else:
                uf.union(edge[j][0]-1, edge[j][1]-1)
        if uf.group_count()>1:
            bridge += 1
    print(bridge)



if __name__ == '__main__':
    main()


Measured memory_bytes: 9384
#093C
import sys
L = list(map(int, sys.stdin.readline().split()))
L.sort()

cnt =0
while True:
    if L[2]-L[0] >=2:
        L[0]+=2
        cnt+=1
        L.sort()
    elif L[2]-L[1] >=2:
        L[1]+=2
        cnt+=1
        L.sort()
    elif L[0] != L[1] or L[0] !=L[2]:
        L[0]+=1
        L[1]+=1
        cnt+=1
        L.sort()
    #print(L)
    if L[0]==L[1] and L[1]==L[2]:
        break

#print(L)
print(cnt)


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

int main()
{   int i;
    char s[11],t[12];
    cin>>s>>t;

    for(i=0;i<strlen(s);i++)
    {
        if(s[i]!=t[i])
            break;
    }
    if(i==strlen(s))
         cout<<"Yes";
    else
        cout<<"No";

    return 0;
}


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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
const int MAX = 4001;
char s[MAX];
void solve() {
  int N;
  scanf("%d", &N);
  scanf("%s", s);

  map<char, int> u;
  u['R'] = 0;
  u['G'] = 1;
  u['B'] = 2;
  vector<vi> f(3, vi(N + 1, 0));
  rep(i, 0, N) {
    rep(j, 0, 3)
      f[j][i + 1] = f[j][i];
    f[u[s[i]]][i + 1]++;
  }

  ll ans = 0;
  rep(i, 0, N) rep(j, i + 2, N)
    if (s[i] != s[j]) {
      int x = 3 - u[s[i]] - u[s[j]];
      ans += f[x][j + 1] - f[x][i];
      if (!((i - j) & 1))
        ans -= u[s[(i + j) / 2]] == x;
    }
  printf("%lld\n", ans);
}

int main() {
  // int _; scanf("%d", &_); while (_--)
  solve();
	return 0;
}


Measured memory_bytes: 3848
def main():
    s = str(input())
    t = str(input())

    if s.islower() and t.islower():
        if 1 <= int(len(s)) and int(len(s)) <= 10:
            if int(len(t)) == int(len(s)) + 1:
                if s == t[0:len(s)]:
                    print("Yes")
                    return 

    print("No")
    return

main()

Measured memory_bytes: 8996
#include<stdio.h>
#include<string.h>
int main(void){
    int f = 0, i,o, j, l, z, q, k[6], s[100][6], n[6], n2[6];
    char c;
    scanf("%d",&q);
    for (z = 0; z < q; z++){
        for (i = 0; i < 6; i++){
            scanf("%d", &s[z][i]);
            n[i] = i;
        }
    }
    for (i = 0; i < q; i++){
        for (z = 0; z < q; z++){
            if (i != z){
                for (j = 0; j < 5000; j++){
                    if (j % 5 == 0){
                        n2[0] = n[1]; 
                        n2[1] = n[5]; 
                        n2[3] = n[3]; 
                        n2[4] = n[0]; 
                        n2[2] = n[2]; 
                        n2[5] = n[4];
                    }
                    else {
                        n2[0] = n[3]; 
                        n2[1] = n[1]; 
                        n2[3] = n[5]; 
                        n2[4] = n[4]; 
                        n2[2] = n[0]; 
                        n2[5] = n[2];
                    }
                    for (o = 0; o < 6; o++){
                        n[o] = n2[o];
                    }
                    for (l = 0; l < 6; l++){
                        if (s[i][l] != s[z][n[l]])break;
  
                    }
                    if (l == 6){ 
                        f = 1; 
                        break;
                    }
  
                }
            }
            if (f == 1)break;
        }
        if (f == 1)break;
    }
        if (f == 1)printf("No\n");
        else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 2080
//
//  abc169_d.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 998244353;
ll INF = 1000000007;
#define PI 3.14159265

std::map<ll, ll> factorization (ll n) {
  std::map<ll, ll> f;
  for (ll i = 2; i*i <= n; i++) {
    while (n%i == 0) {
      f[i] += 1;
      n /= i;
    }
  }
  if (n > 1) {
    f[n] += 1;
  }
  return f;
}

int main() {
  ll n;
  std::cin >> n;
  std::map<ll, ll> n_factorized;
  n_factorized = factorization(n);

  ll ans = 0;
  for (std::map<ll, ll>::iterator it = n_factorized.begin(); it != n_factorized.end(); it++) {
    ll start = 1;
    while (it->second - start >= 0) {
      ans++;
      it->second -= start;
      start++;
    }
  }
  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);
		 
		 int N = scan.nextInt();
		 int[] d = new int[N];
		 
		 for (int i = 0; i < N; i++) {
			 d[i] = scan.nextInt();
		 }
		 
		 Arrays.sort(d);
		 
		 int same_d = 0;
		 for (int j = 0; j < N-1; j++) {
			 if (d[j] == d[j + 1]) {
				 same_d += 1; 
			 }
		 }
		 
		 System.out.println(N - same_d);
		 
		 scan.close();
		 
	}

}


Measured memory_bytes: 23124
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	for (i = 1; i < 10; i++)
	{
		if (n % i == 0 && n / i < 10)
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <limits>

using namespace std;

using ll = unsigned long long;

//N*M*max(A,B)+1
const ll inf = 300*(ll)(300*299/2)*300+1;

int main(void){
    int N, M, L, Q;

    cin >> N >> M >> L;

    vector<vector<ll>> dist(N, vector<ll>(N, inf));

    for(int i=0; i<N; i++){
        dist[i][i] = 0;
    }
    for(int q=0; q<M; q++){
        int a, b, c;
        cin >> a >> b >> c;

        dist[a-1][b-1] = dist[b-1][a-1] = c;
    }

    //ワーシャルフロイド法
    for(int k=0; k<N; k++){
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    
    vector<vector<ll>> fcnt(N, vector<ll>(N, inf));
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(dist[i][j] <= L)
                fcnt[i][j] = 1;
        }
    }

    //ワーシャルフロイド法
    for(int k=0; k<N; k++){
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                fcnt[i][j] = min(fcnt[i][j], fcnt[i][k] + fcnt[k][j]);
            }
        }
    }

    cin >> Q;
    for(int q=0; q<Q; q++){
        int s, t;
        cin >> s >> t;

        int ans = fcnt[s-1][t-1]-1;
        if(fcnt[s-1][t-1] == inf)
            ans = -1;

        cout << ans << endl;
    }

    return 0;
}

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

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

    int h[200];
    for (int i = 0; i < n; i++)
        cin >> h[i];

    int ans = 1, mx = h[0];
    for (int i = 1; i < n; i++){
        if (h[i] >= mx){
            ans += 1;
            mx = h[i];
        }
    }

    cout << ans << '\n';

    return 0;
}


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

using namespace std;

int main()
{
    long long a, b;

    scanf("%lld%lld", &a, &b);

    if((a & 1) != (b & 1)) {
        puts("IMPOSSIBLE");
    } else {
        printf("%lld\n", (a + b) >> 1);
    }

    return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n; scanf("%d",&n);
    vector<int> c[n];
    rep(i,0,n){
        int m; scanf("%d",&m);
        rep(j,0,m){
            int p; scanf("%d",&p);
            c[i].push_back(p);
        }
    }
    priority_queue<int> pq; ll ans=0;
    rrep(i,n-1,-1){
        rep(j,0,c[i].size())pq.push(c[i][j]);
        ans+=pq.top(); pq.pop();
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 19512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;

int n, res, u, mx, y, t, q;

int main(){
	cin>>n;
	vector<int> vec(n, 0);
	map<int,int> m;
	map<int, bool> flag;
	for(int i = 0; i < n; ++i){
		cin>>vec[i];
		m[vec[i]]++;
		mx = max(mx, vec[i]);
		flag[vec[i]] = false;
	}
	res = 0;
	for(auto x : m){
		if(x.second > 1)flag[x.first] = true;
		t = x.first;
		for(int r = 2; t * r <= mx; r+=4){
			q = t * r;
			if(m.count(q)){
				flag[q] = true;
			}
			q = t * (r + 1);
			if(m.count(q)){
				flag[q] = true;
			}
			q = t * (r + 2);
			if(m.count(q)){
				flag[q] = true;
			}
			q = t * (r + 3);
			if(m.count(q)){
				flag[q] = true;
			}
		}
	}
	for(auto x : flag)if(!x.second)res++;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 22796
n, k, c = map(int, input().split())
s = input()

def yutori(s, inv):
    ans = [0] * k
    index = 0
    for i in range(k):
        if inv:
            ans[(k - 1) - i] = (n - 1) - s.find('o', index)
            index = s.find('o', index) + (c + 1)
        else:
            ans[i] = s.find('o', index)
            index = ans[i] + (c + 1)
    return ans

l = yutori(s, 0)
r = yutori(s[::-1], 1)
for i, j in zip(l, r):
    if i == j:
        print(i + 1)

Measured memory_bytes: 20744
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

const int INF = 1e9 + 10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s = "CODEFESTIVAL2016";
  string t;
  cin >> t;
  int ans = 0;
  for (int i = 0; i < 16; i++) {
    if (s[i] != t[i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main()
{
	
	int a;
	int n,i,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		sum=sum+a-1;
	}
	printf("%d",sum);
		
	
		
		
	
	
}

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

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

const int MX = (int)1e5 + 10;
const int mod = (int)1e9 + 7;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);

    int n;
    cin >> n;

    vector<pair<int, int>> A(n), B(n);
    int id = 0;
    for(auto &p : A){
        cin >> p.X;
        p.Y = id++;
    }
    id = 0;
    for(auto &p : B){
        cin >> p.X;
        p.Y = id++;
    }

    sort(all(A));
    sort(all(B));
    
    for(int i = 0; i < n; ++i)
        if(A[i].X > B[i].X) return puts("No"), 0;

    for(int i = 0; i < n - 1; ++i)
        if(A[i + 1].X <= B[i].X) return puts("Yes"), 0; // can sort every element of the remaining n - 2 elements with at most n - 2 swaps

    vector<int> perm(n);
    for(int i = 0; i < n; ++i)
        perm[A[i].Y] = B[i].Y; // what order should A be if sorted ascending-ly

    int idx = 0;
    int cycle_length = 0;

    do{
        idx = perm[idx]; // loop through permutation cycle
        cycle_length++;
    }while(idx != 0);

    //if cycle contains all n elements, it requires n - 1 swaps at minimum
    return puts(cycle_length == n ? "No": "Yes"), 0;
}

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

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

  int N;
  string tmp;
  set<string> s;
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> tmp;
    s.insert(tmp);
  }
  
  cout << s.size() << endl;
  
  return 0;
}

Measured memory_bytes: 19248
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define INF 1145141919810364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int k;
int ans;

signed main() {
	cin >> k;
	for (int i = 1; i <= k; i++)for (int j = 1; j <= k; j++)for (int l = 1; l <= k; l++)ans += gcd(i, gcd(j, l));
	cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n,k,q,a,sum[100000]={};
    cin>>n>>k>>q;
    while(cin>>a)
        sum[--a]++;
    for(int i=0;i<n;i++)
        cout<<(q-sum[i]<k?"Yes":"No")<<endl;
}


Measured memory_bytes: 1408
while 1:
    t,d,l=map(int,input().split())
    if not t+d+l:
        break
    a=0
    j=-1
    for i in range(t):
        x=int(input())
        a+=(j>-1and i-j<=d)
        if x>=l:
            j=i
    print(a)


Measured memory_bytes: 5616
a,b,c,d = map(int, input().split())

taka1 = a//d
taka2 = a%d
aoki1 = c//b
aoki2 = c%b

if a%d != 0:
    taka1 += 1
if c%b != 0:
    aoki1 += 1

if taka1 >= aoki1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9124
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define repi(i,a,b) for (int i=a;i<(b);i++)
using namespace std;
typedef long long ll;
  
  int main(void){
    cin.tie(0); //cin高速化
    ios::sync_with_stdio(false); //cin高速化
	
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if(s=="abc"){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
    return 0;
  }    

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

#define fast ios::sync_with_stdio(false);cin.tie(NULL)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;

int n, k, ans;
string s;

int main() {
	fast;

	cin >> n >> k;
	cin >> s;

	for(int i=1; i<s.size(); i++) {
		if(s[i] == s[i-1]) ans++;
	}

	for(int i=0; i<k; i++) {
		if(n - ans >= 3) ans += 2;
		else if(n - ans == 2) ans++;
	}

	cout << ans;
}

Measured memory_bytes: 512
N = int(input())
h = [int(x) for x in input().split()]

Cost = [0] * N
Cost[1] = abs(h[1] - h[0])

for i in range(2, N):
    Cost[i] = min(Cost[i - 1] + abs(h[i] - h[i - 1]), Cost[i - 2] + abs(h[i] - h[i - 2]))

print(Cost[-1])

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

using namespace std;
const static double eps = 1e-9;
bool equal(const double& a, const double& b) {
  return abs(a - b) < eps;
}

struct tensor {
  vector<double> v;
  size_t n;
  
  tensor(){}
  tensor(const vector<double>& vec) {
    v = vec;
    n = vec.size();
  }
  tensor(const tensor& t) {
    v = t.v;
    n = t.n;
  }
  
  tensor operator+(const tensor& t) const {
    assert(n == t.n);
    vector<double> nv(v);
    for (int i = 0; i < n; ++i) nv[i] += t.v[i];
    return tensor(nv);
  }
  
  tensor operator-(const tensor& t) const {
    assert(n == t.n);
    vector<double> nv(v);
    for (int i = 0; i < n; ++i) nv[i] -= t.v[i];
    return tensor(nv);
  }
  
  tensor operator*(const double& a) const {
    vector<double> nv(v);
    for (int i = 0; i < n; ++i) nv[i] *= a;
    return tensor(nv);
  }
  
  double norm() const {
    double s(0.0);
    for (int i = 0; i < n; ++i) s += v[i] * v[i];
    return sqrt(s);
  }
  
  void rect_rotate() { // only for 2d
    assert(n == 2);
    swap(v[0], v[1]);
    v[0] *= -1;
  }
};

struct circle {
  tensor o;
  double r;
  
  circle(){
  	o.v.resize(2);
    o.n = 2;
  }
  circle(const tensor& origin, const double& radius) {
    o = origin;
    r = radius;
  }
  circle(const circle& c) {
    o = c.o;
    r = c.r;
  }
  
  vector<tensor> intersect(const circle& c) const {
    tensor v(c.o-o);
    double d(v.norm());
    if (equal(d, 0)) return {};
    double d1(d+r+c.r), d2(max(d, max(r, c.r)));
    if (equal(d1, d2)) return {o + v * (r / d)};
    if (d1 < d2) return {};
    double x((r*r+d*d-c.r*c.r) / (2*d)), y(sqrt(r*r-x*x));
    tensor mid(o + v * (x/d));
    v.rect_rotate();
    return {mid + v * (y / d), mid - v * (y / d)};
  }
  
  bool inside(const tensor& v) const {
    return (v-o).norm() < r + eps;
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  
  vector<circle> cs(n);
  for (int i = 0; i < n; ++i)
    cin >> cs[i].o.v[0] >> cs[i].o.v[1] >> cs[i].r;
  
  double min_t(0), max_t(400000);
  while (!equal(min_t, max_t)) {
    double mid_t((min_t + max_t) / 2);
    
    vector<circle> tcs(cs);
    for (circle& c: tcs) c.r = mid_t / c.r;
    
    vector<tensor> points;
    for (int i = 0; i < n; ++i) {
      points.push_back(cs[i].o);
      for (int j = 0; j < i; ++j) {
        vector<tensor> temp = tcs[i].intersect(tcs[j]);
        points.insert(points.end(), temp.begin(), temp.end());
      }
    }
    
    bool found(false);
    for (tensor p: points) {
      int cnt(0);
      for (int i = 0; i < n; ++i) cnt += tcs[i].inside(p);
      if (cnt >= k) {
        found = true;
        break;
      }
    }
    found ? max_t = mid_t : min_t = mid_t;
  }
  printf("%.10f\n", min_t);
  return 0;
}

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

int main(){
  int N;
  int a[100];
  cin>>N;
  for(int i=0;i<N;++i){
   cin>>a[i]; 
  }
  sort(a, a + N, greater<int>());  
  int Alice = 0;
  int Bob = 0;
  for (int i = 0; i < N; ++i) {
      if (i % 2 == 0) { 
          Alice += a[i];
      }
      else { 
          Bob += a[i];
      }
   }
   cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.begin(), v.end(),greater<int>());
#define INF 999999999
#define MOD 1000000007
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,Wmax;
vector<ll> V,W;

void input(){
  #ifdef __LOCAL
    fs::path p = __FILE__;
    fs::path input,output;
    input = output = p.parent_path();
    input += string("/input/") + string(p.stem()) + string(".txt");
    output += string("/output/") + string(p.stem()) + string(".txt");
    freopen(input.c_str(), "r", stdin);
    freopen(output.c_str(), "w", stdout);
  #endif
  cin >> N >> Wmax;
  for (int i = 0; i < N; i++)
  {
    ll v,w;
    cin >> w >> v;
    W.push_back(w);
    V.push_back(v);    
  }
  
}

int solve(){
  vector<vector<ll> > dp(N+1,vector<ll>(Wmax+1,0LL));
  for (int i = 1; i <= N; i++)
  {
    for (int j = 0; j <= Wmax; j++)
    {
      if(j-W[i-1]<0) dp[i][j] = dp[i-1][j];
      else dp[i][j] = max(dp[i-1][j], dp[i-1][j-W[i-1]] + V[i-1]);
    }
  }
  ll ans=0;
  for (int j = 0; j <= Wmax; j++)
  {
    ans = max(ans,dp[N][j]);
  }
  
  cout << ans << endl;


  return 0;
}

int main()
{
  input();
  solve();
  return 0;
}


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

using ll = long long;
typedef pair<ll, ll> P;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define INF (ll)(1e18 + 1)

// Ford-Fulkerson
class MaxFlow {
  struct edge {
    int to;
    ll cap;
    int rev; // 逆辺のindex(G[to][rev]が逆辺)
  };

 private:
  vector<vector<edge>> G;
  vector<bool> used;
  int sink;

  // f: 頂点vに流れてきている量
  ll dfs(int v, ll f) {
    if (v == sink) {
      return f;
    }

    used[v] = true;
    for (auto e = G[v].begin(); e != G[v].end(); e++) {
      if (used[e->to] || e->cap <= 0) {
        continue;
      }

      ll d = dfs(e->to, min(f, e->cap));
      if (d > 0) {
        e->cap -= d;
        G[e->to][e->rev].cap += d;
        return d;
      }
    }

    return 0;
  }

 public:
  MaxFlow(int max_v) : G(max_v), used(max_v) {
  }

  void add_edge(int from, int to, ll cap) {
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
  }

  // source: Start
  // sink: Goal
  ll max_flow(int source, int _sink) {
    sink = _sink;

    ll flow = 0;
    for (;;) {
      fill(all(used), false);

      ll f = dfs(source, INF);
      if (f == 0) {
        return flow;
      }
      flow += f;
    }
  }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;
  vector<P> p, q;

  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    p.emplace_back(a, b);
  }

  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    q.emplace_back(a, b);
  }

  MaxFlow mf(202);

  rep(x, p.size()) {
    rep(y, q.size()) {
      if (p[x].first < q[y].first && p[x].second < q[y].second) {
        mf.add_edge(x, 100 + y, 1);
      }
    }
  }

#define SOURCE_INDEX 200
#define SINK_INDEX 201

  rep(i, p.size()) {
    mf.add_edge(SOURCE_INDEX, i, 1);
  }

  rep(i, q.size()) {
    mf.add_edge(100 + i, SINK_INDEX, 1);
  }

  cout << mf.max_flow(SOURCE_INDEX, SINK_INDEX) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;
 vector<ll> v, p;
ll dfs(ll n,ll x){
    if(n==0){
        return x <= 0 ? 0 : 1;
    }
    else if(x<=1+v[n-1])
        return dfs(n - 1, x - 1);
    else
        return p[n - 1] + 1+dfs(n - 1, x - 2 - v[n - 1]);
}

int main(){
    ll N, X;
    cin >> N>>X;

    v.assign(N+1, 1);
    p.assign(N + 1, 1);
    for (int i = 0; i < N; i++)
    {
        v[i+1]=(2 * v[i] + 3);
        p[i+1]=(2 * p[i] + 1);
    }

    cout << dfs(N, X) << endl;

    return 0;
}

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

struct TDice
{
    int Top;
    int Front;
    int Right;
    int Back;
    int Left;
    int Bottom;
};
TDice MakeDice(std::istream& in)
{
    TDice Dice;
    in >> Dice.Top
       >> Dice.Front
       >> Dice.Right
       >> Dice.Left
       >> Dice.Back
       >> Dice.Bottom;
    return Dice;
}
void RollN(TDice& Dice)
{
    int temp    = Dice.Top;
    Dice.Top    = Dice.Front;
    Dice.Front  = Dice.Bottom;
    Dice.Bottom = Dice.Back;
    Dice.Back   = temp;
}
void RollE(TDice& Dice)
{
    int temp    = Dice.Top;
    Dice.Top    = Dice.Left;
    Dice.Left   = Dice.Bottom;
    Dice.Bottom = Dice.Right;
    Dice.Right  = temp;
}
void RollW(TDice& Dice)
{
    int temp    = Dice.Top;
    Dice.Top    = Dice.Right;
    Dice.Right  = Dice.Bottom;
    Dice.Bottom = Dice.Left;
    Dice.Left   = temp;
}
void RollS(TDice& Dice)
{
    int temp    = Dice.Top;
    Dice.Top    = Dice.Back;
    Dice.Back   = Dice.Bottom;
    Dice.Bottom = Dice.Front;
    Dice.Front  = temp;
}

void Roll(char c, TDice& Dice)
{
    switch(c){
    case 'N': RollN(Dice); break;
    case 'E': RollE(Dice); break;
    case 'W': RollW(Dice); break;
    case 'S': RollS(Dice); break;
    }
}
bool IsInclude(int Num, const TDice& Dice)
{
    return
        Dice.Top    == Num ||
        Dice.Front  == Num ||
        Dice.Right  == Num ||
        Dice.Back   == Num ||
        Dice.Left   == Num ||
        Dice.Bottom == Num; 
}
void RollToTop(int Num, TDice& Dice)
{
    assert(IsInclude(Num, Dice));
    if(Dice.Top == Num){
    }else
    if(Dice.Left == Num){
        RollE(Dice);
    }else
    if(Dice.Right == Num){
        RollW(Dice);
    }else
    if(Dice.Front == Num){
        RollN(Dice);
    }else
    if(Dice.Back == Num){
        RollS(Dice);
    }else
    if(Dice.Bottom == Num){
        RollE(Dice);
        RollE(Dice);
    }else{
        assert(false);
    }
}
void RollToFront(int Num, TDice& Dice)
{
    RollToTop(Num, Dice);
    RollS(Dice);
}
void RollToTopFront(int Top, int Front, TDice& Dice)
{
    RollToFront(Front, Dice);
    RollToTop(Top, Dice);
}

bool Equal(const TDice& A, const TDice& B)
{
    return
        A.Top    == B.Top &&
        A.Front  == B.Front &&
        A.Right  == B.Right &&
        A.Back   == B.Back &&
        A.Left   == B.Left &&
        A.Bottom == B.Bottom;
}
bool EqualIfRoll(const TDice&A, const TDice&B)
{
    TDice X = A;
    RollToTopFront(B.Top, B.Front, X);
    return Equal(X, B);
}
int main()
{
    TDice A = MakeDice(std::cin);
    TDice B = MakeDice(std::cin);
    std::cout << (EqualIfRoll(A, B) ? "Yes" : "No") << std::endl;
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
const ll LLINF = 1000000000000000000;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main()
{
   int n;
   cin >> n;
   vector<ll> t(n);
   rep(i,n) cin >> t[i];
   ll ans =1;
   rep(i,n){
      ans = lcm(ans,t[i]);
      if(ans == LLINF){
         cout << LLINF << endl;
         return 0;
      }
   }
   cout << ans << endl;
}

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

int main() {
    ll a, b;
    cin >> a >> b;
    if(a == 0 || b == 0 || (a < 0 && 0 < b)) {
        cout << "Zero" << endl;
        return 0;
    }
    if(b < 0 && (b-a)%2 == 0) {
        cout << "Negative" << endl;
    }
    else {
        cout << "Positive" << endl;
    }

    return 0;
}

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

const long long INF = 1LL << 60;

long long dp[40];

long long rec(int i){
    if(i == 0) return 1;
    
    long long res = 0;
    for(int j = 1; j <= 3; j++){
        if(i - j >= 0) res += rec(i - j);
    }
    return dp[i] = res;
}

int main(){
  for(int i = 0; i < 40; i++){
    dp[i] = INF;
  }
    while(true){
        int n; cin >> n;
        if(n == 0) break;
        int tmp = rec(n);
        if(tmp % 3650 == 0){
            cout << tmp/3650 << endl;
        }
        else{
            cout << tmp/3650 + 1 << endl;
        }
    }
}


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

int main () {
  string sd;
  string t;
  cin >> sd >> t;

  reverse(sd.begin(), sd.end());
  reverse(t.begin(), t.end());

  if (t.size() > sd.size()) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  int matched_pos = -1;
  for (int pos = 0; pos <= sd.size() - t.size() && matched_pos == -1; pos++) {
    for (int i = 0; i < t.size() && matched_pos == -1; i++) {
      if (sd[i + pos] == t[i] or sd[i + pos] == '?') {
        if (i == t.size() -1) {
          matched_pos = pos;
        } else {
          continue;
        }
      } else {
        break;
      }
    }
  }
  
  if (matched_pos >= 0) {
    for (int i = 0; i < t.size(); i++) {
      sd[i + matched_pos] = t[i];
    }
    for (int i = 0; i < sd.size(); i++) {
      if (sd[i] == '?') sd[i] = 'a';
    }
    reverse(sd.begin(), sd.end());
    cout << sd << endl;
  } else {
    cout << "UNRESTORABLE" << endl;
  }

}


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

    for (int i = 0; i < N; i++){
        cin >> T[i];
    }

    int M;
    cin >> M; 
    for (int i = 0; i < M; i++){
        int P, X;
        cin >> P >> X;
        int answer =0;

        for (int j = 0; j < N; j++){
            if ( j == P - 1){
                answer += X;
            }
            else {
                answer += T[j];
            }
        }
        cout << answer << endl;
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const ll mod = 1000000007;
int main() {
	ll K, A, B;
	scanf("%lld%lld%lld", &K, &A, &B);
	if (A < B - 2) {
		ll c = A - 1;
		printf("%lld\n", (K - c) / 2 * (B - A) + (K - c) % 2 + A);
	}
	else printf("%lld\n", K + 1);
	return 0;
}


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

int main(){
  ll k, x;
  cin >> k >> x;

  if(500 * k >= x){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256