akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        int[][] a = new int[n][2];
        for (int i = 0; i < n; i++) {
            a[i][0] = sc.nextInt();
            a[i][1] = sc.nextInt();
        }
        int[] dp = new int[h+1];
        Arrays.fill(dp, Integer.MAX_VALUE/2);
        dp[0] = 0;
        for (int i = 0; i <= h; i++) {
            for (int j = 0; j < n; j++) {
                int nex = h < a[j][0] + i ? h : a[j][0] + i;
                if(a[j][1] + dp[i] < dp[nex]) dp[nex] = a[j][1] + dp[i];
            }
        }
        System.out.println(dp[h]);
        sc.close();

    }

}


Measured memory_bytes: 27524
#include<bits/stdc++.h>
#define ll long long
#define MOD 1e9+7;

using namespace std;

int main(){
    double A,B;
    cin>>A>>B;
    double x1=A/0.08;
    double y1=(A+1)/0.08;
    double x2=B/0.1;
    double y2=(B+1)/0.1;
    double x=max(x1,x2);
    double y=min(y1,y2);
    int ans;
    if(x-(int(x))==0.0){
        ans=x;
    }else{
        ans=(int)(x+1.0-(x-(double)((int)x)));
    }
    //cout<<x<<endl;
    if((double)(ans)<y){
        cout<<(int)(ans)<<endl;
    }else{
        cout<<-1<<endl;
    }

}


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

int main() {
    int a, b, c, aa, bb, cc, ans = 0;
    cin >> a >> b >> c;
    if(a == b && b == c) {
        if(a%2) cout << 0 << '\n';
        else cout << -1 << '\n';
        return 0;
    }
    while(1) {
        if(a%2 || b%2 || c%2) break;
        aa = b/2 + c/2;
        bb = a/2 + c/2;
        cc = a/2 + b/2;
        a = aa, b = bb, c = cc;
        ans++;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}

int main()
{
    string S;
    cin>>S;
    if(S=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;

signed main(){
    int n;
    cin >> n;
    vint num(n);
    int sum = 0;
    rep(i,n){
        cin >> num[i];
        sum += num[i];
    }
    int ans = 0;
    if(sum % 10 == 0){
        bool flag = false;
        rep(i,n){
            if((sum - num[i]) % 10 != 0){
                ans = max(ans,sum-num[i]);
                flag = true;
            }
        }
        if(flag) cout << ans << endl;
        else cout << 0 << endl;
    }
    else cout << sum << endl;
}

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

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

int main() {
  string S;
  cin >> S;
  string ans;
  if ((S[2] == S[3]) && (S[4] == S[5])) {
    ans = "Yes";
  } else
    ans = "No";

  cout << ans << endl;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  double n;
  cin >> n;

  int ans = -1;
  for (int i = 0; i < n * 2; i++) {
    if (floor(i * 1.08) == n) {
      ans = i;
      break;
    }
  }

  if (ans < 0) {
    cout << ":(\n";
  } else {
    cout << ans << '\n';
  }

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

bool flag[500000];
int n;
string str[100001];
int cal[5];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin >> str[i];
	}
	cal[0]=1;
	for(int i=1;i<5;i++){
		cal[i]=cal[i-1]*26;
	}
	int len=1;
	while(1){
		memset(flag,false,sizeof(flag));
		for(int i=0;i<n;i++){
			int hash=0;
			if(str[i].size()<len)continue;
			for(int j=0;j<len;j++){
				hash=hash*26+(str[i][j]-'a');
			}
			flag[hash]=true;
			for(int j=len;j<str[i].size();j++){
				hash-=(str[i][j-len]-'a')*cal[len-1];
				hash=hash*26+(str[i][j]-'a');
				flag[hash]=true;
			}
		}
		for(int i=0;i<cal[len];i++){
			if(!flag[i]){
				string res="";
				int g=i;
				for(int j=0;j<len;j++){
					res+='a'+(g/cal[len-j-1]);
					g%=cal[len-j-1];
				}
				cout << res << endl;
				return 0;
			}
		}
		len++;
	}
	return 0;
}

Measured memory_bytes: 8672
#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);
  
  int s=abs(a.at(0)) + abs(a.at(N-1));
  
  for(int i=1;i<N;i++) s+=abs(a.at(i-1)-a.at(i));
  
  for(int i=0;i<N;i++){
    if(i==0)
      cout<<s-abs(a.at(0))-abs(a.at(1)-a.at(0))+abs(a.at(1))<<endl;
    else if(i==N-1)
      cout<<s-abs(a.at(N-1))-abs(a.at(N-2)-a.at(N-1))+abs(a.at(N-2))<<endl;
    else
      cout<<s-abs(a.at(i-1)-a.at(i))-abs(a.at(i)-a.at(i+1))+abs(a.at(i-1)-a.at(i+1))<<endl;
  }
  
}

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


int main()
{
    int x=1;
    //cin>>t;
    while( x-- )
    {
        ll n;
        cin>>n;
        ll a[n];

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

        ll suf_sum[n];
        suf_sum[n-1]=a[n-1];

        for( int i=n-2 ; i>=0 ; i-- )
            suf_sum[i]=(suf_sum[i+1]+a[i])%mod;

        ll ans=0;

        for( int i=0 ; i<n-1 ; i++ )
        {
            ans= (ans + (( a[i]*suf_sum[i+1] )%mod))%mod;
        }
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 6724
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define ll long long
#define lld double
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<pii, ll>
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define ppb pop_back
#define d0(x) cout<<x<<" "
#define d1(x) cout<<(x)<<"\n"
#define d2(x,y) cout<<x<<" "<<y<<"\n"
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define d5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<endl
using namespace std;
const ll mod = 998244353;

char c[1001];int N;

bool isp(int L,int R)
{
    while(L<R)
    {
        if(c[L]!=c[R])
            return 0;
        L++;R--;
    }
    return 1;
}
void solve(int t)
{
    cin>>(c+1);

    N=1;
    for(;c[N];N++);
    N--;
    
    if(isp(1,N) && isp(1,(N-1)/2) && isp((N+3)/2,N))
    {
        d1("Yes");return;
    }

    d1("No");


}


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int T=1;
    //cin>>T;
    for(int t=1;t<=T;t++)
        solve(t);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int cnt[100];
int main(){
	string t;
	cin >> t;
	int h=0;
	for(int i = 0; i < t.size(); i ++){
		if(t[i] == 'A' or t[i] == 'C' or t[i] == 'G' or t[i] == 'T'){
			cnt[h] ++;
		}
		else {
			h++;	
		}
	}
	int ma = -11;
	for(int  i = 0; i < 100; i ++){
		ma = max(ma, cnt[i]);
	}
	cout << ma;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
using ll = long long;

int main() {

	int n;
	cin >> n;

	for (int i = 1; i <= 9; ++i) {
		for (int j = 1; j <= 9; ++j) {
			if (i * j == n)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();

		if((a==b && a != c) || (a==c && a != b) || (b==c && b != a)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}


Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX=200000;
int main()
{
  int n,k,i,j,d,t;
  int a[N_MAX],c[N_MAX];
  long long res=0;
  cin >> n;
  fill(c,c+n,0);
  for(i=0;i<n;i++){
    cin >> a[i];
    if(i-a[i]>=0)
      c[i-a[i]]++;
  }
  for(i=0;i<n;i++)
    if(i+a[i]<n)
      res+=c[i+a[i]];
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4756
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
#include<set>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000;
int main() {   
    ll k;
    cin>>k;
    ll n=50LL;
    cout<<n<<endl;
    ll a[51];
    for(ll i=0;i<n;i++){
        a[i]=(n-1)+(k/n);
    }
    for(ll i=0;i<k%n;i++){
        for(ll j=0;j<n;j++){
            if(i==j){
                a[j]+=n;
            }else{
                a[j]--;
            }
        }
    }
    for(ll i=0;i<n;i++){
        cout<<a[i];
        if(i==n-1){
            cout<<endl;
        }else{
            cout<<" ";
        }
    }
    getchar();
    getchar();
}

                           


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int main()
{
	deque<char> dq;
	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0' || s[i] == '1') dq.push_back(s[i]);
		else if( !dq.empty() ) dq.pop_back();
	}

	while (!dq.empty()) {
		cout << dq.front();
		dq.pop_front();
	}

	return 0;
}


Measured memory_bytes: 256
N, K, S = map(int, input().split())

ans = [None] * N
for i in range(N):
    if i < K:
        ans[i] = S
    else:
        if S + 1 <= 1000000000:
            ans[i] = S + 1
        else:
            ans[i] = 1
            
print(' '.join(map(str, ans)))

Measured memory_bytes: 15012
#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);
  }
  
  sort(a.begin(), a.end());
  
  cout << a.at(n - 1) - a.at(0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  if(A*B*1 % 2 != 0 || A*B*2 % 2 != 0 || A*B*3 % 2 != 0) {
    cout <<"Yes" << endl;
  }else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(){
    long long x, cont=0;
    scanf("%lld", &x);
    long long eq=100;
    while (x > eq){
        eq= eq+(eq*1)/100;
        cont++;
    }
    printf("%lld\n", cont);
    return 0;
}

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

int main(){
    int N,i,x=0;
    string S;
    cin >> N;
    cin >> S;
    for(i=0;i<N-2;i++){
        if(S[i]=='A'){
            if(S[i+1]=='B'){
                if(S[i+2]=='C'){
                    x++;
                }
            }
        }
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define INF 1e9+7
int main() {
	int N, L;
	cin >> N >> L;
	int tCost = (N*(N-1)/2)+(L*N);
	int ans;
	int tDiff = INF;
	int temp;
	for(int i = 0; i < N; ++i) {
		temp = abs(tCost-(tCost-(i+L)));
		if (temp < tDiff) {
			tDiff = temp;
			ans = tCost-(i+L);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#! env/bin/local python3
# -*- coding: utf-8 -*-

n = int(input())
counter = {
    'AC': 0,
    'WA': 0,
    'TLE': 0,
    'RE': 0
}

while True:
    try:
        counter[input()] += 1
    except EOFError:
        break

for key, value in counter.items():
    print(f"{key} x {value}")



Measured memory_bytes: 9176
#include<stdio.h>

int main(int argc, char const *argv[]) {
    int a,b;
    scanf("%d %d",&a,&b);
    if (a<b) printf("a < b\n");
    else if (a>b)printf("a > b\n");
    else printf("a == b\n");
    return 0;
}

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

int main() {
  int x, y, z;
  int k;
  cin >> x >> y >> z;
  cin >> k;

  vector<long long> A(x), B(x), C(z);

  for (int i = 0; i < x; i++) cin >> A[i];
  for (int i = 0; i < y; i++) cin >> B[i];
  for (int i = 0; i < z; i++) cin >> C[i];

  vector<long long> AB;
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      AB.push_back(A[i] + B[j]);
    }
  }
  sort(AB.begin(), AB.end());
  reverse(AB.begin(), AB.end());

  vector<long long> ABC;
  for (int i = 0; i < min(k, (int)AB.size()); i++) {
    for (int j = 0; j < z; j++) {
      ABC.push_back(AB[i] + C[j]);
    }
  }
  sort(ABC.begin(), ABC.end());
  reverse(ABC.begin(), ABC.end());

  for (int i = 0; i < k; i++) cout << ABC[i] << endl;
}


Measured memory_bytes: 43240
Point = Struct.new(:x,:y)
def kochcurve(n,pl,pr)
  a = Array.new
  if n == 0
    a.push(pl)
    return a
  end
  vx = pr.x - pl.x
  vy = pr.y - pl.y
  wx = -vy / 6 * (3**(1.0/2.0))
  wy = vx / 6 * (3**(1.0/2.0))
  s = Point.new(pl.x+vx/3, pl.y+vy/3)
  t = Point.new(pl.x+vx/3*2, pl.y+vy/3*2)
  u = Point.new(pl.x+vx/2+wx, pl.y+vy/2+wy)
  a.concat(kochcurve(n-1,pl,s))
  a.concat(kochcurve(n-1,s,u))
  a.concat(kochcurve(n-1,u,t))
  a.concat(kochcurve(n-1,t,pr))
  a
end

n = gets.to_i
s = Point.new(0.0,0.0)
t = Point.new(100.0,0.0)
a = kochcurve(n,s,t)
a.push(t)
l = a.length
for i in 0...l
  printf("%.8f %.8f\n",a[i].x, a[i].y)
end

Measured memory_bytes: 6240
using System;
class aizu{
    public static int Main(){
        int i;
        int[] n = new int[100];
        string[] str = new string[500];
        str = Console.ReadLine().Split(' ');
        for(i=0;i<3;i++)
            n[i] = int.Parse(str[i]);
        for(i=n[0];i<=n[1];i++){
            if(n[2]%i==0)
                n[3]+=1;
        }
        Console.WriteLine("{0}",n[3]);
        return 0;
    }
}

Measured memory_bytes: 9088
def all_num(text):
    for c in text:
        if not c in "1234567890":
            return False
    return True

a, b = [int(m) for m in input().split(" ")]
s = input()

print("Yes" if all([all_num(s[:a]), s[a] == "-", all_num(s[a+1:a+1+b])]) else "No")

Measured memory_bytes: 3060
#!/usr/bin/env python3
#ABC106 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

n,m,q = map(int,input().split())

c = [[0]*(n+1) for _ in range(n+1)]
for _ in range(m):
    l,r = map(int,input().split())
    c[l][r] += 1
for i in range(1,n):
    c[i] = list(accumulate(c[i]))
for i in range(n):
    for j in range(n+1):
        c[i+1][j] += c[i][j]
for _ in range(q):
    p,q = map(int,input().split())
    ans = c[q][q] - c[p-1][q] - c[p][p-1] + c[p-1][p-1]
    print(ans)


Measured memory_bytes: 59480
N, C = gets.split.map(&:to_i)
s, t, c = [], [], []
N.times do |i| 
  s[i], t[i], c[i] = gets.split.map(&:to_i)
  c[i] -= 1
end

w = t.max + 1
imos = Array.new(C){ Array.new(w, 0) }
(0...N).each do |i|
  imos[c[i]][s[i] - 1] += 1
  imos[c[i]][t[i]] -= 1
end

(0...C).each do |i|
  (1...w).each do |j|
    imos[i][j] += imos[i][j - 1]
  end
end

(0...C).each do |i|
  (1...w).each do |j|
    imos[i][j] = 1 unless imos[i][j].zero?
  end
end

puts imos.transpose.map{|row| row.reduce(:+)}.max


Measured memory_bytes: 61152
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int Func(int x){
        if(x%2==0){
                return x/2;
        } else{
                return 3*x+1;
        }
}

int main()
{
        //input->compute->output//
        int S;
        cin>>S;
        vector<int> N(300,0);
        for (int i = 0;; i++)
        {
                N[S]++;
                if(N[S]==2){
                        cout<< i+1<<endl;
                        return 0;
                }
                S=Func(S);
        }

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define sp(x) fixed<<setprecision(x)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

//vector<vector<double>> dp(3001,vector<double>(3001,-1));
double dp[3001][3001];
double fun(vector<double> &p, int i, int atleast_heads)
{
    //Base case
    if(atleast_heads == 0)
    return 1;

    if(i == 0)
    return 0;

    //Lookup
    if(dp[i][atleast_heads] > -0.9)
    return dp[i][atleast_heads];

    //Rec case
    //double op1 = p[i]*fun(p,i-1,atleast_heads-1);
    //double op2 = (1-p[i])*fun(p,i-1,atleast_heads);
    return dp[i][atleast_heads] = p[i]*fun(p,i-1,atleast_heads-1) + (1-p[i])*fun(p,i-1,atleast_heads);
}

int main()
{
    fast_io;

    memset(dp,-1,sizeof(dp));
    int n;
    cin>>n;
    vector<double> p(n+1);

    for(int i=1;i<=n;i++)
    cin>>p[i];

    cout<<sp(10)<<fun(p,n,(n+1)/2)<<endl;

    return 0;
}

Measured memory_bytes: 70912
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();

    let a: u32 = s[..2].parse().unwrap();
    let b: u32 = s[2..].parse().unwrap();

    if 0 < a && a < 13 {
        if 0 < b && b < 13 {
            println!("AMBIGUOUS");
        } else {
            println!("MMYY");
        }
    } else {
        if 0 < b && b < 13 {
            println!("YYMM");
        } else {
            println!("NA");
        }
    }
}

Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 105
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

char s[MAXN], t[8]="keyence";

int main()
{
    scanf("%s", s);
    int len=strlen(s);
    for(rint i=0; i<=7; ++i)
    {
	int j=0, p=0, tag=1;
	for(; j<=7; ++j)
	{
	    if(p==i) p+=len-7;
	    if(s[p]==t[j]) p++;
	    else {tag=0; break;}
	}
	if(tag)
	{
	    printf("YES\n");
	    return 0;
	}
    }
    printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
using namespace std;

int ac, wa, tle, re;
int main() {
	int n;
	cin >> n;
	vector<string> data(n);
	rep(i, 0, n) cin >> data[i];

	rep(i, 0, n){
		if(data[i] == "AC") ac++;
		else if(data[i] == "WA") wa++;
		else if(data[i] == "TLE") tle++;
		else if(data[i] == "RE") re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
    return 0;
}


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

int main()
{
  string str;

  cin >> str;

  for (int i = 0; i < str.size(); i++)
  {
    for (int k = 0; k < str.size(); k++)
    {
      if (i != k && str[i] == str[k])
      {
        cout << "no" << endl;
        exit(0);
      }
    }
  }

  cout << "yes" << endl;
}


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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

int main(){
	int n;
	string s; cin>>n>>s;
	s="<"+s;

	// dp[i][j] = 左から i 個目まで決めて, 最後に置いた数より大きい数が j 個残っているような置き方の数
	static mint dp[3001][3001];
	dp[0][n]=1;
	rep(i,n){
		rep(j,n-i+1){
			if(s[i]=='<'){
				dp[i+1][0]+=dp[i][j];
				dp[i+1][j]-=dp[i][j];
			}
			else{
				dp[i+1][j]+=dp[i][j];
				dp[i+1][n-i]-=dp[i][j];
			}
		}
		rep(j,n) dp[i+1][j+1]+=dp[i+1][j];
	}
// O(n^3) DP
/*
	rep(i,n){
		rep(j,n-i+1){
			if(s[i]=='<'){
				rep(k,j) dp[i+1][k]+=dp[i][j];
			}
			else{
				rep(k,n-i-j) dp[i+1][k+j]+=dp[i][j];
			}
		}
	}
*/
	cout<<accumulate(dp[n],dp[n]+n+1,mint(0))<<'\n';

	return 0;
}


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

class Main {

  private static long INF = Long.MAX_VALUE / 4;

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    int W = Integer.parseInt(scanner.next());
    int[] weight = new int[N];
    int[] value = new int[N];
    for (int i = 0; i < N; i++) {
      weight[i] = Integer.parseInt(scanner.next());
      value[i] = Integer.parseInt(scanner.next());
    }
    scanner.close();
    long[][] dp = new long[110][100010];

    for (long[] ls : dp) {
      Arrays.fill(ls, -INF);
    }
    Arrays.fill(dp[0], 0);
    for (int i = 0; i < N; i++) {
      for (int sum_w = 0; sum_w <= W; sum_w++) {
        if (sum_w - weight[i] >= 0) {
          dp[i + 1][sum_w] = Math.max(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
        }
        dp[i + 1][sum_w] = Math.max(dp[i + 1][sum_w], dp[i][sum_w]);
      }
    }
    System.out.println(dp[N][W]);
  }

}


Measured memory_bytes: 128976
/**
 *   author: sahushivam
 *   created: 26 January 2020 (Sunday)  17:32:54
**/
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int long long

void solve(){
	int h; int n; cin>>h>>n;
	vector<int> a(n);
	int s=0;
	for(int i=0;i<n;i++){cin>>a[i]; s+=a[i];}
	if(s>=h)
	{
		cout<<"Yes";
	}
	else
		cout<<"No";

}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int t=1; while(t--) solve();
    return 0;
}

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


Measured memory_bytes: 23636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static long solveWeights[][] = new long[101][100001];
    public static int weights[] = new int[100];
    public static int value[] = new int[100];
    public static long n,w;
    public static void main(String args[])throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String nw[]=br.readLine().split(" ");
        n=Long.parseLong(nw[0]);
        w=Long.parseLong(nw[1]);
        int sumValues=0;
        for(int i=0;i<n;i++)
        {

            String S[]=br.readLine().split(" ");
            weights[i]=Integer.parseInt(S[0]);
            value[i]=Integer.parseInt(S[1]);
            sumValues+=value[i];
        }
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=sumValues;j++)
                solveWeights[i][j]=-1;
        }
        solveWeights[0][0]=0;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<=sumValues;j++)
            {
                if(solveWeights[i][j]!=-1)
                {
                    if(solveWeights[i+1][j]==-1||solveWeights[i][j]<solveWeights[i+1][j])
                        solveWeights[i+1][j]=solveWeights[i][j];
                    if(solveWeights[i+1][j+value[i]]==-1||solveWeights[i][j]+weights[i]<solveWeights[i+1][j+value[i]])
                        solveWeights[i+1][j+value[i]]=solveWeights[i][j]+weights[i];
                }
            }
        }
        int maxValue=0;
        for(int i=0;i<=sumValues;i++)
        {
            if(solveWeights[(int)n][i]!=-1&&solveWeights[(int)n][i]<=w)
                maxValue=i;
        }
        System.out.println(maxValue);
    }
}

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

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    cout << max(a[0], max(a[1], a[2])) - min(a[0], min(a[1], a[2])) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n, W; cin >> n >> W;
  V<> w(n), v(n); for (int i = 0; i < n; ++i) cin >> w[i] >> v[i];
  int V = n * 1000;
  VV<lint> dp; assign(dp, n + 1, V + 1, 9e18);
  dp[0][0] = 0;
  for (int i = 0; i < n; ++i) for (int j = 0; j <= V; ++j) {
    dp[i + 1][j] = dp[i][j];
    if (j >= v[i]) {
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
    }
  }
  int res = 0;
  for (int j = 0; j <= V; ++j) {
    if (dp[n][j] <= W) {
      res = j;
    }
  }
  cout << res << '\n';
}

Measured memory_bytes: 79488
import java.util.Scanner;

// https://atcoder.jp/contests/abc168/tasks/abc168_a
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		sc.close();


		int len = n.length();
		n = n.substring(len-1, len);

		if(n.equals("3")) {
			System.out.println("bon");
		}else if(n.equals("0")||n.equals("1")||n.equals("6")||n.equals("8")) {
			System.out.println("pon");
		}else {
			System.out.println("hon");
		}
	}
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

ll mod_num = 10e8+7;

int main() {
    ll h,w; cin >> h >> w;
    vector<vector<char>> a(h,vector<char>(w));
    rep(i, h) rep(j, w) cin >> a[i][j];


    // dpテーブル
    // dp[0][0]からdp[i][j]へたどり着くルートが何通りかを記録する
    vector<vector<ll>> dp(h,vector<ll>(w,0));
    // 初期位置は1にしておく
    dp[0][0] = 1;
    rep(i, h) rep(j, w)  {
        if(a[i][j] == '.') {
            if(i > 0) dp[i][j] += dp[i-1][j]%mod_num;
            if(j > 0) dp[i][j] += dp[i][j-1]%mod_num;
            dp[i][j]%mod_num;
        } else {
            dp[i][j] = 0;
        }

    }

    cout << dp[h-1][w-1]%mod_num << endl;
    return 0;
}


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


int main() {
    int l;
    cin >> l;
    long double ans = 0;
    long double a,b,c;
    a = l / 3.000000000000000;
    b = l / 3.000000000000000;
    c = l - a - b;
    ans = a * b * c;
    cout << fixed << setprecision(13) << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

int main(void){
  ll s;
  cin >> s;

  ll div = (ll)1e9;
  ll a = (s % div == 0) ? (s / div) : (s / div) + 1;
  ll b = (s % div == 0) ? 0 : a * div - s;
  cout << 0 << " " << 0 << " "
       << (ll)1e9 << " " << 1 << " "
       << b << " " << a << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
#include<unordered_map>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define Pll pair<ll,ll>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}
int n,q;
hei(ll) seg, lazy;

void aaa(int k) {
	if (lazy[k] == 0)return ;
	if (k < n - 1) {
		lazy[k * 2 + 1] += lazy[k];
		lazy[k * 2 + 2] += lazy[k];
	}
	seg[k] += lazy[k];
	lazy[k] = 0;
}

void update(int a, int b, ll x,int k,int l,int r) {
	aaa(k);
	if (a<=l && b>=r) {
		lazy[k] += x;
		aaa(k);
	}
	else if(a<r&&l<b){
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		seg[k] = seg[k * 2 + 1]+seg[k * 2 + 2];
	}
}

ll query(int a,int b,int k,int l,int r){
	aaa(k);
	if (l >= b || r <= a)return 0;
	if (a <=l  && b >= r) {
		return seg[k];
	}
	ll v1 = query(a, b, k*2+1, l, (l + r) / 2);
	ll v2 = query(a, b, k*2+2, (l + r) / 2, r);
	return v1 + v2;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	int n;
	cin >> n;
	hei(int) dp(n + 1,100000);
	dp[0] = 0;
	rep(i, 1, n + 1) {
		dp[i] = dp[i - 1] + 1;
		rep(j, 1, 6)if (i >= 6 * j)dp[i] = min(dp[i - (6 * j)] + j, dp[i]);
		for (int j = 1;; j++) {
			if (i < pow(6, j))break;
			dp[i] = min(dp[i - pow(6, j)] + 1, dp[i]);
		}
		rep(j, 1, 9)if(i>=9*j)dp[i] = min(dp[i], dp[i - 9 * j] + j);

		for (int j = 1;; j++) {
			if (i < pow(9, j))break;
			dp[i] = min(dp[i - pow(9, j)] + 1, dp[i]);
		}
	}
	cout << dp[n] << endl;
	return 0;
}

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

using namespace std;

#define int 		  long long
#define f(i,n)        for(int i=0;i<(n);++i)
#define fa(i,a,n)     for(int i=a;i<=(n);++i)
#define fd(i,a,n)     for(int i=a;i>=(n);--i)
#define tc 			  int t;cin>>t;f(testcase,t)
#define pii             pair<int,int>

void c_p_c() {

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

}

int32_t main() {

	c_p_c();
	int n;
	cin >> n;
	int ans = 0;
	if (n % 1000)
		ans = (1000 - (n % 1000));
	cout << ans;
	return 0;
}



Measured memory_bytes: 3644
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
char str[1100][1100];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%s",str[i]);
	bool ok=false;
	for(int i=0;i<a;i++)for(int j=0;j<a;j++)if(str[i][j]=='#')ok=true;
	if(!ok){
		printf("-1\n");return 0;
	}
	int ad=0;
	int ret=114514;
	for(int i=0;i<a;i++){
		bool dd=false;
		for(int j=0;j<a;j++)if(str[j][i]=='.')dd=true;
		if(dd)ad++;
	}
	for(int i=0;i<a;i++){
		bool OK=false;
		for(int j=0;j<a;j++)if(str[j][i]=='#')OK=true;
		
		int cnt=0;
		for(int j=0;j<a;j++){
			if(str[i][j]=='.')cnt++;
		}
		if(!OK)cnt++;
		ret=min(ret,cnt);
		//printf("%d\n",cnt);
	}
	printf("%d\n",ret+ad);
}


Measured memory_bytes: 640
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');

_b(input);

function _b(input: string) {
  const [nk, _p] = input.split('\n');
  const k = parseInt(nk.split(' ')[1]);
  const p = _p.split(' ').map((s) => parseInt(s));

  const minOfK = p.sort((a, b) => a - b).splice(0, k);

  console.log(minOfK.reduce((p, c) => p + c, 0));
}


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

using namespace std;

// #define LOG(...) fprintf(stderr, __VA_ARGS__)
#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for(int i = (int)(n - 1); i >= 0; --i)
#define RFOR(i, a, b) for(int i = (int)(b - 1); i >= (int)(a); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)
#define BIT(x, i) (((x) >> (i)) & 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

bool field[100][100];

int main() {
  int W, H, N;
  cin >> W >> H >> N;

  REP(i, N) {
    int x, y, a;
    cin >> x >> y >> a;

    switch(a) {
      case 1:
        REP(iy, H) REP(ix, x) {
          field[iy][ix] = true;
        }
        break;
      case 2:
        REP(iy, H) FOR(ix, x, W) {
          field[iy][ix] = true;
        }
        break;
      case 3:
        REP(iy, y) REP(ix, W) {
          field[iy][ix] = true;
        }
        break;
      case 4:
        FOR(iy, y, H) REP(ix, W) {
          field[iy][ix] = true;
        }
        break;
    }
  }

  int cnt = 0;
  REP(iy, H) {
    REP(ix, W) {
      if (!field[iy][ix]) {
        cnt++;
      LOG(".");
      } else {
        LOG("#");
      }
    }
    LOG("\n");
  }
  cout << cnt << endl;
}


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

int main(){
  long long int a,b,k;
  cin >> a >> b >> k;
  
  if(a<=k){
    k -= a;
    a = 0;
  }else{
    a -= k;
    cout << a << " " << b << endl;
    return 0;
  }
 
  if(b-k>0){
    b -= k;
  }else if(b-k==0){
    b = 0;
  }else{
    b = 0;
  }
  
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

struct Node {int p, l, r;};
struct Node T[10000];
int n;

void preParse(int u){
  if(u == -1) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u == -1) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u == -1) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main(){
  int i, v, l, r, root;

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

  for(i = 0;i < n;i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if(l != -1) T[l].p = v;
    if(r != -1) T[r].p = v;
  }

  for(i = 0;i < n;i++) if(T[i].p == -1) root =i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}

Measured memory_bytes: 2752
import java.util.Scanner;

public class Main {
    //Palindrome-philia
    //改变最少的字符来使得字符串变成回文
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        System.out.println(helper(s));
        sc.close();
    }

    static int helper(String s) {
        int lo = 0, hi = s.length() - 1;
        int count = 0;
        while (lo < hi) {
            if (s.charAt(lo) != s.charAt(hi)) count++;
            lo++;
            hi--;
        }
        return count;
    }
}


Measured memory_bytes: 21840
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 2000005;
static const int RANGE = 10005;
int A[MAX], C[RANGE], B[MAX];


void countingSort(int A[], int B[], int k, int n) {
    for (int j = 0; j < n; j++) C[A[j]]++; // 配列Cにそれぞれの数が何回現れるかを記録
    for (int i = 1; i <= k; i++) C[i] += C[i-1]; // 配列Cをある数以下の出現回数に直す
    for (int j = n-1; j >= 0; j--) { // 配列Cの最後から配列Bに移していく 
        B[C[A[j]] - 1] = A[j];
        C[A[j]]--;
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i]; // 0~n-1に格納
    countingSort(A, B, RANGE, n);
    for (int i = 0; i < n-1; i++) cout << B[i] << " ";
    cout << B[n-1] << endl;
    
    return 0;
}


Measured memory_bytes: 18764
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
  int n;
  cin >> n;
  vector<vector<int>> a(n,vector<int>(n,-1));
  for(int i=0;i <n;i++){
    int A; cin >> A;
    for(int j = 0;j < A;j++){
      int x,y;
      cin >> x >> y;
      a.at(i).at(x-1) = y;
    }
  }
  int ans = 0;
  for (int bit = 0; bit < (1<<n); ++bit) {
    vector<int> s(n,0);
    int flag = 1;
    int buf = 0;
    for (int i = 0; i < n; ++i) {
      if (bit & (1<<i)) { 
        s.at(i) = 1;
      }
    }
    for(int i = 0;i < n;i++){
      if(s.at(i) == 1){
        buf++;
        for(int j = 0;j < n;j ++){
          if(a.at(i).at(j) == -1){continue;}
          if(a.at(i).at(j) != s.at(j)){
            //cout << i << endl;
            //cout << s.at(0) << s.at(1) << s.at(2) << endl;
            flag = 0; break;}
        }
      }
    }
    if(flag){ans = max(ans,buf);}
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
n, m, k = gets.chomp.split(" ").map(&:to_i)
flag = false
if k % n == 0 || k % m == 0
	flag = true
end
for i in 1..n
	for j in 1..m
		target = ((n-i)*j) + ((m-j)*i)
		if target == k
			flag = true
		end
	end
end

if flag
	puts "Yes"
else
	puts "No"
end



Measured memory_bytes: 1788
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest069-B
#  https://beta.atcoder.jp/contests/abc085/tasks/abc085_a


def change_i18n(s):

	length = len(s)
	umekomiINT = length-2
	umekomiSTR = str(umekomiINT)
	answerStr = s[0:1] + umekomiSTR + s[length-1:length]
	return answerStr


if __name__ == '__main__':
	problemStr=input()
	answerStr=change_i18n(problemStr)
	print(answerStr)

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const ll MOD = 1e9 +7;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    bool can =false;
    if(a<c&&c<b) can=true;
    else if(b<c&&c<a) can =true;
    if(can) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
an = list(map(int, input().split()))
bn = list(map(int, input().split()))
cn = list(map(int, input().split()))

s = sum(bn)
a0 = n+1
for ai in an:
  if ai == a0 + 1:
    s += cn[a0-1]
  a0 = ai
print(s)
    

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
int prime(int );

int main(){

  int n,m,i,ans = 0;

  scanf("%d\n",&n);

  for(i = 0;i < n;i++){

    scanf("%d",&m);
    if(m == 2) ans++;
    if(prime(m) == 1){
      // printf("m = %d\n",m);
      ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}
  int prime(int in){

    int i,j;
    if(in % 2 == 0) return 0;
    for(i = 3;i <= sqrt(in);i+=2){
      if(in % i == 0) return 0;
    }
    return 1;
  }

Measured memory_bytes: 2592
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    ll a; cin >> a;
    string b; cin >> b;
    for(int i = 0; i < b.size(); i++) {
        if(b[i] == '.') {
            b.erase(b.begin()+i);
            break;
        }
    }
    cout << a*stol(b)/100 << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  long f[10][n],p[11][n];
  long kekka = -10000000000000;
  for(int i = 0;i < n;i++){
    for(int j = 0;j < 10;j++){
      cin >> f[j][i];
    }
  }
  for(int i = 0;i < n;i++){
    for(int j = 0;j < 11;j++){
      cin >> p[j][i];
    }
  }
  for(int i = 1;i < 1<<10;i++){
    long cur = 0;
    for(int k = 0;k < n;k++){
      long c = 0;
      for(int j = 0;j < 10;j++){
        if((1 & i>>j) == 1 && f[j][k] == 1){
          c++;
        }
      }
      cur += p[c][k];
    }
    kekka = max(kekka,cur);
  }
  cout << kekka << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5e5+10;
int main()
{
    //std::ios::sync_with_stdio(0);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ax[4];
    ax[0]=a*c;
    ax[1]=a*d;
    ax[2]=b*c;
    ax[3]=b*d;
    sort(ax,ax+4);
    cout<<ax[3]<<endl;




}


Measured memory_bytes: 3672
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	if v[0]%2 == 1 && v[1]%2 == 1 {
		println!("Odd");
	}else{
		println!("Even");
	}
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include <set>

#define DIV 1000000007
using namespace std;
using ll = long long;

typedef struct {
    vector<int> edge;
    int dis;
    int clr;
    int visit;
}node_t;
vector<node_t> node;

queue<int> q;
bool judge() {
    int x = q.front();
    q.pop();

    for (auto to : node[x].edge) {
        if (node[to].visit) {
            if (node[x].clr == 1 && node[to].clr == 1)
                return false;
            else if (node[x].clr == -1 && node[to].clr == -1)
                return false;
        }

        else {
            q.push(to);
            node[to].visit = 1;
            if (node[x].clr == 1)
                node[to].clr = -1;
            else if (node[x].clr == -1)
                node[to].clr = 1;
        }
    }
    if (!q.empty())
        return judge();
    return true;
}

int main() {
    int N;
    cin >> N;
    node = vector<node_t>(N);
    vector<vector<int>> dis(N, vector<int>(N,1e5));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) dis[i][j] = 0;
            char c;
            cin >> c;
            if (c == '1') {
                node[i].edge.push_back(j);
                 dis[i][j] = 1;
            }
        }
    }
    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) 
            printf("dis[%d][%d]=%d", i, j, dis[i][j]);
            cout << endl;       
    }
    */
    q.push(0);
    node[0].clr = 1;
    if (!judge()) cout << -1 << endl;
    else {
        int ans = 0;
        for (int k = 0; k < N; k++) {
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
                    if (k == N - 1) {
                        ans = max(ans, dis[i][j]);
                    }
                }
            }
        }
        cout << ans+1 << endl;
    }
   /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) 
            printf("dis[%d][%d]=%d", i, j, dis[i][j]);
            cout << endl;      
    }
    */
}


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

// GCD, LCM
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 S,W;
    cin>>S>>W;

    if(W>=S){
        cout<<"unsafe"<<endl;
    }else{
        cout<<"safe"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3636