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

int nat_m,nat_h[111111],nat_n[111111*2],nat_t[111111*2];
int nat_c[111111];
int neko_m,neko_h[111111],neko_n[111111*2],neko_t[111111*2];
int neko_c[111111],neko_c_natsu[111111];
int q[555555],inq[111111],hd,tl;
int nat_natsu_c[111111],neko_natsu_c[111111];

int main(void)
{
  int n,m,nat,neko,u,v,i,e,p,res,T;
  char c;
  scanf("%d",&T);
  while( T-- ) {
    scanf("%d%d",&n,&m);
    scanf("%d%d",&nat,&neko);
    nat_m = neko_m = 0;
    for(i = 0; i <= n; i++) {
      nat_h[i] = neko_h[i] = -1;
      neko_c[i] = neko_c_natsu[i] = 1<<21;
      nat_c[i] = 1<<21;
    }
#define add_edge1(n,h,t,m,u,v) (n[m]=h[u],h[u]=m,t[m]=v,++m)
    for( i = 0; i < m; i++ ) {
      scanf("%d%d %c",&u,&v,&c);
      if( c == 'N' ) {
        add_edge1(nat_n,nat_h,nat_t,nat_m,u,v);
        add_edge1(nat_n,nat_h,nat_t,nat_m,v,u);
      }
      if( c == 'L' ) {
        add_edge1(neko_n,neko_h,neko_t,neko_m,u,v);
        add_edge1(neko_n,neko_h,neko_t,neko_m,v,u);
      }
    }
    nat_c[nat] = 0;
    hd = tl = 0;
    q[tl++] = nat;
    while( hd != tl ) {
      p = q[hd++];
      for( e = nat_h[p]; e != -1; e = nat_n[e] ) {
        if( nat_c[nat_t[e]] > nat_c[p]+1 ) {
          nat_c[nat_t[e]] = nat_c[p]+1;
          q[tl++] = nat_t[e];
        }
      }
    }
    memset(inq,0,sizeof(inq));
    hd = tl = 0;
    q[tl++] = 0; neko_c_natsu[0] = 0; inq[neko] = 1;
    while( hd != tl ) {
      p = q[hd++]; inq[p] = 0;
      if( neko_c_natsu[p] == 0 ) {
        for(e = neko_h[p]; e != -1; e = neko_n[e]) {
          if( neko_c_natsu[neko_t[e]] > neko_c_natsu[p] ) {
            neko_c_natsu[neko_t[e]] = neko_c_natsu[p];
            if( !inq[neko_t[e]] ) {
              inq[neko_t[e]] = 1;
              q[tl++] = neko_t[e];
            }
          }
        }
      }
      for(e = nat_h[p]; e != -1; e = nat_n[e]) {
        if( neko_c_natsu[nat_t[e]] > neko_c_natsu[p]+1 ) {
          neko_c_natsu[nat_t[e]] = neko_c_natsu[p]+1;
          if( !inq[nat_t[e]] ) {
            inq[nat_t[e]] = 1;
            q[tl++] = nat_t[e];
          }
        }
      }
    }
    memset(inq,0,sizeof(inq));
    hd = tl = 0;
    q[tl++] = neko; neko_c[neko] = 0; inq[neko] = 1;
    while( hd != tl ) {
      p = q[hd++]; inq[p] = 0;
      if( neko_c[p] == 0 ) {
        for(e = neko_h[p]; e != -1; e = neko_n[e]) {
          if( neko_c[neko_t[e]] > neko_c[p] ) {
            neko_c[neko_t[e]] = neko_c[p];
            if( !inq[neko_t[e]] ) {
              inq[neko_t[e]] = 1;
              q[tl++] = neko_t[e];
            }
          }
        }
      }
      for(e = nat_h[p]; e != -1; e = nat_n[e]) {
        if( neko_c[nat_t[e]] > neko_c[p]+1 ) {
          neko_c[nat_t[e]] = neko_c[p]+1;
          if( !inq[nat_t[e]] ) {
            inq[nat_t[e]] = 1;
            q[tl++] = nat_t[e];
          }
        }
      }
    }
    res = 1<<21;
    if( neko_c[0] == 0 ) res = 0;
    for( i = 0; i <= n; i++ ) {
      int k = nat_c[i]+neko_c[i]+neko_c_natsu[i];
      if( res > k ) res = k;
    }
    printf("%d\n",res);
  }
  return 0;
}

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

	int n,d;
	cin >> n>>d;

	if (n%(2*d+1)) {
		cout << n/(2*d+1) + 1 << endl;
	} else {
		cout << n/(2*d+1) << endl;
	}
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl

typedef long long LL;

const int N = 200009;
int n, a[N];
LL ans;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    map<int, int> f;

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

    cout << ans << '\n';
    
    return 0;
}


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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    int n, m;
    cin >> n >> m;
    ll ans = 0;
    vector<int> a(n);
    roop(i, m){
        cin >> a[i];
    }

    roop(i, m){
        ans += a[i];
    }

    cout << (n >= ans ? n-ans : -1) << endl;

    return 0;
}


Measured memory_bytes: 7152
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    string s;
    ll k;
    cin >> s >> k;
    ll a=1,ans=0;
    rep(i,s.size()-1){
        if (s[i]==s[i+1]){
            a++;
        }
        else {
            ans+=(a/2);
            a=1;
        }
    }
    ans+=(a/2);
    if (a==s.size()) {
        cout << (s.size()*k)/2 << endl;
        return 0;
    }
    ll c=0,m=0;
    char u=s[s.size()-1];
    rep(i,s.size()){
        if (s[i]!=u) break;
        m++;
    }
    if (a%2==1 && m%2==1) c=1;
    cout << ans*k+c*(k-1) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define M 1000003

int getChar(char);
int getKey(char *);
int h1(int);
int h2(int);
void insert(char *);
void find(char *);

char H[M][13];

int main(){
  int i,j,n;
  char com[8],str[13];

  for(i=0;i<M;i++) H[i][0]='\0';

  scanf("%d",&n);

  for(i=0;i<n;i++){    
    scanf("%s%s",com,str);
    
    if(strcmp(com,"insert")==0) insert(str);
    else find(str);
  }
    
  return 0;
}

int getChar(char ch){
  if(ch=='A') return 1;
  else if(ch=='C') return 2;
  else if(ch=='G') return 3;
  else if(ch=='T') return 4;
}

int getKey(char *str){
  int i,sum=0,p=1;

  for(i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
  return sum;
}

int h1(int key){
  return key%M;
}

int h2(int key){
  return 1+key%(M-1);
}

void insert(char *str){
  int i=0,key;
  
  while(1){
    key=(h1(getKey(str))+i*h2(getKey(str)))%M;
    if(H[key][0]=='\0'){
      strcpy(H[key],str);
      break;
    }
    else i++;
  }
}

void find(char *str){
  int i=0,key;

  while(1){
    key=(h1(getKey(str))+i*h2(getKey(str)))%M;
    if(strcmp(H[key],str)==0){
      printf("yes\n");
      break;
    }
    else if(H[key][0]=='\0'||i>=M){
      printf("no\n");
      break;
    }
    else i++;
  }
}

Measured memory_bytes: 13300
#include <iostream>
#include <string>
using namespace std ;
using ll = long long ;

string yorn(bool a){
    if(a) return "AC" ; return "WA" ;
}


int main(){
    string s ; cin >> s ;
    bool ok = true ;
    bool c = false ;
    for(int i=0;i<s.size();i++){
        if(i==0&&s.at(0)!='A') ok = false ;
        if((i==1||i==s.size()-1)&&s.at(i)>='A'&&s.at(i)<='Z') ok = false ;
        if(1<i&&i<s.size()-1){
            if((!c)&&s.at(i)=='C') c = true ;
            else if(s.at(i)>='A'&&s.at(i)<='Z') ok = false ;
        }
    }
    cout << yorn(ok&&c) << endl ;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <bitset>
#include <cstring>
using namespace std;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } else return false; }

int n, stage;
vector<vector<double> > p;

double dp[(1<<16)+10][20]; // remained member, #. of remained stages
double rec(int bit, int rem) {
    if (dp[bit][rem] >= -1e-10) return dp[bit][rem];
    if (rem == 0) return 1.0;
    
    double res = 0.0;
    int start = stage - rem;
    for (int i = 0; i < n; ++i) {
        if (!(bit & (1<<i))) continue;
        int nbit = bit & ~(1<<i);
        double tmp = 0.0;
        double prob = 1.0;
        for (int lose = start; lose < stage; ++lose) {
            double loseprob = prob * (1.0 - p[i][lose]);
            tmp += loseprob * rec(nbit, stage - lose);
            prob *= p[i][lose];
        }
        tmp += prob * rec(nbit, 0);
        chmax(res, tmp);
    }
    return dp[bit][rem] = res;
}

int main() {
    while (cin >> n >> stage) {
        p.assign(n, vector<double>(stage, 0.0));
        for (int i = 0; i < n; ++i) for (int j = 0; j < stage; ++j) cin >> p[i][j];

        memset(dp, -1, sizeof(dp));
        cout << fixed << setprecision(10) << rec((1<<n)-1, stage) << endl;
    }
}


Measured memory_bytes: 13532
#include <bits/stdc++.h> 
#include <complex>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

ll mpow(ll a, ll b){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}

ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}

ll range(ll l, ll r){
	return l + rand()%(r-l+1);
}

void solve(){
	ll n;
	cin >> n;
	ll x2 = 1e9;
	ll rem = n%x2;
	if(rem!=0) rem = x2-rem;
	cout << 0 << " " << 0 << " " << 1 << " " << (n+rem)/x2 << " " << x2 << " " << rem << ln;
}

int main()
{
	fast_cin();
    ll t=1;
    // cin >> t;
    forn(i,t) {
    	solve();
    }
    return 0;
}


Measured memory_bytes: 256
L, R= (int(x) for x in input().split())
m = 2019
if (R-L)//2019 >= 1:
  print(0)
else:
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      if (i*j)%2019 <= m:
        m = (i*j)%2019
  print(m)

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

int n, L, Q, lg;
std::vector <int> a;
std::vector <std::pair<int,int>> query;
std::vector <std::vector<int>> reach;

int main () {
	std::cin >> n;
	a.resize (n+1);
	for (int i = 1; i <= n; ++i)
		std::cin >> a[i];
	std::cin >> L >> Q;
	query.resize (Q);
	for (int i = 0; i < Q; ++i)
		std::cin >> query[i].first >> query[i].second;
	lg = std::__lg (n) + 2;
	std::cerr << "lg = " << lg << "\n";
	reach.assign (n+1, std::vector<int> (lg+1, 0));

	for (int i = 1; i <= n; ++i) {
		if (a[i] + L >= a[n])
			reach[i][0] = n;
		else
			reach[i][0] = std::upper_bound (a.begin()+1, a.end(), a[i]+L)-a.begin()-1;
	}
	for (int j = 1; j <= lg; ++j)
		for (int i = 1; i <= n; ++i)
			reach[i][j] = reach[reach[i][j-1]][j-1];
	for (int i = 0; i < Q; ++i) {
		int st = query[i].first, ed = query[i].second;
		if (st > ed) std::swap (st, ed);
		int ans = 0;
		for (int j = lg; j >= 0; --j)
			if (reach[st][j] < ed)
				st = reach[st][j], ans += (1<<j);
		std::cout << ans+1 << "\n";
	}
	return 0;
}

Measured memory_bytes: 13824
#include<cstdio>
#include<queue>
#include<iostream>
#include<algorithm>
#include<list>
#include<vector>
using namespace std;
vector<int>a;
int main() {
	int t,n;
	cin >> t;
	n = t;
	while (n--)
	{
		int temp;
		cin >> temp;
		a.push_back(temp);
	}
	cin >> n;
	while (n--)
	{
		int begin, end;
		cin >> begin >> end;
		end--;
		while (begin <= end)
		{
			int temp;
			temp = a[begin];
			a[begin++] = a[end];
			a[end--] = temp;
		}
	}
	for (int i = 0; i < t; i++)
	{
		if (i != 0)
		{
			cout << " ";
		}
		cout << a[i];
	}
	cout << endl;
}




Measured memory_bytes: 3160
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    if(a>8 || b>8){
        cout<<":("<<endl;
    }
    else if(a<=8 || b<=8){
        cout<<"Yay!"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	for(int n;cin>>n,n;){
		n=1000-n;
		int m=0;
		m+=n/500;	n-=n/500*500;
		m+=n/100;	n-=n/100*100;
		m+=n/50;	n-=n/50*50;
		m+=n/10;	n-=n/10*10;
		m+=n/5;		n-=n/5*5;
		m+=n;
		cout<<m<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;


void solve()
{
	int k;
	cin>>k;
	ll sum=0;
	rep(i,k)rep(j,k)rep(l,k){
		sum+=gcd(l+1,gcd(i+1,j+1));
	}
	cout<<sum<<endl;
	
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3660
n = int(input())
a = [int(input()) for i in range(n)]
cnt = 0

if not a.count(2):
    print('-1')
else:
    i = 0
    while True:
        cnt += 1
        if a[i] == 2:
            print(cnt)
            break
        elif a[i] == i+1 or cnt > n:
            print('-1')
            break
        i = a[i]-1

Measured memory_bytes: 12816
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
ll grcd(ll p, ll q){
	if(p*q==0)return p+q;
	if(p>q){
		return grcd( p%q, q);
	}
	else{
		return grcd( p, q%p);
	}
}
int main(){
	ll n,k;
	cin>>n>>k;
	vector<ll> a;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		a.pb(x);
	}
	ll gc = a[0];
	for(int i=1;i<n;i++){
		gc = grcd(gc,a[i]);
	}
	sort(a.begin(),a.end());
	if(a[a.size()-1]<k){
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	else if(k%gc!=0){
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	else{
		cout<<"POSSIBLE"<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 1400
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace AOJV0
{
    class P0005
    {
        static void Main()
        {
            foreach(var s in EnumerateInputs()
                            .Select(x => x.Split(' '))
                            .Select(x => x.Select(int.Parse).ToArray()))
            {
                var gcd = Gcd(s[0], s[1]);
                var lcm = (long)s[0] * (long)s[1] / (long)gcd;
                Console.WriteLine(string.Format("{0} {1}", gcd, lcm));
            }
        }

        static int Gcd(int x, int y)
        {
            while(true)
            {
                var a = Math.Max(x, y);
                var b = Math.Min(x, y);
                if(a % b == 0)
                    return b;
                x = b;
                y = a % b;
            }
        }

        static IEnumerable<string> EnumerateInputs()
        {
            while(true)
            {
                var s = Console.In.ReadLine();
                if(s == null)
                    break;
                yield return s;
            }
        }
    }
}

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

int main(){
    int N,i;
    string ans;
    cin>>N;
    vector <int> t(N+1),X(N+1),Y(N+1);
    t.at(0)=0;
    X.at(0)=0;
    Y.at(0)=0;
    if (N==1){
        cin>>t.at(1)>>X.at(1)>>Y.at(1);
        if(X.at(1)+Y.at(1)>t.at(1)){
            ans ="No";
            goto Output;
        }else if((t.at(1)-X.at(1)-Y.at(1))%2==0){
            ans ="Yes";
            goto Output;
        }else if((t.at(1)-X.at(1)-Y.at(1))%2==1){
            ans ="No";
            goto Output;
        }
    }else{
        for(i=1;i<N;i++){
            cin>>t.at(i)>>X.at(i)>>Y.at(i);
            int T,x,y;
            T = t.at(i)-t.at(i-1);
            x = abs(X.at(i)-X.at(i-1));
            y = abs(Y.at(i)-Y.at(i-1));
            if(x+y>T){
                ans ="No";
                goto Output;
            }else if((T-x-y)%2==0){
                ans ="Yes";
            }else if((T-x-y)%2==1){
                ans ="No";
                goto Output;
            }
        }
    }
Output:
    cout<<ans<<endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define deb(x) cout << #x << " => " << x << endl

int main() {
    
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string a, b;
    cin >> a >> b;
    int m = b.length(), n = a.length();
    int dp[n][m];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (a[i] == b[j]) {
                dp[i][j] = (i > 0 and j > 0 ? dp[i - 1][j - 1] : 0) + 1;
            } else {
                dp[i][j] = max(i > 0 ? dp[i - 1][j] : 0, j > 0 ? dp[i][j - 1] : 0);
            }
        }
    }

    string res;
    int i = n - 1, j = m - 1;
    while (i >= 0 and j >= 0) {
        if (a[i] == b[j]) {
            res.push_back(a[i]);
            i--; j--;
        } else if ((i > 0 ? dp[i - 1][j] : 0) > (j > 0 ? dp[i][j - 1] : 0)) {
            i--;
        } else {
            j--;
        }
    }
    reverse(res.begin(), res.end());
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
using P = pair<int,int>;
typedef long long ll;

bool ans[100001];
int wa[100001];
 
int main() {
    
    ll n,m;
    cin>>n>>m;
    rep(i,m) {
        int p;
        string s;
        cin >> p >> s;
        if(s=="AC") {
            ans[p] =true;
        }
        else {
            if(!ans[p]) {
                wa[p]++;
            }
        }
    }

    int A=0,W=0;
    for(int i=1;i<n+1;i++) {
        if(ans[i]) {
            A++;
            W+=wa[i];
        }
    }

    cout <<A<<" "<<W<<endl;
 
 return 0;
}

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

int main(void){
    int a,b;
    int d;
    int r;
    double f;
    cin >> a >> b;
    d = a/b;
    r = a%b;
    f = (double)a/b;
    cout << d << " " << r << " ";
    cout << fixed << setprecision(8) << f << endl;
    return 0;
}


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

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}
int main() {
	int N, M;
	string S, T;
	cin >> N >> M >> S >> T;
	int g = gcd(N, M);
	for (int i = 0;i < g;i ++) {
		if (S[i * N / g] != T[i * M / g]) {
			cout << -1;
			return 0;
		}
	}
	cout << (int64_t) N / g * M;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、答えはNとMの最小公倍数lcm(N, M)の倍数であることは確定
というか1倍と仮定しよう
これがもしも不可能だった場合、どこかに同じ文字がある訳だが
これ2倍や3倍しても同じ文字ばかり重なるのよね


*/

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <list>
#include <set>
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
using namespace std;
using ll = long long;
const int INF = 1e9 + 1;
ll MOD = 1e9+7;
ll dx[9] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
ll dy[9] = {-1,  0,  1,-1, 0, 1,-1, 0, 1};
int N, A, B, C;
int l[8];

int dfs(int cur, int a, int b, int c){
    int ret0, ret1, ret2, ret3;
    if(cur == N){
        return min(a,min(b,c)) > 0 ? abs(a - A) + abs(b - B) + abs(c - C) - 30 : INF;
    }
    ret0 = dfs(cur+1, a, b, c);
    ret1 = dfs(cur+1, a+l[cur], b, c)+10;
    ret2 = dfs(cur+1, a, b+l[cur], c)+10;
    ret3 = dfs(cur+1, a, b, c+l[cur])+10;
    return min(ret0, min(ret1, min(ret2, ret3)));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> A >> B >> C;
    REP(i, N){
        cin >> l[i];
    }
    cout << dfs(0,0,0,0) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n, p[20] = {0}, c = 0;
  scanf("%d", &n);getchar();
  for(int i = 0; i < n; i++){
    scanf("%d", &p[i]);getchar();
  }
  for(int i = 0; i < n - 2; i++){
    if((p[i] < p[i + 1] && p[i + 1] < p[i + 2]) || (p[i] > p[i + 1] && p[i + 1] > p[i + 2])){
      c++;
    }
  }
  printf("%d\n", c);
  return 0; 
}

Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> N >> M;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for (int i = M; i < N; i++) {
		K += v[i];
	}
	cout << K << endl;
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;

namespace AOJ.Volume2
{
    public class SevenSegments
    {
        public static int Main()
        {
            // 0???9?????°???????????°????????????on???off??§??¨???
            var bit_0 = new bool[7] { true, true, true, true, true, true, false };
            var bit_1 = new bool[7] { false, true, true, false, false, false, false };
            var bit_2 = new bool[7] { true, true, false, true, true, false, true };
            var bit_3 = new bool[7] { true, true, true, true, false, false, true };
            var bit_4 = new bool[7] { false, true, true, false, false, true, true };
            var bit_5 = new bool[7] { true, false, true, true, false, true, true };
            var bit_6 = new bool[7] { true, false, true, true, true, true, true };
            var bit_7 = new bool[7] { true, true, true, false, false, true, false };
            var bit_8 = new bool[7] { true, true, true, true, true, true, true };
            var bit_9 = new bool[7] { true, true, true, true, false, true, true };

            // ??°?????¨?????°??????????????±????´???????
            var dict = new Dictionary<int, bool[]>();
            dict.Add(0, bit_0);
            dict.Add(1, bit_1);
            dict.Add(2, bit_2);
            dict.Add(3, bit_3);
            dict.Add(4, bit_4);
            dict.Add(5, bit_5);
            dict.Add(6, bit_6);
            dict.Add(7, bit_7);
            dict.Add(8, bit_8);
            dict.Add(9, bit_9);

            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n < 0) { break; }

                bool[] before = new bool[7];
                bool[] current = new bool[7];
                for (int i = 0; i < n; i++)
                {
                    int input = int.Parse(Console.ReadLine());
                    var change = new bool[7];
                    if (i == 0)
                    {
                        // ??????
                        change = dict[input];
                        before = dict[input];
                    }
                    else
                    {
                        current = dict[input];
                        // XOR??§???????????????????????????????????§??????
                        for (int j = 0; j < 7; j++) { change[j] = before[j] ^ current[j]; }

                        before = current;
                    }

                    string output = "";
                    for (int j = 6; j >= 0; j--) { output += change[j] ? "1" : "0"; }
                    Console.WriteLine(output);
                }
            }
            return 0;
        }
    }
}

Measured memory_bytes: 9544
n = input()
no = len(n)

num1 = 0
num2 = 0

i = 0
while(i < no):
    if(n[i] == '0'):
        num1 += 1
    if(n[i] == '1'):
        num2 += 1
    i += 1
    if(i < no):
        if(n[i] == '1'):
            num1 += 1
        if(n[i] == '0'):
            num2 += 1
    i += 1
    #print(i," ", num1, " ", num2)

if(num1 < num2):
    ans = num1
else:
    ans = num2

print(ans)

Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=1e5+100;
int a[maxn];
int main(){
	int n;
	while(~scanf("%d",&n)){
		for(int i=1;i<=n;i++)
			scanf("%d",a+i);
		sort(a+1,a+n+1);
		long long ans=0;
		if(n<=3){
			if(n==2)
				ans=a[2]-a[1];
			else
				ans=max(a[2]+a[3]-2*a[1],2*a[3]-a[1]-a[2]);
			goto loop;
		}
		if(n&1){
			for(int i=1;i<=n;i++){
				if(i==n/2+1)continue;
				else if(i<n/2+1){
					if(i==n/2)
						ans-=a[i];
					else
						ans-=a[i]*2;
				}
				else if(i>n/2+1){
					if(i==n/2+2)
						ans+=a[i];
					else
						ans+=a[i]*2;
				}
			}
			ans+=max(a[n/2+1]-a[n/2],a[n/2+2]-a[n/2+1]);
		}
		else{
			for(int i=1;i<=n;i++){
				if(i<n/2)
					ans-=a[i]*2;
				else if(i>n/2+1)
					ans+=a[i]*2;			
			}
			ans+=a[n/2+1]-a[n/2];
		}
loop:	printf("%lld\n",ans);
	}
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	char a[100],b[100],c[100];
	int x,y;
	scanf("%s %s %s",a,b,c);

	for (int i = 0; i < sizeof(a)/sizeof(char); i++)
	{
		if(a[i]==0) 
		{
			x = i-1;
			break;
		}
	}

	for (int i = 0; i < sizeof(b)/sizeof(char); i++)
	{
		if(b[i]==0) 
		{
			y = i-1;
			break;
		}
	}

	if(a[x]==b[0] && b[y]==c[0]) printf("YES");
	else printf("NO");
	
   	return 0;
}

Measured memory_bytes: 2128
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

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

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
pair<int, int> P[201];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", &P[i].first), P[i].second = i;

    VI ans;
    while (1) {
	if ((P[0].first < P[N-1].first) != (P[0].second < P[N-1].second)) {
	    ans.push_back(N-1);
	    swap(P[0].first, P[N-1].first);
	}

	if (P[0].second == 0) {
	    bool ok = true;
	    REP (i, N) if (P[i].first != i) {
		ok = false;
		break;
	    }
	    if (ok) break;
	}
	ans.push_back(1);
	for (int i=1; i<N; i++) swap(P[i], P[i-1]);
    }

    printf("%d\n", (int)ans.size());
    EACH (e, ans) printf("%d\n", *e);

//    REP (i, N) eprintf("%d %d, ", P[i].first, P[i].second);
//    eprintf("\n");
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

typedef long long ll;

ll n;
ll ans[2];
ll ans2[2];
bool v = false;
ll mx3 = -4e18, mi = -1;
ll now = 1;
vector<ll> ve, a;

int main()
{
    cin>>n;
    for(ll i = 0; i < n; i++)
    {
        ll t;
        cin>>t;
        a.push_back(t);
        if(mx3 < a[i]) mx3 = a[i], mi = i;
        ans[i % 2] += max(0LL, a[i]);
        if(a[i] >= 0) v = true;
    }
    if(!v)
    {
        cout<<mx3<<endl;
        cout<<n - 1<<endl;
        for(ll i = 0; i < mi; i++) cout<<1<<endl;
        for(ll i = n - mi; i >= 2; i--) cout<<i<<endl;
        return 0;
    }
    cout<<max(ans[0], ans[1])<<endl;
    if(ans[0] < ans[1])
    {
        ve.push_back(1);
        a.erase(a.begin(), a.begin() + 1);
    }
    while(a.size() > 1)
    {
        if(a[0] < 0)
        {
            ve.push_back(1);
            a.erase(a.begin(), a.begin() + 1);
            if(a.size() > 1)
            {
                ve.push_back(1);
                a.erase(a.begin(), a.begin() + 1);
            }
            continue;
        }
        if(a.size() <= 2)
        {
            ve.push_back(2);
            break;
        }
        if(a.size() > 2)
        {
            if(a[2] < 0)
            {
                if(a.size() > 3)
                {
                    ve.push_back(3);
                    a.erase(a.begin() + 2, a.begin() + 4);
                }
                else
                {
                    ve.push_back(3);
                    a.erase(a.begin() + 2, a.begin() + 3);
                }
            }
            else
            {
                ve.push_back(2);
                a.erase(a.begin() + 1, a.begin() + 3);
            }
        }
    }
    cout<<ve.size()<<endl;
    for(ll i = 0; i < ve.size(); i++)
    {
        cout<<ve[i]<<endl;
    }
    return 0;
}


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

int N, M;

int main(){
	scanf("%d%d", &N, &M);
	if(abs(N - M) > 1) printf("0\n");
	else{
		long long val = (abs(N - M) % 2 == 0) ? 2 : 1;
		for(int i = 2; i <= N; i++)
			val *= i, val %= 1000000007;
		for(int i = 2; i <= M; i++)
			val *= i, val %= 1000000007;
		printf("%lld\n", val);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	double x1, y1, x2, y2, xq, yq, a1, b1, a2, b2, cx, cy;
	
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq)!=EOF){
		if((y2-y1) == 0){
			a1 = xq;
			a2 = yq-y1;
			b1 = yq-2*a2;
		} else if((x2-x1) == 0){
			b1 = yq;
			a2 = xq-x1;
			a1 = xq-2*a2;
		} else{
			a1 = (y2-y1)/(x2-x1);
			a2 = -1/a1;
			b1 = y1-a1*x1;
			b2 = yq-a2*xq;
			cx = a1*(b2-b1)/(a1*a1+1);
			cy = a1*cx+b1;
			a1 = 2*cx-xq;
			b1 = 2*cy-yq;
		}
		printf("%.6f %.6f\n", a1, b1);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <sstream>

using namespace std;

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
    if (!item.empty()) {
            elems.push_back(item);
        }
    }
    return elems;
}

int main()
{
    string S;
    cin>>S;
    int len = S.length();
    string C = "";
    
    for(int i = 0;i<len-1;i++)
    {
        C.push_back(S[i]);
        C.push_back('-');
    }
    C.push_back(S[len-1]);

    long long sum = 0;
    for(int bit =0;bit<(1<<(len-1));bit++)
    {
        string T = C;
        for(int i = 0;i<len-1;i++)
        {
            if(bit &(1<<i))
            {
                T[i*2+1] = '+';
            }
        }
        T.erase(remove(T.begin(),T.end(),'-'),T.end());
        vector<string> v = split(T,'+');
        for(int i = 0;i<v.size();i++)
        {
            sum+=atoll(v[i].c_str());
        }

    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    ll int n,k;
    cin>>n>>k;
    ll int a[n+1];ll int i,z;
    for(i=1;i<=n;i++)
    	cin>>a[i];
    z=1;
    for(i=k+1;i<=n;i++)
    {
    	if(a[i]>a[z])
    	{
    		cout<<"Yes\n";
    	}
    	else
    	{
    		cout<<"No\n";
    	}
    	z++;
    }
}

Measured memory_bytes: 5236
n,h=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(n)]

attack=max(AB)[0]
AB=sorted(AB, reverse=True, key=lambda x:x[1])
cnt=0
for i,j in AB:
    if j>=attack:
        h -=j
        cnt +=1
    if h<=0:print(cnt);exit()

print(cnt+h//attack if h%attack==0 else cnt+h//attack+1)

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int min_a = 1001, max_a = -1;
    rep(i, n) {
        int a;
        cin >> a;
        min_a = min(min_a, a);
        max_a = max(max_a, a);
    }
    cout << max_a - min_a << endl;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if (a>12) {
    cout << b << endl;
  }
  else if (a<6) {
    cout << 0 << endl;
  }
  else {
    cout << b/2 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int d[3];

int main() {
	inc(i, 3) { cin >> d[i]; }
	sort(d, d + 3);
	
	cout << d[0] + d[1] << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt(); //問題数
		
		int[] d = new int[n]; //難易度
		
		for(int i = 0; i < n; i++) {
			d[i] = stdIn.nextInt();
		}
		
		Arrays.sort(d);
		
		int cnt = 0;
		if(d.length%2!=0) {
			System.out.println(cnt);
		}else {
			System.out.println(d[d.length/2]-d[d.length/2-1]);
		}
		
	}

}


Measured memory_bytes: 60736
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a, b;
  cin >> a >> b;

  if(a < 10 && b < 10) cout << (a * b) << endl;
  else cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()
int main()
{
  int N, W, v, w;
  cin >> N >> W;
  int dp[N+1][W+1];
  for (int i=0; i < W+1; ++i) {
    dp[0][i] = 0;
  }

  for (int i=1; i < N+1; ++i) {
    cin >> v >> w;
    for (int j = 0; j < W+1; ++j) {
      if (j >= w) {
        dp[i][j] = max(dp[i-1][j], dp[i-1][j-w]+v);        
      }else {
        dp[i][j] = dp[i-1][j];
      }

    }
  }
  cout << dp[N][W] << "\n";
  return 0;
}



Measured memory_bytes: 7032
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      s: chars,
    }
    let v1 = (s[0] as u8 - '0' as u8) as usize;
    let v2 = (s[1] as u8 - '0' as u8) as usize;
    let v3 = (s[2] as u8 - '0' as u8) as usize;
    let v4 = (s[3] as u8 - '0' as u8) as usize;
    let v1 = v1 * 10 + v2;
    let v2 = v3 * 10 + v4;

    let mut mv1 = false;
    if v1 >= 1 && v1 <= 12 {
        mv1 = true;
    }
    let mut mv2 = false;
    if v2 >= 1 && v2 <= 12 {
        mv2 = true;
    }

    if mv1 && mv2 {
        return println!("{}", "AMBIGUOUS");
    }
    if mv1 {
        return println!("{}", "MMYY");
    }
    if mv2 {
        return println!("{}", "YYMM");
    }
    println!("{}", "NA");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  if(b%a  == 0){
    cout << a+ b << endl;
  }else{
    cout << b- a << endl;
  }
}


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

int main(void) {
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i) cin >> a[i];
    
    vector<int> sq;
    for(int i=-100; i<=100; ++i) {
        int r = 0;
        for(auto e: a) {
            r += (e-i)*(e-i);
        }
        sq.push_back(r);
    }
    
    int ans = 1e9;
    for(auto e: sq) {
        ans = min(ans, e);
    }
    cout << ans << endl;
    return 0;
}
    

Measured memory_bytes: 256
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int m = in.nextInt();

        int odd = (n * m) & 1;

        if (odd == 1) {
            System.out.println("Odd");
        } else {
            System.out.println("Even");
        }
    }
}


Measured memory_bytes: 22996
#!/usr/bin/env python3
from copy import deepcopy
import random
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]

last = {}
for i in range(26):
    last[i] = -1

s = 0
Ret = []
for d in range(D):
    sr = {}
    ll = {}
    for c in range(26):
        last_cp = deepcopy(last)
        s_cp = deepcopy(s)
        last_cp[c] = d
        s_cp += S[d][c]
        for i in range(26):
            s_cp -= C[i] * (d-last_cp[i])
        sr[c] = s_cp
        ll[c] = last_cp
    sr = sorted(sr.items(), key=lambda x:x[1])
    x = random.randint(1,2)
    ret = sr[-x][0]
    s = sr[-x][1]
    last = deepcopy(ll[ret])
    Ret.append(ret+1)

for r in Ret:
    print(r)


Measured memory_bytes: 81548
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import re
import math
import itertools
import functools
import logging

logging.basicConfig(level=logging.DEBUG, format="DBG: %(message)s")

def dbg(msg, *args, **kwargs):
    logging.debug(msg, *args, **kwargs)

def fib(n):
    assert n >= 0

    f0 = 1
    f1 = 1

    if n == 0: return f0
    if n == 1: return f1

    for _ in range(n-1):
        f2 = f1 + f0
        f0 = f1
        f1 = f2

    return f2

def main():
    n = int(input())

    print(fib(n))

if __name__ == "__main__": main()

Measured memory_bytes: 9092
#include <iostream>

int main()
{
  int N;
  std::cin >> N;
  int tmp = N;
  int sum = 0;

  while ( tmp > 0 ) {
    sum += tmp % 10;
    tmp /= 10; 
  }

  if ( N % sum == 0 ) std::cout << "Yes\n";
  else std::cout << "No\n";
  return 0;
}


Measured memory_bytes: 384
package main

import (
    "bufio"
    "os"
    "fmt"
    "strings"
    "strconv"
    "sort"
    "math"
)

/************** Input *************/
var sc = bufio.NewScanner(os.Stdin)

func ReadLineToInt () []int{
    sc.Scan()
    line := strings.Split(sc.Text(), " ")
    length := len(line)
    var intLine []int
    for i := 0;i < length; i++ {
        n, _ := strconv.Atoi(line[i])
        intLine = append(intLine, n)
    }
    return intLine
}

/************* Pairs **************/
type Pair struct {
    a int
    b int
}

type SortablePairs struct {
    arr []*Pair
    lessfunc []lessFunc
}

type lessFunc func(p *Pair, q *Pair)bool

func (sp SortablePairs) Len() int {
    return len(sp.arr)
}

func (sp SortablePairs) Swap(i ,j int) {
    sp.arr[i], sp.arr[j] = sp.arr[j], sp.arr[i]
}

func (sp SortablePairs) Less(i, j int) bool {
    p, q := sp.arr[i], sp.arr[j]
    for k := 0; k < len(sp.lessfunc); k++ {
        less := sp.lessfunc[k]
        if less(p, q) {
            return true
        } else if less(q, p) {
            return false
        }
    }
    return false
}

/***********  min, max  *************/
func min(a, b int) int {
    return int(math.Min(float64(a), float64(b)))
}

func max(a, b int) int {
    return int(math.Max(float64(a), float64(b)))
}


/************  main  ***************/
func main() {
    nmk := ReadLineToInt()
    n, m, k := nmk[0], nmk[1], nmk[2]
    aSlice := ReadLineToInt()
    bSlice := ReadLineToInt()
    sp := SortablePairs{}
    for i := 0; i < n; i++ {
        sp.arr = append(sp.arr, &Pair{a: aSlice[i], b: bSlice[i]})
    }

    sortFunc := func(p, q *Pair) bool {
        return p.a > q.a
    }

    sp.lessfunc = append(sp.lessfunc, sortFunc)
    sort.Sort(sp)

    var dp [4][10001]int
    for i := 0; i < n; i++ {
        item := sp.arr[i]
        a := item.a
        b := item.b
        for y := k - 1;y >= 0; y-- {
            for x := m - 1; x >= 0; x-- {
                use := min(b, m - x)
                dp[y + 1][x + use] = max(dp[y + 1][x + use], dp[y][x] + use * a)
            }
        }
    }
    var ans int
    for y := 0; y <= k; y++ {
        for x := 0; x <= m; x++ {
            ans = max(ans, dp[y][x] + m - x)
        }
    }
    fmt.Println(ans)
}


Measured memory_bytes: 1512
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int(i)=int (a);i<=int (b);i++)
#define ff(i,a,b) for(int(i)=int (a);i<int (b);i++)
#define F(i,a,b) for(int(i)=int (a);i>=int (b);i--)
#define foreach(i,x) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vt vector
#define ll long long
#define lower(p,x) lower_bound(all(p),x)
#define upper(p,x) upper_bound(all(p),x)
#define ms(a,x) memset(a,x,sizeof a)
#define minn(a,b,c,d) min(a,min(b,min(c,d))) 
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const double pi=acos(-1.0);//NOTE:PI
const double eps=1e-5;
const int INF=1e9,mod=1e9+7,N=1e6+6;
int a[N];
int main(){
	//freopen("BIPERM.inp","r",stdin);
	//freopen("BIPERM.out","w",stdout);
	int n,k;
	cin>>n>>k;ms(a,0);
	f(i,1,n) {
		int x;cin>>x;a[x]++;
	}
	int s=n;
	while(true){
		int tmp=s;
		bool check=1;
		while(tmp){
			if(a[tmp%10]) {
				check=0;break;
			}
			tmp/=10;
		}
		if(check){
			break;
		}
		s++;
	}	
	cout<<s;
	
}

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

using namespace std;

int main() {
    
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i ++)
        cin >> arr[i];
    int cnt = 0;
    for (int i = 0; i < n - 2; i ++) {
        for (int j = i + 1; j < n - 1; j ++) {
            for (int k = j + 1; k < n; k ++) {
                if (arr[i] + arr[j] > arr[k] && arr[i] + arr[k] > arr[j] && arr[j] + arr[k] > arr[i]) {
                    if (arr[i] != arr[j] && arr[i] != arr[k] && arr[j] != arr[k]) {
                        cnt ++;
                    }
                }
            }
        }
    }

    cout << cnt;

    return 0;
}

Measured memory_bytes: 3652
n, k = map(int, input().split())

ab = [[0, 0] for _ in range(n)]

for i in range(n):
  a, b = map(int, input().split())
  ab[i][0] = a
  ab[i][1] = b

ab.sort()
s = 0
i = 0
while s< k:
  s += ab[i][1]
  ans = ab[i][0]
  i += 1
print(ans)
    
    
    

  

Measured memory_bytes: 54816
#include <iostream>
#include <array>

int main() {
    int k;
    std::array<int, 5> a;
    for (int i = 0 ; i < 5 ; i++) {
        std::cin >> a[i];
    }
    std::cin >> k;
    for (int i = 0 ; i < 5 ; i++) {
        for (int j = i+1 ; j < 5 ; j++) {
            if(a[j]-a[i] > k){
                std::cout << ":(" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "Yay!" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int main()
{
	int a,b;
	std::cin>>a>>b;
	if(a>b)
	std::cout<<(a*2)-1<<"\n";
	else if(a==b)
	std::cout<<a+b<<"\n";
	else
	std::cout<<(b*2)-1<<"\n";
}

Measured memory_bytes: 3492