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

#define N 8
#define FREE -1
#define Not_FREE 1

int row[N], col[N], dpos[2 * N -1], dneg[2 * N - 1];
int x[N][N];

void initialize(){
  int i, j;
  
  for(i = 0 ; i < N ; i++){
    row[i] = FREE;
    col[i] = FREE;
  }
  for(i = 0 ; i < 2 * N -1 ; i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
}

void printBoard(){
  int i, j;
  
  for(i = 0 ; i < N ; i++){
    for(j = 0 ; j < N ; j++){
      if(x[i][j]){
	if(row[i] != j) return;
      }
    }
  }

  for(i = 0 ; i < N ; i++){
    for(j = 0 ; j < N ; j++){
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;
  
  if(i == N){
    printBoard();
    return;
  }
  for(j = 0 ; j < N ; j++){
    if(Not_FREE == col[j] || Not_FREE == dpos[i + j] || Not_FREE == dneg[i - j + N - 1]) continue;
    row[i] = j;
    col[j] = dpos[i + j] = dneg[i - j + N - 1] = Not_FREE;

    recursive(i + 1);
    row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
  }
}


int main(){
  initialize();

  int i, j, k, l, m;

  for(i = 0 ; i < N ; i++)
    for(j = 0 ; j < N ; j++) x[i][j] = 0;

  scanf("%d", &k);
  for(i = 0 ; i < k ; i++){
    scanf("%d %d", &l, &m);
    x[l][m] = 1;
  }
  recursive(0);

  return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];}
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";}
#define S second
#define F first
const int  MOD = 1e9 + 7;
const int  N = 10005;
ll dp[N][105][2];
string K;
int d , n;

ll rec(int ind, int s, int less){
    if(ind == n) return s == 0;
    ll res = dp[ind][s][less] , k ;
    if(res != -1) return res;
    res = 0;
    for(int i = 0; i <= 9; i++){
        if(less){
            res += rec(ind + 1 , (s + i) % d, 1);
        }else{
            if(i > K[ind]-'0')break;
            if(i == K[ind]-'0') res += rec(ind + 1,(s + i)%d , 0);
            if(i < K[ind]-'0') res += rec(ind + 1,( s + i )%d ,1);
        }
        res %= MOD;
    }
    dp[ind][s][less] = res;
    return res;
}

//  a d f j k  l  ;
int main(){
    ios::sync_with_stdio(0);  cin.tie(0);
    cin>>K>>d;
    n = K.size();
    memset(dp, -1, sizeof(dp));
    cout << (rec(0,0,0) - 1 + MOD)%MOD << endl;

    return 0;
}

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

int n;
int a[200010];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		a[i] -= i + 1;
	}
	sort(a, a + n);
	long long ans = 0;
	const int b = a[n - 1 >> 1];
	for (int i = 0; i < n; ++i)
		ans += abs(a[i] - b);
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 4484
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int getProfit(int x, vector<int>& f, vector<int>& pi) {
  int cnt = 0;
  rep(j, 10) {
    if (((x >> j) & 1) && f[j]) {
      cnt++;
    }
  }
  return pi[cnt];
}

int main() {
  int n;
  cin >> n;
  vector<vector<int> > f(n, vi(10));
  rep(i, n) rep(j, 10) cin >> f[i][j];
  vector<vector<int> > p(n, vi(11));
  rep(i, n) rep(j, 11) cin >> p[i][j];

  ll ans = INT_MIN;
  REP(x, 1, (1 << 10)) {
    ll profit = 0;
    rep(i, n) { profit += getProfit(x, f[i], p[i]); }
    ans = max(ans, profit);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void)
{
    double xp,yp;
    double a,b,c,r;
    int n,i,j;
    scanf("%d",&n);
    double x[n][3],y[n][3];
    for(i = 0; i < n; i++){
        for(j = 0; j < 3; j++){
            scanf("%lf %lf",&x[i][j],&y[i][j]);
        }
    }
    for(i = 0; i < n; i++){
        xp = (((x[i][0]*x[i][0])+(y[i][0]*y[i][0]))*(y[i][1]-y[i][2])+((x[i][1]*x[i][1])+(y[i][1]*y[i][1]))*(y[i][2]-y[i][0])+((x[i][2]*x[i][2])+(y[i][2]*y[i][2]))*(y[i][0]-y[i][1]))/(x[i][0]*(y[i][1]-y[i][2]) + x[i][1]*(y[i][2]-y[i][0]) + x[i][2]*(y[i][0]-y[i][1]))/2;
        yp = (((x[i][0]*x[i][0])+(y[i][0]*y[i][0]))*(x[i][1]-x[i][2])+((x[i][1]*x[i][1])+(y[i][1]*y[i][1]))*(x[i][2]-x[i][0])+((x[i][2]*x[i][2])+(y[i][2]*y[i][2]))*(x[i][0]-x[i][1]))/(y[i][0]*(x[i][1]-x[i][2]) + y[i][1]*(x[i][2]-x[i][0]) + y[i][2]*(x[i][0]-x[i][1]))/2;
        a = (x[i][1]-x[i][2])*(x[i][1]-x[i][2]) + (y[i][1]-y[i][2])*(y[i][1]-y[i][2]);
        b = (x[i][2]-x[i][0])*(x[i][2]-x[i][0]) + (y[i][2]-y[i][0])*(y[i][2]-y[i][0]);
        c = (x[i][0]-x[i][1])*(x[i][0]-x[i][1]) + (y[i][0]-y[i][1])*(y[i][0]-y[i][1]);
        a = sqrt(a);
        b = sqrt(b);
        c = sqrt(c);
        r = a*b*c/sqrt((a+b+c)*(b+c-a)*(c+a-b)*(a+b-c));
        printf("%.3lf %.3lf %.3lf\n",xp,yp,r);
        xp = 0,yp = 0,r = 0;
    }
    return 0;
}

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

void check(int[], char);

int main() {
    int n;
    cin >> n;
    int s[13] = {0};
    int h[13] = {0};
    int c[13] = {0};
    int d[13] = {0};
       
    for (int i = 0; i < n; i++){
        char a;
        int b;
        cin >> a;
        cin >> b;
        b -= 1;
        switch(a) {
        case 'S':
            s[b]++;
            break;
        case 'H':
            h[b]++;
            break;
        case 'C':
            c[b]++;
            break;
        case 'D':
            d[b]++;
            break;
        default:
            break;
        }
    }

    check(s, 'S');
    check(h, 'H');
    check(c, 'C');
    check(d, 'D');
}

void check(int array[], char c){
    for (int i = 0; i < 13; i++){
        if (array[i] == 0) {
            cout << c << " " << i + 1 << endl;
        }
    }
    return;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> A(N),B(N);
    for (int i=0;i<N;++i) cin >> A[i];
    for (int i=0;i<N;++i) cin >> B[i];
    ll sum=0;
    for (int i=0;i<N;++i){
        A[i]-=B[i]; sum+=A[i];
    }
    if (sum<0){cout << -1 << '\n'; return 0;}
    sort(A.begin(),A.end());
    int ans=0,last=N;
    for (int i=0;i<N;++i) if (A[i]<0){
        ++ans;
        if (last==N) --last;
        while(A[i]<0){
            ll use=min(-A[i],A[last]);
            A[i]+=use; A[last]-=use;
            if (A[i]<0) --last;
        }
    }
    cout << ans+(N-last) << '\n';
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  rep(i, 100) {
    C -= B;
    if (C <= 0) {
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if (A <= 0) {
      cout << "No" << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3592
A, B, K = map(int, input().split())
for i in range(K):
    if A + i <= B:
        print(A + i)
    else:
        exit()
m = A + K - 1
for j in range(K):
    if m < B - K + j + 1 <=B:
        print(B - K + j + 1)


Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> stack = new ArrayList<Integer>();
		ArrayList<Integer> exit = new ArrayList<Integer>();
		while(sc.hasNextInt()){
			int a = sc.nextInt();
			if(a==0){
				exit.add(stack.get(stack.size()-1));
				stack.remove(stack.size()-1);
			}
			else {
				stack.add(a);
			}
		}
		for(int i=0; i<exit.size(); i++){
			System.out.println(exit.get(i));
		}
	}

}

Measured memory_bytes: 17212
# dpA - Frog 1
# 配るDP
def main():
    n = int(input())
    A = tuple(map(int, input().rstrip().split()))
    dp = [float("inf")] * n
    dp[0] = 0
    for i in range(n):
        if i + 1 < n:
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(A[i + 1] - A[i]))
        if i + 2 < n:
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(A[i + 2] - A[i]))
    print(dp[n - 1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 14056
/*=============================================================================================================================/*
                                               Bismillahir Rahmanir Rahim

      _     ____  ___  ____   _   _  _         ___  ____   _         _     __  __
     / \   / ___||_ _|| __ ) | | | || |       |_ _|/ ___| | |       / \   |  \/  |
    / _ \  \___ \ | | |  _ \ | | | || |        | | \___ \ | |      / _ \  | |\/| |
   / ___ \  ___) || | | |_) || |_| || |___     | |  ___) || |___  / ___ \ | |  | |
  /_/   \_\|____/|___||____/  \___/ |_____|   |___||____/ |_____|/_/   \_\|_|  |_|

   _   __           __  __  __
  |_) (_  _  o__   /   (_  |_
  |_)o__)(_  || |  \__ __) |__

    ___                    _   _      _                _ _               __   ___                 _         _        _
   / __|_ _ ___ ___ _ _   | | | |_ _ (_)_ _____ _ _ __(_) |_ _  _   ___ / _| | _ ) __ _ _ _  __ _| |__ _ __| |___ __| |_
  | (_ | '_/ -_) -_) ' \  | |_| | ' \| \ V / -_) '_(_-< |  _| || | / _ \  _| | _ \/ _` | ' \/ _` | / _` / _` / -_|_-< ' \
   \___|_| \___\___|_||_|  \___/|_||_|_|\_/\___|_| /__/_|\__|\_, | \___/_|   |___/\__,_|_||_\__, |_\__,_\__,_\___/__/_||_|
                                                            |__/                           |___/


   FB: https://facebook.com/SIAsibul
   Gmail: asibulislam8@gmail.com

/*=============================================================================================================================*/

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vii;
typedef vector<pil> vil;
typedef vector<pli> vli;
typedef vector<pll> vll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,n) for(int i=0;i<(n);i++)
#define f1(i,n) for(int i=1;i<=(n);i++)
#define f2(i,a,n) for(int i=(a);i<=(n);i++)
#define fr(i,n,a) for(int i=(n);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define nl "\n"


const int INF = 1e9 + 5;
const int MXN = 2e5 + 5;

int main(){
    int n; cin >> n;
    int a = 0, b = 0, c = 0, d = 0;
    f0(i, n){
        string s; cin >> s;
        if(s == "AC") a++;
        else if(s == "WA") b++;
        else if(s == "TLE") c++;
        else if(s == "RE") d++;
    }

    cout << "AC x " << a << nl;
    cout << "WA x " << b << nl;
    cout << "TLE x " << c << nl;
    cout << "RE x " << d << nl;
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int main(){
    vector<int> a(3);
    REP(i,3)a[i]=0;
    string S;
    cin>>S;
    REP(i,S.size()){
        a[S[i]-'a']++;
    }
    sort(a.begin(),a.end());
    if(abs(a[2]-a[0])<=1){
       cout<<"YES"<<endl;
    }else{
       cout<<"NO"<<endl;
    }
	return(0);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}

int main() {
  ll l, r;
  cin >> l >> r;
  if (r - l > 1e4) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 2019;
  for (ll i = l; i < r; i++)
    for (ll j = i + 1; j <= r; j++) chmin(ans, i * j % 2019);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int xdir[4] = {0, 1, 0, -1}, ydir[4] = {-1, 0, 1, 0};
char dir[4] = {'U', 'R', 'D', 'L'};

int main()
{
  int l, x, y, d;
  string str;
  bool a[11][11][11][11];

  while(cin>>str){
    l = str.size()+1;
    y = 1;
    fill(&a[0][0][0][0], &a[l+1][0][0][0], false);

    for(int i = 1; i < l; ++i)
      if(str[i-1] == '1')
	a[0][i-1][0][i] = a[0][i][0][i-1] = true;

    for(int i = 1; i <= 8; ++i){
      cin >> str;
      if(i%2){
	for(int j = 0; j < l; ++j)
	  if(str[j] == '1') 
	    a[y-1][j][y][j] = a[y][j][y-1][j] = true;
      } else {
	for(int j = 1; j < l; ++j)
	  if(str[j-1] == '1')
	    a[y][j-1][y][j] = a[y][j][y][j-1] = true;
	y++;
      }
    }

    x = y = d = 0;
    do {
      for(int i = 3; i < 7; ++i){
	int nd = (d+i)%4;
	int dx = x+xdir[nd], dy = y+ydir[nd];
	
	if(0 <= dx && dx < l && 0 <= dy && dy < l && a[y][x][dy][dx]){
	  cout << dir[(d+i)%4];
	  a[y][x][dy][dx] = false;
	  x = dx;
	  y = dy;
	  d = nd;
	  break;
	}
      }
    } while(x+y != 0);
    
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 0
def resolve():
    #n=int(input())
    #a,b=map(int,input().split())
    #x=list(map(int,input().split()))
    #a=[list(map(lambda x:int(x)%2,input().split())) for _ in range(h)]
    n,m=map(int,input().split())
    f=[set() for _ in range(n)]
    for i in range(m):
        a,b=map(int,input().split())
        f[a-1].add(b-1)
        f[b-1].add(a-1)
    chk=[False]*n
    q=[]
    ans=0
    for i in range(n):
        if chk[i]==True:
            continue
        q.append(i)
        chk[i]=True
        cnt=1
        while q:
            x=q.pop()
            for nx in f[x]:
                if chk[nx]==True:
                    continue
                q.append(nx)
                chk[nx]=True
                cnt+=1
        ans=max(ans,cnt)
    print(ans)

if __name__ == '__main__':
    resolve()

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

int N;

int lsb(int x) { return x & (-x); }

bool isPower2(int x) {
  return (x ^ lsb(x)) == 0;
}

void out(int x, int y) {
  cout << x << " " << y << "\n";
}

void printOdd(int n) {
  out(1, 2);
  out(2, 3);
  out(N+1, N+2);
  out(N+2, N+3);
  out(N+3, 1);
  for (int k = 4; k < n; k += 2) {
    out(1, k);
    out(k, k+1);
    out(N+k, N+k+1);
    out(N+k+1, 1);
  }
}

void printEven(int n) {
  printOdd(n-1);
  int x = n ^ lsb(n);
  int y = n - x;
  out(y, n);
  out(N + x + 1, N + n);
}

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  cin >> N;
  if (isPower2(N)) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  if (N % 2 == 1) {
    printOdd(N);
  }else {
    printEven(N);
  }

  return 0;
}



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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll ret = 0;
vector<ll> A;
bool flg = false; //負の整数が奇数個であるか

void input() {
  IN(N);
  ll tmp;
  REP(i, N) {
    IN(tmp);
    if (tmp < 0) {
      flg = !flg;
      tmp = -tmp;
    }
    A.pb(tmp);
  }
}

void solve() {
  sort(ALL(A));
  if (flg) {
    A[0] = -A[0];
  }
  FOREACH(a, A) {
    ret += a;
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n){
        a[i]-=(i+1);
    }
    sort(a.begin(),a.end());
    ll all=a[n/2];
    ll res=0;
    rep(i,n){
        ll buf=abs(a[i]-all);
        res+=buf;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1792
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]
# dp[i][j](j=0,1,...,W)の値が求まっている状態で、dp[i+1][j]を更新することを考える
for i in range(N):
    for j in range(W + 1):
		# 品物(w[i],v[i])を選ぶとき、j-w[i]>=0に限って、価値v[i]が加算される
        if j - w[i] >= 0:
            dp[i + 1][j] = dp[i][j - w[i]] + v[i]
		# 品物(w[i],v[i])を選ばないとき、何も加算しない
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
#print(dp)

print(dp[N][W])

Measured memory_bytes: 120556
lst = input().split()
X = int(lst[0])
Y = int(lst[1])
A = int(lst[2])
B = int(lst[3])
C = int(lst[4])

p_list = [int(num) for num in input().split(" ")]
q_list = [int(num) for num in input().split(" ")]
r_list = [int(num) for num in input().split(" ")]

sort_p = sorted(p_list,reverse = True)[:X]
sort_q = sorted(q_list,reverse = True)[:Y]
sort_r = sorted(r_list,reverse = True)[:X+Y]

max_score = 0
sort_p.extend(sort_q)
sort_p.extend(sort_r)
sort_p.sort(reverse = True)
for i in range(X+Y):
    max_score += sort_p[i]

print(max_score)


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

int main()
{
	std::string input;
	for (int i = 0; i < 4; ++i) {
		char c;
		std::cin >> c;
		input.push_back(c);
	}

	const int first = 10 * int(input[0] - 48) + int(input[1] - 48);
	const int second = 10 * int(input[2] - 48) + int(input[3] - 48);

	const bool first_valid_year = first >= 0 && first < 100;
	const bool second_valid_year = second >= 0 && second < 100;

	const bool first_valid_month = first > 0 && first < 13;
	const bool second_valid_month = second > 0 && second < 13;
	
	std::string res;
	if (first_valid_year && !first_valid_month && second_valid_month) {
		res = "YYMM";
	}
	else if (second_valid_year && !second_valid_month && first_valid_month) {
		res = "MMYY";
	}
	else if ((first_valid_year && first_valid_month) && (second_valid_year && second_valid_month)) {
		res = "AMBIGUOUS";
	}
	else {
		res = "NA";
	}
	std::cout << res;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main () {
  int n, m;
  int i, j;
  int GyuretuA[100][100], VectorB[100], Vector_result[100]={0};
  scanf("%d %d", &n, &m);
  for (i=0; i<n; i++) {
    for (j=0; j<m; j++) {
      scanf("%d", &GyuretuA[i][j]);
    }
  }

  for (i=0; i<m; i++) {
    scanf ("%d", &VectorB[i]);
  }
  for (i=0; i<n; i++) {
    for (j=0; j<m; j++) {
      Vector_result[i] += GyuretuA[i][j]*VectorB[j];
    }
  }
  for (i=0; i<n; i++) {
    printf("%d\n", Vector_result[i]);
  }

  return 0;
}

Measured memory_bytes: 640
import math
import sys
import copy
input = sys.stdin.readline


N,D=map(int,input().split())

count=0
for i in range(N):
    A,B=map(int,input().split())
    tmp=math.sqrt(A*A+B*B)
    if (tmp<=D):
        count+=1

print(count)
    



Measured memory_bytes: 9344
import Control.Monad
import Text.Printf

getLines :: Int -> IO [String]
getLines n = replicateM n getLine

getLinesInt :: Int -> IO [Int]
getLinesInt n = fmap read <$> getLines n

getInts :: IO [Int]
getInts = map (read :: String -> Int) . words <$> getLine

getDoubles :: IO [Double]
getDoubles = map (read :: String -> Double) . words <$> getLine

main :: IO ()
main = do
    n <- getInts
    l <- getInts

    putStrLn $ if let s = sum l in
        foldl (\b x -> (s > x + x) && b) True l
        then "Yes"
        else "No"




Measured memory_bytes: 508
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
using namespace std;
int main()
{
	ll n,m,k,i,j;
	cin>>n>>m>>k;
	for(i=0;i<=n;i++)for(j=0;j<=m;j++)if(i*m+j*n-2*i*j==k)
	{
		cout<<"Yes";return 0;
	}
	cout<<"No";
}

Measured memory_bytes: 256
N, W = (int(x) for x in input().split())
value = []
weight = []

for _ in range(N):
    tmp_v, tmp_w = (int(x) for x in input().split())
    value.append(tmp_v)
    weight.append(tmp_w)

dp = [[0 for i in range(W+1)] for j in range(N+1)]
for w in range(W+1):
    dp[0][w] = 0

for n in range(N):
    for w in range(W+1):
        if w >= weight[n]:
            dp[n+1][w] = max(dp[n][w-weight[n]] + value[n], dp[n][w])
        else:
            dp[n+1][w] = dp[n][w]
print(dp[N][W])


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

int a[6], k;
bool sol = true;

int main()
{
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
	for (int i = 0; i < 5; ++i){
		for (int j = i; j < 5; ++j){
			if (a[j] - a[i] > k) sol = false;
		}
	}	
	if (sol) cout << "Yay!";
	else cout << ":(";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

int n;

signed main(){
    while(cin >> n, n){
        vector<int> t(n);
        rep(i, 0, n) cin >> t[i];
        sort(all(t));
        int ans = 0;
        rep(i, 0, n){
            ans += t[i] * (n - 1 - i);
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 3188
#include <cstdio>
#ifdef _MSC_VER
#include <conio.h>
#else
#define getch()
#endif

#define LIMIT 100000

#define int long long int

signed main(){
	int Data[LIMIT]={};
	int N=0;
	int K=0;
	scanf(" %lld %lld",&N,&K);
	for(int i=0;i<N;i++){
		int TempA=0;
		int TempB=0;
		scanf(" %lld %lld",&TempA,&TempB);
		Data[TempA-1]+=TempB;
	}
	for(int i=0;i<LIMIT;i++){
		K-=Data[i];
		if(K<=0){
			printf("%lld\n",i+1);
			break;
		}
	}
	getch();
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

ll f(ll i){
    return (i + 1) * i / 2;
}

int main(){
    ll x;
    cin >> x;
    for(int i = 1; i <= x; i++){
        ll sum = f(i);
        if (sum >= x){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

int main() {
	string s;
	cin >> s;
	int n = 0;
	n = s.size();
	int x['z'+1] = { 0 };
	for (int i = 0; i < n; i++) {
		x[s[i]]++;
	}
	bool flag = true;
	for (int i = 'a'; i <= 'z' ; i++) {
		if (x[i] % 2 != 0) {
			flag = false;
		}
	}
	if (flag==false) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

double dist(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

vec eratosthenes(ll N){
  ll i;
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.push_back(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}
int main(){
  ll i,N,M,s,g,a,b,c,e,cnt=1;
  cin>>N;
  vec dp(N),h(N);
  rep(i,N){
    cin>>h[i];
    if(i>=2){
      dp[i]=min(dp[i-2]+labs(h[i-2]-h[i]),dp[i-1]+labs(h[i-1]-h[i]));
    }else if(i){
      dp[i]=dp[i-1]+labs(h[i-1]-h[i]);
    }else{
      dp[i]=0;
    }
  }
  cout<<dp[N-1]<<endl;
  return 0;
}


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

int main() {
	int A, B, K;
	cin >> A >> B >> K;
	for (int i = 0;i < min(B - A + 1, K);++ i) cout << A + i << endl;
	for (int i = max(A - B + (K << 1), 1);i <= K;++ i) cout << B - K + i << endl;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

この通りにやるだけ
ただ、重複する場合のみ注意が必要でこれを除外する必要がある
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
char c;
int main(){
	cin>>c;
	cout<<(char)(c+1)<<"\n";
	exit(0);
} 

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] h = new int[n];
		for ( int i=0; i<n; i++ ) {
			h[i] = sc.nextInt();
		}
		int[] f = new int[n];
		for ( int i=0; i<n; i++ ) {
			f[i] = 1;
		}

		for ( int i=0; i<m; i++ ) {
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			if ( h[a] > h[b] ) {
				f[b] = 0;
			} else if ( h[a] < h[b] ) {
				f[a] = 0;
			} else {
				f[a] = 0;
				f[b] = 0;
			}
		}

		int g = 0;
		for ( int i=0; i<n; i++ ) {
			g += f[i];
		}


		System.out.println(g);
	}
}


Measured memory_bytes: 59888
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a;
  cin >> a;
  cout << 3 * a * a << "\n";
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k, x, y, arr[2][1001][1001], l, mx = 0;
	bool f;
	char c;
	cin >> n >> k;
	for(int i=0; i<2; i++){
		for(int j=0; j<=k; j++) fill(arr[i][j], arr[i][j] + k + 1, 0);
	}
	for(int i=0; i<n; i++){
		cin >> x >> y >> c;
		if((x / k + y / k) % 2) f = (c == 'W' ? 0 : 1);
		else f = (c == 'W' ? 1 : 0);
		arr[f][y%k + 1][x%k + 1]++;
	}
	for(int t=0; t<2; t++){
		for(int i=1; i<=k; i++){
			for(int j=1; j<=k; j++){
				arr[t][i][j] += arr[t][i-1][j] + arr[t][i][j-1] - arr[t][i-1][j-1];
			}
		}
	}
	for(int i=1; i<=k; i++){
		for(int j=1; j<=k; j++){
			l = arr[0][k][k] - arr[0][i-1][k] - arr[0][k][j-1] + 2 * arr[0][i-1][j-1] + arr[1][i-1][k] + arr[1][k][j-1] - 2 * arr[1][i-1][j-1];
			mx = max(mx, max(l, n - l));
		}
	}
	cout << mx;
}


Measured memory_bytes: 8064
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    vector<pii> v;

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,k,i,j;
            cin>>n>>k;
            int ans=0;
            for(i=2;i<=n;++i)
            {
                ans=ans+i-2;
                v.pb({1,i});
            }
            //cout<<ans<<" "<<k<<endl;
            if(ans<k)
            {
                cout<<-1<<endl;
                return 0;
            }
            for(i=n;i>=1;--i)
            {
                if(ans==k)
                    break;
                for(j=i-1;j>=2;--j)
                {
                    v.pb({i,j});
                    --ans;
                    if(ans==k)
                        break;
                }
                //cout<<i<<" "<<ans<<endl;
                if(ans==k)
                    break;
            }
            cout<<v.size()<<endl;
            for(i=0;i<v.size();++i)
                cout<<v[i].f<<" "<<v[i].s<<endl;
        }
        return 0;
    }


Measured memory_bytes: 384
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n';)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;if((c=gcu())=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

struct T {
	struct N {int t, w;};
	vector<vector<N>> t;
	T (int n) : t {vector<vector<N>>(n)} {
		times(i, n - 1) {
			int a {in}, b {in}, w {in};
			t[a].push_back({b, w});
			t[b].push_back({a, w});
		}
	}
	N depth (int i, int p = -1) {
		N r {i, 0};
		for (N j: t[i])
			if (j.t != p) {
				N t {depth(j.t, i)};
				t.w += j.w;
				if (r.w < t.w)
					r = t;
			}
		return r;
	}
};

int main() {
	T t((int) in);
	outl(t.depth(t.depth(0).t).w);
}


Measured memory_bytes: 11508
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp_20190501
{
    class Program
    {
        public static int AreaMethod(int AB, int BC)
        {
            int Area = AB * BC / 2;
            return Area;
        }

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int AB = int.Parse(input[0]);
            int BC = int.Parse(input[1]);
            int CA = int.Parse(input[2]);

            Console.WriteLine(AreaMethod(AB, BC));
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int MAXN = 7777;
long long inf = 1000000000000000000;
vector < pair<LL, LL> > eg;
pair <LL , LL> p[MAXN];
long long int n, m, r, a, b, c;
long long int dis[MAXN], y[MAXN], dist[MAXN][MAXN];
//////////////////////////////////////////////////////////////////////////
void bel(int f){
	dis[f] = 0;
	for(int i = 0; i < n; i++) if(i != f) dis[i] = inf;

	for(int i = 1; i < n; ++i){
		int o = (int)eg.size();
		for(int j = 0; j < o; ++j){
			long long int u = eg[j].first;
			long long int v = eg[j].second;
			long long int O = dis[u] + y[j];
			if (dis[u] != inf)
			dis[v] = min(dis[v], O);
		}
	}

}
bool cyc(){
	for(int j = 0; j < (int)eg.size(); ++j){
		int u = eg[j].first;
		int v = eg[j].second;
		LL O = dis[u] + y[j];
		if(dis[v] > O && dis[u] != inf) return true;
	}
	return false;
}
////////////////////////////////////////////////////////////////////
void floydWarshall(){
	for (int k = 0; k < n; k++)
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				if(dist[i][k] != inf && dist[k][j] != inf) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}
////////////////////////////////////////////////////////////////////
int main(){
	cin >> n >> m;
	/**/
	for (int i = 0; i < n; i++) {
		fill(dist[i], dist[i] + n, inf);
		dist[i][i] = 0;
	}
	/**/
	for(int i = 0; i < m; i++){
		cin >> a >> b >> c;
		eg.push_back(make_pair(a, b));
		y[i] = c;
		dist[a][b] = min(dist[a][b], c);
	}
	/**/
	bel(0);
	/**/
	if(cyc()) return cout << "NEGATIVE CYCLE\n", 0;
	else{
		floydWarshall();
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(dist[i][j] == inf) cout << "INF";
				else cout << dist[i][j];
				if(j != n - 1) cout << " ";
			}
			cout << "\n";
		}
	}
	/**/
	return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S[55];
ll C[55];

map<string,ll> cost[2];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>S[i]>>C[i];
		for(j=0;j<=S[i].size();j++) {
			FOR(y,2) {
				string A=S[i].substr(0,j);
				if(y==1&&j==0) continue;
				if(y==1) A.pop_back();
				string B=S[i].substr(j);
				reverse(ALL(A));
				x=min(A.size(),B.size());
				if(B.substr(0,x)==A.substr(0,x)) {
					if(A.size()<B.size()) {
						string D=B.substr(x);
						if(cost[1].count(D)==0) cost[1][D]=1LL<<60;
						cost[1][D]=min(cost[1][D],C[i]);
					}
					else {
						string D=A.substr(x);
						if(cost[0].count(D)==0) cost[0][D]=1LL<<60;
						cost[0][D]=min(cost[0][D],C[i]);
					}
					
				}
			}
		}
	}
	priority_queue<pair<ll,pair<int,string>>> PQ;
	FOR(i,2) FORR(c,cost[i]) {
		PQ.push({-c.second,{i,c.first}});
	}
	
	while(PQ.size()) {
		ll co=-PQ.top().first;
		int type=PQ.top().second.first;
		string cur=PQ.top().second.second;
		PQ.pop();
		if(cost[type][cur]!=co) continue;
		if(cur=="") {
			cout<<co<<endl;
			return;
		}
		
		FOR(i,N) {
			string A;
			string B;
			if(type==1) {
				A=S[i];
				B=cur;
				reverse(ALL(A));
			}
			else {
				A=cur;
				B=S[i];
			}
			x=min(A.size(),B.size());
			if(A.substr(0,x)==B.substr(0,x)) {
				if(A.size()<B.size()) {
					string D=B.substr(x);
					if(cost[1].count(D)==0) cost[1][D]=1LL<<60;
					if(co+C[i]<cost[1][D]) {
						cost[1][D]=co+C[i];
						PQ.push({-cost[1][D],{1,D}});
					}
				}
				else {
					string D=A.substr(x);
					if(cost[0].count(D)==0) cost[0][D]=1LL<<60;
					if(co+C[i]<cost[0][D]) {
						cost[0][D]=co+C[i];
						PQ.push({-cost[0][D],{0,D}});
					}
				}
			}
		}
		
	}
	cout<<-1<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3748
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

void change(string, string&);

int main() {

	int n;

	while(cin >> n, n) {
		string s;
		cin >> s;
		while(n--) {
			string r;
			change(s, r);
			s=r;
		}
		cout << s << endl;
	}

	return 0;

}


void change(string s, string &r) {

	int i=0;
	char c;
	while(i<s.size()) {
		int cnt=0;
		c=s[i];
		for(; i<s.size(); i++) {
			if(c==s[i]) {
				cnt++;
			}
			else {
				break;
			}
		}
		char tmp[100];
		sprintf(tmp, "%d", cnt);
		r.append(tmp);
		r.append(1, c);
	}
}

Measured memory_bytes: 0
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
  int a;
  int s;
  int d;
  cin>>a>>s;
 d=a-s;
if (d<=0){
  d=0;
}
std::cout << d << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
        int a = sc.nextInt();
        int taxi = sc.nextInt();
        int train,ans;

      	train = n * a;
        if(train >= taxi){
          System.out.println(taxi);
        }else{
          System.out.println(train);
        }
    }
}

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

int main(){
  string s;
  int k;
  cin >> s >> k;
  int i=0;
  while(s.at(i)=='1'&&i<s.size()-1)
    i++;
  cout << ((i<k)?s.at(i)-48:1) << endl;
}

Measured memory_bytes: 256
<?php

$n = trim(fgets(STDIN));
$map = explode(" ", trim(fgets(STDIN)));
$count = 0;
while(max($map) > 0){
    $max = max($map);
    $maxPosition = array_search($max, $map);
    $map[$maxPosition]--;
    $r = $maxPosition + 1;
    $l = $maxPosition - 1;
    while(isset($map[$r]) && $map[$r] > 0){
        $map[$r]--;
        $r++;
    }
    while(isset($map[$l]) && $map[$l] > 0){
        $map[$l]--;
        $l--;
    }
    $count++;
}
echo $count;

Measured memory_bytes: 4728
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N, D;
int X[10][10];

signed main()
{
	cin >> N >> D;
	REP(n, N) REP(d, D) cin >> X[n][d];

	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			int sum = 0;
			for (int d = 0; d < D; d++)
			{
				sum += (X[j][d] - X[i][d]) * (X[j][d] - X[i][d]);
			}
			double s = sqrt(sum);
			int n = (int)s;
			if (n * n == sum)
			{
				cnt++;
			}
		}
	}

	cout << cnt << endl;
}











Measured memory_bytes: 256
<?php
	
	$output = array();

	while( true ) {
		$data = trim( fgets( STDIN ) );
		if( "0" == $data ) { break; }

		$n = strlen( $data );
		$sum = 0;
		for( $i=0; $i<$n; $i++ ) {
			$num = intval( $data[$i] );
			$sum += $num;
		}
		array_push( $output, $sum );
	}
	print implode( "\n", $output );
?>

Measured memory_bytes: 6604
using System;

namespace _159b
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int N = S.Length;
            char[] arr = S.ToCharArray();
            Array.Reverse(arr);
            string temp = new string(arr);
            bool flag = false;
            if(S.Equals(temp)){
                string first = S.Substring(0,(N-1)/2);
                char[] arr_2 = first.ToCharArray();
                Array.Reverse(arr_2);
                string temp_2 = new string(arr_2);
                                
                if(first.Equals(temp_2)){
                    string second = S.Substring((N+3)/2-1,N-(N+3)/2+1);
                    //Console.WriteLine(second);
                    char[] arr_3 = second.ToCharArray();
                    Array.Reverse(arr_3);
                    string temp_3 = new string(arr_3);
                    //Console.WriteLine(temp_3);
                    if(second.Equals(temp_3)){
                        flag = true;
                    }
                }else{
                    flag = false;
                }
            }else{
                flag = false;
            }
            Console.WriteLine(flag? "Yes":"No");
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include<string>
using namespace std;
int main(){
	int h, n, a,s=0;
	cin >> h >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		s += a;
	}
	if (h <= s)
		cout << "Yes";
	else
		cout << "No";
}

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

int main() {
  
  int N, A, B;
  cin >> N >> A >> B;
  
  if (N * A < B) {
    cout << N * A << endl;
  }
  else {
    cout << B << endl;
  }
  
return 0;
}

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

int main() {
  int K;
  cin >> K;
  int A, B;
  cin >> A >> B;
  int A_K = A / K;
  int B_K = B / K;
  if (B_K - A_K != 0) {
    cout << "OK" << endl;
  }
  else if (B_K - A_K == 0 && A % K == 0) {
    cout << "OK" << endl;
  }
  else {
    cout << "NG" << endl;
  }
}


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

const int N=2*1e3+20;
map<int,int> m;
vector<int> g[N];
int n;

void bfs(int node){
	vector<bool> visited(n+10,false);
	vector<int> dis(n+10,0);
	queue<int> q;

	visited[node]=true;
	dis[node]=0;
	q.push(node);

	while(!q.empty()){
		int u=q.front();
		q.pop();
		for(auto x : g[u]){
			if(visited[x])continue;
			visited[x]=true;
			dis[x]=dis[u]+1;
			m[dis[x]]++;
			q.push(x);
		}
	}
} 

// 5 2 4

int main(){

	int x,y; cin>>n>>x>>y;
	for(int i=1;i<n;i++){
		g[i].push_back(i+1);
		g[i+1].push_back(i);
	}
	g[x].push_back(y);
	g[y].push_back(x);

	for(int i=1;i<=n;i++) bfs(i);

	for(int i=1;i<n;i++) cout<<(m[i]/2)<<endl;



	return 0;
}

Measured memory_bytes: 512
require 'bigdecimal'
def calc_standard_dev(scores)
  length = scores.length.to_f
  avarage = scores.inject(:+)/length
  # BigDecimal(avarage.to_s).floor(10).to_f
  tmp = 0
  for i in 0..(length-1)
    tmp += (scores[i]- avarage)**2
  end
  standard_dev = ((tmp/length)**0.5).round(6)
  return standard_dev
end


answers = []
loop do
  n = gets.chomp.to_i
  if n == 0
    break
  else
  scores = gets.chomp.split.map(&:to_i)
  answers.push(calc_standard_dev(scores))
  end
end
length = answers.length
for i in 0..(length-1)
  puts answers[i]
end

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    int x,n; cin >> x >> n;
    int a[105] = {}; 
    rep(i,0,n) {
        int b; cin >> b;
        a[b] = 1;
    }

    int ans = MOD;
    rep(i,0,104){
        if(a[i] == 0  && abs(ans-x) > abs(i-x)){
            ans = i;
        }
    }
    cout << ans << "\n";
}

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

int main(){
	int N, D, answer;
	cin >> N >> D;
	if(N%(2*D+1) == 0){
		answer = N/(2*D+1);
	}
	else{
		answer = N/(2*D+1)+1;
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256