akhauriyash/Code-Regression huggingface dataset:
#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() {
    int n, k;
    cin >> n >> k;

    vector<int> l(n);
    rep(i, n) {
        cin >> l.at(i);
    }

    sort(l.rbegin(), l.rend());
    int res = 0;
    for (int j = 0; j < k; ++j) {
        res += l.at(j);
    }

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


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

int main(){
  int N;
  cin >> N;

  vector<string> W(N);
  set<string> S;  
  
  for (int i = 0; i < N; i++)
  {
    cin >> W.at(i);
  }
  bool ok = true;
  for (int i = 0; i < N; i++)
  {
    if (i == 0){
      S.insert(W.at(i));
      continue;
    }
    if (S.count(W.at(i))) ok = false;
    if (W.at(i - 1).at(W.at(i - 1).size() - 1) != W.at(i).at(0)) ok = false;
    S.insert(W.at(i));
  }

  if (ok){
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
  

}

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

const ll INF = 1LL << 50;

int main(void) {
  ll N, M;
  cin >> N >> M;
  vector<vector<char>> S(N, vector<char>(M));
  REP(i, 0, N) REP(j, 0, M) cin >> S[i][j];

  ll sy, sx, gy, gx;
  REP(i, 0, N) REP(j, 0, M) {
    if (S[i][j] == 'S') {
      sy = i;
      sx = j;
    }
    if (S[i][j] == 'G') {
      gy = i;
      gx = j;
    }
  }

  struct state {
    ll y, x, t;
    bool operator<(const state &s) const {
      return t > s.t;
    }
  };

  vector<vector<ll>> dp(N, vector<ll>(M, INF));
  priority_queue<state> q;
  q.push((state) { sy, sx, 0 });

  while (q.size()) {
    ll y = q.top().y, x = q.top().x, t = q.top().t;
    q.pop();

    if (dp[y][x] <= t) continue;
    dp[y][x] = t;

    ll dd[5] = { 0, 1, 0, -1, 0 };
    REP(i, 0, 4) {
      ll ny = y + dd[i], nx = x + dd[i + 1];
      if (0 <= ny && ny < N && 0 <= nx && nx < M && S[ny][nx] != '#') {
        ll nt = t;
        if (S[ny][nx] == 'x') nt += 3;
        else if (S[ny][nx] == 'o') nt += 1;
        else nt += 2;
        if (dp[ny][nx] > nt) q.push((state) { ny, nx, nt });
      }
      REP(j, 1, 4) {
        ll ny = y + dd[i] * j, nx = x + dd[i + 1] * j, nt = t + 2 + j;
        if (0 <= ny && ny < N && 0 <= nx && nx < M && S[ny][nx] != '#') {
          if (dp[ny][nx] > nt) q.push((state) { ny, nx, nt });
        } else {
          break;
        }
      }
    }
  }

  cout << dp[gy][gx] << endl;
}


Measured memory_bytes: 3192
import math

N, dis = map(int, input().split())
counter = 0

for i in range(N):
    temp_list = list(map(int, input().split()))
    temp_num = temp_list[0]**2 + temp_list[1]**2
    temp_dis = math.sqrt(temp_num)
    if temp_dis <= dis:
        counter += 1
print(counter)

Measured memory_bytes: 9192
from collections import deque
n,x,y=map(int,input().split())
l=[[1]]
for i in range(1,n-1):
    l.append([i-1,i+1])
l.append([n-2])
x,y=x-1,y-1
l[x].append(y)
l[y].append(x)
#print(l)
p=[0 for i in range(n)]
for j in range(n):
    s=[-1 for i in range(n)]
    s[j]=0
    q=deque([j])
    while len(q)>0:
        a=q.popleft()
        for i in l[a]:
            if s[i]==-1:
                s[i]=s[a]+1
                q.append(i)
    for i in s:
        if i!=0:
            p[i]+=1
print(*map(lambda x:x//2,p[1:]),sep='\n')

Measured memory_bytes: 76220
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>
#include<deque>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  int n;
  while(n = getInt()){
    multiset<int> tate,yoko;
    int cntt = 0, cnty = 0;

    REP(i,n) tate.insert(getInt());
    REP(i,n) yoko.insert(getInt());

    while(true){
      multiset<int>::iterator it;

      /*
      printf("cntt = %d\n",cntt);
      FOR(it,tate) printf("%d ",*it); puts("");
      printf("cnty = %d\n",cnty);
      FOR(it,yoko) printf("%d ",*it); puts("");
      */

      it = tate.find(cnty);
      if(it != tate.end()){
        tate.erase(it);
        continue;
      }

      it = yoko.find(cntt);
      if(it != yoko.end()){
        yoko.erase(it);
        continue;
      }

      it = tate.find(yoko.size() + cnty);
      if(it != tate.end()){
        tate.erase(it);
        cntt++;
        continue;
      }

      it = yoko.find(tate.size() + cntt);
      if(it != yoko.end()){
        yoko.erase(it);
        cnty++;
        continue;
      }

      break;
    }

    puts(tate.size() == 0 && yoko.size() == 0 ? "Yes" : "No");
  }
  return 0;
}

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

int main(){
	int n;
	float x[10], yen = 0.0;
	string u[10];
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> u[i];
		if(u[i] == "JPY") yen += x[i];
		else yen += x[i] * 380000.0;
	}
	cout << yen << endl;
	return 0;
}


Measured memory_bytes: 256
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

import sys
sys.setrecursionlimit(4100000)
input = sys.stdin.readline

N,K = Ints()
ALL = []
NetaMax = 0
MaxNeta = {}

for i in range(N):
    t,d = Ints()
    ALL.append([d,t])
    if not t in MaxNeta:
        NetaMax += 1
        MaxNeta[t] = d
    else:
        MaxNeta[t] = max(MaxNeta[t], d)
    
ALL.sort()
ALL = ALL[::-1]
NetaBest = []

for i in MaxNeta:
    NetaBest.append(MaxNeta[i])
    
NetaBest.sort()
NetaBest = NetaBest[::-1]

ans = 0
tmpans = 0
count = 0
tmpD = {}
Second = []

for i in range(K):
    d, t = ALL[i]
    if not t in tmpD:
        tmpD[t] = 1
        count += 1
    else:
        Second.append(d)
    tmpans += d

Second.sort()
#print(Second, count)
ans = tmpans + count**2
#print(NetaBest)

for i in range(count+1, min(K, NetaMax)+1):
    #print(i,i - (count+1))
    tmpans -= Second[i - (count+1)]
    tmpans += NetaBest[i-1]
    #print(tmpans + i**2)
    ans = max(ans, tmpans + i**2)
    
print(ans)

Measured memory_bytes: 73820
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();
            int num = 0;
            for(int i = 0; i<S.Length;i++){
                if(S[i]!=T[i]){
                    num++;
                }
            }
            Console.WriteLine(num);
        }
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


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

int main(){
	

	int t = 1;
	//cin >> t;
	while(t--){
		ll n, a, b;
		cin >> n >> a >> b;
		if(a || b){
		ll x = n / (a + b);
		ll ans = x * a;
		x = n % (a+b);
		if(x >= a) ans+=a;
		else ans += x;
		cout << ans;}
		else cout << 0;

	}
	return 0;
}

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

int main(){
   	int n,d,max=0;
   	cin>>n;
   	vector<int> v(n);
   	vector<int> a(n);
   	for(int i=0; i<n; i++){
   		cin>>v[i];
   	}
   	for(int i=0; i<n; i++){
   		a[i]=v[i];
   	}
   	sort(a.begin(), a.end());

   	for(int i=0; i<n; i++){
   		if(v[i]==a[n-1])cout<< a[n-2]<<endl;

   		else cout << a[n-1]<<endl;
   	}
  

	return 0;
}


Measured memory_bytes: 3200
#import numpy as np
import copy as cp

n = int(input())
a = list(map(int,input().split()))

def nck(n,k):
    if 0 <= k <= n:
        ret = 1
        for i in range(k):
            ret = ret*(n-i)/(i+1)
        return ret
    return 0

def numzero(a):
    if a <= 1:
        return 0
    elif a == 2:
        return 1
    else: return nck(a,2)

cumsum = [0]
s = 0
for i in range(len(a)):
    s += a[i]
    cumsum.append(s)
#print(cumsum)

v = cp.deepcopy(cumsum)
v.sort()
#print(v)

cnt = [1]
c = 0
for i in range(1,len(v)):
    if v[i] == v[i-1]:
        cnt[c] += 1
    else:
        cnt.append(1)
        c += 1
#print(cnt)    

ans = 0
for i in range(len(cnt)):
    ans += numzero(cnt[i])
print(int(ans))


Measured memory_bytes: 26488
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()
{
	int n, x=0, maxi=0;
	char s;
	
	scanf("%d", &n);
	while(n--){
		scanf(" %c", &s);
		
		if(s == 'I') x++;
		else if(s == 'D') x--;
		
		maxi = max(maxi, x);
	}
	
	printf("%d", maxi);
	
	return 0;
}

Measured memory_bytes: 128
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

int main(int, const char**)
{
    int n;
    cin >> n;
    vector<int> edge(n - 1, 0);
    int nc = 0;
    vector<vector<int*>> v(n);
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        v[a].push_back(&edge[i]);
        v[b].push_back(&edge[i]);
    }
    rep(i, n)
    {
        auto es = v[i];
        nc = max(nc, (int)es.size());
        vector<bool> used(nc + 1, false);
        for(auto e : es)
        {
            if(*e != 0)
            {
                used[*e] = true;
            }
        }
        int c = 1;
        for(auto e : es)
        {
            if(*e != 0)
            {
                continue;
            }
            while(used[c])
            {
                c++;
            }
            *e = c;
            used[c] = true;
        }
    }

    cout << nc << endl;
    rep(i, n - 1)
    {
        cout << edge[i] << endl;
    }
    return 0;
}


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

void Main(){
    
}

int main(){
    int H,W;
    while(cin>>H>>W,H){
        rep(i,H){
            rep(j,W){
                if(  i == 0 || i == H - 1 || j == 0 || j == W - 1  ){
                 printf("#");
                } else {
                   printf(".");
        }
        
    }
    printf("\n");
}
printf("\n");
    }
}


Measured memory_bytes: 3044
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
 
int main()
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if (k <= a)
    {
        cout << k << endl;
    }else if (k-a <= b)
    {
        cout << a << endl;
    }else{
        cout << a-(k-a-b) << endl;
    }
    
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void)
{
    int i,j,n,k;
    scanf("%d%d",&n,&k);
    unsigned long h[n],temp,sum = 0;
    for(i = 0; i < n; i++)
    {
        scanf("%lu",&h[i]);
    }
    
    qsort(h,n,sizeof(unsigned long),compare_int);
    
    for(i = 0; i < n - k; i++)
    {
        sum += h[i];
    }
    printf("%lu",sum);
    return 0;
}

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

using namespace std;

int main()
{
    int N,T;
    cin >> N >> T;
    vector <int> c(N);
    vector <int> t(N);

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

    int c_min = 10000;
    for (int i = 0; i < N; i++){
        if (t.at(i) <= T){
            c_min = min(c_min,c.at(i));
        }
    }

    if(c_min == 10000) cout << "TLE" << endl;
    else cout << c_min << endl;
}


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    vector<char> chr{
        'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
        'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
    };
    vector<int> num(26, 0);

    for (int i = 0; i < s.size(); ++i) {
        char c = s[i];
        for (int j = 0; j < 26; ++j) {
            if (c == chr[j]) {
                num[j] = 1;
                break;
            }
        }
    }

    for (int i = 0; i < 26; ++i) {
        if (num[i] == 0) {
            cout << chr[i] << endl;
            break;
        }
        else if (i == 25 && num[i] == 1) {
            cout << "None" << endl;
            break;
        }
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define repp(i,n,s) for (int i= (int)(n); i >= (int)(s); i--)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;
 
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    rep(i,0,n) cin>>a[i];
    deque<int> nib;
    nib.push_front(a[0]);
    rep(i,1,n){
        int x = a[i];
        int j = lower_bound(nib.begin(),nib.end(),x) - nib.begin();
        if (j==0){
            nib.push_front(x);
        }else{
            nib[j-1] = x;
        }
    }
    cout<<nib.size()<<endl;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005;

double func(double a,double b,double t,double v){
    if(a<=t&&t<=b) return v;
    if(t<a) return v+(a-t);
    return v+(t-b);
}

int main(){
    
    int N;cin>>N;
    vector<double> T(N+1,0),V(N);
    for(int i=0;i<N;i++){
        cin>>T[i+1];
        T[i+1]+=T[i];
    }
    for(int i=0;i<N;i++){
        cin>>V[i];
    }
    
    vector<double> S(T[N]*2+1);
    int j=0;
    for(double t=0.0;t<=T[N];t+=0.5){
        double v=1000.0;
        for(int i=0;i<N;i++){
            v=min(v,func(T[i],T[i+1],t,V[i]));
        }
        v=min(v,t);
        v=min(v,T[N]-t);
        S[j]=v;
        j++;
    }
    double ans=0.0;
    for(int i=1;i<2*T[N]+1;i++){
        ans+=0.25*(S[i-1]+S[i]);
    }
    
    cout<<setprecision(15)<<ans<<endl;
}


Measured memory_bytes: 512
sn = list(input())
t = list(input())
ls = len(sn)
lt = len(t)
Flag = False  
reali = 0 #tの文が始まるときのi
if lt > ls:
  print("UNRESTORABLE")
  exit()
for i in range(ls-lt+1): #スライスを繰り返して当てはまるところを探す
  ss = sn[i:i+lt]
  count = 0
  for j in range(lt):
    if ss[j] == "?" or ss[j] == t[j]:
      count += 1
  if count == lt:
    reali = i
    Flag = True
for i in range(ls): #見つけたとこをtの文にしてそれ以外をaにする
  if i == reali:
    for j in range(lt):
      sn[i+j] = t[j]
  if sn[i] == "?":
    sn[i] = "a"
if Flag:
  for i in sn:
    print(i,end="")
else:
  print("UNRESTORABLE")

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

int main(){
    ll n, q;
    string s;
    cin >> n >> q >> s;
    vector<ll> l(q), r(q);
    rep(i, 0, q) cin >> l[i] >> r[i];

    vector<ll> nac(n, 0);
    ll i = 0;
    while(i < n){
        nac[i] = nac[i-1];
        if(s[i] == 'A' && s[i+1] == 'C'){
            nac[i+1] = nac[i]+1;
            i++;
        }
        i++;
    }

    rep(i, 0, q){
        cout << nac[r[i]-1] - nac[l[i]-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n;
    cin>>n;
    double x[n];
    string u[n];
    double ans=0;
    for(int i=0;i<n;i++){
        cin>>x[i]>>u[i];
        if(u[i]=="JPY"){
            ans+=x[i];
        }else{
            ans+=x[i]*380000;
        }
    }
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,j,n,k;
    scanf("%d%d",&n,&k);
    if(n<10)
    {
        i=k+(100*(10-n));
    }

    else if(n>=10)
    {
        i=k;
    }
     printf("%d\n",i);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;




int main(){
    int a,b,c; cin>>a>>b>>c;

    cout<<min(b/a,c)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define eb emplace_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3+5;
const lli INF = 1e18;
const lli MOD = 1e6+3;

bool mm[N];
vi primes(1,2);
ld nk[N][N];
void sieve(){
	for(int i = 4; i<N; i+=2)mm[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!mm[i])for(int j = i*i; j<N; j+=i)mm[j]=1;
	for(int i = 3; i<N; i+=2)if(!mm[i])primes.pb(i);
}

void pascal(){
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7




int main(){_
	int n; cin>>n;
	cout<<(1000-n%1000)%1000;
	return 0;
}


Measured memory_bytes: 3660
#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(){
    int a, b;
    cin >> a >> b;
    if(a < b){
        rep(i, b) cout << a;
    }
    else rep(i,a) cout << b;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(ll i=0; i<n; i++)
#define all(v) v.begin(), v.end()
#define vec vector
typedef long long ll;
const int INF = 1001001001;
const double PI = 3.141592653589793238462643383;


/*　<<stringで読み込んだ数列を一桁ずつint型へ変換>>
 
    string str;
    int N[桁数];
 
    cin >> str;
 
    for (int i = 0; i < 桁数; ++i) {
 
        N[i] = (int)(str[i] - '0');  //str[i]　はchar型なのでchar→intへ変換
 
        //cout << N[i] << endl;  //確認のため表示
    }
*/
 


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


int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double a, b, c, r;

    a = ((10.0000000000000*H + M/6.000000000000) / 60.000000000000) * PI;
    b = (M/60.000000000000) * 2.000000000000 * PI;
    r = abs(min(a-b,b-a));
  if(r > PI){
    r = 2.000000000000 * PI - r;
  }

    c = sqrt(A*A + B*B - 2.000000000000*A*B*cos(r));

    cout << fixed << setprecision(15) << c << endl;
}

Measured memory_bytes: 4228
#pragma GCC target("avx")
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORR(i,a,n) for(i=n-1;i>=a;i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL LBn(VL &v,LL a){LL mx=v.size(),mn=-1,md;while(mx-mn>1){md=(mx+mn)/2;if(v[md]<a)mn=md;else mx=md;}return mx;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a%m<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
template<typename T>bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  FAST;
  LL i=0,a=100,X;
  cin>>X;
  while(a<X){
    a*=1.01;
    i++;
  }

  cout<<i<<endl;
}


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

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> menu(m, 0);
    rep(i, n) {
        int k;
        cin >> k;
        rep(j, k) {
            int a;
            cin >> a;
            menu[a - 1]++;
        }
    }

    int ans = 0;
    rep(i, m) {
        if (menu[i] == n)
            ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))

A_asc = sorted(A)
max1 = A_asc[-1]
max2 = A_asc[-2]

for a in A:
  if a == max1:
    print(max2)
  else:
    print(max1)

Measured memory_bytes: 14068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a; string s; cin >> a >> s;
    if (a>=3200) cout << s << endl;
    else cout << "red" << endl;
}

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

#define INF 1050000000

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }

    // c[i] = 足場 i にたどり着くまでのコストの最小値
    vector<int> c(N, INF); // DP 配列の全要素をでっかい数で初期化
    c[0] = 0;              // c[0] が 0 であることは分かっている

    // i = 1 からループ
    for (int i = 1; i < N; i++) {
        // i-k が負にならないようにループ範囲の最大を min(i, K) に設定
        for (int k = 1; k <= min(i, K); k++) {
            c[i] = min(c[i], c[i - k] + abs(h[i - k] - h[i]));
        }
    }

    cout << c[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 1024
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
int mod = 1000000007;
int mod1 = 998244353;
vector<int> g[Max];
bool vis[Max];
int d, x, y;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void ex(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        ex(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}


void dfs(int u){

	vis[u]=1;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(vis[v]!=1)
			dfs(v);
	}
}



int power(int a,int b){
    if(b==1)return a;
    if(a>mod)a%=mod;
    int r=1;
    while(b){
        if(b&1)r=r%mod*a%mod;
        a=a%mod*a%mod;
        b/=2;
    }
    return r;
}
class uf{
    vector<int> v;
    vector<int> sz;
    
    
    public :
    uf(int n){
        v.resize(n+1);
        iota(v.begin()+1,v.end(),1);
        sz.resize(n+1,1);
        //1 to sz
    }
    int root(int b){
        while(v[b]!=b){
            b = v[b];
        }   
        return b;
    }
    void u(int a, int b){
        //combine a and b
        
        int ra=root(a);
        int rb=root(b);
        if(ra==rb)return ;
        if(sz[ra]<sz[rb]){
            v[ra] = v[rb];
            sz[rb]+=sz[ra];
        }else{
            v[rb]=v[ra];
            sz[ra]+=sz[rb];
        }
    }
    bool f(int a,int b){
        //same set
        return (root(a)==root(b));
    }
   
    
};
vector<int> matmul(vector<int> a,vector<int> b){
    vector<int> c(4,0);
    c[0] = (a[0]%mod*b[0]%mod + a[1]%mod*b[2]%mod)%mod;
    c[1] = (a[0]%mod*b[1]%mod + a[1]%mod*b[3]%mod)%mod;
    c[2] = (a[2]%mod*b[0]%mod + a[3]%mod*b[2]%mod)%mod;
    c[3] = (a[2]%mod*b[1]%mod + a[3]%mod*b[3]%mod)%mod;
    return c;
}
vector<int> id={1,0,0,1};

int32_t main(){
	IO
	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
	int n;
  	cin>>n;
  	vector<int> v(n+1);
  	for(int i=1;i<=n;i++)cin>>v[i];
  	map<int,int> m;
  	int i=1;
  	bool f=0;
  	int steps=0;
  	while(m[i]==0){
      	
      	if(i==2){f=1;break;}
     	 m[i]=1;
      	 i = v[i];
      	 steps++;
    }
    if(f)cout<<steps;
  	else cout<<-1;
  	
  
  	
  	
  	
}


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

int main(){
  int n;
  cin >> n;
  vector<double> vec(n);
  for (int i = 0; i < n; i++){
  	cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  double value;
  for(int i = 0; i < n-1; i++){
    value = (vec.at(i) + vec.at(i+1)) / 2;
    vec.at(i+1) = value;
  }
  cout << value << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = 0; i < N; ++i) {
    cin >> D[i];
  }
  sort(D.rbegin(), D.rend());
  int result = D[N / 2 - 1] - D[N / 2];
  cout << result << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main {
	public static int gcd(int n1, int n2){
			if (n1 < n2) return gcd(n2,n1);
			if (n2 == 0) return n1;
			if (n1 == n2) return n1;
			return gcd(n2, n1%n2);
		}
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		System.out.println(gcd(a,b));
		
	}
}



Measured memory_bytes: 26352
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	set<int> S;
	int q;
	cin >> q;
	while( q-- > 0 ) {
		int a, b;
		cin >> a >> b;

		if( a == 0 ) {
			S.insert( b );
			cout << S.size() << '\n';
		}
		else if( a == 1 ) {
			cout << (S.find( b ) != S.end()) << '\n';
		}
		else if( a == 2 ) {
			S.erase( b );
		}
	}

	return 0;
}



Measured memory_bytes: 12384
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>

using namespace std;
/*
double area(double x1,double y1,
        double x2,double y2,
        double x3,double y3){
    double vx1 = x2-x1;
    double vy1 = y2-y1;

    double vx2 = x3-x1;
    double vy2 = y3-y1;

    return (abs(vx1*vy2)+abs(vy1*vx2))/2.0;
}*/

int main(){

    int count=0;
    while(true){
        ++count;
        int n;
        double ans = 0.0;
        vector<double> vx;
        vector<double> vy;

        std::cin >> n;
        if(n==0)return 0;
        for(int i=0;i<n;i++){
            double x,y;
            cin >> x >> y;
            vx.push_back(x);
            vy.push_back(y);
        }
        for(int i =0;i<vx.size();i++){
            if(i==vx.size()-1){
                ans+=(vx[i]-vx[0])*(vy[i]+vy[0]);
                break;
            }
            ans+=(vx[i]-vx[i+1])*(vy[i]+vy[i+1]);
        }
        
        printf("%d %.1f\n",count,abs(ans/2));
    }
    return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            long T = long.Parse(s[1]);

            s = Console.ReadLine().Split(' ');

            long ans = 0;
            long prev = long.Parse(s[0]);

            for (int i = 1; i < N; i++)
            {
                int now = int.Parse(s[i]);

                if (now - prev < T)
                {
                    ans += now - prev;
                }
                else
                {
                    ans += T;
                }

                prev = now;
            }

            ans += T;

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 26464
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

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


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

    ll ans = 0;
    while((ans*1000) < N){
        ans++;
    }
    ans = (ans*1000)-N;

    cout << ans << endl;
}




Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 2e5 + 10,mod = 1e9 + 7;

int a[N],pre[N],Las[N],dp[N];

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

int main() {

	int n = read();
	For(i,1,n) {
		a[i] = read();
		Las[i] = pre[a[i]],pre[a[i]] = i;
	}
	dp[0] = 1;
	For(i,1,n) {
		if(Las[i] && Las[i] < i - 1) dp[i] = dp[Las[i]];
		dp[i] = (dp[i] + dp[i - 1]) % mod;
	}
	printf("%d\n",dp[n]);

	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int w,h;
    int i,j;
    while(1){
        cin >> h;
        cin >> w;
        if(w == 0 || h == 0) break;
        vector< vector<char> > v(101, vector<char>(101));
        for(j=0;j<h;++j){
            for(i=0;i<w;++i){
                cin >> v[i][j];
            }
        }
        int mi = 0, mj = 0;
        while(true){
            char c = v[mi][mj];
            v[mi][mj] = '#';
            if(c == '>') mi++;
            else if(c == '<') mi--;
            else if(c == '^') mj--;
            else if(c == 'v') mj++;
            else if(c == '#'){
                cout << "LOOP" << endl;
                break;
            } else if( c == '.' ){
                cout << mi << ' ' << mj << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

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

bool has_key_using_count(map<char, char> &m, char n){
    if (m.count(n) == 0){
		//cout << "m doesn't have " << n << "." << endl;
        return false;
    }
    else{
        //cout << "m has " << n << "." << endl;
        return true;
    }
}

int main()
{
	//ifstream cin("sampleA.txt");

	int n = 0;
	//map<string, string> table;
	map<char, char> table;
	string input = "", ans = "";
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		table.clear();
		ans = "";
		input = "";

		//cin >> n;
		rep(i, n) {
			// 暗号表をmapに追加する
			char a, b;
			cin >> a >> b;
			//table.insert( map<string, string>::value_type(a, b));
			table.insert( map<char, char>::value_type(a, b));
		}
		
		// 変換対象文字列の読み込み&出力
		cin >> n;
		rep(i, n) {
			char t = 'a';
			cin >> t;
			input.push_back(t);

			// 表にない場合はそのまま出力
			//if (table[t] != null) {
			if ( has_key_using_count(table, t)) {
				ans.push_back(table[t]);
			} else {
				ans.push_back(t);
			}
		}

		// 出力する
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1340
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int a, b;
int main(){
	while(~scanf("%d %d", &a, &b)){
		if(a == 1) a = 14;
		if(b == 1) b = 14;
		if(a > b) printf("Alice\n");
		else if(a < b) printf("Bob\n");
		else printf("Draw\n");
	}
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define ff first
#define ss second
#define N 2000001
#define M 1000000007
#define MOD 998244353
#define INF 1000000000000000
vector<ll> v[100001];
ll vis[100001]={0};
void dfs(ll u)
{
	vis[u]=1;
	for(auto it:v[u])
	{
		if(vis[it]==0)
		{
			dfs(it);
		}
	}

}
int main()
{
	ll n,m,i;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		ll u,v1;
		cin>>u>>v1;
		v[u].pb(v1);
		v[v1].pb(u);
	}
	ll ans=0;
	for(i=1;i<=n;i++)
	{
		if(vis[i]==0)
		{
			dfs(i);
			ans++;
		}
		
	}
	cout<<ans-1;
}


Measured memory_bytes: 11088
import sys
sys.setrecursionlimit(100000)
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N-1)]
c = list(map(int, input().split()))

if N == 1:
    print(0)
    print(c[0])
    exit()

c.sort(reverse = True)
edge = [[] for _ in range(N)]
for a, b in ab:
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

def dfs(v, p):
    global ans
    global count
    if p != -1:
        anse[v] = c[count+1]
        ans += min(anse[v], anse[p])
        count += 1
    for nv in edge[v]:
        if nv == p:
            continue
        dfs(nv, v)

#search = [i for i, e in enumerate(edge) if len(e) == 1]
search = [0]
res = 0
rese = [None for _ in range(N)]
for i in search:
    count = 0
    ans = 0
    anse = [None for _ in range(N)]
    anse[i] = c[0]
    dfs(i, -1)
    if res < ans:
        res = ans
        rese = anse
print(res)
print(" ".join(map(str, rese)))

Measured memory_bytes: 16056
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
#include <random>
#include <future>
#include <thread>
#include <utility>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define INF_L (LLONG_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
#define int long long


// booooooooooooost
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)


signed main() {

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

	sort(A.begin(), A.end(), [](int x, int y){return x > y; });

	int bak = -1;
	vector<int> anss;
	for (auto p : A) {
		if (bak == p) {
			bak = -1;
			anss.push_back(p);
			if (anss.size() == 2) break;
		}
		else {
			bak = p;
		}
	}

	if (anss.size() == 2) cout << anss[0] * anss[1] << endl;
	else cout << 0 << endl;


	return 0;
}

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

Measured memory_bytes: 3060
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int num[] = new int[n];
        int count = 0;
        int x = 1;
        for(int i = 0; i < n; i++){
        	num[i] = sc.nextInt();
            if(num[i] != x){
            	count++;
            }else{
            	x++;
            }
        }
        if(x == 1){
        	System.out.println("-1");
        }else{
        	System.out.println(count);
        }
    }
}

Measured memory_bytes: 60560
#include <bits/stdc++.h>
using namespace std;
int main(){
    int l,r,d;
    int e=0;
    scanf("%d %d %d",&l,&r,&d);
    for(int i=l;i<r+1;i++){
        if(i%d==0)e++;
    }
    printf("%d",e);
    return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(stdIn.hasNext()){
			int n = stdIn.nextInt();
			int[] a = new int[n];
			for(int i=0;i<n;i++){
				a[i] = stdIn.nextInt();
			}
			Arrays.sort(a);
			int ans = 0;
			for(int i=0;i<n;i++){
				ans += a[i] * (n-i);
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n,k;
char a[N];
int b[N];
#define mid (l+r>>1)
#define ls o<<1
#define rs o<<1|1
int t[N<<2];
void build(int o,int l,int r){
    if(l==r){
        t[o]=b[l];
        return ;
    }
    t[o]=0;
    build(ls,l,mid);
    build(rs,mid+1,r);
    t[o]=max(t[ls],t[rs]);
}
const int MAXN=1e9;
int get(int o,int l,int r,int x,int y){
    if(l>y||r<x||l>r)return 0;
    if(l>=x&&r<=y)return t[o];
    int ans=0;
    if(y>mid&&t[rs])ans=max(ans,get(rs,mid+1,r,x,y));
    if(x<=mid&&ans==0&&t[ls])ans=max(ans,get(ls,l,mid,x,y));
    return ans;
}
int f[N];
int main() {
    ios::sync_with_stdio(false);
    cin>>n>>k>>a+1;
    n++;
    for(int i=1;i<=n;i++){
        if(a[i]=='1')b[i]=0;
        else b[i]=i;
    }
    build(1,1,n);
    for(int i=n-1;i>=1;i--){
        if(a[i]=='0'){
            int nex=get(1,1,n,i+1,min(n,i+k));
            if(nex==0){
                f[i]=MAXN;
                continue;
            }
            f[i]=f[nex]+1;
        }else f[i]=MAXN;
    }
    if(f[1]>=MAXN)cout<<-1<<endl;
    else{
        int l=2;
        int pre=1;
        while(l<=n){
            if(n>pre&&n-pre<=k){
                return cout<<n-pre<<' ',0;
            }
            if(a[l]=='1'||f[l]>=f[pre]){
                l++;
                continue;
            }
            cout<<l-pre<<' ';
            pre=l;
            l++;

        }
    }
    return 0;
}

Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int[][] a = new int[100][2];

        int i;

        for (i = 0;; i++) {
            a[i][0] = sc.nextInt();
            a[i][1] = sc.nextInt();

            if (a[i][0] == 0 && a[i][0] == 0) {
                break;
            }
        }

        for (int l = 0; l < i; l++) {
            for (int k = 0; k < a[l][0]; k++) {
                for (int j = 0; j < a[l][1]; j++) {
                    System.out.print("#");
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }

        sc.close();
    }
}


Measured memory_bytes: 37940
#include<bits/stdc++.h>
using namespace std;
 int main(){
   char c;
   cin >> c;
   if(c == 'a'||c =='e'||c =='i'||c =='o'||c =='u'){
   cout << "vowel" << endl;
   }
   else {
   cout << "consonant" << endl; 
   }
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}

signed _main(){
  int N,R; cin >> N >> R;
  if(N>=10) cout << R << endl;
  else cout << R+100*(10-N) << endl;
  return 0;
}


Measured memory_bytes: 256
r,c= map(int,input().split())
table= [list(map(int,input().split())) for i in range(r)]

for j in range(r):
  b=0
  for k in range(c):
    b+=table[j][k]
    print(table[j][k],end=" ")
  print(b)
a=[]
for k in range(c):
  d=0
  for j in range(r):
    d+=table[j][k]
  a.append(d)
print(' '.join(map(str,a)),end=' ')
print(sum(a))


Measured memory_bytes: 6220