akhauriyash/Code-Regression huggingface dataset:
# ペンキの種類を求めよ

abc = input()

ls_abc = abc.split()
len_abc = len(ls_abc)

for i in range(len_abc):
    ls_abc[i] = int(ls_abc[i])

# print(ls_abc)

counter = {}
# この状態では，カウンターがからッぽ．０にするためには１８．１９行目
for i in range(len_abc):
    x = ls_abc[i]

    if not x in counter:
        counter[x] = 0

    counter[x] = counter[x] + 1

print(len(counter))

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

char s[200009];
LL cnt[26], n, ans;

int main(){
	scanf("%s", &s);
	n = strlen(s);
	for (int i=0; s[i]; i++)
		cnt[s[i]-'a']++;
	ans = n*(n-1)/2+1;
	for (int i=0; i<26; i++)
		ans -= cnt[i]*(cnt[i]-1)/2;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(void){
string s;cin>>s;
char x[5];
strcpy(x,s.c_str());
for(int i=0;i<3;i++)
    if(x[i]==x[i+1])
        {cout<<"Bad"<<endl;return 0;}
cout<<"Good"<<endl;

return 0; }


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

#define rep(i, e) for (int i = 0; i < e; i++)
#define repp(i, s, e) for (int i = s; i < e; i++)
#define N_Max 100
#define Card_Max 36
#define ll long long

int dy[] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dx[] = {-1, 0, 1, 1, 1, 0, -1, -1};

int main()
{
    int n; cin>>n;
    for(int i=1; ; i++){
        if(i*i > n)
        {
            cout << (i-1)*(i-1) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i< (n);i++)
using namespace std;
int main(){
    int r;
    cin >> r;
    string ans;
    if(r < 1200) ans = "ABC"; 
    else if(r < 2800) ans = "ARC";
    else ans = "AGC";
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys


def resolve(in_):
    S = next(in_).strip()
    T = next(in_).strip()

    ans = 0
    for i in range(len(S)):
        if len(S) - i < len(T):
            break
        v = 0
        for x, y in zip(S[i:], T):
            if x == y:
                v += 1
            ans = max(ans, v)
    
    return len(T) - ans
    

def main():
    answer = resolve(sys.stdin)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9028
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }
int main(){
  int ans = 0;
  int N;
  string S;
  cin >> N >> S;
  for(int i=0; i<=999; ++i){
    std::ostringstream sout;
    sout << setfill('0') << setw(3) << i;
    string str = sout.str();
    int flg = 0;
    for(int j=0; j<N; ++j){
      if(S[j]==str[flg]) ++flg;
      if(flg==3){
        ++ans;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s):
    if 'LOCAL' in os.environ:
        print(s)

def main():
    global PX, nodes
    if 'BIG' in os.environ:
        N = 2* 10** 5
        Q = 2 * 10 ** 5
        AB = [[i, i + 1] for i in range(1, N)]
        PX = [[i, 10] for i in range(Q)]
    else:
        N, Q = LI()
        #  AB = []
        nodes = [[] for _ in range(N+1)]
        PX = [0] * (N+1)
        for i in range(N-1):
            a, b = LI()
            #  AB += (a, b)
            nodes[a].append(b)
            nodes[b].append(a)

        for i in range(Q):
            p, x = LI()
            PX[p] += x
        dfs(1, -1)
        print(' '.join(map(lambda x: str(x), PX[1:])))
        #  for i in PX[1:]:
        #      print(i, end=' ')
        #  ans = [0 for _ in range(N)]

def dfs(parent, parent_parent):
    for node in nodes[parent]:
        if node != parent_parent:
            PX[node] += PX[parent]
            dfs(node, parent)

if __name__ == '__main__':
    main()


Measured memory_bytes: 235756
x = input()
 
def Combination(x):
  if x[0] == x[1] and x[2] == x[3] and x[0] != x[2]:
      return "Yes"
  elif x[0] == x[2] and x[1] == x[3] and x[0] != x[1]:
      return "Yes"
  elif x[0] == x[3] and x[1] == x[2] and x[0] != x[2]:
      return "Yes"
  else:
    return "No"
print(Combination(x))

Measured memory_bytes: 3064
N,M=map(int,input().split())
A=[];B=[]
for i in range(M):
    a,b=map(int,input().split())
    A.append(a);B.append(b)
G=[set() for i in range(N)]
for i in range(M):
    G[A[i]-1].add(B[i]-1)
    G[B[i]-1].add(A[i]-1)
ans=[-1 for i in range(N)]
from collections import deque
dist = [-1]*N
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for w in G[v]:
        if dist[w] > -1:
            continue
        dist[w] = d + 1
        que.append(w)
        ans[w]=v
ex=True
for i in range(1,N):
    if ans[i]==-1:
        ex=False
if ex:
    print("Yes")
    for i in range(1,N):
        print(ans[i]+1)
else:
    print("No")

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  ll n,k;cin>>n>>k;
  ll ans=0;
  for(int i=1;i<=n;i++){
    ll num=2*i;
    if(num%k==0){
      ll aaa=n+i;
      ll kosuu=aaa/k;
      ll nu=i/k;
      //cout<<aaa<<" "<<kosuu<<" "<<nu<<endl;
      if(kosuu-nu>0)
	ans+=(kosuu-nu)*(kosuu-nu);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
// AOJ 1290: Traveling Cube
// 2017.10.20 bal4u@uu

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

typedef struct { char r, c, d[3], n; int s; } Q;
Q q[100000]; int top, end;

#define RED     1		// top  r
#define MAGENTA 2		// south  m
#define BLUE    3		// east  b
#define YELLOW  4		// west  y
#define GREEN   5		// north  g
#define CYAN    6		// bottom c
#define WHITE   7		// w
#define BLACK   8       // k

char map[32][32];
char mk[32][32][6][6][6];
char seq[7];
int mv[4][2] =  {{-1,0},{0,1},{1,0},{0,-1}};
int rot[4][3] = {{2,6,3},{4,2,1},{5,1,3},{3,2,6}};
int tr['z'];

int main()
{
	int w, d, i, r, c, n, r2, c2, n2, s, ans;
	char dice[7], dice2[7];

	tr['r'] = RED, tr['m'] = MAGENTA, tr['b'] = BLUE, tr['c'] = CYAN, tr['g'] = GREEN, tr['y'] = YELLOW;
	tr['w'] = WHITE, tr['k'] = BLACK;
	while (scanf("%d%d", &w, &d) && w > 0) {
		memset(mk, 0, sizeof(mk));
		for (r = 0; r < d; r++) {
			scanf("%s", map[r]);
			for (c = 0; c < w; c++) {
				if (map[r][c] == '#') {
					q[0].r = r, q[0].c = c; map[r][c] = WHITE;
					q[0].d[0] = RED, q[0].d[1] = MAGENTA, q[0].d[2] = BLUE;
					q[0].n = 0, q[0].s = 0;
				} else map[r][c] = tr[map[r][c]];
			}
		}
		scanf("%s", seq); for (i = 0; i < 6; i++) seq[i] = tr[seq[i]];
		ans = -1; top = 0, end = 1;
		while (top < end) {
			r = q[top].r, c = q[top].c, n = q[top].n, s = q[top].s+1;
			memcpy(dice+1, q[top].d, 3); for (i = 4; i <= 6; i++) dice[i] = 7 - dice[7-i]; top++;
			for (i = 0; i < 4; i++) {
				r2 = r + mv[i][0], c2 = c + mv[i][1];
				if (r2 < 0 || r2 >= d || c2 < 0 || c2 >= w || map[r2][c2] == BLACK) continue;
				dice2[1] = dice[rot[i][0]],	dice2[2] = dice[rot[i][1]], dice2[3] = dice[rot[i][2]];
				if (map[r2][c2] == WHITE) n2 = n;
				else {
					if (dice2[1] != seq[n] || dice2[1] != map[r2][c2]) continue;
					if (n == 5) { ans = s; goto done; }
					n2 = n + 1;
				}
				if (mk[r2][c2][dice2[1]][dice2[2]][n]) continue;
				mk[r2][c2][dice2[1]][dice2[2]][n] = 1;
				q[end].r = r2, q[end].c = c2, q[end].n = n2, q[end].s = s;
				memcpy(q[end].d, dice2+1, 3); end++;
			}
		}
		if (ans < 0) puts("unreachable");
		else {
done:		printf("%d\n", ans);
		}
	}
	return 0;
}

Measured memory_bytes: 2700
#include <bits/stdc++.h>
#define INF 1023456789
#define sacnf scanf
#define CRLF <<'\n';
#define PRPAIR(x) x.first << x.second
#define DEBUG(x) do { std::cerr <<(x)<<'\n'; } while (0)
#define rep(i,a,b) for(int i=(a);i!=(int)b-((a)>(b));(a)>(b)?--i:++i)
#define trav(it,v) for(typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> pip;
typedef vector<int> vi;
typedef long long ll;

int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    int arr[n];
    rep(i,0,n){
        scanf("%d",&arr[i]);
    }
    sort(arr,arr+n);
    int c=0;
    rep(i,0,min(k,n)){
        c+= arr[i];
    }
    cout << c;

}


Measured memory_bytes: 3684
<?php
  $n = trim(fgets(STDIN));
  $s = trim(fgets(STDIN));
  $e = 0;
  for($i=0; $i<$n; $i++){
      if($s[$i] == "E"){
          $e++;
      }
  }
  $right = $e;
  $left = 0;
  $min = PHP_INT_MAX;
  for($i=0; $i<=$n; $i++){
      $ans = $right+$left;
      if($s[$i] == "W"){
          $left++;
      }else{
          $right--;
      }
      $min = min($min, $ans);
  }
  echo $min;


Measured memory_bytes: 4604
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
//#define mp make_pair
#define pii pair<int,int>
using namespace std;
void read(int &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void read(ll &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void Min(int &x,int y){	
	if (x>y)x=y;
}
void Min(ll &x,ll y){	
	if (x>y)x=y;
}
void Max(int &x,int y){	
	if (x<y)x=y;
}
void Max(ll &x,ll y){	
	if (x<y)x=y;
}


#define M 200005

int mp[M*5][26];
int len[M],n,id[M],tot,to[M*5][26];
string s[M];
bool cmp(int x,int y){
	return len[x]<len[y];
}
int cnt[26];
int main(){
//	freopen("1.in","r",stdin);
	read(n);
	int i,j,k,l;
	for (i=1;i<=n;i++){
		cin>>s[i];
		len[i]=s[i].length(); 
		id[i]=i;
	}
	ll res=0;
	sort(id+1,id+n+1,cmp);
	int p;
	for (k=1;k<=n;k++){
		i=id[k];
		for (j=0;j<len[i];j++)cnt[s[i][j]-'a']++;
		p=0;
		for (l=0;l<26;l++)if (cnt[l]){
			res+=mp[p][l];
		}
		for (j=len[i]-1;j>=1;j--){
			if (!to[p][s[i][j]-'a']){
				to[p][s[i][j]-'a']=++tot;
			}
			p=to[p][s[i][j]-'a'];
			cnt[s[i][j]-'a']--;
			for (l=0;l<26;l++)if (cnt[l]){
				res+=mp[p][l];
			}
		}
		mp[p][s[i][j]-'a']++;
		cnt[s[i][j]-'a']--;
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 160932
import math

A, B, H, M = map(int, input().split())

kaku_a = 360 * (H/12) + 360 * (M/60/12)
#print(kaku_a)
kaku_b = 360 * (M/60)
#print(kaku_b)
kaku_c = abs(kaku_a - kaku_b)
if kaku_c > 180:
    kaku_c = 360 - kaku_c

ans = A**2 + B**2 - 2*A*B*math.cos(math.radians(kaku_c))
ans = math.sqrt(ans)

print(ans)


Measured memory_bytes: 9508
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<map>
#include<bitset>
#include<queue>
#define lson (rt << 1)
#define rson (rt << 1 | 1)
const int maxn = 100+50;
const int maxm = 4e5 + 10;
const int inf_max = 0x3f3f3f;
using namespace std;
typedef long long ll;
int k,a,b;
int main()
{
    cin>>k>>a>>b;
    int ok = 0;
    for(int i = 1;i <= 10000;i++) {
        if(k * i >= a && k * i <=b) ok = 1;
    }
    if(ok) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3624
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() throws IOException{
		out.println(br.readLine().replaceAll("apple","TEMP").replaceAll("peach","apple").replaceAll("TEMP","peach"));
	}

	public static void main(String[] args) throws Exception {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		br.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 24564
#include<iostream>
#include<cstdio>
using namespace std;
const int magic=307;
int n,x[111111],l,q,a,b,nxt[111111],bignxt[111111],pos,ans;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&x[i]);
	scanf("%d",&l);
	pos=n;
	for (int i=n;i>=1;i--)
	{
		while(pos>=1 && x[pos]-x[i]>l) pos--;
		nxt[i]=pos;
	}
	for (int i=1;i<=n;i++)
	{
		pos=i;
		for (int j=1;j<=magic;j++)
		{
			pos=nxt[pos];
		}
		bignxt[i]=pos;
	}
	scanf("%d",&q);
	while(q--)
	{
		scanf("%d%d",&a,&b);
		if (a>b) swap(a,b);
		ans=0;
		while(bignxt[a]<b) 
		{
			ans+=magic;
			a=bignxt[a];
		}
		while(nxt[a]<b) 
		{
			ans++;
			a=nxt[a];
		}
		if (a!=b) ans++;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2048
N = int(input())

one = (0, 0)
two = (0, 0)
for i in range(N):
    A = int(input())
    if A > one[0]:
        two = one
        one = (A, i)
    elif A > two[0]:
        two = (A, i)

for i in range(N):
    if i == one[1]:
        print(two[0])
    else:
        print(one[0])


Measured memory_bytes: 55816
use std::io;


/// https://beta.atcoder.jp/contests/arc058/tasks/arc058_a
fn main() {
    let (n, _k) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let d = read::<usize>();
    let mut ans = 0;
    for i in n.. {
        let mut tmp = i;
        let mut flg = true;
        while tmp > 0 {
            if d.binary_search(&(tmp % 10)).is_ok() { flg = false; }
            tmp /= 10;
        }
        if flg { ans = i; break; }
    }

    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <stdio.h>
 
int main() {
 
  long long i,j,k,n,m,l,a,b,c;
  long long A[101][101] = {0};
  long long B[101][101] = {0};
  long long C[101][101] = {0};
 
  scanf("%lld %lld %lld",&n,&m,&l);
 
  for(j=0; j<n; j++) {
    for(i=0; i<m; i++) {
 
      scanf("%lld", &a);
      A[j][i] = a;
     
    }
  }
 
  for(j=0; j<m; j++){
    for(i=0;i<l;i++){
      scanf("%lld",&b);
      B[j][i] = b;
    }
  }
 
    for(i=0 ;i<n; i++) {
      for(j=0; j<l; j++){
    C[i][j] = 0;
    for(k=0;k<m; k++) {
       C[i][j] += A[i][k]*B[k][j];  
       /*    printf("%d ",C[i][j]); */
    }
    /* printf("\n"); */
      }
    }
 
 
     for(i=0; i<n; i++) {
      for(j=0; j<l; j++) {
    printf("%lld",C[i][j]);
    if(j !=l-1) {
      printf(" ");
    }
      }
      printf("\n");
      } 
 
    return 0;
 
  }


Measured memory_bytes: 2148
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
				int n = scan.nextInt();
				if(n == 0){
					break;
				}
				int count = 0;
				while(n != 1){
					if(n % 2 == 0){
						n /= 2;
					}else{
						n = 3 * n + 1;
					}
					count++;
				}
				System.out.println(count);
		}
		
	}
}

Measured memory_bytes: 17204
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[]  args) {
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		scanner.close();
		
		int[] fib = new int[n + 1];
		for (int i = 0; i <= n; i ++) {
			fib[i] = (i < 2) ? 1: fib[i - 1] + fib[i - 2];
		}
		
		System.out.println(fib[n]);
	}
} 



Measured memory_bytes: 26200
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=1000000007LL;
const ll MOD=998244353LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

int main(){
  ll n,m;cin>>n>>m;
  vl a(m),b(m);
  rep(i,m)cin>>a[i]>>b[i];
  map<ll,ll>M;
  rep(i,m){
    M[a[i]]++;
    M[b[i]]++;
  }
  for(auto p:M){
    if(p.second%2!=0){
      cout<<"NO"<<endl;
      return 0;
    }

  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 7168
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int q = scan.nextInt();
        String s = scan.next();
        int[] l = new int[q];
        int[] r = new int[q];
        for(int i = 0; i < q; i++){
            l[i] = scan.nextInt();
            r[i] = scan.nextInt();
        }
        int[] out = new int[n];
        for(int i = 1; i < n; i++){
            if(s.charAt(i) == 'C' && s.charAt(i - 1) == 'A'){
                Arrays.fill(out, i, n, out[i - 1] + 1);
            }
        }
        for(int i = 0; i < q; i++){
            System.out.println(out[r[i] - 1] - out[l[i] - 1]);
        }
    }

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


Measured memory_bytes: 64236
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
	int N;
	cin >> N;
	vector<LL> input;
	for(int i=0; i<N; i++) {
		LL p;
		cin >> p;
		input.push_back(p);
	}
	
	input.push_back(2000000000);
	input.push_back(0);
	sort(input.begin(), input.end());
	vector<LL> ret;
	reverse(input.begin(), input.end());
	
	int x ;
	int cnt =0;
	bool ok = false;
	for(int i=0; i<input.size(); i++) {
		if(input[i] < i) {
			x = i-1;
			if(input[x+1] == x) {
				int y = x+1;
				while(input[y] == x) {
					y++;
				}
				y--;
				
				if( (y+input[y]) % 2 == 1) ok = true;
//				cout << y << " " << input[y] << endl;
			}
			if( (x + input[x]) % 2 == 1) ok = true;
//			cout << x << " " << input[x] << endl;
			
			break;
		}
	}
	
	string F = "First" ;
	string S = "Second" ;
	if(ok) {
		cout << F << endl;
	}
	else cout << S << endl;
	
	
	
	/*
	int a = color(x, x, input);
	int b = color(x+1, x-1, input);
	int c = color(x-1, x+1, input);
	
	if(a == 1 && (b==1 || c==1)) {
		
		
	}
	*/
	/*
	
	if(ret.size() %2 == 0) {
		vector<LL> tmp;
		for(int i=1; i<ret.size(); i++) {
			tmp.push_back(max(ret[i] , ret[i-1]));
		}
		ret = tmp;
	}
	int m = ret.size();
	if(m == 1) {
		if(ret[0] == 1) cout << F << endl;
		else cout <<S << endl;
	}
	else {
		if( (ret[m/2]==1 && ret[m/2-1]==1) || (ret[m/2]==1 && ret[m/2+1]==1)) {
			cout << F << endl;
		}
		else cout << S << endl;
	}
	*/
	return 0;
}



Measured memory_bytes: 1400
#include <stdio.h>
#include <stdlib.h>

int main(){
  
  char *str;
  int num;

  scanf("%d",&num);
  str = malloc(sizeof(char) * num);

  scanf("%s",str);

  int i;

  int Rcnt = 0;
  int Lcnt = 0;

  for(i = 0; i < num; i++){
    if(str[i] == '(')
      Lcnt++;

    if(str[i] == ')')
      if(Lcnt == 0)
        Rcnt++;
      else
        Lcnt--;
  }

  for(i = 0; i < Rcnt; i++){
    printf("(");
  }

  printf("%s",str);

  for(i = 0; i < Lcnt; i++){
    printf(")");
  }
  free(str);
  return 0;
}

Measured memory_bytes: 128
/**
 * abc 160 a
 * Kartikeya (doomsday861)
**/
#include<bits/stdc++.h>
#include<time.h>
#define ll long long
#define testcase ll t;cin>>t;while(t--)
#define timeb  auto start = high_resolution_clock::now(); 
#define timee auto stop = high_resolution_clock::now();auto duration = duration_cast<seconds>(stop - start);cout << "Time taken by function: "<<duration.count() << "seconds" << endl; 
using namespace std;
int main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
using namespace std::chrono;
//timeb
 string s;
 cin >>s;
 if(s[2]==s[3] && s[4]==s[5])
 	cout<<"Yes"<<endl;
 else
 	cout<<"No"<<endl;
//timee
    return 0; 
} 

Measured memory_bytes: 256
# ???????¨?????????????????§£???
# ?????°?????¨?????¢??????????????¨???????????¢????????£???


def fibonacci(n):
    num1 = 1
    num2 = 1
    tmp = 1

    for i in range(1, n):
        tmp = num1 + num2
        num1 = num2
        num2 = tmp

    return tmp


if __name__ == '__main__':
    n = int(input())
    result = fibonacci(n)
    print(result)

Measured memory_bytes: 7692
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    x -= accumulate(ALL(v),0);
    sort(ALL(v));
    OUT(n + x / v[0])

    return 0;
}

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

using namespace std;

int powmod(long base, long exp, long mod){
    base %= mod;
    long result = 1;
    while (exp > 0){
        if(exp & 1){
            result = (result * base) % mod;
        }
        base = (base * base) % mod;
        exp >>= 1;
    }
    return result;
}

int mod_combination(long N, long A, long M){
    A = min(A, N - A);
    long child = 1;
    for(long k = N; k > (N - A); k--){
        child = (child * k) % M;
    }

    long mother = 1;
    for(long k = 1; k <= A; k++){
        mother = (mother * k) % M;
    }
    long fermat = powmod(mother, M - 2, M);
    return (child * fermat) % M;
}

int main() {
    long N, A, B;
    long M = 1000000000 + 7;
    cin >> N >> A >> B;

    long a, b;
    a = mod_combination(N, A, M);
    b = mod_combination(N, B, M);
    long ans = powmod(2, N, M) - a - b - 1;
    while (ans < 0){
        ans += M;
    }
    cout << ans << endl;
    return 0;
}

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

int gcd(int a, int b)
{
    if(a < b) swap(a, b);
    if(b == 0) return a;
    else{
        return gcd(b, a%b);
    }
}

int main(void)
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ans = gcd(a[0], a[1]);
    rep(i, n-2)
    {
        ans = gcd(ans, a[i+2]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;
int a[101010];
const LL mod = 1e9 + 7;
int main(){
    cin >> n;
    REP(i, n)cin >> a[i];
    LL ans = 1;
    int cnt = 0;
    REP(i, n){
        if(a[i] < 2 * cnt + 1){
            ans *= (cnt + 1);
            ans %= mod;
        }else{
            cnt++;
        }
    }
    for(int i = 1;i <= cnt;i++){
        ans *= i;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main(){
  int n;
  cin >> n;
  ll cnt=1;
  vector<string> s(n);
  for(int i; i<n; i++) cin >> s.at(i);
  sort(s.begin(), s.end());
  for(int i=1; i<n; i++) {
    if (s.at(i)!=s.at(i-1)) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 9600
#include <stdio.h>

using namespace std;
#define MAX(a,b) (a>b?a:b)
int main(){
  int num, cap;
  scanf("%d %d", &num,&cap);
  int itens[num+1][2];
  for (size_t i = 1; i < num+1; i++) {
      scanf("%d %d",itens[i],itens[i]+1);
    // printf("%d %d\n",itens[i][0],itens[i][1]);
  }
  num++,cap++;
  long long parciais[num][cap];
  for (size_t i = 0; i < cap; i++) {
    parciais[0][i] = 0;
  }
  for (size_t i = 1; i < num; i++) {
    for (size_t j = 0; j < cap; j++) {
      if(j < itens[i][0])
        parciais[i][j] = parciais[i-1][j];
      else
        parciais[i][j] = MAX(parciais[i-1][j],(long long)itens[i][1] + parciais[i-1][j-itens[i][0]]);
    }
  }
  // printf("   ");
  // for (size_t i = 0; i < num; i++) {
  //   printf("qtd%d            ", i);
  // }
  // printf("\n");
  // printf("\n");
  // for (size_t i = 0; i < cap; i++) {
  //   printf("%d  ", i);
  //   for (size_t j = 0; j < num; j++) {
  //     printf("%02lld              ", parciais[j][i]);
  //   }
  //   printf("\n\n");
  // }

  num--,cap--;
  printf("%lld\n",parciais[num][cap]);
}


Measured memory_bytes: 79104
import java.util.Scanner;


class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int x , y;
		int a = 0;
		while(a==0){
			x = scan.nextInt();
			y = scan.nextInt();
			if(x == 0 && y == 0){
				 a=1;
				 break;
			}else if(x > y){
					System.out.println(y + " " + x);
				}else{
					System.out.println(x + " " + y);
			}
		}
	}
}


Measured memory_bytes: 36108
int main(){
    int a;
    int b;
    int x;
    while(1){
        scanf("%d %d",&a,&b);
        if(a==0 && b==0)
            break;
        if(a>b){
            x=a;
            a=b;
            b=x;
        }
        printf("%d %d\n",a,b);
    }
    return 0;
}

Measured memory_bytes: 1712
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
    int N, A, B;
    cin >> N >> A >> B;

    cout << min(A, B) << " " << max(0, min(A, B) - (N - max(A, B))) << endl;
}

Measured memory_bytes: 256
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

N = int(input())
A = list(map(int, input().split()))
B = [A[0]]
C = [A[N-1]]
for i in range(1,N):
  B.append(gcd(A[i],B[i-1]))
  C.append(gcd(A[N-i-1],C[i-1]))
D = [C[N-2]]
for j in range(N-2):
  D.append(gcd(B[j],C[N-j-3]))
D.append(B[N-2])
print(max(D))

Measured memory_bytes: 14488
#include <atcoder/segtree>
#include <cstdio>
#include <iostream>
#include <vector>
#define MAXN 300000

using namespace std;

template <typename T> void read(T& x) {
    x = 0;
    char c = getchar();
    T sig = 1;
    for (; !isdigit(c); c = getchar())
        if (c == '-') sig = -1;
    for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
    x *= sig;
}

int op(int a, int b) { return max(a, b); }
int e() { return 0; }

int main() {
    int n, k;
    read(n), read(k);
    vector<int> a(n);
    for (int i = 0; i < n; ++i) read(a[i]);
    atcoder::segtree<int, op, e> seg(MAXN + 1);
    int ans = 1;
    seg.set(a[0], 1);
    for (int i = 1; i < n; ++i) {
        int l = max(0, a[i] - k);
        int r = min(MAXN, a[i] + k);
        int hi = seg.prod(l, r + 1);
        seg.set(a[i], hi + 1);
        ans = max(ans, hi + 1);
    }
    cout << ans;
}

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

typedef long long int ll;
#define INF (ll)(1e18)

int main(void){
  int N;
  ll K;
  cin >> N;
  cin >> K;
  vector<ll> v;
  for(int i=0;i<N;i++){
    ll ai;
    cin >> ai;
    v.push_back(ai);
  } 
  sort(v.begin(),v.end());
  ll l=-INF;
  ll r= INF+1;
  while(r-l>1){
    ll c = (l+r)/2;
    //cout << c << endl;
    ll sum = 0;
    for(int i=0;i<N;i++){
      if(v[i] >= 0){
	int lin = -1;
	int rin = N;
	//v[l]*v[i] <= cなる最大のlを探す
	while(rin-lin>1){
	  int cin = (lin+rin)/2;
	  if(v[i]*v[cin] < c){
	    lin = cin;
	  }else{
	    rin = cin;
	  }
	}
	//このときの個数は
	//cout << "+" << c << "," << v[i] << ":" << rin << endl;
	sum = sum + rin;
      }else{
	int lin = -1;
	int rin = N;
	while(rin-lin > 1){
	  int cin = (lin+rin)/2;
	  if(v[i]*v[cin] < c){
	    rin = cin;
	  }else{
	    lin = cin;
	  }
	}
	//cout << "-" << c << "," << v[i] << ":" << N - rin << endl;
	sum = sum + N - rin;
      }
      if(v[i]*v[i]<c){
	sum = sum - 1;
      }
    }
    //sumで場合分け
    sum = sum/2;
    //cout << "sum:" << sum << endl;
    if(sum < K){
      l = c;     
    }else{
      r = c;
    }
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define inf 1000000000
#define mod 1000000007
using namespace std;
using LL = long long;

int GCD(int a,int b){
    if(a>b)return GCD(b,a);
    if(b%a==0)return a;
    return GCD(b%a,a);
}

int main(){
    int n;cin>>n;
    vector<int> a(n);for(int i=0;i<n;i++)cin>>a[i];
    int g=a[0];
    for(int i=0;i<n;i++)g=GCD(g,a[i]);
    int ans=0;
    while(g%2==0){ans++;g/=2;}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=1e6+5;
int sum[N],suf[N],n;
char s[N];

int calc(int mi){
	int ma=0,tot=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='?'&&suf[i]-tot-2>=mi) tot+=2;
		ma=max(ma,sum[i]-tot);
	}
	return ma-mi;
}

signed main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+(s[i]!='0')-(s[i]=='0');
	suf[n]=sum[n];
	for(int i=n-1;~i;i--) suf[i]=min(suf[i+1],sum[i]);
	write(min(calc(suf[0]-1),calc(suf[0])));
}

Measured memory_bytes: 12508
int a[9][9][11],b,f,r,v,n;
main(){for(scanf("%d",&n);n--;scanf("%d%d%d%d",&b,&f,&r,&v),a[b][f][r]+=v);for(b=0;b++<4;b>3?:puts("####################"))for(f=0;f++<3;puts(""))for(r=0;r++<10;printf(" %d",a[b][f][r]));exit(0);}

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

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<char>> a(50, vector<char>(50)), b(50, vector<char>(50));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < m; j++) {
			cin >> b[i][j];
		}
	}
	bool ans = false;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i + m - 1 >= n || j + m - 1 >= n)continue;
			bool t = true;
			for (int k = 0; k < m; k++) {
				for (int l = 0; l < m; l++) {
					if (a[i + k][j + l] != b[k][l])t = false;
				}
			}
			if (t)ans = true;
		}
	}

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

now = a.first

ans = 0

if n == 1
  p 0
  exit
end

1.upto(n-1) do |i|
  t = a[i]
  if t >= now
    now = t
  else
    hu = now - t
    ans += hu
  end
end
p ans


Measured memory_bytes: 30312
#include <cstdio>
#include <cstring>

int main()
{
  long long k;
  char s[101];
  scanf("%s %lld", s, &k);
  long long len = strlen(s);
  long long count = 0;
  if (s[0] != s[len - 1])
  {
    char last;
    for (char *p = s; *p;)
    {
      last = *p;
      char* start = p;
      while (*p == last)
      {
        ++p;
      }
      long long c = p - start;
      count += c / 2;
    }
    count *= k;
  }
  else
  {
    bool all = true;
    for (long long i = 0; i < len - 1; ++i)
    {
      if (s[i] != s[i + 1])
      {
        all = false;
        break;
      }
    }
    if (all)
    {
      count = k * len / 2;
    }
    else
    {
      char *p = s;
      char *q = s + len - 1;
      while (*p == *s)
      {
        ++p;
      }
      while (*q == *s)
      {
        --q;
      }
      ++q;
      long long first = p - s;
      long long end = s + len - q;

      char last;
      for (char *a = p; a != q;)
      {
        last = *a;
        char* start = a;
        while (*a == last)
        {
          ++a;
        }
        long long c = a - start;
        count += c / 2;
      }
      count = count * k + first / 2 + end / 2 + ((first + end) / 2) * (k - 1);      
    }
  }
  printf("%lld\n", count);
  return 0;
}


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

int main(){
  int n;
  cin>> n;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin>> a.at(i);
  
  set<int> s;
  for (int i=n-1; i>=0; i--){
    int num=0;
    for (int j=1; (i+1)*j<=n; j++){ //=の入れ忘れ？
      if(s.count((i+1)*j)) num++;
    }
    if (num%2!=a.at(i)) s.insert(i+1);
  }
  cout<<s.size()<<endl;
  for (auto i: s) cout<< i <<" ";
}

Measured memory_bytes: 7808
import sys
"""
for line in sys.stdin:
    A, B, C = map(int, line.split())
"""
for line in sys.stdin:
    N = int(line)

cnt = 0
for n in range(1,N+1):
  n = str(n)
  if len(n) % 2 != 0:
    cnt += 1

print(cnt)

Measured memory_bytes: 2940
# include <algorithm>
# include <cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<cstdlib>
using namespace std;
namespace fastio{
	template<typename tn> void read(tn &a){
	    tn x=0,f=1;char c=' ';
	    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	    for(;isdigit(c);c=getchar() ) x=x*10+c-'0';
	    a=x*f;
	}
	template<typename tn> void print(tn a){
	    if(a<0) putchar('-'),a=-a;
	    if(a>9) print(a/10);
	    putchar(a%10+'0');
	}
};
using namespace fastio;
char c[10005]; 
int n;
int main(){
	read(n);
	cin>>c;
	int len=strlen(c);
	for(int i=0;i<len;i++) c[i]=(c[i]+n-'A')%26+'A';
	for(int i=0;i<len;i++) putchar(c[i]);
	puts("");
	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
bool isPali(string s){
	string rev(s);
	reverse(rev.begin(), rev.end());
	return s==rev;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	cin>>s;
	int len = s.size();
	cout<<(isPali(s) && 
	isPali(string(s.begin(), s.begin() + (len-1)/2)) &&
	isPali(string(s.begin() + (len+3)/2-1, s.end()))?
	"Yes\n":"No\n");

	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 105000;

int n;
int cnt[MAXN];
long long ans;

int main() { 

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &cnt[i]);
  }

  for (int i = 0; i < n; i++) {
    if (i > 0) {
      int use = min(cnt[i - 1], cnt[i]);
      ans += use;
      cnt[i] -= use;
    }
    ans += cnt[i] / 2;
    cnt[i] %= 2;
  }

  cout << ans << endl;

  return 0;
}


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

class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] a = new int[n];
        int[] c = new int[n + 1];

        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
            c[i] = 0;
        }
        c[n] = 0;

        int m = 0;
        for (int i = 0; i < n; i++) {
            if (c[a[i]] == 0) {
                m++;
            }
            c[a[i]]++;
        }
        Arrays.sort(c);

        int answer = 0;
        for (int i = 0; i <= n; i++) {
            if (k >= m) {
                break;
            }
            if (c[i] > 0) {
                answer += c[i];
                k++;
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 69748
#include <stdio.h>
#include <limits.h>

int m[101][101],p[101],n;

int min(int a,int b){
  return a <b ? a :b ;
}

int main(){
  int i,j,k,l,n,q;

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

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=INT_MAX;
      for(k=i;k<=j-1;k++){
        q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
        m[i][j]=min(m[i][j],q);
      }
    }
  }
   printf("%d\n",m[1][n]);
   return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;

int dp[200005];
int ans[200005];
int A[200005];
int parent[200005];
int N;
vector<int> graph[200005]; // 0-indexed

void dfs(int cur) {
    int a = A[cur];
    int index = lower_bound(dp, dp+N, a) - dp;
    int old = dp[index];
    dp[index] = a;
    ans[cur] = lower_bound(dp, dp+N, INF) - dp;
    for (auto next : graph[cur]) {
        if (next == parent[cur]) continue;
        parent[next] = cur;
        dfs(next);
    }
    dp[index] = old;
}

int main() {
    // LIS, dp, dfs, rollback
    cin >> N;
    rep(i, N) cin >> A[i];
    memset(parent, -1, N);
    rep(i, 200005) dp[i] = INF;
    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    dfs(0);
    rep(i, N) {
        cout << ans[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 32072
//package Soccor;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] score = new int[N];
		int[] order = new int[N];
		for(int i = 0; i < order.length; i++) order[i] = 1;
		for(int i = 0; i < N * (N - 1) / 2; i++) {
			int A = sc.nextInt() - 1;
			int B = sc.nextInt() - 1;
			int C = sc.nextInt();
			int D = sc.nextInt();
			if(C > D) score[A]+= 3;
			else if(C < D) score[B]+= 3;
			else {
				score[A]++;
				score[B]++;
			}
		}
		//for(int i = 0; i < order.length; i++) System.out.println(score[i]);
		for(int i = 0; i < score.length - 1; i++) {
			for(int j = i + 1; j < score.length; j++) {
				if(score[i] < score[j]) order[i]++;
				else if(score[i] > score[j]) order[j]++;
			}
		}
		for(int i = 0; i < order.length; i++) System.out.println(order[i]);
	}

}

Measured memory_bytes: 41908
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vec;
 
#define vecc vector<vector<ll>>
#define LM LLONG_MAX
 
#define int long long int
#define P pair<ll,ll>
 
#define ff first
#define ss second
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
 
#define N 200005
#define MOD (ll)1000000007

ll dp[105][N],a[105][3];

ll solve(ll n,ll w)
{
      if(n<1 || w<1)           return 0;
      
      ll &ans=dp[n][w];
      
      if(ans!=0)        return ans;
      
      ans = solve(n-1,w);
      
      if(w>=a[n][1])
      ans = max(ans,a[n][2]+solve(n-1,w-a[n][1]));
      
      return ans;
}

signed main()
{
      FAST;
      
      ll n,w;
      cin>>n>>w;
      
      memset(dp,0,sizeof(dp));
      
      for(int i=1;i<=n;i++)
            cin>>a[i][1]>>a[i][2];
            
      cout<<solve(n,w)<<"\n";
      
}

Measured memory_bytes: 164352
import math

N, P = list(map(int, input().split()))

if N == 1:
    print(P)
else:
    for i in range(1, round(math.pow(P, 1 / N)) + 1):
        if P % (i ** N) == 0:
            now_max = i
    
    print(now_max)

Measured memory_bytes: 3060
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, a, b;
int p[2222];
int cnt[10];

int main(){
    INIT;
    cin >> n >> a >> b;
    REP(i, n){
        cin >> p[i];
        if(p[i] <= a)cnt[0]++;
        else if(p[i] <=b)cnt[1]++;
        else cnt[2]++;
    }
    cout << min({cnt[0], cnt[1], cnt[2]}) << endl;
}

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

const int N = 100010;

int n, m;
int problems[N];
int solved = 0;
int penalty = 0;
int wa[N];

signed main () {
  cin >> n >> m;
  while (m > 0) {
    m--;
    int p; string s;
    cin >> p >> s;
    if (problems[p] == 1) continue;
    if (s == "AC") {
      problems[p] = 1;
      solved++;
      penalty += wa[p];
    } else {
      wa[p]++;
    }
  }
  cout << solved << " " << penalty << endl;
  return 0;
}


Measured memory_bytes: 1664
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), y = sc.nextInt();
        for (int i = 0; i <= n; i++)
            for (int j = 0; j <= n-i; j++)
                if (i*10000 + j*5000 + (n-i-j)*1000 == y) {
                    System.out.println(i + " " + j + " " + (n - i - j));
                    return;
                }
        System.out.println("-1 -1 -1");
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871;
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
        cout << "3\n";
        return 0;
    }
    if(s[0] == 'R' && s[1] == 'R') {cout << "2\n"; return 0;}
    if(s[1] == 'R' && s[2] == 'R') {cout << "2\n"; return 0;}
	if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
        cout << "1\n";
        return 0;
	}
	cout << "0\n";
	return 0;
}


Measured memory_bytes: 3612
n = int(input())   
i = 1



while True:
    x = i
    if (x%3) == 0:
        print(" ",end="")
        print(i,end="")
    else:
        while True:
            
            if int(x%10) == 3:
                print(" ",end="")
                print(i,end="")
                break 
            x = x/ 10
            if x < 1:
                break
             
    
    i+=1
    if i > n:
        break
            
        
print("")


Measured memory_bytes: 6240
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Character L1 = sc.nextLine().charAt(0);
    Character L2 = sc.nextLine().charAt(1);
    Character L3 = sc.nextLine().charAt(2);
    System.out.println(L1.toString()+L2.toString()+L3.toString());
  }
}

Measured memory_bytes: 23764
n = int(input())
A = list(map(int, input().split()))
q = int(input())
B = list(map(int, input().split()))

s = set()
def check(i, m):
    if i == n:
        s.add(m)
        return
    check(i+1, m+A[i])
    check(i+1, m)

check(0,0)

for i in B:
    if i in s:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 5652
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	while(a>0&&c>0)
	{
		a-=d;
		c-=b;
	}
	if(c<=0)cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

int main(){
    int e[12];
    for(int i = 0; i < 12; i++) cin >> e[i];
    sort(e, e+12);

    if(e[0] == e[1] && e[1] == e[2] && e[2] == e[3] && 
       e[4] == e[5] && e[5] == e[6] && e[6] == e[7] && 
       e[8] == e[9] && e[9] == e[10] && e[10] == e[11])
        cout << "yes" << endl;
    else
        cout << "no" << endl;

    return 0;
}


Measured memory_bytes: 3152