akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

/********
*	??¬????????\?±??????°
*********/


/*********??¢?????´?????????
*	(1)
*	(2)
*	(3)
*********/

int main(void){
	int n;			//?????±?????°
	int b,f,r,v;	//b?£?(1???4)???f???(1???3)??????r??????(1???10)?????¨?±????v???(-9???9)????±????

	int i,j,k;		//?£?????´?i(0???3)??????????´?j(0???2)????????°?????±k(0???9)
	int count[4][3][10]={{{0,0,0}}};	//[?£?][???][??¨?±?]	3?¬???????????????\?±??????¶???????????????
	
	scanf("%d\n", &n);		//?????±?????°?????\???

	for ( i = 0 ; i<n ; i++ ){
		scanf("%d %d %d %d\n", &b ,&f, &r, &v );
        count[b-1][f-1][r-1] += v;
	}

	for( i = 0 ; i <4 ; i++ ){				//??\?±??????¶????????????
		for( j = 0 ; j < 3 ; j++ ){
			for(k = 0 ; k < 10 ; k++){
                    
                    v = count[i ][j ][k ];
					if(0 <= v && v <= 9 ){
					    printf(" %d", v);
					}else {
						//?????°???0??\???????????????????????\?????¨??????;
					}
    		}
		    printf("\n");
	    }
	    if(i < 3 ){
	    	printf("####################\n");
	    }
	}

    return 0;
}

Measured memory_bytes: 1044
def gcd(a, b):
    if a == 0: return b
    if b == 0: return a
    return gcd(b, a % b)
    
n = int(input())
a = list(map(int,input().split()))	

l = [0] * (n + 1)
r = [0] * (n + 1)

for i in range(n):
    l[i + 1] = gcd(l[i], a[i])

for i in reversed(range(n)):
    r[i] = gcd(r[i + 1], a[i])

ans = 1
for i in range(n):
    ans = max(ans, gcd(l[i], r[i + 1]))

print(ans)

Measured memory_bytes: 63856
from collections import deque

n,m = map(int, input().split())
dic = {} 

for i in range(m):
  a,b = map(int,input().split())
  
  dic.setdefault(a,[])
  dic.setdefault(b,[])

  dic[a].append(b)
  dic[b].append(a)

array = [-1] * (n+1)

d = deque()
d.append(1)

while len(d) != 0:
  tmp = d.popleft()
  arr = dic.get(tmp, [])
  
  for v in arr:
    if array[v] == -1:
      array[v] = tmp
      d.append(v)
      
print('Yes')
for i in range(2,n+1):
  print(array[i])
    

Measured memory_bytes: 105712
//最长递增子序列
//DP+二分查找
#include <iostream>
#include <algorithm>
using namespace std;

static const int MAX=100000; 

int main(){
	
	int n;
	cin>>n;
	int A[MAX+1];
	for(int i=0;i<n;i++)
		cin>>A[i];
	int L[MAX];//表示末尾数字的最小值
	L[0]=A[0]; 
	int length=1;//表示第i个元素最长递增子序列的长度
	for(int i=1;i<n;i++){
		if(L[length-1]<A[i]){
			L[length++]=A[i];//将A[i]添加到末尾，并将length加1 
		}else{
			*lower_bound(L,L+length,A[i])=A[i];//二分查找A[i],返回A[i]的地址 
		}
	} 
	
	cout<<length<<endl;
	
	return 0;
} 


Measured memory_bytes: 3848
a=raw_input()
b=raw_input()
a=list(a)
a.sort()
b=list(b)
b.sort()
b.reverse()

ch=0
for i in range(len(b)):
    if len(a)-1>=i:

        if a[i]<b[i]:
            ch=1
            break
    else:

        if a[:i]==b[:i]:
            ch=1

if ch==1:
    print "Yes"
else:
    print "No"


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

typedef long long int lli;
typedef long int li;

int a[13][13];
int c[13];
int n, m, x;

lli inf = 1e18 + 9;

int main(){
	
    ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

    cin >> n >> m >> x;

    for(int i = 1; i <= n; i++){
        cin >> c[i];
        for(int j = 1; j <= m; j++)
            cin >> a[i][j];
    }
    
    lli mc = inf;
    for(int i = 0; i <= (1 << n); i++){
        lli sum[13];
        lli cc = 0;
        memset(sum, 0, sizeof(sum));
        for(int j = 1; j <= n; j++){
            if(i & (1 << (j-1))){
                cc += c[j];
                for(int k = 1; k <= m; k++)
                    sum[k] += a[j][k];
            }
           // cout << cc << '\n';
        }

        bool b = 1;
        for(int i = 1; i <= m; i++){
            if(sum[i] < x) b = 0;
        }
        if(b)mc = min(cc, mc);
    }


    if(mc == inf) cout << "-1\n";
    else cout << mc << '\n';
    
}	

/*
	check for corner cases.
	When using log check for zeros.
	Use queues and stacks if they are helping.           
                            
    (___)           
    . . )____________ 
   _|__/\           |\
  (o_o_) \__________| \
           /|     ||   )     
          < |     ||  
*/



Measured memory_bytes: 3656
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;

//////////////////////////////////////////////////////////////////////

int main(void) {
	int n, a, b; cin >> n >> a >> b;
	cout << min(n*a, b) << endl;
	return 0;
}

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define forr(i,a,b) for(ll i=(a);i<=(b);i++)
#define ford(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define size(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)



int main(void) {
    int N,i,j;
    cin >> N;
    int n[200895];
    int m[200895];
    for(i=0;i<N-1;++i){
       cin >> n[i];
      
    }
     for(i=0;i<N-1;++i){
     
       m[n[i]-1]++;
    }
    for (j=0;j<N;++j){
        
         cout << m[j] << "\n";
    

    }   
    
  return 0;
}

Measured memory_bytes: 5092
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String top = s.substring(0,1);
		String finish =  s.substring(s.length()-1,s.length());
		//System.out.println(top);
		//System.out.println(finish);
		
		int a = s.length()-2;


		System.out.println(top + "" + a + "" + finish );
		
		
		
		
	
	}
}


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

int main(void){
  string s;
  cin >> s;
  if(s == "AAA" || s == "BBB") cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3624
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
#if l[i] == l[j]: continue
x = int(input())

if x == 0:
    print(1)
else:
    print(0)


Measured memory_bytes: 9140
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n;
  
  ans=n/200;
  ans=10-ans;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3620
N = int(input())
*T, = map(int, input().split())
*V, = map(int, input().split())
speed = [0] # speed[i]: speed of train after 0.5*i seconds
for t, v in zip(T, V):
    speed[-1] = min(speed[-1], v)
    speed += [v]*(2*t)
speed[-1] = 0
temp = 0
for t in range(1, len(speed)):
    speed[t] = temp =  min(speed[t], temp + 0.5)
temp = 0
for t in range(len(speed)-1, 0, -1):
    speed[t] = temp =  min(speed[t], temp + 0.5)
ans = sum((v1 + v2)/4 for v1, v2 in zip(speed, speed[1:]))
print(ans)

Measured memory_bytes: 3760
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int h, w;char t [52][52]; char s;
	cin >> h >> w;
	bool f = true;
	int i, j;
	for (i = 0; i <= h+1; i++) {
		for (j = 0; j <= w + 1; j++) {
			t[i][j] = '.';
			if (i >= 1 && j >= 1 && i <= h && j <= w) {
				cin >> s; t[i][j] = s;
			}
		}
	}
	for (i = 1; i <= h; i++) {
		for (j = 1; j <= w; j++) {
			if (t[i][j] == '#'&&t[i - 1][j] == '.'&&t[i + 1][j] == '.'&&t[i][j - 1] == '.'&&t[i][j + 1] == '.')f = false;
		}
	}
	if (f)cout << "Yes" << endl;
	else cout << "No" << endl;
	char nyaa;
	cin >> nyaa;
	return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
s=[['.']*(W+2) for i in range(H+2)]
for i in range(H):
  S=input()
  t='.'+S+'.'
  s[i+1]=t
for i in range(H):
  for j in range(W):
    b=0
    if s[i+1][j+1]!='#':
      for k in range(-1,2,1):
        for l in range(-1,2,1):
          if s[i+1+k][j+1+l]=='#':
            b+=1
    else:
      b='#'
    print(b,end='')
  print()

Measured memory_bytes: 9168
import java.util.*;

public class Main {
    public static void  main (String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String str = sc.next();
        
        char c1 = str.charAt(0);
        char c3 = str.charAt(2);
        
        if (c1 == c3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 20948
-- modules to import --
import Data.ByteString.Char8
import Data.Maybe
import Prelude

-- functions for this task --

read_Integer     = Prelude.fst . Data.Maybe.fromJust . Data.ByteString.Char8.readInteger
read_ListInteger = Prelude.map read_Integer . Data.ByteString.Char8.words

get_Integer     = read_Integer     <$> Data.ByteString.Char8.getLine
get_ListInteger = read_ListInteger <$> Data.ByteString.Char8.getLine

isMultiple :: Integer -> Integer -> Bool
isMultiple target base = mod target base == 0

isEven :: Integer -> Bool
isEven target = isMultiple target 2

task_A :: [Integer] -> ByteString
task_A [a, b] = Data.ByteString.Char8.pack $ if (isEven $ a * b) then "Even" else "Odd"

-- main process is below --

main :: IO ()
main = do

        -- STEP.01
        -- read out the given string
        [a, b] <- get_ListInteger

        -- STEP.02
        -- output the answer of this task
        Data.ByteString.Char8.putStrLn $ task_A $ [a, b]

-- End of this source code --

Measured memory_bytes: 380
from collections import defaultdict
from heapq import heappop, heappush


class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):  # デフォルトの距離は1
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    """
    ダイクストラ法 (二分ヒープ) による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):  # graph: Graphオブジェクト, start: 始点のIndex
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # そのノードまでの最短経路を定義した時、どのノードから来たのかを記録する
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))  # そのノードまでの仮の最短距離, ノードのIndex
        # 本当の最短距離はself.distに格納する
        while self.Q:
            # 距離が最小であるものをキューから取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:  # 仮の距離より短い距離が正式に求まっているならスルー
                continue
            for v, weight in self.g[u]:  # 対象のノードに隣接しているノードに対して操作を行う, 始点はu
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))  # 更新された仮の距離, ノード

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:  # startノードはprevを持たないからこの条件でよい
            path.append(node)
            node = self.prev[node]
        return path[::-1]  # 逆順にして返す


N, M = map(int, input().split())
g = Graph()
visited_edges = {}
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    g.add_edge(a, b, c)
    g.add_edge(b, a, c)
    visited_edges[(a, b)] = False
    visited_edges[(b, a)] = False

for i in range(N):  # 始点
    shortest = Dijkstra(g, i)
    for j in range(i+1, N):  # 終点
        paths = shortest.shortest_path(j)
        for k in range(len(paths)-1):
            visited_edges[(paths[k], paths[k+1])] = True
            visited_edges[(paths[k+1], paths[k])] = True
print(M - sum(visited_edges.values())//2)


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

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x-a) < abs(x-b)){
        cout << "A" << endl;
    } else {
        cout << "B" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int k = sc.nextInt();
		HashMap<Integer, Integer> hm = new HashMap<>();
		int a;
		for (int i = 0; i < n; i++) {
			a = sc.nextInt();
			if (hm.containsKey(a)) {
				hm.put(a, hm.get(a) + 1);
			} else {
				hm.put(a, 1);
			}
		}

		if (hm.size() <= k) {
			System.out.println(0);
		} else {
			int[] s = new int[hm.size()];
			int idx = 0;
			for (int i : hm.keySet()) {
				s[idx] = hm.get(i);
				idx++;
			}
			Arrays.sort(s);
			int ans = 0;
			for (int i = 0; i < hm.size() - k; i++) {
				ans += s[i];
			}
			System.out.println(ans);
		}

	}
}

Measured memory_bytes: 98300
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = str(input())
A = []
point = 0
for i in range(K):
  if T[i] == 'r':
    A.append('p')
    point += P
  elif T[i] == 's':
    A.append('r')
    point += R
  else:
    A.append('s')
    point += S

for i in range(K, N-K):
  if T[i] == 'r':
    if A[i-K] == 'p':
      if T[i+K] == 's':
        A.append('s')
      else:
        A.append('r')
      continue
    A.append('p')
    point += P
  elif T[i] == 's':
    if A[i-K] == 'r':
      if T[i+K] == 'p':
        A.append('p')
      else:
        A.append('s')
      continue
    A.append('r')
    point += R
  else:
    if A[i-K] == 's':
      if T[i+K] == 'r':
        A.append('r')
      else:
        A.append('p')
      continue
    A.append('s')
    point += S


for i in range(N-K, N):
  if T[i] == 'r':
    if A[i-K] == 'p':
      continue
    A.append('p')
    point += P
  elif T[i] == 's':
    if A[i-K] == 'r':
      continue
    A.append('r')
    point += R
  else:
    if A[i-K] == 's':
      continue
    A.append('s')
    point += S
print(point)

Measured memory_bytes: 4212
n, x = map(int, input().split())
pty = [[] for i in range(n + 1)]
lay = [[] for i in range(n + 1)]
pty[0] = 1
lay[0] = 1
for L in range(1, n + 1):
    pty[L] = 2 * pty[L - 1] + 1
    lay[L] = 2 * lay[L - 1 ] + 3
ans = 0
while x > 0:
    if x >= lay[L] + 1:
        x -= lay[L] + 1
        ans += pty[L] + 1
    elif x == lay[L]:
        x -= lay[L]
        ans += pty[L]
    else:
        L -= 1
        x -= 1
print(ans)

Measured memory_bytes: 3064
import math
from fractions import gcd


def read():
    A, B, C, D = list(map(int, input().strip().split()))
    return A, B, C, D


def count(X, C, D):
    nC = X // C
    nD = X // D
    lcm = C * D // gcd(C, D)
    nCD = X // lcm
    return X - (nC + nD - nCD)

def solve(A, B, C, D):
    return count(B, C, D) - count(A-1, C, D)


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))


Measured memory_bytes: 65132
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n, m;
    cin >> n >> m;
    vector<int> H(n);
    REP(i, n) cin >> H[i];

    vector<vector<int>> pass(n);
    vector<int> A(m), B(m);
    REP(i, m) {
        cin >> A[i] >> B[i];
        pass[A[i]-1].push_back(B[i]-1);
        pass[B[i]-1].push_back(A[i]-1);
    }

    REP(i, n) {
        REP(j, pass[i].size()) {
            cerr << pass[i][j] << " ";
        }
        cerr << endl;
    }

    int res = 0;

    for(int i = 0; i < n; i++) {
        bool can = 1;

        for(int j = 0; j < pass[i].size(); j++) {
            if (H[i] <= H[pass[i][j]]) can = 0;
        }

        if (can) res++;
    }


    cout << res << endl;
    return 0;
}

Measured memory_bytes: 9496
N=int(input())
A=list(map(int,input().split()))
X=[0]*(N + 1)

for i in A:
    X[i] += 1

cnt=0
for i in X:
    cnt += (i * (i - 1)// 2)

for i in A:
    print(cnt - (X[i] - 1))


Measured memory_bytes: 26140
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
*/
//#define sqr(qwert) qwert * qwert
#define eb emplace_back
#define pb push_back
#define ld long double
#define ll long long
#define f first
//#define s second
#define deb(a) cerr << #a << " = " << a << '\n';
#define fast() { \
    ios_base::sync_with_stdio(0); \
    cin.tie(0); \
    cout << fixed << setprecision(15); \
    cerr << fixed << setprecision(11); \
}

const int INF = 1e9 + 7;
const ld EPS = 1e-10;
const int MAXI = 20000;
const int MOD = 998244353;
const int MAXST = 2000000;
const int P = 62;
const ld PI = 3.14159265358979323;

int main() {
    ll a, b, n, l = 0, r = 1e12, maxx = 0, k = 0;
    cin >> a >> b >> n;
    do{
        ll m = (l + r) / 2;
        if(a * m / b - a * (m / b) > maxx){
            if(m > n){
                r = m;
            }
            else{
                maxx = a * m / b - a * (m / b);
                l = m + 1;
            }
        }
        else r = m;
    }while(l != r);
    cout << maxx << '\n';
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n;
    cin>>n;
    if (n%10==9 || n/10==9)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> C(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> C.at(i).at(j);
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << C.at(i).at(j);
    }
    cout << endl;
    for (int j = 0; j < W; j++) {
      cout << C.at(i).at(j);
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(ll i=vv;i<n;i++)
#define FORR(i,n,vv) for(ll i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)




int main(){

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt	
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif	

    FAST
//	PRECISE

ll k;
cin>>k;
ll ans=0;
unordered_set <ll> s;
ll st=7;
st=st%k;
ll c=1;
ll po=7;
while(s.find(st)==s.end()){
	if(st%k==0){
		ans=c;
		break;
	}
	//cout<<st<<endl;
	s.insert(st%k);
	st=(st+10*po)%k;
	po=po*10%k;
	c++;
}

if(ans==0)cout<<-1;
else cout<<ans;


return 0;
 }



Measured memory_bytes: 42632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  map<ll,int> mp;
  rep(i,N){
    ll x;cin >> x;
    ++mp[x];
  }
  bool issat = false;
  vector<PLI> v;
  for(auto itr = mp.begin();itr!=mp.end();++itr) v.push_back(PIL(itr->first,itr->second));
  if(mp.count(0)){
    if(v.size()==1) issat= true;
    else if(v.size()==2){
      if(v[1].first==0ll)swap(v[0],v[1]);
      if((v[1].second&1) == 0) issat = true;
    }
  }else if(v.size()==3){
    if(v[0].second == v[1].second && v[1].second == v[2].second)issat = true;
    if(v[0].first!=(v[1].first^v[2].first))issat = false;
  }
  YesNo(issat);
  return 0;
}


Measured memory_bytes: 7284
#include <stdio.h>

int main(void) {
    int a,b,min,max;
    for ( ; ; ){
        scanf("%d %d",&a,&b);
        if (a == 0 && b == 0) break;
        else {
            if (a >= b){
                max = a;
                min = b;
            }
            else {
                max = b;
                min = a;
            }
            printf("%d %d\n",min,max);
        }
    }
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define vs vector<string>
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
    int n, m;
    cin>>n>>m;
    bool is[n] = {0};
    int wa[n] = {0};
    for(int i = 0; i<m; ++i)
    {
        int p; string s;
        cin>>p>>s;
        p -= 1;
        if(s == "AC") 
            is[p] = 1;
        else
        {
            if(!is[p])
                wa[p] += 1;
        }
    }

    int a1 = 0;
    int b1 = 0;
    for(int i = 0; i<n; ++i)
    {
        if(is[i])
        {
            a1 += 1;
            b1 += wa[i];
        }
    }

    cout<<a1<<" "<<b1<<endl;
}

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

int main() {
  long Q, H, S, D;
  cin >> Q >> H >> S >> D;
  long N;
  cin >> N;
  H = min(Q * 2, H);
  S = min(H * 2, S);
  if (S * 2 <= D) cout << N * S << "\n";
  else cout << N / 2 * D + N % 2 * S << "\n";
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	static Scanner sc =  new java.util.Scanner(System.in);

	public static void main(String[] args) {
		
		while ( sc.hasNext() ){
		
		int n = sc.nextInt();
		int x = n * ( n + 1 ) / 2 + 1 ;
				
		System.out.println( x );
	
		}

	}

}

Measured memory_bytes: 26280
#include<iostream>
#include<string.h>
#include<algorithm>

char s[3][16];

int input(){
	std::cin >> s[0] >> s[1] >> s[2];
	return 0;
}

int run(){
	int l[3];
	for( int i = 0; i < 3; i++ ){
		l[i] = strlen(s[i]) - 1;
	}
	if( s[0][l[0]] == s[1][0] && s[1][l[1]] == s[2][0] ){
		std::cout << "YES" << std::endl;
	}else{
		std::cout << "NO" << std::endl;
	}
	return 0;
}

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


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

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

    while(n > 1000){
        n -= 1000;
    }
    cout << 1000-n << endl;;
}

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

int main(){
	int n, m;
	cin >> n >> m;
	int ok1[n];
	int okn[n];
	for(int i = 0; i < n; i++){
		ok1[i] = okn[i] = 0;
	}
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		if(a > b) swap(a,b);
		if(a == 1){
			ok1[b-1] = 1;
		}
		if(b == n){
			okn[a-1] = 1;
		}
	}
	int ok = 0;
	for(int i = 0; i < n; i++){
		if(ok1[i] && okn[i]){
			ok = 1;
		}
	}
	cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1.0)

#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pf(a) printf("%lld\n",a)

#define stll(a) stoll(a,nullptr,10)
#define all(a) a.begin(),a.end()
#define PII pair<ll,ll>
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define EL printf("\n")
#define ff first
#define ss second
#define rev(a) reverse(all(a))


#define mem(ar,val) memset(ar,val,sizeof(ar))
#define ssort(ar) sort(ar.begin(),ar.end())
#define csort(ar,comp) sort(ar.begin(),ar.end(),comp)

#define bug1(a) cerr<<"test "<<a<<endl;
#define bug2(a,b) cerr<<"test "<<a<<" "<<b<<endl;
#define bug3(a,b,c) cerr<<"test "<<a<<" "<<b<<" "<<c<<endl;
#define bug4(a,b,c,d) cerr<<"test "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

#define fout freopen("output.txt","w",stdout)
#define fin  freopen("input.txt","r",stdin)

/// unordered_map<int,int>mp;
/// mp.reserve(1024);
/// mp.max_load_factor(0.25);

/// pbds
/// *find_by_order(k) - return k th largest element.. 0 based
/// order_of_key(k) - number of items strictly smaller than k

///  priority_queue <ll, vector<ll>, greater<ll> >

/*
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
*/

typedef long long ll;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;



int main()
{
    ll n,a,b,tt;
    PII x,p,q,r;
    cin>>n;
    cin>>x.ff>>x.ss;
    for(int i=1;i<n;i++)
    {
        cin>>a>>b;
        tt = max(x.ff/a,x.ss/b);
        if(a*tt <x.ff || b*tt<x.ss)
            tt++;
        x.ff=a*tt,x.ss=b*tt;
    }
    cout<<x.ff+x.ss<<endl;
}













Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t,a,b,c,d,cnt=0,pk;
     cin>>a>>b>>c>>d;
     d=d/50;
     for(int i=0;i<=a;i++)
     {
         for(int j=0;j<=b;j++)
         {
             for(int k=0;k<=c;k++)
             {
                 pk=i*10+j*2+k;
                 if(pk==d)
                    cnt++;
             }
         }
     }
     cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    std::string s;
    std::cin >> s;
    int k = 0, n = s.size();
    std::string p = " ";
    for (int i = 0; i < n; i += p.size()) {
        if (p.size() == 2 || s[i] != p[0]) p = s.substr(i, 1);
        else if (i == n - 1) break;
        else p = s.substr(i, 2);
        k++;
    }
    std::cout << k << std::endl;

    return 0;
}


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

using namespace std;

using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<ll> sum(n);
  for (int i = 0; i < n; ++i) {
    cin >> sum[i];
  }
  for (int i = 1; i < n; ++i) {
    sum[i] += sum[i - 1];
  }
  ll ans = 1e18;
  int left = 0, right = 2;
  //切れ目の真ん中は n-3 こ
  for (int i = 1; i <= n - 3; ++i) {
    if (i == right)
      right++;
    ll pre_gap = sum[i];
    //左の切れ目を探す
    for (int j = left; j < i; ++j) {
      ll gap = abs(sum[i] - sum[j] - sum[j]);
      if (gap > pre_gap)
        break;
      else {
        pre_gap = gap;
        left = j;
      }
    }
    //右の切れ目を探す
    pre_gap = sum.back() - sum[i];
    for (int j = right; j <= n - 2; ++j) {
      ll gap = abs(sum.back() - sum[j] - (sum[j] - sum[i]));
      if (gap > pre_gap)
        break;
      else {
        pre_gap = gap;
        right = j;
      }
    }
    // cout << left << " " << i << " " << right << endl;
    ll p = sum[left], q = sum[i] - p, r = sum[right] - p - q,
       s = sum.back() - p - q - r;
    ans = min(ans, max({p, q, r, s}) - min({p, q, r, s}));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
from math import sqrt
def main():
    ins=[]
    x=0
    y=0
    while True:
        x,y=map(int,input().split())
        if x==0 and y==0:
            break
        if x<y:
            ins.append(f"{x} {y}")
        else:
            ins.append(f"{y} {x}")
    for i in range(len(ins)):
        print(ins[i])
    return 0
if __name__ == "__main__":
    main()


Measured memory_bytes: 5948
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    Int N, T;

    void solve() {
        cin >> N >> T;
        vector<Int> A(N);
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
        }
        A.push_back(INFl);

        Int ans = 0;
        for (int i = 0; i < N; ++i) {
            Int tmp = min(A[i + 1] - A[i], T);
            ans += tmp;
        }
        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


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

using namespace std;

#define INF 0x3f3f3f3f

int val[105];
int weight[105];
int n, W;

int dp[105][100005];


int main(){
    
    cin >> n >> W;
    
    memset(dp, INF, sizeof(dp));
    
    for(int i=1; i<=n;i++){
        cin >> weight[i] >> val[i];
    }
    
    dp[0][0] = 0;
    
    // dp[i][v] = menor peso possivel para ver ate o item i com exatamente valor v
    for(int i=1; i<=n; i++){

        dp[i][0] = 0;
        
        for(int v=1; v<=100001; v++){
            
            dp[i][v] = dp[i-1][v];
            
            if(v >= val[i]){
                dp[i][v] = min(dp[i-1][v-val[i]] + weight[i], dp[i][v]);
            }
        
        }
    
    }
    
    for(int v=100000; v>=0; v--){
        if(dp[n][v] <= W){
            cout << v << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 41344
#include <algorithm>
#include <iterator>
#include <iostream>
#include <utility>
#include <string>
#include <vector>

using namespace std;

bool dfs(int v, const vector<vector<int> >& g, int depth)
{
    if(depth == 2)
        return false;

    for(size_t i = 0; i < g[v].size(); i++) {
        if(g[v][i] + 1 == g.size())
            return true;
        if(dfs(g[v][i], g, depth + 1))
            return true;
    }

    return false;
}

int main()
{
    int n, m;
    cin >> n >> m;
    
    vector<vector<int> > g(n);

    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
    }

    if(dfs(0, g, 0)) {
        cout << "POSSIBLE" << endl;
        return 0;
    }

    
    cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
int a[105],b[105];
int main(){
	cin >> N;
	for(int i=0;i<N;i++)cin >> a[i];
	for(int i=0;i<N;i++)cin >> b[i];
	for(int i=1;i<N;i++)a[i]+=a[i-1];
	for(int i=N-2;i>=0;i--)b[i]+=b[i+1];
	int ans = 0;
	for(int i=0;i<N;i++){
		ans = max(ans,a[i]+b[i]);
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    cout << fixed;
    int N;
    cin >> N;
    if (N%2==0)
    {
        cout << setprecision(9) << (double)N/(2.0*(double)N) << endl;
    }
    else{
        cout <<  setprecision(9) << ((double)N+1.0)/(2.0*(double)N) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
E,W = [0]*(N+1), [0]*(N+1)
ans = 10 ** 9

for i in range(N):
    E[i+1], W[i+1] = E[i], W[i]
    if S[i] == 'E':
        E[i+1] += 1
    else:
        W[i+1] += 1

for j in range(N):
    tmp = E[N]-E[j+1]+W[j]
    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 17568
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

int R, C, N;
bool onEdge(int x1, int y1, int x2, int y2) {
  bool on1 = x1 == 0 || x1 == R || y1 == 0 || y1 == C;
  bool on2 = x2 == 0 || x2 == R || y2 == 0 || y2 == C;
  return on1 && on2;
}

const int offset = 1000000000;

signed main() {
  cin >> R >> C >> N;
  vector<int> x1(N), y1(N), x2(N), y2(N);
  vector<int> X, Y, ID;


  rep(i, N) {
    cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
    if (onEdge(x1[i], y1[i], x2[i], y2[i])) {
      X.pb(x1[i]), X.pb(x2[i]);
      Y.pb(y1[i]), Y.pb(y2[i]);
      ID.pb(i), ID.pb(i);
    }
  }

  typedef pair<int, int> P;  // pos, id
  vector<P> ps;
  rep(i, len(X)) {
    int id = ID[i];
    int x = X[i], y = Y[i];
    int pos;
    if (x == 0)
      pos = y;
    else if (y == C)
      pos = offset + x;
    else if (x == R)
      pos = offset * 2 + (C - y);
    else
      pos = offset * 3 + (R - x);
    ps.pb(P(pos, id));
  }
  sort(all(ps));

  vector<bool> seen(N, false);

  stack<int> st;
  for (auto p : ps) {
    int id = p.se;
    if (seen[id]) {
      if (id != st.top()) {
        cout << "NO\n";
        return 0;
      } else {
        st.pop();
      }
    } else {
      st.push(id);
      seen[id] = true;
    }
  }
  cout << "YES\n";
}

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

namespace ALDS1_15_A
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            int res = 0;
            int[] coins = new int[] {25,10,5,1};

            for (int i = 0 ; i < coins.Length ; i++)
            {
                res += n / coins[i];
                n %= coins[i];
            }

            Console.WriteLine(res.ToString());
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 19996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
ll dp[440][440], flag[440][440], cum[440];
ll calc(int l, int r){
    if(flag[l][r]) return dp[l][r];
    flag[l][r] = 1;
    if(l==r) return 0;
    ll res = LINF;
    FOR(i, l, r)
        res = min(res, calc(l, i)+calc(i+1, r));
    return dp[l][r] = res +cum[r]-cum[l-1];
}


int main(){
    ll n;   cin >> n;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
        cum[i+1] = cum[i]+a[i];
    }
    
    calc(0, n);
    cout << dp[1][n] << endl;

}


Measured memory_bytes: 6364
// 2014/06/03 Tazoe

#include <iostream>
#include <string>
using namespace std;

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

	int N;
	cin >> N;

	int cnt = 0;

	for(int i=0; i<N; i++){
		string R;
		cin >> R;

		R = R+R;

		if(R.find(S)!=string::npos){
			cnt++;
		}
	}

	cout << cnt << '\n';

	return 0;
}

Measured memory_bytes: 1212
import java.util.Scanner;

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

		// ?????°??£?¨?
		int n = 0;
		int x = 0;
		int count = 0;

		while ( true ) {
			
			// ??\?????????
			n = sc.nextInt ();
			x = sc.nextInt ();

			if ( n == 0 && x == 0 ) {
				System.exit ( 0 );
			}

			// ???????????????
			for ( int i = 1; i <= n; i++ ) {
				for ( int j = i + 1; j <= n; j++ ) {
					for ( int k = j + 1; k <= n; k++ ) {
						if ( i + j + k == x ) {
							count++;
						}
					}
				}
			}
			System.out.println ( count );
			count = 0;
		}
	}
}

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

int main () {
  int n;
  cin >> n;
  vector<int> a(n);
  set<int> b;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b.insert(a[i]);
  }

  if (a.size() == b.size()) cout << "YES";
  else cout << "NO";
}


Measured memory_bytes: 10368
import re

s = input()


def is_valid_yymm(s):
    match = re.search('^[0-9]{2}(01|02|03|04|05|06|07|08|09|10|11|12)$', s)
    return bool(match)
    

def is_valid_mmyy(s):
    match = re.search('^(01|02|03|04|05|06|07|08|09|10|11|12)[0-9]{2}$', s)
    return bool(match)


if is_valid_yymm(s) and is_valid_mmyy(s):
    print('AMBIGUOUS')
elif is_valid_yymm(s):
    print('YYMM')
elif is_valid_mmyy(s):
    print('MMYY')
else:
    print('NA')


Measured memory_bytes: 9892
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define eb emplace_back
#define PI 3.14159265
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.rbegin(), c.rend()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double ld;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
vector<vll> dp(3005, vll(3005, -1));
ll dfs(int nd, int l, int r, vpll &a)
{
    if (l > r)
    {
        return 0;
    }
    else if (dp[l][r] != -1)
    {
        return dp[l][r];
    }
    return dp[l][r] = max(a[nd].F * abs(a[nd].S - l) + dfs(nd + 1, l + 1, r, a),
               a[nd].F * abs(a[nd].S - r) + dfs(nd + 1, l, r - 1, a));
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, l, r;
    cin >> n;
    vpll a(n);
    fr(i, 0, n)
    {
        cin >> a[i].F;
        a[i].S = i;
    }
    sort(all(a));
    ll ans = dfs(0, 0, n - 1, a);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 74548
using System;

class Program
{
    static void Main()
    {
        int D =int.Parse(Console.ReadLine());

        switch (D)
        {
            case 22:
                Console.WriteLine("Christmas Eve Eve Eve");
                break;
            case 23:
                Console.WriteLine("Christmas Eve Eve");
                break;
            case 24:
                Console.WriteLine("Christmas Eve");
                break;
            case 25:
                Console.WriteLine("Christmas");
                break;
            default:
                break;
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>

#define IS_BIT(i, j) (((i) & (1 << j)) ? 1 : 0)

int main(int argc, char* argv[]) {
    int a[20];
    int m[200];
    int n, i, j, d, c, q, k;
    int max_check = 1;

    scanf("%d\n", &n);
    for ( i = 0; i < n; i++ ) {
        scanf("%d", &d);
        a[i] = d;
        c = getc(stdin);        /* space */
    }
    if ( c == '\r' ) {
        c = getc(stdin);
    }
    assert( c == '\n' );

    scanf("%d\n", &q);
    for ( i = 0; i < q; i++ ) {
        scanf("%d", &d);
        m[i] = d;
        c = getc(stdin);        /* space */
    }
    if ( c == '\r' ) {
        c = getc(stdin);
    }
    assert( c == '\n' );

    for ( i = 0; i < n; i++ ) {
        max_check = max_check * 2;
    }

    for ( k = 0; k < q; k++ ) {
        int hit = 0;
        for ( i = 1; i < max_check; i++ ) {
            int sum = 0;
            for ( j = 0; j < n; j++ ) {
                int bit = IS_BIT(i, j);
                sum = sum + bit * a[j];
                if ( sum > m[k] ) {
                    break;
                }
            }
            if ( sum == m[k] ) {
                hit = 1;
                break;
            }
        }
        if ( hit ) {
            printf("yes\n");
        } else {
            printf("no\n");
        }
    }

    return 0;
}



Measured memory_bytes: 2136