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

#define fec(i, x, y) (int i = head[x], y = g[i].to; i; i = g[i].ne, y = g[i].to)
#define dbg(...) fprintf(stderr, __VA_ARGS__)
#define File(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
#define fi first
#define se second
#define pb push_back

template<typename A, typename B> inline char SMAX(A &a, const B &b) {return a < b ? a = b , 1 : 0;}
template<typename A, typename B> inline char SMIN(A &a, const B &b) {return b < a ? a = b , 1 : 0;}

typedef long long ll; typedef unsigned long long ull; typedef std::pair<int, int> pii;

template<typename I>
inline void read(I &x) {
	int f = 0, c;
	while (!isdigit(c = getchar())) c == '-' ? f = 1 : 0;
	x = c & 15;
	while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15);
	f ? x = -x : 0;
}

int k, a, b;

int main() {
	#ifdef hzhkk
	freopen("hkk.in", "r", stdin);
	#endif
	read(k), read(a), read(b);
	if (b - a <= 2) return printf("%d\n", k + 1), 0;
	if (k <= a - 1) return printf("%d\n", k + 1), 0;
	else{
		ll ans = 1;
		ans += a - 1; k -= a - 1;
		ans += (ll)(k >> 1) * (b - a);
		if (k & 1) ++ans;
		printf("%lld\n", ans);
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long llint;
typedef long double ldouble;
// 大小
int compare( const void *a, const void *b){return *(llint *)b - *(llint *)a;}
typedef struct{
    llint aa;
    llint bb;
}frequent;
// 小大
int cmp( const void *p, const void *q ) {
    return ((frequent*)p)->bb - ((frequent*)q)->bb;
}
/*2つのうち小さい数を返す*/
llint min2(llint a,llint b){return a>=b?b:a;}


int main(void){
    llint n,i,even[100001],odd[100001],count;
    scanf("%lld",&n);
    llint num[n];
    for(i=0;i<n;i++){
        scanf("%lld",&num[i]);
    }
    for(i=0;i<100001;i++){
        even[i]=0;
        odd[i]=0;
    }
    // 0:amount 1:num[i]
    llint emax[2]={0,0},emax2[2]={0,0},omax[2]={0,0},omax2[2]={0,0};
    for(i=0;i<n;i++){
        if(i%2==0){
            even[num[i]]++;
            if(even[num[i]] > emax[0]){
                emax[0]++;
                emax[1]=num[i];
                continue;
            }
            if(even[num[i]] > emax2[0]){
                emax2[0]++;
                emax2[1]=num[i];
            }
        }
        if(i%2==1){
            odd[num[i]]++;
            if(odd[num[i]] > omax[0]){
                omax[0]++;
                omax[1]=num[i];
                continue;
            }
            if(odd[num[i]] > omax2[0]){
                omax2[0]++;
                omax2[1]=num[i];
            }
        }
    }

    if(emax[1]!=omax[1]){
        count = n - emax[0] - omax[0];
        printf("%lld\n",count);
        return 0;
    }
    count = min2(n-emax[0]-omax2[0],n-emax2[0]-omax[0]);
    printf("%lld\n",count);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    bool ok=true;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]=='L')ok=false;
        }
        else{
            if(s[i]=='R')ok=false;
        }
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define ll                 long long                            
#define ra                 return a;                                          
#define pb                 push_back                                                     
#define sti                stack<ll>
#define spi                stack<pair<ll,ll>>
#define S                  second
#define msi                map<string,ll >
#define msi                map<string,ll >
#define mii                map<ll ,ll >
#define dbg(x)             { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y)          { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z)        { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define mis                map<ll , string>
#define rep(i,a,b)         for(ll  i=a;i<b;i++)
#define mpi                map<pair<ll ,ll >,ll >                                                
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define F                  first 
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define pqi                priority_queue<ll>
#define si                 set <ll>
#define vs                 vector<string>
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define hell               1000000007
#define bs                 binary_search
#define mp                 make_pair
#define qi                 queue<ll>
#define qs                 queue<string>
#define qpi                queue<pair<ll,ll>>
#define qps                queue<pair<ll,string>> 
#define endl               '\n' 
#define itr(a,it)          for(typeof(a.begin()) it=a.begin();it!=a.end();it++)// This will produce const_iterator for const object and normal iterator for non-const object
#define ss                 set<string>
using namespace std;
#define N  3001
ll dp[N][N];
ll rev[N][N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll test=1;
//    cin>>t;
    while(test--)
{
	string s,t;
	cin>>s>>t;
	ll n=sz(s);
	ll m=sz(t);
	rep(i,0,n+1)
	{
		rep(j,0,m+1)
		{
			if(i==0 || j==0)
				{
					;
				}
			else if(s[i-1]==t[j-1])
				{
					dp[i][j]=dp[i-1][j-1]+1;
					rev[i][j]=2;
				}
			else 
				{
					if(dp[i-1][j]>dp[i][j-1])
					{
						rev[i][j]=1;
						dp[i][j]=dp[i-1][j];
					}		
					else
					{
						rev[i][j]=0;
						dp[i][j]=dp[i][j-1];
					}
				}
		}
	}
	string s1;
	ll c1=n,c2=m;
	while(c1 && c2)
	{
		if(rev[c1][c2]==1)c1--;
		else if(rev[c1][c2]==0)c2--;
		else
		{
			c1--;
			c2--;
			s1+=s[c1];
		}
	}
	reverse(all(s1));
	cout<<s1;
}
    return 0;
}

Measured memory_bytes: 140928
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define big 1000000007
vector<vector<ll>> done(105, vector<ll>(100005));
vector<vector<ll>> memo(105, vector<ll>(100005));
vector<vector<ll>> data1(105, vector<ll>(2));
ll dp(ll n, ll sum) //(n番目まで使った時に合計がsum以上になる)これを満たす最小の重さを返す。
{
    if (sum == 0)
    {
        return 0;
    }
    if (n==0){
        return big;
    }
    if (done[n][sum] == 1)
    {
        return memo[n][sum];
    }
  /* if (n == 1)
    {
        if (sum <= data1[0][1])
        {
            return data1[0][0];
        }
        else
        {
            return 1000004;
        }
    }*/
    ll res;
    if (sum - data1[n - 1][1] < 0)
    {
        res = dp(n - 1, sum);
    }
    else
    {
        res = min(dp(n - 1, sum - data1[n - 1][1]) + data1[n - 1][0], dp(n - 1, sum));
    }
    done[n][sum] = 1;
    memo[n][sum] = res;
    return res;
}
int main()
{
    ll n, w;
    cin >> n >> w;
    ll count = 0;
    ll ans = 0;
    rep(i, n)
    {
        cin >> data1[i][0] >> data1[i][1];
        count += data1[i][1];
    }
    ll i;
    for (i = count; i > 0; i--)
    {
        if (dp(n, i) <= w)
        {
            break;
        } //つまり初めてw以下となった値がw=15だから出力してるが価値としてはw=14の方が高いので注意。
    }
    cout << i << endl;
    //  cout << count << endl;
}

Measured memory_bytes: 165488
#import math
import numpy as np
#import torch
#import torch.nn as nn
#import matplotlib.pyplot as plt
#from decimal import Decimal
#import itertools
#import collections

D=int(input())
#N,M,K = map(int,input().split())
#B,W = map(int,input().split())
#T=int(input())
C = list(map(int,input().split()))
#S=str(input())
c=np.zeros(365)
l=np.zeros([26,365])
T=[]
for i in range(D):
    S = list(map(int,input().split()))
    t=max(S)
    T.append(S.index(t))
    #for i in range(26):
    #    n=
for s in T:
    print(s+1)


Measured memory_bytes: 27272
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long int
#define sec ->second
#define fir ->first
#define mapi map<int,int>
#define veci vector<int,int>
#define pb(a) .push_back(a)
#define pob(a) .pop_back(a)
#define fori(a) for(int i=0;i<a;i++)
#define forill(a) for(long long int i=0;i<a;i++)
#define listi list<int>
ll gcd(ll a, ll b)
{
    // Everything divides 0
    if (a == 0)
       return b;
    if (b == 0)
       return a;

    // base case
    if (a == b)
        return a;

    // a is greater
    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}
int main()
{
    ll sum=0;ll n;cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                sum+=gcd(gcd(i,j),k);
            }
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	
	int sn = 0;
	int nn = n;
	while (nn > 0) {
		sn += nn % 10;
		nn /= 10;
	}

	if (n % sn == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
 
const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 100100;
const long double PI = acos(-1);
 
int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll sum = 0, ans = 0, res = 0, signal;
    cin >> n;

    vector<int> v(n);

    for (auto& x: v) cin >> x;

    signal = 1;
    for (int i=0; i<n; i++){
        sum += v[i];
        // cout << sum << endl;
        if (signal * sum <= 0){
            // cout << v[i] << " " << signal << " " << sum << endl;
            ans += abs(sum) + 1;
            sum = signal;
        }
        signal*=-1;
    }

    signal = -1;
    sum = 0;
    for (int i=0; i<n; i++){
        sum += v[i];
        if (signal * sum <= 0){
            res += abs(sum) + 1;
            sum = signal;
        }
        signal*=-1;
    }

    cout << min(ans, res)<< endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
	int N;
	char S[101];
	scanf("%d",&N);
	int i,ans=0;
	scanf("%s",S);				//ここ！文字列読み取りだけならこれでよい
	
	int cut = 1;
	int memo=0;
	int lFlag=0,rFlag=0;
	
	while(cut <= N){
		memo = 0;
		char target; // 'a' = 97
		for(target='a';target<='z';target++){
			for(i=0;i<cut;i++){
				if(S[i] == target){
					lFlag = 1;
				}
			}
			for(i=cut;i<N;i++){
				if(S[i] == target){
					rFlag = 1;
				}
			}
			if(lFlag==1 && rFlag == 1){
				memo++;
			}
			lFlag=0;rFlag=0;
		}
		if(memo >= ans){
			ans = memo;
		}
		cut++;
	}
	
	printf("%d",ans);
	return 0;}

Measured memory_bytes: 128
#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 rep(i,a,b) for(i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
inline void solve()
{
    string str;
    cin>>str;ll ans=0;
    ll n=str.length();
    for(ll i=0;i<n;i++)
    {
        if(str[i]=='R')
        {
            ll cnt=0;
            while(str[i]=='R' and i<n)
            {
                i++;
                cnt++;
            }
            ans=max(ans,cnt);
        }
    }
    cout<<ans<<endl;
}
int main()
{
    Imposter
    
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
S = input()
N = len(S)

ACGT = ['A', 'C', 'G', 'T']
ans = 0
for i in range(N):
    for j in range(i, N):
        flag = True
        for s in S[i:j + 1]:
            if s not in ACGT:
                flag = False
                break
        if flag and (j - i + 1) > ans:
            ans = j - i + 1
    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  int h = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'L' && i > 0 && s[i - 1] == 'L') h++;
    if (s[i] == 'R' && i < n - 1 && s[i + 1] == 'R') h++;
  }
  h += k * 2;
  int ans = min(h, n - 1);
  cout << ans << endl;
}


Measured memory_bytes: 3720
N = int(input())
A = list(map(int, input().split()))

approvedFlag = True

for a in A:
	if a%2 == 0:
		if (a%3!=0) and (a%5!=0):
			approvedFlag = False
			break

if approvedFlag:
	print('APPROVED')
else:
	print('DENIED')

Measured memory_bytes: 3060
//                             In The Name Of Allah                                           
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define ll long long
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 1e5 + 100, OO = 1e9 + 7, K = 3e5 + 100, T = 5, M = 1e9 + 7, P = 6151, SQ = 450, lg = 20;
typedef pair <int, int> pii;
int mark[N], n;
string s, ans[N];

void solve(int x) {
	int mx = 0;
	for(int i = 1; i < x; i++) 
		mx = max(mx, mark[i]);
	if(mark[x] <= mx)
		return;
	if(s[x - 1] == 'a') {
		ans[x] = "ab";
		for(int i = x + 1; i <= n; i++) {
			if(mark[i] == mark[x]) {
				ans[x] += ans[i + 1];
				break;
			}
		}
	}
	else {
		int cnt = 1;
		ans[x] = "b";
		for(int i = x + 1; i <= n; i++) {
			if(mark[i] <= mx)
				continue;
			ans[x] += s[i - 1];
			if(s[i - 1] == 'a')
				cnt--;
			else
				cnt++;
			if(cnt == 0) {
				ans[x] += ans[i + 1];
				break;
			}
		}
	}
}

int32_t main() {
	use_fast;
	cin >> n >> s;
	n *= 2;
	int a0 = 0, a1 = 0;
	for(int i = 1; i <= n; i++) {
		if(s[i - 1] == 'a')
			a0++, mark[i] = a0;
		else
			a1++, mark[i] = a1;
	}
	for(int i = n; i; i--) 
		solve(i), ans[i] = max(ans[i], ans[i + 1]);
	cout << ans[1] << endl;
	return 0;
}


Measured memory_bytes: 25340
#素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt = 0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    
    if temp!=1:
        arr.append([temp, 1])
    
    if arr==[]:
        arr.append([n, 1])
    
    return arr

def Alifac(arr):
    aarry = []
    for i in arr:
        for j in range(1, i[1] + 1, 1):
            aarry.append([i[0], j])
    return aarry

if __name__ == "__main__":
    n = int(input())
    arr = Alifac(factorization(n))
    arr.sort(key = lambda x: x[1])

    rem = 0
    for i in arr:
        j = i[0]**i[1]
        if n != 1:
            if n % j == 0:
                n = n / j
                rem += 1
    print(rem)



Measured memory_bytes: 9464
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

//GCD(最大公約数)
ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}

int main() {
    int n, x;
    cin >> n >> x;
    vll a(n);
    rep(i, n) {
        int m;
        cin >> m;
        a[i] = abs(m - x);
    } 
    
    ll ans = 0;
    rep(i, n) {
        ans = gcd(ans, a[i]);
    }

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


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys

N = int(input())
H = list(map(int, input().split(' ')))

prev = H[0]
count = 0
result = []

if len(H) == 1:
	print(0)
	sys.exit()

for i in range(1, len(H)):
	if H[i] > prev:
		result.append(count)
		count = 0
	else:
		count += 1
	prev = H[i]

result.append(count)

print(max(result))


Measured memory_bytes: 14252
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
int main()
{
    string s; //获取输入字符
    cin >> s;
    int totalsize = s.size();
    int num = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'S') { //找到一个S
                num++; //S计数
        }
        if (s[i] == 'T') { //找到一个T
            if (num > 0) { //有S与之匹配
                num--; //统计
                totalsize -= 2;
            }
        }
    }
    cout << totalsize << endl; //输出结果
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b;}
template<class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b;}
template<class T> void drop(const T &x) { std::cout<<x<<endl; exit(0);}
void debug_out() { std::cout << "\n";}
template<class T, class... Args> void debug_out(const T &x, const Args &... args) { std::cout<<x<< " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct InitIO{
  InitIO() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
  }
}init_io;

int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i,n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << endl; 
  cout << "WA x " << mp["WA"] << endl; 
  cout << "TLE x " << mp["TLE"] << endl; 
  cout << "RE x " << mp["RE"] << endl; 
  return 0;
}

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

int main() {
    int64_t N, sum = 0;
    cin >> N;
    int A[N];
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    int64_t oneMove = N * (N + 1) / 2;
    if (sum % oneMove) {
        puts("NO");
        return 0;
    }
    int64_t k = sum / oneMove, cnt = 0;
    rep(i, N) {
        int d = A[(i+1)%N] - A[i] - k;
        if (d % N) {
            puts("NO");
            return 0;
        }
        cnt += abs(d / N);
    }
    puts(cnt == k ? "YES" : "NO");
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int a,s;
	int i,n,x;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		s=0;
		for(i=0;i<9;i++){
			scanf("%d",&a);
			s+=a;
		}
		x=n-s;
		printf("%d\n",x);
	}
	return 0;
}


Measured memory_bytes: 2584
#include<stdio.h>
int main(void)
{
    int a,b,c,d,e,f;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	if(1000<=a*1+b*5+c*10+d*50+e*100+f*500){
	printf("1\n");
	}
	else{
		printf("0\n");
		}
		return 0;
		}

Measured memory_bytes: 584
const a:array[0..3]of string=('eraser','erase','dreamer','dream');
var s:ansistring;
    i,t,x:longint;
begin
  readln(s);
  for i:=0 to 3 do
  begin
    t:=pos(a[i],s);
    x:=length(a[i]);
    while t<>0 do
    begin
      delete(s,t,x);
      t:=pos(a[i],s);
    end;
  end;
  if length(s)<>0 then
    writeln('NO')
  else
    writeln('YES');
end.


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)
bool comp(string &a, string &b){
	return a+b<b+a;
}
void solve(int test_case) {
	int n,l;
	cin>>n>>l;
	vector<string> arr(n);
	for(string &s:arr)cin>>s;
	sort(arr.begin(),arr.end(), comp);
	string sol="";
	for(string &s:arr)sol+=s;
	cout<<sol;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    int N;cin>>N;
    int info[N];
    rep(i,N)cin>>info[i];
    ll ans=0;
    rep(i,N-1){
        ans+=info[i]/2;
        info[i]%=2;
        if(info[i] and info[i+1])ans++,info[i+1]--;
    }
    ans+=info[N-1]/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	cat A[3], K;
	cin >> A[0] >> A[1] >> A[2] >> K;
	if(K&1) cout << A[1]-A[0] << "\n";
	else cout << A[0]-A[1] << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 256
def main():
    N, M, *AB = map(int, open(0).read().split())

    E = [[] for _ in range(N + 1)]
    for a, b in zip(*[iter(AB)] * 2):
        E[a].append(b)
        E[b].append(a)

    visited = [False] * (N + 1)
    visited[a] = True
    visited[b] = True

    A = [a]
    while True:
        for a in E[a]:
            if not visited[a]:
                A.append(a)
                visited[a] = True
                break
        else:
            break

    B = [b]
    while True:
        for b in E[b]:
            if not visited[b]:
                B.append(b)
                visited[b] = True
                break
        else:
            break

    ans = A[::-1] + B
    print(len(ans))
    print(*ans)

main()


Measured memory_bytes: 27572
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;
int main(void){
    
    char a[101][101];
    int n,m;
    scanf("%d %d",&n,&m);
    
    for(int i=0;i<n;i++){
        scanf("%s",a[i]);
    }
    for(int i=0;i<m+2;i++){printf("#");}printf("\n");
    for(int i=0;i<n;i++){
        printf("#%s#\n",a[i]);
    }
    for(int i=0;i<m+2;i++){printf("#");}printf("\n");

    /*
    vector <int> T,P,X;
    int n,m,sum;
    
    scanf("%d",&n);
    T.resize(n);
    for(int i=0; i<n; i++){
        scanf("%d",&T[i]);
    }
    scanf("%d",&m);
    P.resize(m);
    X.resize(m);
    for(int i=0; i<m; i++){
        scanf("%d %d",&P[i],&X[i]);
    }
    
    sum = 0;
    for(int i=0; i<T.size(); i++){
        sum += T[i];
    }
    //printf("%d\n",sum);
    for(int i=0; i<P.size(); i++){
        printf("%d\n",sum + X[i] - T[P[i] - 1]);
    }
    
    */
    return 0;    
}


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

int c(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}

int main() {
	int a[3], i;
	for (i = 0; i < 3; i++) scanf("%d", &a[i]);
	qsort(a, 3, sizeof(int), c);
	printf("%d", (2 * a[2] - a[1] - a[0] + 1) / 2 + (a[0] + a[1]) % 2);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if(N%2==1)
        {
            System.out.println("No");
        }
        else
        {
            int ans = 0;
            String str = sc.next();
            String S[] = str.split("");
            for(int i=0;i<N/2;i++)
            {
                if(S[N/2+i].equals(S[i]))
                {
                    ans++;
                }
            }
            if(N/2==ans)
            {
                System.out.println("Yes");
            }
            else
            {
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 23508
n = int(input())
list_a=list(map(int, input().split()))  #リスト入力
diff = 10000000
for i in range(n):
    s1 = sum(list_a[:i])
    s2 = sum(list_a[i:])
    if diff > abs(s1 - s2):
        diff = abs(s1 - s2)
print(diff)

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

int main() {
    int X;
    cin >> X;
    int A = 400;
    for (int i = 8; i >= 1; i--) {
        if (X >= A && X < A + 200) {
            cout << i << endl;
            break;
        }
        A += 200;
    }
    return 0;
}


Measured memory_bytes: 3672
import heapq

rika=[]
syakai=[]

for i in range(4):
    n=int(input())
    rika.append(n)
    
rika=heapq.nlargest(3,rika)

for j in range(2):
    n=int(input())
    syakai.append(n)
    
syakai=heapq.nlargest(1,syakai)

rika.extend(syakai)
print(sum(rika))


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}

int query(int x) {
    cout << x << endl;
    string ret;
    cin >> ret;
    if (ret == "Vacant") {
        exit(0);
    }
    return ret == "Male";
}

void solve() {
    int N;
    cin >> N;
    
    int s0 = query(0);
    query(N - 1);

    int l = 0, r = N;
    while(r - l > 1) {
        int c = (l + r) / 2;
        int s = query(c);
        if ((c % 2) ^ (s != s0) == 0) {
            l = c;
        } else {
            r = c;
        }
    }
    query(l);
    query(r);
    
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 852
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
a = [int(i) for i in input().split()]
counter = 0

if any([True if i % 2 == 0 else False for i in a]):
    for i in a:
        while i % 2 == 0:
            i = i/2
            counter += 1
    print(counter)

else:
    print(0)


Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  ll k = 1;
  for(; k * (k + 1) < 2 * n; k++) {
  }
  bool ok = k * (k + 1) == 2 * n;
  if(!ok) {
    cout << "No" << endl;
    return 0;
  }
  vector<vl> g(k + 1, vl(k));
  ll c = 1;
  rep(i, k) rep2(j, i, k) {
    g[i][j] = c;
    g[j + 1][i] = c;
    c++;
  }
  cout << "Yes" << '\n' << k + 1 << '\n';
  rep(i, k + 1) {
    cout << k << ' ';
    rep(j, k) cout << g[i][j] << ' ';
    cout << '\n';
  }
}

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

#define int long long

signed main() {
    int n;
    while(cin>>n) {
        if(n%39==0) cout << "3C39" << endl;
        else cout << "3C" << setfill('0') << setw(2) << n%39 << endl;
    }
    return 0;
}

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

const ll MOD = 1e9 + 7;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<int> a(N+1, 1);
    rep(i, M) {
        int b;
        cin >> b;
        a[b] = 0;
    }

    vector<ll> dp(N+1);
    dp[0] = 1;

    for (ll now = 0; now < N; ++now) {
        for (ll next = now+1; next <= min(N, now+2ll); ++next) {
            if (a[next]) {
                dp[next] += dp[now];
                dp[next] %= MOD;
            }
        }
    }

    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 1408
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    while True:
        N, X = MI()

        if N == 0 and X == 0:
            return

        ans = 0
        for a in range(1, N+1):
            for b in range(a+1, N+1):
                for c in range(b+1, N+1):
                    if a + b + c == X:
                        ans += 1

        print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 6836
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  vector<int> a(n);
  REP(i, n) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  ll ans = 0;
  if(n % 2 == 0) {
    vector<int> t;
    REP(i, n / 2) {
      t.push_back(a[n / 2 + i]);
      t.push_back(a[i]);
    }

    REP(i, n - 1) ans += abs(t[i + 1] - t[i]);
  } else {
    vector<int> t1, t2;
    t1.push_back(a[n / 2]);
    t2.push_back(a[n / 2]);
    REP(i, n / 2) {
      t1.push_back(a[n - (i + 1)]);
      t1.push_back(a[i]);
      t2.push_back(a[i]);
      t2.push_back(a[n - (i + 1)]);
    }

    ll ans1 = 0, ans2 = 0;
    REP(i, n - 1) {
      ans1 += abs(t1[i + 1] - t1[i]);
      ans2 += abs(t2[i + 1] - t2[i]);
    }
    ans = max(ans1, ans2);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

bool isPrime(int n) {
    if(n <= 1) {
        return 0;
    }
    for(int i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            return 0;
        }
    }
    return 1;
}

vector<int> table(100001, 0);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    for(int i = 0; i < 100001; i++) {
        if(i % 2 && isPrime(i) && isPrime((i + 1) / 2)) {
            table[i] = 1;
        }
    }
    for(int i = 1; i < 100001; i++) {
        table[i] += table[i - 1];
    }
    auto calc = [&](int l, int r) {
        return (l == 0 ? table[r] : table[r] - table[l - 1]);
    };
    int q;
    cin >> q;
    while(q--) {
        int l, r;
        cin >> l >> r;
        cout << calc(l, r) << endl;
    }
}

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

int main() {
	int n,t_point,h_point;
	string t_card;
	string h_card;
	t_point = 0;
	h_point = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> t_card;
		cin >> h_card;
		if(t_card > h_card){
			t_point += 3;
		}else if(t_card < h_card){
			h_point += 3;
		}else{
			t_point++;
			h_point++;
		}
	}
	cout << t_point << " " << h_point << endl;
	return 0;
}


Measured memory_bytes: 3196
a, b, c, x, y = map(int, input().split())

res = a*x + b*y
for i in range(1, max(x, y)+1):
    ab = i*2
    cand = ab*c + a*max(0, x-i) + b*max(0, y-i)
    
    res = min(res, cand)

print(res)

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

int main(){
  int n;
  cin>>n;
  ll a[n];
  rep(i,0,n) cin>>a[i];
  ll ans=1;
  bool p=true;
  rep(i,0,n){
    if(a[i]==0) p=false;
  }
  if(!p) cout<<0<<endl;
  else{
    rep(i,0,n){
      if(a[i]<=(ll)1e18/ans) ans*=a[i];
      else{
        ans=-1;
        break;
      }
    }
    cout<<ans<<endl;
  }
}


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    long long ans=0;
    for(int i=0;i<s.size();i++)
    {
        ans+=s[i]-'0';
    }
    if(stoi(s) % ans)puts("No");
    else puts("Yes");
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(1,n):
    if a[i-1] + a[i] > x:
        s = a[i-1] + a[i] - x
        if a[i] - s >= 0:
            a[i] -= s
            ans += s
        else:
            a[i] = 0
            ans += s
print(ans)


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

typedef long long ll;

const ll mod = 1e9+7;
ll tab[10100];
ll tmp[10100];
ll ver[10100];
ll hol[10100];

ll fact[300100];
ll inv_fact[300100];

int main() {
	fact[0] = inv_fact[0] = 1;
	for(ll i = 1; i < 300100; i++) {
		ll t = mod-2, x;
		fact[i] = (fact[i-1] * i)%mod;
		x = fact[i];
		inv_fact[i] = 1;
		while(t) {
			if(t&1) {
				inv_fact[i]*= x;
				inv_fact[i]%= mod;
			}
			x = x*x%mod;
			t >>= 1;
		}
	}
	ll N, M, K;
	cin >> N >> M >> K;
	tab[0] = 1;
	for(int i = 1; i <= 2*K ; i++) {
		for(int j = 0; j <= K; j++) {
			tmp[j] = 0;
			tmp[j] = (((i >= 2*j && j) ? tab[j-1] : 0)
				+ tab[j]) % mod;
		}
		for(int j = 0; j <= K; j++) {
			tab[j] = tmp[j];
			if(i - 2*j == N) {
				ver[j] += tab[j];
				ver[j] %= mod;
			}
			if(i - 2*j == M) {
				hol[j] += tab[j];
				hol[j] %= mod;
			}
		}
	}
	for(int i = 0; i <= K; i++) {
		for(int j = 0; j <= i; j++) {
			if(2*K-N-i <= j && (N+2*i>2*K)) {
				ver[i] += (tab[j] * fact[N+2*i-2*K] % mod)
					* (inv_fact[i-j] * inv_fact[N+2*i-2*K - (i-j)] % mod);
				ver[i] %= mod;
			}
			if(2*K-M-i <= j && (M+2*i>2*K)) {
				hol[i] += (tab[j] * fact[M+2*i-2*K] % mod)
					* (inv_fact[i-j] * inv_fact[M+2*i-2*K - (i-j)] % mod);
				hol[i] %= mod;
			}
		}
	}
	ll res = 0;
	for(int i = 0; i <= K; i++) {
		res += ((ver[i] * hol[K-i] % mod) *
			((fact[2*K+M+N] * inv_fact[N+2*i] % mod) * inv_fact[2*K+M+N -(N+2*i)] % mod)) % mod;
		res %= mod;
	}
	cout << res << endl;
}

Measured memory_bytes: 8096
X, K, D = map(int, input().split())
X = abs(X)

cnt = X // D
ans1 = X - cnt * D
ans2 = abs(ans1 - D)

if cnt < K:
  if (K - cnt)%2 == 0:
    print(ans1)
  else:
    print(ans2)
else:
    print(X - K * D)

Measured memory_bytes: 9108
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int dp[110][10010]={0};
int main(){
	int n,m;
	while(cin>>n>>m,n){
		vvi dp(n+1,vi(m+1));
		int co;
		cin>>co;
		rep(i,co){
			int a,b;
			cin>>a>>b;
			dp[a][b]=-1;
		}
		dp[1][0]=1;
		rep(i,n)rep(j,m)if(dp[i+1][j+1]!=-1){
			if(dp[i][j+1]!=-1)dp[i+1][j+1]+=dp[i][j+1];
			if(dp[i+1][j]!=-1)dp[i+1][j+1]+=dp[i+1][j];
		}
		if(dp[n][m]!=-1)cout<<dp[n][m]<<endl;
		else cout<<0<<endl;
	}
}

Measured memory_bytes: 3008
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
////
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
//#ifdef __int128
//using hll = __int128;
//#endif
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

//#define solvsh
//#define multi

#ifdef solvsh
#else

ll mod = 1e9 + 7;

ll add(ll a, ll b){
    return (a + b) % mod;
}
ll ml(ll a, ll b) {
    return (a * b) % mod;
}

const int MAXN = 1e4 + 25;

void solve() {
    
    int x;
    cin >> x;
    cout << (x ^ 1);
}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        solve();
        i++;
    }
}

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifndef ONLINE_JUDGE
#else
#endif
#ifdef multi
    //        gen();
    multisolve();
#else
    solve();
//    gen();
#endif
//    time_calc();
}


Measured memory_bytes: 3652
#include <stdio.h>
#define N 100000
#define Q 50000

int search(int *a,int key,int n);

int main(){
  int i,j,n,q,key,con = 0;
  int s[N],t[Q];

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&q);
  for(i = 0;i < q;i++){
    scanf("%d",&t[i]);
    key = t[i];
    con += search(s,key,n);
  }
  printf("%d\n",con);
}

int search(int *a,int key,int n){
  int mid,left = 0,right = n;
  while(left < right){
    mid = (left + right) / 2;
    if(a[mid] == key) return 1;
    else if(key < a[mid]) right = mid;
    else left = mid + 1;
  }
  return 0;
}



Measured memory_bytes: 2288
#include<stdio.h>
int main()
{
    int a,b,h,c,d,e,f,g;
    scanf("%d%d%d",&a,&b,&h);
    if((a>=1&&a<=100)&&(b>=1&&b<=100)&&(h>=1&&h<=100)&&(h%2==0))
    {
        c=a+b;
        d=h/2;
        e=c*d;
        printf("%d",e);
    }
}


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

int main(){
    int n; cin >> n;
    int prev_min = INT_MAX, count = 0;
    vector<int>v(n);
    for(int i = 0; i < n; i++){
        int curr = 0; cin >> curr;
        v[i] = curr;
        //track min;
        if(curr <= prev_min){
            prev_min = curr;
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 1024
from functools import reduce
import math
import copy

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    H, W = (int(_) for _ in input().split())
    c = []
    for i in range(10):
        c.append(list(int(_) for _ in input().split()))
    A = []
    for i in range(H):
        A.append(list(int(_) for _ in input().split()))

    d = copy.deepcopy(c)
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])
    ans = 0
    for i in range(H):
        for j in range(W):
            if A[i][j] != -1:
                ans += d[A[i][j]][1]
    print(ans)
    
if __name__ == '__main__':
    main()


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

typedef struct{
	bool AC;
    int WA;
}QUESTION;

int main(){
  QUESTION *question;
  int q;
  string code;
  int N,M;
  int ac,wa;
  int i;
  cin >> N >> M;
  question = new QUESTION[N];
  for(i=0;i<N;i++){
	question[i].AC = false;
    question[i].WA = 0;
  }
  for(i=0;i<M;i++){
    cin >> q >> code;
    q--;
    if( code == "AC"){
      question[q].AC = true;
    }else if(question[q].AC == false){
	  question[q].WA++;
    }
  }
  ac = wa = 0;
  for(i=0;i<N;i++){
      if( question[i].AC == true){
          ac++;
          wa += question[i].WA;
      }
  }
  cout << ac << " "  << wa << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll, ll>
#define pb push_back
#define ll long long
#define ld long double	
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e18
ll power(ll num, ll g, ll mod) {
	if (g == 0)return 1;
	if (g % 2 == 1)return (num * power((num * num) % mod, g / 2, mod)) % mod;
	return power( (num * num) % mod, g / 2, mod);
}

int main(){
	int n, m, a, b;
	cin >> n >> m;
	vector<int> v[n+1];
	FOR0(i, m){
		cin >> a >> b;
		v[a].pb(b);
		v[b].pb(a);
	}
	int dist[n+1];
	int parent[n+1];
	memset(dist, -1, sizeof(dist));
	memset(parent, -1, sizeof(parent));
	dist[1] = 0, parent[1] = 1;
	queue<int> qu;
	qu.push(1);
	while(!qu.empty()){
		auto x = qu.front();
		qu.pop();
		for (auto u : v[x]){
			if (dist[u] == -1){
				parent[u] = x;
				dist[u] = dist[x] + 1;
				qu.push(u);
			}
		}
	}
	bool chk = 1;
	FOR1(i, n) if (parent[i] == -1) chk = 0;
	if (chk == 0){
		cout << "No";
	}
	else{
		cout << "Yes" << endl;
		for (int i = 2; i <= n; i++){
			cout << parent[i] << endl;
		}
	}
}

Measured memory_bytes: 10892
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n, m;
	cin >> n >> m;
	cout << (m * (1900) + (n - m) * 100) * (1 << m);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
const int N = 501;

int main(){
    int n, m;
    while(cin >>n >>m){
        if(n == 0 && m == 0) break;
        vector< vector<int> > vec(n + 1, vector<int>());

        for(int i = 0; i < m; i++){
            int tmp1, tmp2;
            cin >>tmp1 >>tmp2;
            vec[tmp1].push_back(tmp2);
            vec[tmp2].push_back(tmp1);
        }

        bool useflg[N] = {false};
        queue<int> use;

        for(int i = 0; i < vec[1].size(); i++) use.push(vec[1][i]);

        while(!use.empty()){
            int now = use.front();
            use.pop();
            useflg[now] = true;
            for(int i = 0; i < vec[now].size(); i++){
                if(useflg[vec[now][i]] == false) useflg[vec[now][i]] = true;
            }
        }

        int cnt = 0;
        for(int i = 2; i <= n; i++){
            if(useflg[i]) cnt++;
        }

        cout <<cnt <<endl;
    }
    return 0;
}

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

long long lcm(long long a, long long b)
{
	return (a / __gcd(a, b) * b);
}

int main()
{
	int N;
	long long T[105];
	long long val = 1;

	cin >> N;
	for ( int i = 0; i < N; i++ ) {
		cin >> T[i];
		val = lcm(val, T[i]);
	}

	cout << val << endl;

	return ( 0 );
}


Measured memory_bytes: 256