akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<tuple<string,int,int>> vec(N);
  
  for(int i = 0;i<N;i++){
    string s;
    int p;
    cin >>s >> p;
    vec.at(i) = make_tuple(s,-p,i+1);
  }
  
  sort(vec.begin(),vec.end());
  
  for(int j = 0;j<N;j++){
    string s;
    int p;
    int i;
    tie(s,p,i) = vec.at(j);
    cout << i << endl;
  }

}
  


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#define N 4
#define N2 16
#define LIMIT 100

static const int dy[4] = { 1, 0, -1, 0};
static const int dx[4] = { 0, -1, 0, 1};
static const char dir[4] = { 'r', 'u', 'l', 'd'};
int MDT[N2][N2];

typedef struct p{
  int f[N2];
  int space;
  int MD;
} Puzzle;

Puzzle state;
int lim;
int path[LIMIT];

int getAllMD(Puzzle p){
  int sum=0, i;
  for( i = 0 ; i < N2 ; i++ ){
    if( p.f[i] == N2 ) continue;
    sum += MDT[i][p.f[i]-1];
  }
  return sum;
}

int isSolved(){
  int i;
  for( i = 0 ; i < N2 ; i++ ){
    if( state.f[i] != i+1 ) return 0;
  }
  return 1;
}

int dfs(int depth, int prev){
  int r;
  Puzzle tmp;
  if( state.MD == 0 ) return 1;
  if( depth + state.MD > lim ) return 0;

  int sx = state.space / N;
  int sy = state.space % N;

  for( r = 0 ; r < 4 ; r++ ){
    int tx = sx + dx[r];
    int ty = sy + dy[r];
    if( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
    if( (fmax( prev, r ) - fmin( prev, r )) == 2 ) continue;
    tmp = state;
    state.MD -= MDT[tx * N + ty][state.f[tx * N + ty]-1];
    state.MD += MDT[sx * N + sy][state.f[tx * N + ty]-1];
    int t;
    t = state.f[tx * N + ty];
    state.f[tx * N + ty] = state.f[sx * N + sy];
    state.f[sx * N + sy] = t;
    state.space = tx * N + ty;
    if( dfs(depth+1,r) == 1 ){
      path[depth] = r;
      return 1;
    }
    state = tmp;
  }
  return 0;
}

char ans[1000];

int iterative_deepening(Puzzle in){
  int i;

  in.MD = getAllMD(in);

  for( lim = in.MD ; lim <= LIMIT ; lim++ ){
    state = in;
    if( dfs(0, -100) == 1 ){
      ans[0] = '\0';
      for( i = 0 ; i < lim ; i++ ) ans[i+1] = dir[path[i]];
      return i;
    }
  }
  ans[10] = '\0';
  return 10;
}

int main(){
  int i, j, ans;

  for( i = 0 ; i < N2 ; i++ ){
    for( j = 0 ; j < N2 ; j++ ){
      MDT[i][j] = fabs( i / N - j / N ) + fabs( i % N - j % N );
    }
  }
  Puzzle in;
  for( i = 0 ; i < N2 ; i++ ){
    scanf("%d",&in.f[i]);
    if( in.f[i] == 0 ){
      in.f[i] = N2;
      in.space = i;
    }
  }
  ans = iterative_deepening(in);
  printf("%d\n",ans);

  return 0;
}



Measured memory_bytes: 2108
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            String predicted = in.next();
            String forecasted = in.next();
            int c = 0;
            for (int i = 0; i < predicted.length(); i++)
            {
                if (predicted.charAt(i) == forecasted.charAt(i))
                {
                    c++;
                }
            }
            out.print(c);
        }

    }
}

Measured memory_bytes: 22100
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <functional>
#include <time.h>
#include <math.h>

using namespace std;


int main() {

	int n;
	cin >> n;
	double x;
	for (int i = 1; i < 10; i++) {
		x = (double)n / (double)i;
		if ((fmod(x,1) == 0) && (x < 10)) {
			cout << "Yes";
			exit(0);
		}
	}
	cout << "No";
}

Measured memory_bytes: 384
"""
https://abc062.contest.atcoder.jp/tasks/abc062_b
"""
[h,w]=[int(i) for i in input().split()]
pic=[]
d=""
for i in range(h):
    pic.append([j for j in input().split()])
#print(pic)

for i in range(w+2):
    print("#",end="")
print("")
for i in range(h):
    d=d+str(pic[i][0])
    print("#"+d+"#")
    d=""
for i in range(w+2):
    print("#",end="")


Measured memory_bytes: 3064
n,m=(int(x) for x in input().split())
A=[[0 for i in range(m)] for j in range(n)]
b=[0]*m
for i in range(n):
    A[i]=list(int(x) for x in input().split())
for i in range(m):
    b[i]=int(input())
c=[0]*n
for i in range(n):
    for j in range(m):
        c[i]=c[i]+A[i][j]*b[j]
    print(c[i])


Measured memory_bytes: 6036
#include <iostream>
#include <climits>
#include <string>
#include <stdlib.h>
#include <algorithm>

using namespace std;
 
int ascSort(const void* v1, const void* v2) {
    const int _v1 = *((const int*)v1);
    const int _v2 = *((const int*)v2);
 
    if ( _v1 < _v2 ) {
        return 1;
    } else if ( _v1 > _v2 ) {
        return -1;
    } else {
        return 0;
    }
}
int main(){
	long int n,i,look,start,end,check,ans=0;
	string get,getrep;
	cin >> n;
	cout << ans << endl;
	cin >> get;
	start = 0;
	look = n/2;
	end = n;
	for(i=1;i<=20;i++){
		cout << look <<endl;
		cin >> getrep;
		if(getrep == "Vacant"){
			break;
		}else if((look%2==0 && get == getrep) || (look%2==1 && get != getrep)){
			start = look;
			look = (start +end)/2;
		}else{
			end = look;
			look = (start+end)/2;
		}
	}
	return 0;
}


Measured memory_bytes: 852
<?php
$word = str_split(trim(fgets(STDIN)));

if (isKaibun($word)) {
  echo 'Yes';
} else {
  echo 'No';
}

function isKaibun($word) {
  $result = true;

  $length = count($word);
  for ($i=0; $i < $length/2; $i++) {
    if ($word[$i] != $word[$length-1 - $i]) {
      $result = false;
      break;
    }
  }

  $length = ($length-1)/2;
  for ($i=0; $i < $length/2; $i++) {
    if ($word[$i] != $word[$length-1 - $i]) {
      $result = false;
      break;
    }
  }

  return $result;
}


Measured memory_bytes: 4604
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
const double pi = 3.141592653589;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {return (a%b) ? gcd(b, a%b) : b;}
ll modPow(ll x, ll n) {
    if(n==0) return 1;
    ll res = modPow(x*x%MOD, n/2);
    if(n&1) res=res*x%MOD;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    while(true) {
        int h,w;cin>>h>>w;
        if (h==0 && w==0) {
            return 0;
        }
        rep(i,h) {
            rep(j,w) {
                if (i==0 || i==h-1 || j==0 || j==w-1) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << "\n";
        }
        cout << "\n";
    }
}


Measured memory_bytes: 3044
import java.util.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int A = in.nextInt(), B = in.nextInt(), C = in.nextInt();
    System.out.println(Math.max(0, B + C - A));
  }
}


Measured memory_bytes: 21844
# Problem B - Multiplication 2

# input
N = int(input())
a_nums = list(map(int, input().split()))

# count
if 0 in a_nums:
    print(0)
else:
    ans = 1
    for a in a_nums:
        ans *= a
        if ans > 10**18:
            ans = -1
            break
    print(ans)


Measured memory_bytes: 21636
import math
def plot(x,y):
    print(f'{x:.8f} {y:.8f}')

def koch(n,x1,y1,x2,y2):
    if n==0:
        plot(x1,y1)
        return
    sx=(2*x1+1*x2)/3
    sy=(2*y1+1*y2)/3
    tx=(1*x1+2*x2)/3
    ty=(1*y1+2*y2)/3
    ux=(tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
    uy=(tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
    
    koch(n-1,x1,y1,sx,sy)
    koch(n-1,sx,sy,ux,uy)
    koch(n-1,ux,uy,tx,ty)
    koch(n-1,tx,ty,x2,y2)

n=int(input())
koch(n,0,0,100,0)
plot(100,0)


Measured memory_bytes: 5752
#include<stdio.h>
#include<string.h>
char s[300000];
int main(void){
    int i,n;
    double a_cnt,ans=0;
    for(i=0;i<300000;i++){
        s[i]=0;
    }
    scanf("%s",s);
    n=strlen(s);
    a_cnt=0;
    for(i=0;i<n;i++){
        if(s[i]=='A'){
            a_cnt++;
        }else if(s[i]=='B'&&s[i+1]=='C'){
            ans+=a_cnt;
            i++;
        }else{
            a_cnt=0;
        }
    }
    printf("%.0lf\n",ans);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(int argc, char *argv[]){
    int y;
    cin >> y;
    if (y == 3 || y == 5 || y == 7)
    {
        cout << "YES" << endl;
    } else
    {
        cout << "NO" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())

ans = H * W
for ha in range(1, H):
    a = ha * W

    hb = (H - ha) // 2

    b = hb * W
    c = H * W - a - b

    ans = min(ans, max(a, b, c) - min(a, b, c))

    wb = W // 2
    b = (H - ha) * wb
    c = H * W - a - b

    ans = min(ans, max(a, b, c) - min(a, b, c))

for wa in range(1, W):
    a = H * wa

    wb = (W - wa) // 2

    b = H * wb
    c = H * W - a - b

    ans = min(ans, max(a, b, c) - min(a, b, c))

    hb = H // 2
    b = (W - wa) * hb
    c = H * W - a - b

    ans = min(ans, max(a, b, c) - min(a, b, c))

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int l,r,d;
  cin >> l>>r>>d;
  int ans=0;
  for(int i=l;i<=r;i++){
    if(i%d==0){
      ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

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

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	bool ac = abs(c - a) <= d;
	bool abc = (abs(b - a) <= d) && (abs(c - b) <= d);
	if (ac || abc) wrln("Yes");
	else wrln("No");
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ac = [0]*n
wa = [0]*n

for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        ac[p-1] = 1
    elif s == "WA":
        if ac[p-1] != 1:
            wa[p-1] += 1

for i in range(n):
    if ac[i] == 0:
        wa[i] = 0

print(sum(ac), sum(wa))


Measured memory_bytes: 45656
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long i,j=0,k,b,c,d,t,n,y,z;
    cin>>n;
    long long a[10000];
    z=n;
    for(i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            c=i-1;
            d=(n/i)-1;
            y=c+d;
            z=min(z,y);
        }
    }
   
    cout<<z<<endl;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] cnt = new int[m + 1];
            for (int i = 0; i < n; i++) {
                int k = in.nextInt();
                for (int j = 0; j < k; j++) {
                    int a = in.nextInt();
                    cnt[a]++;
                }
            }
            int ans = 0;
            for (int i = 0; i < m + 1; i++) {
                if (cnt[i] == n) ans++;
            }
            out.println(ans);
        }
    }

    public static void main(String argds[]) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}



Measured memory_bytes: 21972
#include<cstdio>
#include<cstring>
#include<algorithm>

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

using namespace std;

int n,star;
int cnt[12]; // 数字 i が書かれた牌はあと i 個
int rem[12]; // * が i に成れるのは rem[i] 個まで

bool dfs(int i){
	if(i==12) return star==0;

	if(cnt[i]==0){
		if(dfs(i+1)) return true;
	}

	// i, i, i
	if(cnt[i]+min(star,rem[i])>=3){
		int tmp=min(cnt[i],3);
		cnt[i]-=tmp;
		star-=3-tmp;
		rem[i]-=3-tmp;
		bool res=dfs(i);
		cnt[i]+=tmp;
		star+=3-tmp;
		rem[i]+=3-tmp;
		if(res) return true;
	}

	// i, i+1, i+2
	if(i<=9){
		bool b=true; // i, i+1, i+2 の割り当てが可能かどうか
		int minus=0;
		rep(j,3){
			if(cnt[i+j]==0 && min(star-minus,rem[i+j])==0) b=false;
			if(cnt[i+j]==0) minus++;
		}
		if(b){
			bool used[3]={};
			rep(j,3){
				if(cnt[i+j]>0) cnt[i+j]--, used[j]=true;
				else           star--, rem[i+j]--;
			}
			bool res=dfs(i);
			rep(j,3){
				if(used[j]) cnt[i+j]++;
				else        star++, rem[i+j]++;
			}
			if(res) return true;
		}
	}

	return false;
}

int main(){
	scanf("%d",&n);
	int hai[47],star=0;
	rep(i,3*n+1){
		char s[4]; scanf("%s",s);
		if(s[0]=='*'){
			hai[i]=-1;
			star++;
		}
		else{
			hai[i]=atoi(s)-1;
			cnt[hai[i]]++;
		}
	}

	bool none=true;
	rep(a,12) if(cnt[a]<4) { // 3*n+2 枚目の牌
		hai[3*n+1]=a;
		cnt[a]++;

		rep(i,12) rem[i]=4-cnt[i];

		bool ok=false;
		rep(b,12) if(cnt[b]+star>=2) { // 最後の二つの牌
			int tmp1[47],tmp2[12],tmp3[12];
			memcpy(tmp1,hai,sizeof hai);
			memcpy(tmp2,cnt,sizeof cnt);
			memcpy(tmp3,rem,sizeof rem);

			::star=star;
			int m=3*n+2,two=2;
			rep(i,m) if(two>0 && hai[i]== b) swap(hai[i],hai[m-1]), i--, m--, two--, cnt[b]--;
			rep(i,m) if(two>0 && hai[i]==-1) swap(hai[i],hai[m-1]), i--, m--, two--, rem[b]--, ::star--;
			ok=dfs(0);

			memcpy(hai,tmp1,sizeof hai);
			memcpy(cnt,tmp2,sizeof cnt);
			memcpy(rem,tmp3,sizeof rem);

			if(ok) break;
		}

		if(ok) printf("%d\n",a+1), none=false;

		cnt[a]--;
	}
	if(none) puts("-1");

	return 0;
}

Measured memory_bytes: 1028
n = int(input())
a = list(map(int,input().split()))
m = int(sum(a)/n)
power1 = 0
power2 = 0
for ind in range(n):
    power1 += (a[ind]-m)**2
    power2 += (a[ind]-m-1)**2
print(min(power1,power2))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[4];
    rep(i,0,4){
        cin>>a[i];
    }
    sort(a,a+4);
    if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9) cout <<"YES"<<"\n";
    else cout <<"NO"<<"\n";
}

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

long long n,m;
long long ans;

class shop{
	public:
		bool operator < (shop that){
			if(this->a < that.a)
				return 1;
			else
				return 0;
		}
		long long a;//money
		long long b;//amount
};

shop arr[100005];

inline long long read(){//快读 
	long long s=0,w=1;
	char ch = getchar();
	while(ch < '0' || ch > '9'){
		if(ch == '-')w = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		s = s*10+ch-'0';
		ch = getchar();
	}
	return w*s;
}

int main(){
	n = read(),m = read();
	for(long long i = 1;i <= n;++i){
		arr[i].a = read();
		arr[i].b = read();
	}
	sort(arr+1,arr+n+1);
	for(long long i = 1;i <= n;++i){
		if(m > arr[i].b){
			ans += arr[i].a*arr[i].b;
			m -= arr[i].b;
		}else{
			ans += m*arr[i].a;
			break;
		}
	}
	cout << ans;
	return 0;
}

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

using namespace std;


int main()
{

        int n, k;
        int input;
        vector<int> h;
        float avg;

        vector<int> hoge;

        cin >> n;
        cin >> k;
        int sum = 0;

        for (int i=0; i<n; i++) {
                cin >> input;
                h.push_back(input);
                sum += input;
        }

        avg = sum / (float)n;

        sort(h.begin(), h.end());

        for (int i=0; i<n-k+1; i++) {
                hoge.push_back(h[i+k-1]- h[i]);
        }


        cout << *(min_element(hoge.begin(), hoge.end())) << endl;

        return 0;
}


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

int main() {
  long double a, b, x;
  cin >> a >> b >> x;
  if (x >= a * b * 0.5 * a) {
    cout << fixed << setprecision(10) << atan(2.0 * b / a - 2.0 * x / (a * a * a)) * 180.0 / M_PI << endl;
  } else {
    cout << fixed << setprecision(10) << 90.0 - (atan(2.0 * x / (a * b * b)) * 180.0 / M_PI) << endl;
  }
}

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

int main(){
  int N;
  cin>>N;
  vector<vector<int>> am(N,vector<int>(5)),pm(N,vector<int>(5));
  for(int i=0;i<N;++i){
    for(int j=0;j<5;++j){
      cin>>am[i][j]>>pm[i][j];
    }
  }

  vector<vector<int64_t>> p(N,vector<int64_t>(11));
  for(int i=0;i<N;++i){
    for(int j=0;j<11;++j){
      cin>>p[i][j];
    }
  }

  int64_t ans=-1e10;

  for(int tmp=1;tmp<(1<<10);++tmp){ 
    bitset<10> s(tmp);
    //0から4がam、5から9がpm
    vector<int64_t> c(N);
    for(int i=0;i<5;++i){
      if(s.test(i)){
        for(int j=0;j<N;++j){
          if(am[j][i]==1) ++c[j];
        }
      }
    }
    for(int i=5;i<10;++i){
      if(s.test(i)){
        for(int j=0;j<N;++j){
          if(pm[j][i-5]==1) ++c[j];
        }
      }
    }
    
    int64_t subans=0;
    for(int i=0;i<N;++i){
      subans += p[i][c[i]];
    }
    ans=max(ans,subans);
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int N,i;
  	char str[100] = {0};
  
 	scanf("%d",&N);
  	scanf("%s",str);
  	if(str[N] == 0){
		printf("%s",str);
    }
    else{
    	for(i = 0; i< N ; i++){
        	printf("%c",str[i]);
        }
      	printf("...");
    }  
  
return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define int                  long long int
#define ff                   first
#define ss                   second
#define pb                   push_back
#define mp                   make_pair
#define pii                  pair<int,int>
#define vi                   vector<int>
#define mi                   map<int,int>
#define pqb                  priority_queue<int>
#define pqs                  priority_queue<int,vi,greater<int>>
#define setbits(x)           __builtin_popcountll(x)
#define zrobits(x)           __builtin_ctzll(x)
#define mod                  1000000007
#define inf                  1e18
#define precise(x,y)         fixed<<setprecision(y)<<x
#define w(x)                 int x;cin>>x;while(x--)
#define endl                 "\n"
#define no_of_digit(n)       floor(log10(n))+1
#define copyarr(a,b,n)       copy_n(a,n,b)

bool vowelcheck(char c) {
	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U')
		return true;

	return false;
}

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//*****************Enter the code here*******************//
	int a;
	cin >> a;
	cout << a + a*a + a*a*a << endl;
	return 0;
}


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


int main(){
  ll a,c;
  double b;
  cin>>a>>b;
  int b_=b*100+0.00001;
  c=a*b_/100;
  cout<<c<<endl;
}

Measured memory_bytes: 3696
#include<stdio.h>
int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    int d[100], a[100][100];
    for(int i=0;i<k;i++){
        scanf("%d", &d[i]);
        for(int j=0;j<d[i];j++){
            scanf("%d", &a[i][j]);
        }
    }
    int list[101]={};
    for(int i=0;i<n;i++){
        for(int j=0;j<d[i];j++){
            list[a[i][j]]=1;
        }
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(!list[i]){
        ans++;
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 1756
fun main(args: Array<String>) = println(run {
    val (n,m,q)= readLine()!!.split(" ").map { it.toInt() }
    val abcd = (1..q).map { readLine()!!.split(" ").map { it.toInt() } }

    val numsList = getNumsList(1, 0, m, IntArray(n), mutableListOf<IntArray>())
    numsList.map {
        point(abcd, it)
    }.max()!!

})

fun getNumsList(min: Int, index: Int, m: Int, array: IntArray, all: MutableList<IntArray>): List<IntArray> {
    if(index > array.lastIndex) {
        all.add(array.copyOf())
        return all
    }
    for (i in min..m) {
        array[index] = i
        getNumsList(i, index+1, m, array, all)
    }
    return all
}

fun point(abcd: List<List<Int>>, nums: IntArray) =
        abcd.sumBy {
            val (a,b,c,d) = it
            if(nums[b-1]-nums[a-1] == c) d else 0
        }


Measured memory_bytes: 51624
n=input()
if len(n)<3:
    print(0)
    exit()
dp=[[[[[0]*2 for _ in range(2)]for _ in range(2)] for _ in range(2)] for _ in range(len(n)+1)]
dp[0][0][0][0][0]=1
for i,c in enumerate(n):
  c=int(c)
  for l in range(2):
    for m in range(2):
      for s in range(2):
        for t in range(2):
          for j in [7,5,3]:
            if l==0 and c<j:
              continue
            dp[i+1][l or j<c][m or j==7][s or j==5][t or j==3]+=dp[i][l][m][s][t]
an=[0, 0, 0, 6, 36, 150, 540, 1806, 5796]
if len(n)==3:
  print(dp[-1][1][1][1][1]+dp[-1][0][1][1][1])
else:
  print(dp[-1][1][1][1][1]+dp[-1][0][1][1][1]+sum(an[3:len(n)]))

Measured memory_bytes: 3064
from collections import Counter
from itertools import accumulate


def prime_factorize(n):
    """素因数分解し，ユニークな素因数のsetを返す。"""
    ans = []
    ans_add = ans.append
    while n % 2 == 0:
        ans_add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            ans_add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        ans_add(n)
    return ans


def main():
    n = int(input())
    primes = prime_factorize(n)
    acc = tuple(accumulate(range(1, 42)))
    counted = Counter(primes)
    countcount = Counter(counted.values())
    ans = 0

    for c, cc in countcount.items():
        for i, x in enumerate(acc):
            if c >= x:
                tmp = i + 1
            else:
                break
        ans += tmp * cc

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9504
#include <iostream>
#define MAX 100000
#define INFTY 1000000001

using namespace std;

typedef struct{
    char suit;
    int number;
}Card;

Card A[MAX];
Card B[MAX];
int n;

void swapCard(int a, int b){
    Card tmp = A[a];
    A[a] = A[b];
    A[b] = tmp;
}

void merge(Card *A, int left, int mid, int right){
    int i, j;
    int n1 = mid - left;
    int n2 = right - mid;
    Card L[n1+1], R[n2+1];
    for(i = 0; i < n1; i++) L[i] = A[left + i];
    for(i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1].number = INFTY;
    R[n2].number = INFTY;
    i = 0;
    j = 0;
    for(int k = left; k < right; k++){
        if(L[i].number <= R[j].number){
            A[k] = L[i];
            i++;
        }else{
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(Card *A, int left, int right){
    int mid;
    if(left + 1 < right){
        mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int partition(int p, int r){
    int x = A[r].number;
    int i = p - 1;
    int tmp;
    for(int j = p; j < r; j++){
        if(A[j].number <= x){
            i++;
            swapCard(i, j);
        }
    }
    swapCard(i+1, r);
    return i+1;
}

void quickSort(int p, int r){
    if(p < r){
        int q = partition(p, r);
        quickSort(p, q-1);
        quickSort(q+1, r);
    }
}

bool isStable(){
    for(int i = 0; i < n; i++){
        if(A[i].suit != B[i].suit) return false;
    }
    return true;
}

int main(){
    int i;
    cin >> n;
    for(i = 0; i < n; i++) {
        cin >> A[i].suit >> A[i].number;
        B[i] = A[i];
    }
    quickSort(0, n-1);
    mergeSort(B, 0, n);
    if(isStable()) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    for(i = 0; i < n; i++){
        cout << A[i].suit << " " << A[i].number << endl;
    }
    return 0;
}


Measured memory_bytes: 5360
#include <iostream>
#include <algorithm>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n; cin>>n;
	int a=0,un=0;
	string ans="YES";
	rep(i,n){
		string s; cin>>s;
		if(s=="A") a++;
		else un++;
		if(a<un) ans="NO";
	}
	if(a!=un) ans="NO";
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3220
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    char op;
    while(true){
        cin >> a >> op >> b;
        if (op == '?'){
            break;
        }
        if ( op == '+'){
            cout << (a+b) << endl;
        }
        if ( op == '-'){
            cout << (a-b) << endl;
        }
        if ( op == '*'){
            cout << (a*b) << endl;
        }
        if ( op == '/'){
            cout << (a/b) << endl;
        }
         
         
         
         
         
         
         
    }
}


Measured memory_bytes: 3088
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int ans=0,n,p,a[110],i,j;
  scanf("%d\n",&n);
  for(i=0;i<=100;i++){
    a[i]=0;
  }
  for(i=0;i<n;i++){
    scanf("%d ",&p);
    a[p]++;
  }
  for(i=1;i<=100;i++){
    int sum=0;
    for(j=i;j<=100;j++){
      sum+=a[j];
    }
    if(sum>=i){
      ans=i;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 3224
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    int N;
    string S;
    private void Scan()
    {
        N = int.Parse(Console.ReadLine());
        S = Console.ReadLine();
    }

    public void Solve()
    {
        Scan();
        int cnt = 0;
        int min = int.MaxValue;
        for (int i = 0; i < S.Length; i++)
        {
            if (S[i] == '(')
            {
                cnt++;
            }
            if (S[i] == ')')
            {
                cnt--;
            }
            min = Math.Min(min, cnt);
        }
        if (min < 0)
        {
            S = S = new string('(', -min) + S;
            cnt -= min;
        }
        S = S + new string(')', cnt);
        Console.WriteLine(S);
    }
}


Measured memory_bytes: 11092
n,m,x=map(int,input().split())
cost=[0]*n
l=[]
ans=-1
for i in range(n):
    l.append(list(map(int,input().split())))
for i in range(1<<n):
    skill=[0]*m
    cost=0
    bit=[(i>>j)&1 for j in range(n)]
    for j in range(n):
        if bit[j]==1:
            cost+=l[j][0]
            for k in range(m):
                skill[k]+=l[j][k+1]
    check=0
    for num in skill:
        if num<x:
            check=1
            break
    if check==0:
        if ans==-1:
            ans=cost
        else:
            ans=min(ans,cost)
print(ans)


Measured memory_bytes: 9232
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;

bool flag[1005][1005];
int temp[1005][1005];
char map[1005][1005],ch[1005];
int n,m,xy[10][2],sum;
char tt[10]={'1','2','3','4','5','6','7','8','9','10',},t;
void initflag(){
	for(int i=0;i<1005;i++){
		memset(flag[i],true,sizeof(flag[i]));
	}
}
void initmap(){
	for(int i=0;i<1005;i++){
		memset(map[i],'X',sizeof(map[i]));
	}	
}
int main(){
	int i,j,k,x,y;
	while(~scanf("%d%d%d",&n,&m,&k)){
		initmap();
		for(i=1;i<=n;i++){
			scanf("%s",ch);
			for(j=1;j<=m;j++){
				map[i][j]=ch[j-1];
				if(map[i][j]=='S'){
					xy[0][0]=i;
					xy[0][1]=j;
				}
				if(map[i][j]>='1'&&map[i][j]<='9'){
					xy[map[i][j]-'0'][0]=i;
					xy[map[i][j]-'0'][1]=j;
				}
			}
			
		}
		/*
		for(i=0;i<=n+1;i++){
			for(j=0;j<=m+1;j++)
			printf("%c",map[i][j]);
			printf("\n");
		}
		for(i=0;i<=n+1;i++){
			for(j=0;j<=m+1;j++)
			printf("%d",flag[i][j]);
			printf("\n");
		}
		for(i=0;i<10;i++){
			printf("%c %d %d\n",tt[i],xy[i][0],xy[i][1]);
		}
		*/
		
		sum=0;
		for(i=0;i<k;i++){
			initflag();                 //初始 flag	 
			x=xy[i][0];y=xy[i][1];		//起点坐?	 
			queue<int> q;				// ?? 
			q.push(x*10000+y);
			flag[x][y]=false;				//?? 
			temp[x][y]=0;				//?数 
			t=tt[i];					//目? 
				
			//printf("i=%d x=%d y=%d q=%d t=%c\n" ,i,x,y,q.front(),t);
			while(!q.empty()){
				x=q.front()/10000;y=q.front()%10000;
				if(flag[x+1][y]&&map[x+1][y]!='X'){
					q.push((x+1)*10000+y);
					flag[x+1][y]=false;
					temp[x+1][y]=temp[x][y]+1;
				}
				if(map[x+1][y]==t){sum+=temp[x+1][y];break;}
				
				if(flag[x-1][y]&&map[x-1][y]!='X'){
					q.push((x-1)*10000+y);
					flag[x-1][y]=false;
					temp[x-1][y]=temp[x][y]+1;
				}
				if(map[x-1][y]==t){sum+=temp[x-1][y];break;}
				if(flag[x][y+1]&&map[x][y+1]!='X'){
					q.push(x*10000+y+1);
					flag[x][y+1]=false;
					temp[x][y+1]=temp[x][y]+1;
					
				}
				if(map[x][y+1]==t){sum+=temp[x][y+1];break;}
				if(flag[x][y-1]&&map[x][y-1]!='X'){
					q.push(x*10000+y-1);
					flag[x][y-1]=false;
					temp[x][y-1]=temp[x][y]+1;
				}
				if(map[x][y-1]==t){sum+=temp[x][y-1];break;}
				q.pop();
			}
		}
		printf("%d\n",sum);
		
	}
	return 0;
}

Measured memory_bytes: 6956
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << min(a, b) + min(c, d) << endl;


    return 0;
}

Measured memory_bytes: 256
def shichigo(s):
    if '3' not in s:
        return False
    if '5' not in s:
        return False
    if '7' not in s:
        return False
    x = s.replace('3','').replace('5','').replace('7','')
    if x=='':
        return True
    return False

n = input()

l = [[] for i in range(len(n))]
l[0] = ['3','5','7']
for i in range(1,len(l)):
    for j in range(len(l[i-1])):
        l[i].append('3'+l[i-1][j])
        l[i].append('5'+l[i-1][j])
        l[i].append('7'+l[i-1][j])

ans = 0
for i in range(len(l)):
    for j in range(len(l[i])):
        if int(n) >= int(l[i][j]):
            if shichigo(l[i][j]):
                ans += 1

print(ans)


Measured memory_bytes: 42224
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int K, N, ans, m;   cin >> K >> N;
    std::vector<int> v(N);
    for(int i=0; i<N; i++)  cin >> v[i];
    ans = min(v[N-1]-v[0], K+v[0]-v[1]);
    for(int i=0; i<N-1; i++){
        m = min(K+v[i-1]-v[i], K+v[i]-v[i+1]);
        if(m < ans) ans = m;
    }
    cout << ans;
}

Measured memory_bytes: 1024
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#define MOD 1000000007

int A[3000];
int dp[3000][3000];
int main() {
    int i,j;
    int N,Q,X,Y;
    scanf("%d %d",&N,&Q);
    for (i = 0; i < N; i++) scanf("%d",&A[i]);
    for (i = 0; i < N; i++) {
        for (j = 0; j < N; j++) {
            if (A[i] < A[j]) dp[i][j]++;
        }
    }
    print2dArr(dp,N,N);
    for (i = 0; i < Q; i++) {
        scanf("%d %d",&X,&Y);
        X--,Y--;
        for (j = 0; j < N; j++) {
            if ((j != X) && (j != Y)) {
                dp[j][X] = dp[j][Y] = ((LLI) ((dp[j][X]+dp[j][Y]) % MOD)*((MOD+1)/2)) % MOD;
                dp[X][j] = dp[Y][j] = ((LLI) ((dp[X][j]+dp[Y][j]) % MOD)*((MOD+1)/2)) % MOD;
            }
        }
        dp[X][Y] = dp[Y][X] = ((LLI) ((dp[X][Y]+dp[Y][X]) % MOD)*((MOD+1)/2)) % MOD;
    }

    int ans = 0;
    for (i = 0; i < N; i++) {
        for (j = 0; j < i; j++) {
            ans += dp[i][j];
            if (ans >= MOD) ans -= MOD;
        }
    }
    for (i = 0; i < Q; i++) ans = (2*ans) % MOD;
    printf("%d\n",ans);

    return 0;
}



Measured memory_bytes: 38964
n,l = map(int, input().split())
a = [l+i for i in range(n)]
if a[0] <= 0 and a[-1] >= 0:
    print(sum(a))
elif a[0] > 0:
    print(sum(a)- a[0])
else:
    print(sum(a)-a[-1])

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x) {
	return(x + 9) / 10 * 10;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int N, Q;
	cin >> N >> Q;
	vector<vector<int>> G(N + 1);
	vector<int> value(N+1);
	vector<int> look(N + 1, 0);
	for (int i = 0; i < N-1; i++) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for (int i = 0; i < Q; i++) {
		int a, b;
		cin >> a >> b;
		value[a] = value[a] + b;
	}
	queue<int> q;
	q.push(1);
	look[1] = 1;
	while (!q.empty()) {
		int a = q.front();
		q.pop();
		for (auto i : G[a]) {
			if (look[i] != 0) {
				continue;
			}
			else {
				look[i] = 1;
				q.push(i);
				value[i] = value[i] + value[a];
			}
		}
	}
	for (int i = 1; i <= N; i++) {
		cout << value[i] << " ";
	}
}

Measured memory_bytes: 16372
people_num, first_point, correct = map(int,input().split())
who_correct = [input() for i in range(correct)]
points = [first_point-correct for i in range(people_num)]

 
for i in range(correct):
    points[int(who_correct[i])-1] += 1
    
for i in range(people_num):
  if points[i] <= 0:
  	print("No")
  else:
    print("Yes")


Measured memory_bytes: 14208
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int ctoi(char c) {
	return c - '0';
}

int main() {

    string s; cin >> s;

	int a = ctoi(s[0]) * 10 + ctoi(s[1]);
	int b= ctoi(s[2]) * 10 + ctoi(s[3]);

	bool f = false;

	if (a >= 1 && a <= 12)f = true;

	bool g = false;

	if (b >= 1 && b <= 12)g = true;

	if (f == true && g == true) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (f == true && g == false) {
		cout << "MMYY" << endl;
	}
	else if (f == false && g == true) {
		cout << "YYMM" << endl;
	}
	else {
		cout << "NA" << endl;
	}



	return 0;
}

Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
int in(void){int x;cin>>x;return x;}
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define ll long long int
long long int dx[4]={1,0,-1,0};
long long int dy[4]={0,1,0,-1};
int D[2]={1,-1};
int main() {
  string s;
  cin>>s;
  s[0]='2';s[1]='0';s[2]='1';
  s[3]='8';
  cout<<s;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	int X, A, B;
	cin >> X >> A >> B;

	X -= A;

	cout << X % B << endl;

	return 0;
}

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

int A,B,C,X,Y;

int main(){
    cin >> A >> B >> C >> X >> Y;
    int cost = A*X + B*Y;
    int Anum = X;
    int Bnum = Y;
    int ABnum = 0;
    while(Anum>=1 || Bnum>=1){
        if(Anum==0){
            if(cost > cost - B + 2*C){
                Bnum--;
                ABnum++;
                cost = cost - B + 2*C;
            }else{
                break;
            }
        }else if(Bnum==0){
            if(cost > cost - A + 2*C){
                Anum--;
                ABnum++;
                cost = cost - A + 2*C;
            }else{
                break;
            }
        }else{
            if(cost > cost - A - B + 2*C){
                Anum--;
                Bnum--;
                ABnum++;
                cost = cost - A - B + 2*C;
            }else{
                break;
            }
        }
        
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 256
/**
*    author:  boutarou
*    created: 28.06.2020 20:54:48
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

const double PI = 3.1415926535897932;
const int INF = 1e9;

int d;
int c[26];
int s[365][26];
vector<int> previous(26);

int score(int day, int contest, vector<int> before) {
    int cnt = 0;
    cnt += s[day][contest];
    before[contest] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    return cnt;
}

int score2(int day, int contest1, int contest2, vector<int> before) {
    int cnt = 0;
    cnt += s[day][contest1];
    before[contest1] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    day++;
    cnt += s[day][contest2];
    before[contest2] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    return cnt;
}

int score3(int day, int contest1, int contest2, int contest3, vector<int> before) {
    int cnt = 0;
    cnt += s[day][contest1];
    before[contest1] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    day++;
    cnt += s[day][contest2];
    before[contest2] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    day++;
    cnt += s[day][contest3];
    before[contest3] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    return cnt;
}

int score4(int day, int contest1, int contest2, int contest3, int contest4, vector<int> before) {
    int cnt = 0;
    cnt += s[day][contest1];
    before[contest1] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    day++;
    cnt += s[day][contest2];
    before[contest2] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    day++;
    cnt += s[day][contest3];
    before[contest3] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    day++;
    cnt += s[day][contest4];
    before[contest4] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    return cnt;
}



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> d;
    rep(i, 26) cin >> c[i];
    rep(i, d) {
        rep(j, 26) cin >> s[i][j];
    }

    vector<int>vec;
    rep(i, 26) {
        rep(j, c[i]) vec.push_back(i + 1);
    }

    random_device rnd;  
    rep(i, d) {
        cout << vec[rnd() % vec.size()] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3704
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
var nums=[];
for(var i=7;i>=-4;i--){
   nums.push(Math.pow(2,i));
}
while(true){
   var x=Arr.shift()-0;
   if(x==-1)break;
   var str="";
   for(var i=0;i<nums.length;i++){
       if(x>=nums[i]){
          x-=nums[i];
          str+="1";
       }else{
          str+="0";
       }
       if(i==7)str+=".";
   }
   if(x!==0)str="NA";
   console.log(str);
}

Measured memory_bytes: 10344
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>
#include <functional>

using namespace std;

int main() {
  int n, a, b, sum;
  cin >> n >> a >> b >> sum;
  vector<int> v( n );
  for ( int i = 0; i < n; i++ ) {
    cin >> v[ i ];
  }
  sort( v.begin(), v.end(), greater<int>() );
  bool fin = false;
  for ( int k = 0; k < n; k++ ) {
    const int before = sum / ( a + k * b );
    if ( sum * b < v[ k ] * ( a + k * b ) ) {
      sum += v[ k ];
    } else {
      fin = true;
      cout << before << endl;
      break;
    }
  }
  if ( !fin ) {
    cout << sum / ( a + n * b ) << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#include <iostream>
#include <string> 
using namespace std;
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A < B && B < C){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll bigmod(ll a,ll b)
{
    if(b==0)
        return 1;
    ll x =bigmod(a,b/2);
    x = x*x;
    if(b%2)
        x = x*a;
    return x;
}
int main()
{
    ll x;
    cin >> x;
    for(ll i=-200;i<=200;i++)
    {
        for(int j=-200;j<=200;j++)
        {
            if(bigmod(i,5)-bigmod(j,5)==x)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3628