akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
int n, k, l, u, v, p[2][200010], ans[200010], last = 1;
pair<pair<int, int>, int> cc[200010];

int find(int i, int a) {
    return (p[i][a] < 0 ? a : p[i][a] = find(i, p[i][a]));
}

int main() {
    memset(p, -1, sizeof(p));
    scanf("%d%d%d", &n, &k, &l);
    for(int i = 1; i <= n; i++) ans[i] = 1;
    for(int i = 0; i < k; i++) {
        scanf("%d%d", &u, &v);
        int a = find(0, u), b = find(0, v);
        if(a == b) continue;
        if(p[0][a] < p[0][b]) p[0][a] += p[0][b], p[0][b] = a;
        else p[0][b] += p[0][a], p[0][a] = b;
    }
    for(int i = 0; i < l; i++) {
        scanf("%d%d", &u, &v);
        int a = find(1, u), b = find(1, v);
        if(a == b) continue;
        if(p[1][a] < p[1][b]) p[1][a] += p[1][b], p[1][b] = a;
        else ans[b] += ans[a], p[1][b] += p[1][a], p[1][a] = b;
    }
    for(int i = 1; i <= n; i++) cc[i] = {{find(0, i), find(1, i)}, i};
    sort(cc + 1, cc + n+1);
    for(int i = 2; i <= n; i++) {
        if(cc[i].fi.fi == cc[i-1].fi.fi && cc[i].fi.se == cc[i-1].fi.se) continue;
        for(int j = last; j < i; j++) ans[cc[j].se] = i - last;
        last = i;
    }
    for(int j = last; j <= n; j++) ans[cc[j].se] = n - last + 1;
    for(int i = 1; i <= n; i++) printf("%d ", ans[i]);
}

Measured memory_bytes: 5376
# vim: fileencoding=utf-8


def main():
    n, x = map(int, input().split())
    min = 1001
    ans = n
    for i in range(n):
        m = int(input())
        x -= m
        if min > m:
            min = m
    ans += x // min
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 80336
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <sstream>
#include <numeric>
#include <queue>
#include <sstream>
#include <set>
using namespace std;



int main(){
    int n ;
    cin >> n ;
    if (n == 1)
    {
        cout << 1 << endl ;
        return 0 ;
    }
    vector<int> prime(n,0) ;
    int64_t mod = 1000000007 ;
    for (size_t i = 2; i < n+1; i++)
    {
        int icopy = i ;
        for (size_t j = 2; j < i+1; j++)
        {
            while(1){            
                if (icopy % j == 0)
                {
                    prime.at(j-1) ++ ;
                    icopy /= j ;
                }else
                {
                    break ;
                }
                
                if (icopy == 1)
                {
                    break ;
                }
                
            }
            
        }
        
    }
    int64_t ans = 1 ;
    for (size_t i = 0; i < n; i++)
    {
        ans *= prime.at(i) + 1 ;
        if (ans > mod)
        {
            ans %= mod ;
        }
        
    }
    cout << ans << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
ll gcd(ll x,ll y){
    if (y == 0) return x;
    return gcd(y, x%y);
}
int main(void){
    ll n,k;cin>>n>>k;
    ll res=0;
    if(n<=k){
        ll buf=n-k;
        if(buf<0)buf*=-1;
        res=min(n,buf);
    }
    else{
        ll buf=n%k;
        ll buf2=k-buf;
        if(buf2<0)buf2*=-1;
        res=min(buf,buf2);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws java.lang.Exception {
	      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	      int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	      int d = Integer.parseInt(br.readLine());
	      System.out.println(arr[d-1]);
	}
}


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

int main(){
	int a;
	cin>>a;
	for(int i=1;i<=a;i++){
		if(i%3==0){
			cout <<" "<<i;
		}else if(i%10==3){
			cout <<" "<<i;
		}else if((i/10)%10==3){
			cout <<" "<<i;
		}else if((i/100)%10==3){
			cout<<" "<<i;
		}else if((i/1000)%10==3){
			cout <<" "<<i;
		}
		if(i==a){
			cout <<"\n";
		}
	}
	return 0;
}

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

const int MAX = 8;

int main(){
    int n, m, a[MAX], b[MAX];
    cin >> n;

    rep(i,n){
        cin >> a[i];
    }

    rep(i,n){
        cin >> b[i];
    }

    bool change = false;
    for(int i = 0; i < n; i++){
        if(a[i] > b[i]){
            change = true;
            break;
        }else if(a[i] == b[i]){
            continue;
        }else{
            break;
        }
    }

    if(change){
        rep(i,n){
            swap(a[i],b[i]);
        }
    }

    int diff = 0;
    do{
        bool same = true;
        for(int i = 0; i < n; i++){
            if(a[i] != b[i]){
                same = false;
                break;
            }
            same = true;
        }
        if(same) break;
        diff++;
    }
    while(next_permutation(a, a + n));

    cout << diff << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>

//#define PI 3.141592653589

using namespace std;



int main()
{
	string str, sub;
	int joi=0, ioi=0;
	
	while (cin >> str)
	{
		joi = 0;
		ioi = 0;
		for (int i=0; i<str.length()-2; i++)
		{
			sub = str.substr(i, 3);
			if (sub == "JOI")
			{
				joi++;
			} else if (sub == "IOI") {
				ioi++;
			}
		}
		
		cout << joi << endl << ioi << endl;
		//cout << str.length() << endl;
		//cout << str << endl;
		//cout << str.find("JOI", 2) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1212
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>
using namespace std;
using ll = long long;
 
const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
 
mint ncr(ll n, ll k) {
  mint a = 1, b = 1;
  for (int i = 0; i < k; i++) a *= n - i;
  for (int i = 1; i <= k; i++) b *= i;
  return a / b;
}
 
int main() {
  int N, M;
  cin >> N >> M;
  if (N <= 1 && M <= 1) {
      cout << 0 << endl;
    return 0;
  } else if (N <= 1 && M >= 2) {
    auto ans = ncr(M, 2);
    cout << ans.x << endl;
    return 0;

  } else if (N >= 2 && M <= 1) {
    auto ans = ncr(N, 2);
    cout << ans.x << endl;
    return 0;

  } else {
    auto ans = ncr(N, 2) + ncr(M, 2);
    cout << ans.x << endl;
    return 0;

  }
}


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

int SelectionSort(int N, int *A)
{
	//小さい順
	int count = 0, keep;

	for (int i = 0; i < N; i++) {
		keep = i;
		for (int j = i; j < N; j++) {
			if (A[j] < A[keep]) {
				keep = j;
			}
		}
		if (keep != i) {
			swap(A[i], A[keep]);
			count++;
		}
	}

	return count;
}

int main()
{
	int N, A[100];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	int count = SelectionSort(N, A);

	for (int i = 0;i < N; i++) {
		cout << A[i];
		if (i + 1 != N) {
			cout << " ";
		}
	}

	cout << endl << count << endl;

	return 0;
}


Measured memory_bytes: 3080
N = int(input())
A = list(map(int,input().split()))
memo = {}
for a in A:
    if a in memo:
        memo[a] += 1
    else:
        memo[a] = 1
memo_sorted = sorted(memo.items(), key=lambda x:-x[1])
memo = []
for a,b in memo_sorted:
    memo.append([a,b])

for key,val in enumerate(memo):
    val_1, val_2 = val
    if val_2 <= 1:
        continue
    else:
        if val_2%2 == 1:
            memo[key][1] = 1
        elif val_2%2 == 0:
            if key < len(memo)-1:
                memo[key+1][1] -= 1
                memo[key][1] = 1
            else:
                memo[key][1] = 0
ans = 0
for a,b in memo:
    ans += b
print(ans)
                

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

using ll = long long;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    if (s[0] == '0' || s[n - 1] == '1') {
        cout << -1 << endl;
        return 0;
    }
    rep(i, n / 2) {
        if (s[i] != s[n - 2 - i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << "1 2" << endl;
    int root = 2;
    for (int i = 1; i * 2 < n; i++) {
        cout << root << " " << i + 2 << endl;
        if (s[i] == '1') root = i + 2;
    }
    for (int i = (n + 5) / 2; i <= n; i++) {
        cout << root << " " << i << endl;
    }
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
long long d[101][100001];
int main(){
	int n,m;
	cin>>n>>m;
	int a[n+1],b[n+1];
	for(int k=1;k<=n;k++)
	    cin>>a[k]>>b[k];
	    
	for(int k=1;k<=m;k++)
	    if(k>=a[1])d[1][k]=b[1];    
	    
	for(int i=2;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(j>=a[i])d[i][j]=max(d[i-1][j],d[i-1][j-a[i]]+b[i]);
			else d[i][j]=d[i-1][j];
		}
	}    
	
	cout<<d[n][m];
	return 0;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define vll vector<ll>
#define all(x) x.begin(),x.end()
#define vlll vector<vll>
int main()
{
    Imposter
    
    int t=1;
    //cin>>t;
    while(t--)
    {
       
       ll n,ac=0,tle=0,wa=0,re=0;
       cin>>n;
       f(n)
       {
           string s;
           cin>>s;
           if(s=="AC")
           ac++;
           else if(s=="TLE")
           tle++;
           else if(s=="WA")
           wa++;
           else
           re++;
       }
       cout<<"AC x "<<ac<<endl;
       cout<<"WA x "<<wa<<endl;
       cout<<"TLE x "<<tle<<endl;
       cout<<"RE x "<<re<<endl;
    }
    return 0;
}

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

int main(){
        long double N,P;
        unsigned long long ans;
        cin >> N >> P;
        ans = (unsigned long long)pow(P,1/N);
        while((unsigned long long)P % (unsigned long long)pow(ans,N) != 0){
          ans--;
        }
        cout << ans << endl;
        return 0;
}


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

int main() 
{
    int n, k;
    cin>>n>>k;
    vector<int> a(n), dp(n,INT_MAX);
    for(int i = 0; i<n; i++)
        cin>>a[i];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for(int i = 2; i<n; i++)
    {
        for(int j = 1; j<=k; j++)
        {
            if(i-j >= 0)
            {
                dp[i] = min(dp[i], dp[i-j] + abs(a[i] - a[i-j]));
            }
        }
    }
	cout<<dp[n-1]<<"\n";
	return 0;
}


Measured memory_bytes: 4000
//n-slimes
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <bool> vb;
typedef vector <double> vd;
typedef vector <ll> vll;
typedef vector <vector <int>> vvi;
typedef vector <vector <long long>> vvll;
typedef vector <vd> vvd;
typedef vector <long long> vll;
typedef pair <int, int> pii;
typedef pair<ll , ll> pll;
typedef vector <pair <int, int>> vpii;

const ll INF = 1e18;

int main()
{
    ll n;
    cin >> n;
    vll a(n);
    for(ll &i: a)
        cin >> i;
    vvll state(n, vll(n, INF));
    vll prefix(n);
    prefix[0] = a[0];

    for(int i = 1; i < n; i++)
        prefix[i] = prefix[i-1] + a[i];
    
    for(int L = n-1; L >=0; L--)
        for(int R = L; R < n; R++)
        {
            if(L == R)
                state[L][R] = 0;
            else
            {
                for(int i = L; i < R; i++)
                    state[L][R] = min(state[L][R], state[L][i] + state[i+1][R] + prefix[R] - (L-1 <0 ? 0:prefix[L-1]));
            }
        }
    cout << state[0][n-1] << endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
const long long MOD  = 1000000007LL;
const long long MOD2 = 1012455881LL;
const long long MOD3 = 930446593LL;
const long long INF = 1e16;
const int INT_INF   = 1e8;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD, long long tot = 1) {
    for(;exp > 0; exp >>= 1, base = base * base % mod) if((exp & 1) == 1) tot = tot * base % mod;
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD, long long tot = 0) {
    for(;exp > 0; exp >>= 1, base = base * 2 % mod) if((exp & 1) == 1) tot = (tot + base) % mod;
    return tot;
}
struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

int f[100005],done[100005];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    //char c; cin >> c;
    //cout << (char) (c+1) << endl;

    /*int n, k, m; cin >> n >> k >> m;
    m *= n;
    for(int a, b = 1; b < n; ++b){cin >> a; m -= a;}
    m=max(0,m);
    if(m>k)cout<<"-1\n";
    else cout<<m<<"\n";*/

    string s;int n,m;cin>>n>>m;
    int cor=0,pen=0;
    for(int a,i=0;i<m;++i){
        cin>>a>>s;
        if(s=="AC"&&!done[a]){++cor;done[a]=1;pen+=f[a];}
        else if(s=="WA") ++f[a];
    }
    cout << cor << " " << pen << "\n";


    return 0;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
int n,a,b;
int main(){
	n=read(); a=read(); b=read();
	if(abs(a-b)&1)puts("Borys");
	else puts("Alice");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    double t,x;cin>>t>>x;
    printf("%.10f\n",t/x);
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,M,i,s,c;
cin>>N>>M;
vector<int>d(N,-1);
while(i<M){
cin>>s>>c;
s--;
if(d[s]>-1&&d[s]!=c||s+c<1&&N>1){
cout<<-1;
return 0;
}
d[s]=c;
i++;
}
cout<<(d[0]<0?N>1?1:0:d[0]);
for(i=1;i<N;i++)cout<<max(d[i],0);
}

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

int main()
{
	int N;
	string S;

	cin >> N;
	cin >> S;

	for (int i = 0; i < S.size(); i++) {
		if ('A' <= S[i] + N && S[i] + N <= 'Z')
			cout << char(S[i] + N);
		else 
			cout << char(S[i] + N - 'Z' + 'A' - 1);
	}

	cout << '\n';

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
using namespace std;

int main() {
	int a;
	string s;
	cin >> a >> s;

	if (a >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}
}

Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node

using namespace std;
///check n=1;
///check corner case;
 ll ara[123];
int main()
{
    ll n;
    cin>>n;
    char str[n+1];
    ll i,j;
    cin>>str;
    if(n%2==1){
        cout<<"No"<<endl;
        return 0;
    }
    for(i=0;i<n/2;i++){
        if(str[i]==str[i+(n/2)])continue;
    else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll s;
  cin >> s;
  ll hidari = s/100;
  ll migi = s - hidari * 100;
  if((migi==0 || migi > 12) && (hidari == 0 || hidari >12)){
    pri("NA");
    return 0;
  }
  if(!(migi==0 || migi > 12) && !(hidari == 0 || hidari >12)) {
    pri("AMBIGUOUS");
    return 0;
  }
  if(migi==0 || migi > 12){
    pri("MMYY");
  }else{
    pri("YYMM");
  }

  return 0;
}


Measured memory_bytes: 256
import sys
import copy
def input():
    return sys.stdin.readline()
n = int(input())
a = [int(i) for i in input().split()]

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)

  # divisors.sort()
  return divisors

ans = []
tmp = []
for i,x in enumerate(reversed(a)):
  y = n-i
  if x:
    ans.append(y)
    tmp = make_divisors(y)
    for j in tmp:
      a[j-1] ^= 1
      #print(a)
print(len(ans))
for i in reversed(ans):
  print(i,end=' ')

Measured memory_bytes: 67512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ll x ;
    cin>>x ;
    ll count1=0,count2=0 ;
    while(x>=500)
    {
       x=x-500 ;
       count1++ ;
    }
    while(x>=5)
    {
        x = x-5  ;
        count2++ ;
    }
    ll ans = count1*1000 + count2 *5  ;
    cout<<ans<<endl ;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

import itertools

per = list(itertools.permutations(list(range(1, N+1))))

p = -1
q = -1
for i in range(len(per)):
    if P == list(per[i]):
        p = i
    if Q == list(per[i]):
        q = i

print(abs(p - q))

Measured memory_bytes: 8052
import heapq


class DynamicMedian():
    """値をO(logN)で追加し、中央値クエリにO(1)で応える
    add(val): valを追加する
    median_low(): 小さい方の中央値(low median)を返す
    median_high(): 大きい方の中央値(high median)を返す
    """
    def __init__(self):
        self.left_q = []   # 小さい値を降順で格納する
        self.right_q = []  # 大きい値を昇順で格納する
        self.left_sum = 0
        self.right_sum = 0
        
    def add(self, val):
        """valを追加する"""
        if len(self.left_q) == len(self.right_q):
            self.left_sum += val
            val = -heapq.heappushpop(self.left_q, -val)
            self.left_sum -= val
            heapq.heappush(self.right_q, val)
            self.right_sum += val
        else:
            self.right_sum += val
            val = heapq.heappushpop(self.right_q, val)
            self.right_sum -= val
            heapq.heappush(self.left_q, -val)
            self.left_sum += val
            
    def median_low(self):
        """小さい方のmedianを返す"""
        if len(self.left_q) + 1 == len(self.right_q):
            return self.right_q[0]
        else:
            return -self.left_q[0]

    def median_high(self):
        """大きい方のmedianを返す"""
        return self.right_q[0]

q = int(input())
info = [list(map(int, input().split())) for i in range(q)]
dm = DynamicMedian()

b = 0
for i in range(q):
    if info[i][0] == 1:
        _, tmp_a, tmp_b = info[i]
        dm.add(tmp_a)
        b += tmp_b
    else:
        med = dm.median_high()
        lsum = dm.left_sum
        rsum = dm.right_sum
        lnum = len(dm.left_q)
        rnum = len(dm.right_q)
        tmp = (lnum*med - lsum) + (rsum - rnum*med)
        print(dm.median_low(), tmp + b)

Measured memory_bytes: 109528
while line = gets
  a, b = line.split.map(&:to_i)

  if a >= b
    m, n = a, b
  else
    n, m = a, b
  end

  loop do
    break m if n == 0

    m, n = n, m % n
  end

  gcd = m
  lcm = a * b / gcd

  print "#{gcd} #{lcm}\n"
end

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX_N 100000
#define MAX_M 100000
const int MAX = 10000000;
const int MOD = 1000000007;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecbvecb vector<vector<bool>>
#define vecst vector<string>
#define vecch vector<char>
#define vecf vector<float>
#define vecvec vector<vector<int>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
const int INF = 1e9;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;
int main() {
  ll n,ans=0;
  cin>>n;
  vecll s(n,0),A(n,0);
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  s[0]=A[0];
  for(int i=1;i<n;i++){
    s[i]=s[i-1]+A[i];
  }
  map<ll,ll> ma;
  ma[0]++;
  for(int i=0;i<n;i++){
    ma[s[i]]++;
  }
  for(auto m:ma){
    ans+=m.second*(m.second-1)/2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 15872
#include <iostream>
#include <cstdlib>
#define ll long long
using namespace std;

inline int sum_digits(int x) {
    int res = 0;
    while(x) {
        res += x%10;
        x /= 10;
    }
    return res;
}
int main() {
    int n, a, b, t;
    ll ans = 0;
    cin >> n >> a >> b;
    for(int i = 1; i <= n; i++) {
        t = sum_digits(i);
        if(t <= b && t >= a)
            ans += i;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {

	var n int
	fmt.Scan(&n)

	list := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(list)))
	result := 0
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			result += list[i]
		} else {
			result -= list[i]
		}
	}
	fmt.Println(result)

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
const int INF = 1001001001;

int main(){
  int n;
  cin >> n;
  int hig[n][101][101];
  vector<vector<int>> least(101, vector<int>(101,INF));
  for(int i=0; i<n; ++i){
    int x, y, h;
    cin >> x >> y >> h;
    if(h == 0){
      for(int j=0; j<=100; ++j) for(int k=0; k<=100; ++k){
        least[j][k] = min(least[j][k], abs(j-x) +abs(k-y));
      }
    }
    else for(int j=0; j<=100; ++j) for(int k=0; k<=100; ++k){
      hig[i][j][k] = h +abs(j-x) +abs(k-y);
    }
  }
  for(int i=0; i<=100; ++i) for(int j=0; j<=100; ++j){
    bool ansis = true;
    int ansh = 0;
    for(int k=1; k<n; ++k){
      ansh = max(ansh, hig[k][i][j]);
      if(hig[k][i][j] == 0 || hig[k-1][i][j] == 0) continue;
      if(hig[k-1][i][j] != hig[k][i][j]) ansis = false;
    }
    if(ansh > least[i][j]) continue;
    if(ansis){
      printf("%d %d %d\n", i, j, ansh);
      return 0;
    }
  }
}

Measured memory_bytes: 7720
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	1000000000000000000
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef pair<int, int> P;
typedef long long int ll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int n, m, r;
ll land[200][200], sea[200][200], dp[1000][200];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(cin >> n >> m){
		if(n == 0 && m == 0) break;
		int x,y,t; char sl;
		rep(i,n) rep(j,n){ land[i][j] = INF; sea[i][j] = INF; }
		rep(i,n){ land[i][i] = 0; sea[i][i] = 0;}
		rep(i,m){
			cin >> x >> y >> t >> sl;
			x--; y--;
			if(sl == 'L'){
				if(land[x][y] > t){ land[x][y] = t; land[y][x] = t; }
			} else{
				if(sea[x][y] > t){ sea[x][y] = t; sea[y][x] = t; }
			}
		}
		cin >> r;
		Vi z(r);
		rep(i,r){
			cin >> z[i];
			z[i]--;
		}
		rep(i,r) rep(j,n) dp[i][j] = INF;
		if(r == 1){
			cout << "0" << endl;
			return 0;
		}
		
		rep(k,n) rep(i,n) rep(j,n){
			land[i][j] = min(land[i][j], land[i][k]+land[k][j]);
			sea[i][j] = min(sea[i][j], sea[i][k]+sea[k][j]);
		}
		
		dp[1][z[0]] = land[z[0]][z[1]];
		rep(i,n){
			rep(j,n){
				if(i == j) continue;
				//cout << i << " " << j << " " << land[z[0]][i]+sea[i][j]+land[j][z[1]] << endl;
				dp[1][j] = min(dp[1][j],sea[z[0]][j]+land[j][z[1]]);
			}
		}
		for(int i = 2; i < r; i++){
			if(z[i-1] == z[i]){
				rep(j,n){
					dp[i][j] = dp[i-1][j];
				}
				continue;
			}
			rep(j,n) dp[i][j] = min(dp[i][j],dp[i-1][j]+land[z[i-1]][z[i]]);
			rep(j,n){
				rep(k,n){
					if(j == k) continue;
					dp[i][k] = min(dp[i][k], dp[i-1][j]+land[z[i-1]][j]+sea[j][k]+land[k][z[i]]);
				}
			}
		}
		/*
		for(int i = 1; i < r; i++){
			rep(j,n){
				cout << dp[i][j] << " ";
			}
			cout << endl;
		}
		*/
		cout << *min_element(dp[r-1], dp[r-1]+n) << endl;
	}
}

Measured memory_bytes: 3392
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))

X = sorted(X)
diffs = [X[i] - X[i-1] for i in range(1, len(X))]
diffs = sorted(diffs, reverse=True)

# 一番遠い距離から、2点間の距離の中から大きい順に引いていくだけ
res = X[-1] - X[0]
for i in range(min(len(diffs), N-1)):
  res -= diffs[i]

print(res)

Measured memory_bytes: 13968
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    string s;
    cin >> s;
    if(s[5] == '0' && s[6] <= '4') {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
}


Measured memory_bytes: 256
function gcd(a,b){
  if(b==0){return a;}
  return gcd(b, a%b);
}

function main(input){
  const lines = input.split('\n');
  const N = parseInt(lines[0].split(' ')[0]);
  const X = parseInt(lines[0].split(' ')[1]);
  const Xs = lines[1].split(' ').map(x => parseInt(x))

  Xs.push(X)
  Xs.sort(function(a,b){return a-b;})

  var diff_xs = [];
  for(var i=0;i<Xs.length-1;i++){
    diff_xs.push(Xs[i+1] - Xs[i]);
  }

  var result = diff_xs[0];
  for(var i=1;i<diff_xs.length;i++){
    result = gcd(result, diff_xs[i]);
  }

  console.log(result);

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 30404
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main() {
	char a;
  	int b = 95;
  	cin >> a;
  	if(a<=b){
      cout << "A" << endl;
    }
  	else{
      cout << "a" << endl;
    }
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> inline T pow3_L(T a){
  return a*a*a;
}
int N;
int K;
int main(){
  long long res;
  rd(N);
  rd(K);
  res =pow3_L(((long long)N/K));
  if(K%2==0){
    res +=pow3_L(((long long)N/(K/2) - (long long)N/K));
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N, K;
// {
//   ll res;
//   rd(N,K);
//   res = ((ll)N/K)**3;
//   if(K%2==0) res += ((ll)N/(K/2) - (ll)N/K)**3;
//   wt(res);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;
    string s;
    cin>>s;
    n=s.size();
    if(n==1) cout<<1;
    else 
    {
        int dp[2][n];
        dp[0][0]=1;
        dp[1][0]=-1;
        if(s[1]==s[0])
        {
            dp[0][1]=-1;
            dp[1][1]=1;
        }
        else
        {
            dp[0][1]=2;
            dp[1][1]=1;
        }
    
        rep(i,2,n)
        {
            dp[0][i]=dp[1][i]=-1;
            
            if(dp[1][i-1]!=-1) dp[0][i]=max(1+dp[1][i-1],dp[0][i]);
            if(dp[0][i-1]!=-1 && s[i]!=s[i-1]) dp[0][i]=max(1+dp[0][i-1],dp[0][i]);

            if(dp[0][i-2]!=-1) dp[1][i]=max(dp[1][i],1+dp[0][i-2]);
            if(dp[1][i-2]!=-1 && (s[i]!=s[i-2] || s[i-1]!=s[i-3])) dp[1][i]=max(dp[1][i],1+dp[1][i-2]);
        }
        cout<<max(dp[0][n-1],dp[1][n-1]);
    }

    return 0;
}



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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout << max({a+b, a-b, a*b}) << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int N;
    read(N);

    vector<i64> a(N), b(N);
    rep(i, N) read(a[i]);
    rep(i, N) read(b[i]);

    i64 cnt = 0;
    rep(i, N) {
        if (a[i] > b[i]) {
            cnt += a[i] - b[i];
            b[i] = a[i];
        }
    }
    trace(cnt);

    rep(i, N) {
        if (a[i] < b[i]) {
            cnt -= (b[i] - a[i]) / 2;
        }
    }
    trace(cnt);
    if (cnt > 0) {
        print("No");
    } else {
        print("Yes");
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define N 6001
#define INF (1e9)
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
vector<P> G[N];
int n,m,cap,ls[N];
void add_edge(int a,int b,int d){
  G[a].push_back(P(b,d));
  G[b].push_back(P(a,d));
}

int dijkstra(){
  int used[N]={};
  vector<vector<int> >D(cap+1,vector<int>(n,INF));
  priority_queue<PP,vector<PP>,greater<PP> > Q;
  Q.push(PP(0,P(cap,0)));
  D[cap][0]=0;

  while(!Q.empty()){
    PP t=Q.top();Q.pop();
    int d=t.first,c=t.second.first,pos=t.second.second;

    if(pos==1) return d;
    if(D[c][pos]<d||used[pos]>c)continue;
    used[pos]=c;
    if(ls[pos])c=cap;
    
    for(int i=0;i<G[pos].size();i++){
      int nd=d+G[pos][i].second;
      int nx=G[pos][i].first;
      int nc=c-G[pos][i].second;
      if(nc>=0&&D[nc][nx]>nd)Q.push(PP(nd,P(nc,nx))),D[nc][nx]=nd;
    }
  }
  return -1;
}


int main(){
  while(1){
    cin>>n>>m>>cap;cap*=10;
    if(!n&&!m&&!cap)break;
    for(int i=0;i<N;i++)G[i].clear(),ls[i]=0;
    
    map<string,int> M;
    string a,b;
    cin>>a>>b;
    M[a]=0,M[b]=1;
    int _n=2;
    for(int i=0,d;i<n;i++){
      cin>>a>>b>>d;
      if(!M.count(a)) M[a]=_n++;
      if(!M.count(b)) M[b]=_n++;
      add_edge(M[a],M[b],d);
    }
    n=_n;
    for(int i=0;i<m;i++) {cin>>a;if(M.count(a))ls[M[a]]=1;}
    cout <<dijkstra()<<endl;
  }
  return 0;
}

Measured memory_bytes: 50996
#include<stdio.h>
#define INFTY 500000
int R[1000000],L[1000000],C=0;
void merge(int *,int, int,int );
void mergeSort(int *,int,int);

int main()
{
  int S[1000000],i,n,left,right;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      if(n<=500000)
        {
          scanf("%d",&S[i]);
        }
    }
  left=0;
  right=n;
  
  mergeSort(S,left,right);

  for(i=0;i<n;i++)
    {
       printf("%d",S[i]);
      if(i<n-1)
        {
          printf(" ");
        }
      if(i==n-1)
        {
          printf("\n");
        }
    }
  printf("%d\n",C);
    
  return 0;
}
void merge(int A[],int left,int mid,int right)
{
  int n1,n2,i,j,k,l=0,r=0;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<=n1-1;i++)
    {
      L[i]=A[left+i];
      l++;
    }
  
  for(i=0;i<=n2-1;i++)
    {
      R[i]=A[mid+i];
      r++;
    }
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k<=right-1;k++)
    {
      C++;
      if(L[i]<=R[j])
        {
          if(l>0)
            {
              A[k]=L[i];
              i=i+1;
              l--;
            }
          else
            {
            A[k]=R[j];
            j=j+1;
            r--;
        }
        }
      else
        {
          if(r>0)
            {
          A[k]=R[j];
          j=j+1;
          r--;
            }
          else
            {
              A[k]=L[i];
          i=i+1;
          
                    l--;
            }
        }
    }
}
  
void mergeSort(int A[],int left,int right)
{
  int mid;
  if(left+1<right)
    {
      mid=(left+right)/2;
      mergeSort(A,left,mid);
      mergeSort(A,mid,right);
      merge(A,left,mid,right);
    }
}



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

using namespace std;

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

    int ans = 0;
    int l, r;
    for (int i = 0; i < N; ++i) {
        cin >> l >> r;
        ans += r - l + 1;
    }

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

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
flag = True
maxN = H[0]
for i in range(N - 1):
    if(maxN > H[i+1] and abs(maxN - H[i+1]) > 1):
        flag = False
        break
    maxN = max(H[i+1], maxN)
if(flag):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
#include <iostream>
#include <bits/stdc++.h>
#include <string>

using namespace std;

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

		cout << a << " " << b << " " << c; 


		return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()?: return
    val t = readLine()?: return

    for (i in (s.lastIndex - t.lastIndex) downTo 0) {
        var match = true
        for (j in t.indices) {
            if (s[i + j] == '?' || s[i + j] == t[j]) {
                continue
            }
            match = false
            break
        }
        if (match) {
            val result = s.replaceRange(i, i + t.length, t).replace('?', 'a')
            println(result)
            return
        }
    }
    println("UNRESTORABLE")
}

Measured memory_bytes: 31864
def main():
    L, R = map(int, input().split())
    min_ = 2019
    left = L % 2019
    right = R % 2019
    if left >= right:
        return 0
    if R >= L + 2019:
        return 0
    for i in range(left, right):
        for j in range(i + 1, right + 1):
            tmp = i * j % 2019
            if tmp < min_:
                min_ = tmp
    return min_

print(main())

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, n) for (int i = (n)-1; i >= 0; i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase(unique(ALL(v)), v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 2e18;
const double PI = acos(-1);

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	string S;
	cin >> N >> S;
	vi C(26);
	vi pow(N + 1);
	pow[0] = 1;
	ll ans = 1;
	REP(i, SZ(S))
	{
		ans *= 2;
		ans %= MOD;
		pow[i + 1] = ans;
		C[S[i] - 'a']++;
	}
	ans = 1;
	int cnt = 0;
	REP(i, 26)
	{
		if (C[i] == 0)
			continue;
		ans *= C[i] + 1;
		ans %= MOD;
	}
	cout << ans - 1 << endl;
	return 0;
}


Measured memory_bytes: 848
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

int main()
{
	int n, m;
	vector<int> data;
	vector<pair<int, int>> changes;
	long long sum = 0;
	cin >> n;
	cin >> m;
	for (int i=0; i<n; i++) {
		int t;
		cin >> t;
		data.push_back(t);
	}
	sort(data.begin(), data.end());

	for (int i=0; i<m; i++) {
		int k, t;
		cin >> k;
		cin >> t;
		changes.push_back(make_pair(t, k));
	}
	sort(changes.rbegin(), changes.rend());

	auto ptr = data.begin();
	for (auto it=changes.begin(); it != changes.end(); ) {
		if (ptr == data.end()) {
			break;
		}
			if (*ptr < (*it).first) {
				sum += (*it).first;
				++ptr;
				if ((*it).second == 1) {
					++it;
				} else {
					(*it).second--;
				}
			} else {
				break;
			}
	}
	while (ptr != data.end()) {
		sum += *ptr;
		++ptr;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1784
import scala.annotation.tailrec
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val a = readLine.trim
  println((0 until a.length).count{i ⇒
    canMake(a.take(i), a.drop(i))
  })
  def canMake(diff: String, sum: String): Boolean = {
    if (diff != "" && diff(0) == '0') false
    else if (sum == "" || sum(0) == '0') false
    else {
      if (diff == "") canMake(0, sum.toInt)
      else canMake(diff.toInt, sum.toInt)
    }
  }
  def canMake(diff: Int, sum: Int): Boolean = {
    if (diff % 2 != sum % 2) false
    else {
      val x = (diff + sum) / 2
      val y = sum - x
      x >= 0 && y >= 0
    }
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 44012
#include <cstdio>
using namespace std;
float a,b,c,d,e,f,t;
int main(){
  for(;~scanf("%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f);
    t=a*e-b*d,printf("%.3f %.3f\n",(e*c-b*f)/t+0.,(a*f-d*c)/t+0.)
  );
  return 0;
}

Measured memory_bytes: 1076
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

int N,M,K,X,Y;
int a,b,c,d;
string S,T;
vector<int> A,B;
void input()
{
    cin>>N;
}
void solve()
{
    // 1~N までの数で Nを作る
    int num;
    int asum;
    rep(i,1,N){
        if (i*(i+1)/2 >= N){
            num = i;
            asum=i*(i+1)/2;
            break;
        }
    }
    int dif = asum-N;
    
    rep(i,1,num){
        if (!(i==dif))cout<<i<<endl;
    }


}
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    long long int n, i, j, s = 0,sum=0;
    cin >> n;
    for (i = 1; i <= n; i++)
    {
        for (j = i; j <= n; j=j+i)
        sum+=j;
    }
    cout << sum;
}


Measured memory_bytes: 3628
// ---------- begin scannner ----------
#[allow(dead_code)]
mod scanner {
    use std::str::FromStr;
    use std::str::SplitWhitespace;
    use std::io::Read;
    use std;
    pub struct Scanner<'a> {
        it: SplitWhitespace<'a>
    }
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a String) -> Scanner<'a> {
            Scanner {
                it: s.split_whitespace()
            }
        }
        pub fn next<T: FromStr>(&mut self) -> T {
            match self.it.next().unwrap().parse::<T>() {
                Ok(v) => v,
                _ => panic!("Scanner error")
            }
        }
        pub fn next_chars(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }
    }
    pub fn read_string() -> String {
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
}
// ---------- end scannner ----------

use std::io::Write;

fn main() {
    let sc = scanner::read_string();
    let mut sc = scanner::Scanner::new(&sc);
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    run(&mut sc, &mut out);
}

// A != 0 なので
// 最後に操作できる人が1ならどうやってもx!=0となる
// 最後に操作するのが0だとする
// 最後に操作できる空間に入らないように1が調整可能か
// 最後の0連打までは0は何も操作しないのがいい？
// ->嘘、4, 4, 2, 2 (1010)
//
// 落ち着こう、操作がA=1のみで考えよう
// これは最後に操作できる方が勝ち
//
// 1が最後に操作できるbitがあるなら1
// そうでない時は？
// 1,2,3 (110) とかは1になるがどのbitも最後に操作可能なのは0のみ
//
// wa
//
// 0は拾えてると思っていたがそうでもないか全てが間違ってるか
// 

fn calc(x: &mut Vec<u64>) {
    if x.len() == 0 {
        return;
    }
    let mut ans = vec![];
    loop {
        let p = *x.iter().max().unwrap();
        if p == 0 {
            break;
        }
        for x in x.iter_mut().chain(ans.iter_mut()) {
            *x = std::cmp::min(*x, *x ^ p);
        }
        ans.push(p);
    }
    *x = ans;
}

fn run(sc: &mut scanner::Scanner, out: &mut std::io::BufWriter<std::io::StdoutLock>) {
    let t: usize = sc.next();
    for _ in 0..t {
        let n: usize = sc.next();
        let mut a: Vec<u64> = (0..n).map(|_| sc.next()).collect();
        let s: Vec<_> = sc.next_chars().into_iter().map(|d| d.to_digit(10).unwrap() as usize).collect();
        let mut ans = 0;
        for i in (0..n).rev() {
            if s[i] == 1 {
                if a[i] != 0 {
                    ans = 1;
                }
            } else if a[i] != 0 {
                let v = a[i];
                let k = v.trailing_zeros() as u64;
                for j in 0..=i {
                    if a[j] >> k & 1 == 1 {
                        a[j] ^= v;
                    }
                }
            }
        }
        writeln!(out, "{}", ans).ok();
    }
}


Measured memory_bytes: 2424