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

typedef long long int ll;
ll n,W, w[100009], val[100009];
ll dp[100009][109];
ll solve(ll v,int index)
{
    if(index==n)
    {
        return (v==0?0:INT_MAX);
    }
    if(dp[v][index]!=-1)
    return dp[v][index];
    ll ans =solve(v,index+1);
    if(v>=val[index])
    ans=min(w[index]+solve(v-val[index],index+1),ans);
    
    return dp[v][index]=ans;
    
}
ll func(ll n)
{
    for(ll i=n;i>=1;i--)
    {
        
        if(solve(i,0)<=W)
        return i;
    }
    return 0;
}

int main() {
	
	cin>>n>>W;
	ll v_max=0;
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)
	{
	    cin>>w[i];
	    cin>>val[i];
	    v_max+=val[i];
	}
	
	
	cout<<func(v_max)<<"\n";
	return 0;
}

Measured memory_bytes: 88772
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

bool check(vector<int> &buy,int x){
    for(int i=1;i<buy.size();i++){
        if(buy[i]<x) return false;
    }
    return true;
}

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<vector<int>> algo(n,vector<int>(m+1));
    for(int i=0;i<n;i++){
        for(int j=0;j<m+1;j++){
            cin >> algo[i][j];
        }
    }
    int ans=100100100;
    bool flg=false;
    for(int bit=0;bit<(1<<n);bit++){
        vector<int> buy(m+1);
        for(int i=0;i<n;i++){
            if(bit & (1<<i)){
                for(int j=0;j<m+1;j++){
                    buy[j]+=algo[i][j];
                }
            }
        }
        if(check(buy,x)){
            flg=true;
            ans=min(ans,buy[0]);
        }
    }
    if(flg) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

//-------------------------------------------------------------------
int M=1;
std::vector<int> seg, seg2;
void init(int N){
  while(M<N) M*=2;
  M=M*2-1;
  for(int i=0;i<M;i++) {
    seg.push_back(0);
    seg2.push_back(0);
  }
}
void update(ll k, int mode){
  k+=(M+1)/2-1;
  (mode==0?seg[k]:seg2[k]) ++;
  while(k>0){
    k = (k-1)/2;
    (mode==0?seg[k]:seg2[k]) = (mode==0?seg[k*2+1]:seg2[k*2+1]) + (mode==0?seg[k*2+2]:seg2[k*2+2]);
  }
}
ll query(int a, int b, int l, int r, int k, int mode){
  if(r<=a||b<=l) return 0;
  if(a<=l&&r<=b) return (mode==0?seg[k]:seg2[k]);
  ll A = query(a, b, l, (l+r)/2, k*2+1, mode);
  ll B = query(a, b, (l+r)/2, r, k*2+2, mode);
  return A+B;
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ll N;
  ll P = 998244353;
  ll ans = 0;
  std::cin >> N;
  vvl xy = vv(N, 2, 0, ll);
  map<ll, ll> convert;
  for(int i=0;i<N;i++)  std::cin >> xy[i][0] >> xy[i][1];
  sort(xy.begin(), xy.end(), [](std::vector<ll> a, std::vector<ll> b){return a[1]<b[1];});
  for(int i=0;i<N;i++) convert.emplace(xy[i][1], convert.size());
  sort(xy.begin(), xy.end());
  init(N);
  vvl data = vv(N, 4, 0, ll);
  for(int i=0;i<N;i++){
    data[i][0] = query(0, convert.at(xy[i][1]), 0, (M+1)/2, 0, 0);
    data[i][1] = query(convert.at(xy[i][1]), N, 0, (M+1)/2, 0, 0);
    update(convert.at(xy[i][1]), 0);
  }
  for(int i=N-1;i>=0;i--){
    data[i][2] = query(0, convert.at(xy[i][1]), 0, (M+1)/2, 0, 1);
    data[i][3] = query(convert.at(xy[i][1]), N, 0, (M+1)/2, 0, 1);
    update(convert.at(xy[i][1]), 1);
  }
  ans = 0;
  std::vector<ll> p2(N+1, 1);
  for(int i=1;i<=N;i++) p2[i] = (p2[i-1]*2)%P;
  for(int i=0;i<N;i++){
    for(int j=0;j<(1<<4);j++){
      ll a, b, c, d, num = j, reg = 1;
      d = num%2,num/=2;
      c = num%2,num/=2;
      b = num%2,num/=2;
      a = num%2,num/=2;
      reg = (reg * (a==0?1:p2[data[i][0]]-1))%P;
      reg = (reg * (b==0?1:p2[data[i][1]]-1))%P;
      reg = (reg * (c==0?1:p2[data[i][2]]-1))%P;
      reg = (reg * (d==0?1:p2[data[i][3]]-1))%P;
      if((a!=0&&d!=0)||(b!=0&&c!=0)) reg = (reg * 2)%P;
      ans = (ans + reg)%P;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 43876
#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 a, b;
  cin >> a >> b;
  cout << a*b << endl;
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define fi(i,a,b) for(int i=a;i<b;i++)
#define rfi(i,a,b) for(int i=a-1;i>=b;i--)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef long long int lli;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,pair<int,int>> ddp;
typedef pair<long long,pll> ldp;

#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define MAX 100000+5;

/* __A.v.i.n.a.s.h_._P.r.a.s.a.d__ */
/* __N.I.T_._D.U.R.G.A.P.U.R__ */
/* _K.e.E.p_._C.a.L.m_._A.n.D_._c.O.d.E_ */

int main()
    {
        fastio
        int n;
        cin >> n;
        int a[n];int maxm=0;
        for(int i=0;i<n;i++)
        {
            cin >> a[i];
            if(a[i]>maxm)
            maxm=a[i];
        }
        int max2=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]!=maxm )
            {
            max2=a[i];
            break;
            }
        }
        int maxcount=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]==maxm)
            maxcount++;
            if(a[i]<maxm && a[i]>max2 )
            {
            max2=a[i];
            }
        }
         for(int i=0;i<n;i++)
        {
            if(maxcount>1)
            {
                cout << maxm << endl;
                continue;
            }
            if(a[i]==maxm)
            cout << max2 << endl;
            else
            cout << maxm << endl;
        }
        return 0;
    }

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

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

    map<int, int> mp;
    int cnt = 0;

    rep(i, n)
    {
        int a;
        cin >> a;
        if (!mp[a])
        {
            mp[a] = 1;
            cnt++;
        }
        else
        {
            mp[a] = 0;
            cnt--;
        }
    }
    OP(cnt);

    return 0;
}

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


vector<int> adj[26];
string s,t;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s>>t;
	for(int i=0; i < s.size(); ++i){
		adj[ s[i] - 'a' ].push_back(i);
	}
	for(int i=0; i<t.size(); ++i){
		if( adj[ t[i] - 'a'].size() == 0 ){ cout<<-1<<'\n'; return 0; }
	}
	if( s.size() == 1 ){ cout<< t.size() << '\n'; return 0; }
	auto get = lower_bound(adj[t[0]-'a'].begin(),adj[t[0]-'a'].end(),0);
	ll pos = *get;
	ll ans = (pos)+1;
	int m = s.size();

	for(int i=1; i<t.size(); ++i){
		int ind = t[i] - 'a';
		auto get = lower_bound(adj[ind].begin(),adj[ind].end(),pos+1);
		if( get == adj[ind].end() ){
			ans += (m-pos-1);
			ans += (*adj[ind].begin()) + 1;
			pos = *adj[ind].begin();
		}else{
			ans += (*get) - pos;
			pos = *get;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


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

int main() {
    string S; cin >> S;
    int max = 0;
    int tmp = 0;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] == 'A' || S[i] == 'T' || S[i] == 'C' || S[i] == 'G') {
            tmp += 1;
            if (tmp > max) max = tmp;
        } else tmp = 0;
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<math.h>

long double cal_x(int r, int th){
	long double x;
	x=(long double)r*cos(-(long double)th*M_PI/180);
	return (x);
}
long double cal_y(int r,int th){
	long double y;
	y=(long double) r*sin(-(long double)th*M_PI/180);
	return (y);
}

int main(void){
	int r,th;
	int tempth=-90;
	long double x,y;
	long double sumx=0; long double sumy=0;

	while(1){
	scanf("%d,%d", &r, &th);
	if(r==0 && th==0) break;
	else {
		x=cal_x(r,tempth); y=cal_y(r,tempth);
		tempth +=th;
		sumx +=x; sumy +=y;
	};};
	printf("%d\n%d\n",(int)sumx,(int)sumy);

	return (0);
}

Measured memory_bytes: 656
N,*S = $<.map(&:to_i)
T = S.each_with_object(Hash.new(0).tap{|h| h[0] = 1}) do |s,o|
  o.keys.each do |k|
    o[k + s] += 1
  end
end
puts T.keys.reject{|v| v % 10 == 0 }.max || 0




Measured memory_bytes: 5116
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    static int[] makePrimes( final int lim ) {
	
	BitSet isPrime = new BitSet( lim + 1 );
	isPrime.set( 0, lim + 1, true );
	isPrime.set( 0, 2, false );
	final int limIndex = ( int )sqrt( lim );
	for ( int index = 2; index <= limIndex; index++ ) {
	    if ( isPrime.get( index ) ) {
	   	for ( int i = index * index; i <= lim; i += index ) {
		    isPrime.set( i, false );
		}
	    }
	}
	final int count = isPrime.cardinality();
	int[] ans = new int[count];
	int index = 0;
	for ( int i = 0; i <= lim; i++ ) {
	    if ( isPrime.get( i ) ) {
		ans[index++] = i;
	    }
	}
	return ans;
    }
    
    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );
	final int [] primes = makePrimes( 10000 );
	
	while ( stdin.hasNextInt() ) {

	    final int n = stdin.nextInt();
	    if ( n <= 2 ) {
		System.out.println( 0 );
	    } else {
		int count = 0;
		int index = 0;
		while ( index < primes.length && primes[ index ] <= n ) {
		    if ( Arrays.binarySearch( primes, n - primes[ index ] + 1 ) >= 0 ) {
			count++;
		    }
		    index++;
		}
		System.out.println( count );
	    }
	}	
    }    
}

Measured memory_bytes: 24284
#include <stdio.h>
#include <math.h>
int main(void){
	int i,num,n,m,z;
	char str[100];

	for( ; ; ){
		fgets(str,sizeof(str),stdin);
		sscanf(str,"%d",&n);
		num=0;
		if(n==0)
			break;
		for(i=5;i<=n;i++){
			m=i;
			while(m>0){
				if(m%5!=0)
					break;
				num++;
				m/=5;
			}		
		}
		printf("%d\n",num);
	}
	return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <time.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)


vector<string> v;

int d[10];

void solve()
{
    int n, k;
    cin >> n >> k;
    
    for(int i = 0; i < 10; i++)
    {
        d[i] = 1;
    }
    
    for(int i = 0; i < k; i++)
    {
        int x;
        cin >> x;
        d[x] = 0;
    }
    
    for(int t = n; ; t++)
    {
        int yes = 1;
        int m = t;
        
        while(m > 0)
        {
            yes = min(yes, d[m % 10]);
            m /= 10;
        }
        
        if(yes)
        {
            cout << t;
            break;
        }
    }
    
    cout << "\n";
}



int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    solve();
    return 0;
}

Measured memory_bytes: 256
n = int(input())
if n == 1:
    print(0)
    exit()
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

A = factorization(n)

ans = 0
for a in A:
    cnt = 1
    b = a[1]
    while (b-cnt) >= 0:
        b -= cnt
        cnt += 1
        ans += 1

print(ans)


Measured memory_bytes: 9484
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define int long long
int fun(int wts[], int vals[], int n, int w){
    int dp[w+1];
    mset(dp, 0);
    /*dp[i] = maximum total value of items with total weight exactly i*/
    for(int i = 1; i <= n; i++){
        /*all knapsack with capacity >= wt[i] will be able to accomodate object i*/
        for(int j = w; j >= wts[i]; j--){
            dp[j] = max(dp[j], vals[i] + dp[j-wts[i]]);
            /*for every such possible knapsack capacity, 
            ans is maximum of not considering current element
            and considering current element*/
        }
    }
    return dp[w];
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	int T=1;
	//cin >> T;
	FOR1(i, T)
	{
		//cout << "Case #" << i << ": ";
       int n, w;
       cin >> n >> w;
       int vals[n+1], wts[n+1];
       FOR1(i, n){
           cin >> wts[i] >> vals[i];
       }
       cout << fun(wts, vals, n, w);
		cout<<'\n';
	}
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 100005
#define MOD 1000000007

ll factorial[2*ARRAY_MAX];
ll inverse[2*ARRAY_MAX];

/*mod Mでの割り算は割る数aのM-2をかける*/
/*ここではaのb乗をpで割った余りを返す*/
ll calc(ll a,ll b,ll p){

   if(b == 0){
       return 1;
   }else if(b % 2 == 0){
       ll tmp = (calc(a,b/2,p)) % p;
       return ((tmp%p)*(tmp%p))%p;
   }else{
       return ((a%p)*(calc(a,b-1,p)%p)) % p;
   }
}

ll calc_nCr(ll n,ll r){

    return ((factorial[n]*inverse[r])%MOD*inverse[n-r])%MOD;
}

int main(){

    ll h,w,a,b;
    cin >> h >> w >> a >> b;
    factorial[0] = factorial[1] = 1;
    for(ll i = 2;i <= h+w-2;i++){
        factorial[i] = factorial[i-1] * i % MOD;
    }
    for(ll i = 0;i <= h+w-2;i++){
        inverse[i] = calc(factorial[i],MOD-2,MOD);
    }

    ll n = h-a-1;
    ll down = a-1;
    ll ans = 0;

    for(ll i = b;i < w;i++){
        
        ll right = w-i-1;
        //cout << right << endl;
        ans = (ans + (calc_nCr(n+i,i) * calc_nCr(down+right,right))%MOD)%MOD;
    }
    cout << ans << endl;

    




    return 0;
}

Measured memory_bytes: 3328
import bisect

n = int(input())
A = list(map(int, input().split()))
counts = [0]*(n)
for a in A:
    counts[a-1] += 1
counts.sort()

cumsum = []
num = 0
for count in counts:
    num += count
    cumsum.append(num)

answers = [0]*(n)
for i in range(1, n+1):
    idx = bisect.bisect_right(counts, i)
    left = cumsum[idx-1]
    right = (n-idx)*i
    K = (right+left)//i
    answers[K-1] = i

now = 0
for i in range(n-1, -1, -1):
    if answers[i] == 0:
        answers[i] = now
    now = answers[i]

for ans in answers:
    print(ans)

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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define pb push_back
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define ford(i, b, a) for (int i = (int)(b); i >= a; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
const int N = (int)1e5+77;
const ll inf = (ll) 1e15+77;
const int mod = (int) 1e9 + 7;
const ld pi = acos(-1);

int main() {
    fast;
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> dp(k + 1, -1);
    forn(i, n) cin >> a[i];
    dp[0] = 0;
    for1(i, k) {
        dp[i] = 0;
        forn(j, n) {
            if (a[j] > i) break;
            if (dp[i - a[j]] != -1 and dp[i - a[j]] == 0) dp[i] = 1;
        }
    }
    puts(dp[k] == 1 ? "First" : "Second");
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;



int main(){
    ll N; cin >> N;
    ll ans = 0;
    for(int i = 1; i <= N; i+=2){
        ll cnt = 0;
        for(int j = 1; j <= N; j++) if(i%j == 0) cnt++;
        if(cnt == 8) ans++;
    }
    cout << ans << endl;

} 


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define RB rbegin()
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define MD 1000000007
#define PPF pop_front()
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;u.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>u,uc;
LL ar[120005];
LL br[500005];
LL cr[500][500];
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c,str;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
//    cin>>tt;
    while(tt--)
    {
//        UOSMOY;
        cin>>a>>b;
        k=0;
        for(i=0; a[i]; i++)
        {
            if(a[i]!=b[i])
            {
                k++;
            }
        }
        cout<<k<<endl;

    }
    return 0;
    //IN
    //AL
}


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

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

int main(void)
{
	int i, n, choice = 2;
	int a[100000] = {};
	long long int s = 1;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	qsort(a, n, sizeof(int), asc);

	for (i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			s *= a[i];
			i++;
			if (--choice == 0) {
				printf("%lld", s);
				exit(0);
			}
		}
	}
	printf("0");
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int ax[100005];

int gcd (int a,int b){
    if(a==0) return b;
    return gcd (b%a,a);
}

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int i,j,a=0,b;
    for(i=0;i<n;i++){
        scanf("%d",&ax[i]);
        a = max(ax[i],a);
    }
    if(a<k){
        printf("IMPOSSIBLE");
    return 0;}
    int w=ax[0];
    for(i=1;i<n;i++)w = gcd(w,ax[i]);
    if(k%w==0)printf("POSSIBLE");
    else printf("IMPOSSIBLE");
    return 0;
}


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

pair<map<ll, ll>, set<ll>> prime_factor(ll n){
    map<ll, ll> res;
    set<ll> primes;
    for(ll i = 2; i*i <= n; ++i) {
        if(n%i==0) primes.insert(i);

        while(n%i == 0){
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) {
        res[n] = 1;
        primes.insert(n);
    }
    return make_pair(res, primes);
}

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

    ll a, b;
    cin >> a >> b;

    set<ll> sta = prime_factor(a).second;
    set<ll> stb = prime_factor(b).second;

    ll res = 1;
    for(ll ela: sta){
        if(stb.find(ela) != stb.end()) ++res;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const ll MOD = 1000000007LL;

int main(){
    int n;
    std::cin >> n;
    VEC(ll,a,n);
    std::vector<ll> aa(a);
    std::vector<ll> ans(n,0);
    irep(i,n){
        if(i==n-1)continue;
        if(i==0)break;
        ans[i]=a[i]*2;
        a[i]-=ans[i]/2;
        a[i-1]-=ans[i]/2;
    }
    ans[0]=a[0]*2;
    ans[n-1]+=aa[n-1]-ans[0]/2;
    rep(i,n-1)a[i]+=a[n-1];
    rep(i,n-1)ans[i]=0;
    irep(i,n-1){
        ans[i]=(aa[i]-ans[i+1]/2)*2;
    }
    rep(i,n)std::cout << ans[i]<<" " ;//< std::endl;
    std::cout << std::endl;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <string>

using namespace std;

int main() {
  char buf[262144];
  scanf("%s", buf);
  string X(buf);

  int res=0, cur=0;
  for (size_t i=0; i<X.length(); ++i) {
    if (X[i] == 'S') {
      ++cur;
    } else if (X[i] == 'T') {
      --cur;
      if (cur < 0) {
        res -= cur;
        cur = 0;
      }
    }
  }
  res += cur;
  printf("%d\n", res);
}

Measured memory_bytes: 640
n,m=map(int,input().split())
l=[]
min=0
max=n
for i in range(m):
    x,y=map(int,input().split())
    if min<x:
        min=x
    if y<max:
        max=y

if max-min>=0:
    print(max-min+1)
else:
    print(0)

Measured memory_bytes: 3060
N = int(input())

for h in range(1, 1 + 3500):
    for n in range(1, 1 + 3500):
        d = 4 * n * h - N * (h + n)
        if d > 0 and N * n * h % d == 0:
            w = N * n * h // d
            print(h, n, w)
            exit()


Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
using namespace std;
 
int main(){
 
int N,M;
 
cin>>N>>M;

if(N - M == 0) {
  cout << "Yes" << endl;
} else {
  cout << "No" << endl;
}

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define REP(i,a) for(int i=0;i<(a);i++)
#define REPR(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<long long>;
using vvl = vector<vl>;
using vs = vector<string>;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

struct aho_corasick {
	vector<vector<int>> succ;
	vector<int> fail, accept;
	char from, to;

	aho_corasick(char from_ = 'a', char to_ = 'z') : from(from_), to(to_), succ(1, vector<int>(to_ - from_ + 1)), accept(1) {}

	void add(string s) {
		int u = 0;
		for (char c : s) {
			c -= from;
			if (succ[u][c] == 0) {
				succ[u][c] = succ.size();
				succ.push_back(vector<int>(to - from + 1));
				accept.push_back(0);
			}
			u = succ[u][c];
		}
		accept[u]++;
	}

	void build() {
		queue<int> q;
		for (int c = 0; c <= to - from; c++) {
			if (succ[0][c] != 0) {
				q.push(succ[0][c]);
			}
		}
		fail.resize(succ.size());
		while (!q.empty()) {
			int u = q.front(); q.pop();
			for (int c = 0; c <= to - from; c++) {
				int v = succ[u][c];
				if (v != 0) {
					q.push(v);
					fail[v] = succ[fail[u]][c];
				} else {
					succ[u][c] = succ[fail[u]][c];
				}
			}
			accept[u] += accept[fail[u]];
		}
	}

  int next(int k, char c) {
    return succ[k][c - from];
  }
};

int main() {
  aho_corasick ac;
  ac.add("agc");
  ac.add("gac");
  ac.add("acg");

  ac.add("aagc");
  ac.add("acgc");
  ac.add("aggc");
  ac.add("atgc");

  ac.add("agac");
  ac.add("agcc");
  ac.add("aggc");
  ac.add("agtc");
  
  ac.build();

  static mint dp[101][1000];
  dp[0][0]=1;
  int N=si();
  REP(i,N)REP(j,ac.succ.size())REP(k,4){
    int l=ac.next(j,"acgt"[k]);
    if(ac.accept[l]>0)continue;
    dp[i+1][l]+=dp[i][j];
  }
  mint ans=0;
  REP(i,ac.succ.size())ans+=dp[N][i];
  pi(ans.n);br();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
// #define rep(i,n) for(int i=0;i<n;++i)
#define rep(i,i0,n) for(int i=i0;i<n;++i)
#define ALL(x) (x).begin(),(x).end()
#define pb = push_back;
#define INF12 1000000000000 //10^12
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;



int main() {
    vi A(3);
    rep(i,0,3) cin >> A.at(i);
    sort(ALL(A));
    int d1 = A.at(2) - A.at(0);
    int d2 = A.at(2) - A.at(1);
    int ans = 0;
    ans += d1 / 2;
    ans += d2 / 2;
    d1 %= 2;
    d2 %= 2;
    if(d1 == 1 && d2 == 1) ans += 1;
    if(d1+d2 == 1) ans += 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
listInf = input().split()
listInf[0] = int(listInf[0])
listInf[1] = int(listInf[1])
s = []
ans = []

a = [[0]*listInf[1] for _ in range(listInf[0])]
b = [0 for _ in range(listInf[1])]

for column in range(listInf[0]):
    oneOfA = input().split()
    for row in range(listInf[1]):
        a[column][row] = int(oneOfA[row])

for c in range(listInf[1]):
    b[c] = int(input())

for x in range(listInf[0]):
    for y in range(listInf[1]):
        s.append(a[x][y]*b[y])
    print(sum(s))
    s.clear()



Measured memory_bytes: 6020
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

LL n, k;
LL h[303];
LL dp[303][303];

int main(){
    cin >> n >> k;
    for(int i = 1;i <= n;i++)cin >> h[i];
    REP(x, n + 2){
        REP(y, n + 2){
            dp[x][y] = HINF<LL>();
        }
    }
    dp[0][k] = 0;
    LL ans = HINF<LL>();
    REP(i, n + 1)REP(j, k + 1)if(dp[i][j] < HINF<LL>()){
        if(j >= n - i)ans = min(ans, dp[i][j]);
        for(int r = i + 1;r <= n && j >= r - i - 1;r++){
            int dif = max<int>(h[r] - h[i], 0);
            dp[r][j - (r - i - 1)] = min(dp[r][j - (r - i - 1)], dp[i][j] + dif);
        }
    }
    cout << ans << endl;
}

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

typedef long long llint;
typedef long double ld;
typedef pair<int,int> P;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())


priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

int x[10],y[10];

double dist(int i,int j){
    int dx=x[i]-x[j];
    int dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}


void solve(){
    int n,m;
    cin >> n;
    for(int i=1;i<=n;i++)cin >> x[i] >> y[i];
    double sum=0;
    vector<int>v(n);
    for(int i=0;i<n;i++)v[i]=i+1;
    do{
        for(int i=0;i<n-1;i++) sum += dist(v[i], v[i+1]);
    }while(next_permutation(v.begin(),v.end()));
    int Factorial = 1;
    for(int i=2;i<=n;i++) Factorial *= i;
    cout << fixed << setprecision(10) << sum / Factorial << endl;
    return;
}

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





Measured memory_bytes: 4212
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	

using namespace std;

int main() {
	vector<pair<int, int>> time(5);
	for (int i = 0; i < 5; ++i) {
		int buf;
		cin >> buf;
		if (buf % 10 != 0) {
			time[i] = make_pair(10 - buf % 10, buf);
		}
		else {
			time[i] = make_pair(buf % 10, buf);
		}
	}
	sort(time.begin(), time.end());
	int sum = 0;
	for (int i = 0; i < 4; ++i) {
		if (time[i].first == 0) {
			sum += time[i].second;
		}
		else {
			sum += time[i].second + 10 - time[i].second % 10;
		}
	}
	cout << sum + time[4].second << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second

bool compare(const pair<int,int> &p1,const pair<int,int> &p2){
        if(p1.second < p2.second) return true;
        if(p1.second == p2.second) return p1.first < p2.first;
        return false;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;
	
	
	
	return 0;	
}


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

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

#define ll long long
#define vl vector<ll>
#define vll vector<vl>

const ll INF = 1e18;

int main() {
	int n;
	ll a[100010];
	cin >> n;
	rep(i, n) cin >> a[i];
	ll sum=0;
	rep(i, n) sum+=a[i];
	sum/=(ll)2;
	ll x[100010];
	x[0]=-sum;
	rep(i, n/2+1) x[0]+=a[2*i];
	rep(i, n-1) x[i+1]=a[i]-x[i];
	rep(i, n)
	{
		cout << 2*x[i];
		if(i==n-1) cout << endl;
		else cout << ' ';
	}
	return 0;
}

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

int main() {
    string S;
    int64_t Q;
    cin >> S >> Q;

    list<char> l;
    for (char c : S) {
        l.push_back(c);
    }

    bool rev = false;
    for (int64_t i = 0; i < Q; i++) {
        int64_t query;
        cin >> query;
        if (query == 1) {
            rev = !rev;
        } else {
            int64_t F;
            char C;
            cin >> F >> C;
            (F == 1 == rev ? l.push_back(C) : l.push_front(C));
        }
    }

    if (rev) {
        reverse(l.begin(), l.end());
    }

    for (char c : l) {
        cout << c;
    }
    cout << endl;
}

Measured memory_bytes: 9984
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<vector<int>>A(N, vector<int>(26, 0));
	string S;
	for (int i = 0; i < N; i++) {
		cin >> S;
		for (int j = 0; j < S.size(); j++) {
			A.at(i).at(S.at(j) - 97)++;
		}
	}
	vector<int>ans(26);
	for (int i = 0; i < 26; i++) {
		int MIN = 3000;
		for (int j = 0; j < N; j++) {
			if (A.at(j).at(i) < MIN) MIN = A.at(j).at(i);
		}
		ans.at(i) = MIN;
	}
	string T;
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < ans.at(i); j++) {
			T.push_back('a' + i);
		}
	}
	cout << T << endl;
}


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

int main(){
	// sengen
	int p,q,r;
	// nyuryoku
	cin >> p >> q >> r;
	// keisan
	cout << min(p+q,min(q+r,r+p)) << endl;
	// syutsuryoku
}

Measured memory_bytes: 3604
#include <stdio.h>
int SelectionSort(int *a,int b);

int main(int argc, const char * argv[]) {
    int a[100],n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    printf("%d\n",SelectionSort(&a,n));
}

int SelectionSort(int *a,int n){
    int i,j,tmp,minj,count=0;
    
    for(int i=0;i<n;i++){
        minj=i;
        for(j=i;j<n;j++){
            
            if(a[j]<a[minj]){
                minj=j;
            }
           
        }
        if(a[i]>a[minj]){
            tmp=a[minj];
            a[minj]=a[i];
            a[i]=tmp;
            count++;
        }
    }
    
    for(i=0;i<n-1;i++){
        printf("%d ",a[i]);
    }
    printf("%d\n",a[i]);
    return count;
}


Measured memory_bytes: 2072
#include<bits/stdc++.h>
#define int         int64_t
#define pb          push_back
#define endl        '\n'
#define pll         pair<int,int>
#define vll          vector<int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mi        map<int,int>
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
int n,i,j,k,l,sum=0,flag=0,t,a[200005],ans=0;
void solve(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if((i%2==0 && s[i]=='L')||(i%2==1 && s[i]=='R')){
            cout<<"No\n";
            return;
        }
    }
    cout<<"Yes\n";
}
signed main()
{
    ios
    int test=1;
    //cin>>test;
    while(test--){
        solve();
    }
    return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll a,b,c;
    cin >> a >> b >> c;
    
    if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
        cout << 0 << endl;
        return 0;
    }
    
    ll maxv = max({a,b,c});
    ll minv = min({a,b,c});
    ll midv = a + b + c - maxv - minv;
    
    cout << minv * midv << endl;
    
    
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,q,i,c=0,key;
    cin>>n;
    int S[n+1];
    for(i=0;i<n;i++) cin>>S[i];
    cin>>q;
    for(i=0;i<q;i++){
        cin>>key;
        S[n]=key;
        for(int j=0;j<n;j++){
            if(S[j]==key&&j!=n){ 
                c++;
                break;
            }      
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3100
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func update(cur, ans string) string {
	if len(cur) < 2 {
		return ans
	}
	if len(cur)-1 > len(ans) {
		return cur[:len(cur)-2]
	}
	return ans
}

func main() {
	s, t := readString(), readString()

	dp := make([][]int, len(s)+1)
	for i := range dp {
		dp[i] = make([]int, len(t)+1)
	}

	for i := range dp[1:] {
		for j := range dp[i][1:] {
			dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])
			if s[i] == t[j] {
				dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)
			}
		}
	}

	ans := []byte{}
	i, j := len(s), len(t)
	cur := dp[i][j]
	for i > 0 && j > 0 {
		// fmt.Println(i, j)
		if cur == dp[i-1][j] {
			i--
		} else if cur == dp[i][j-1] {
			j--
		} else {
			i--
			j--
			ans = append(ans, s[i])
		}
		cur = dp[i][j]
	}

	// for i := range dp {
	// 	fmt.Println(dp[i])
	// }

	trueAns := make([]byte, len(ans))
	for i := range ans {
		trueAns[i] = ans[len(ans)-1-i]
	}

	fmt.Println(string(trueAns))
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 75392
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
#define int long long
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
int a[MAX];

 main() {
    //fr;
    int n, x;
    cin >> n >> x;
    
    REP(i, n) cin >> a[i];
    
    int ans = 0;
    
    for(int i=1;i<n;i++){
        if(a[i]+a[i-1] > x){
            int diff = a[i]+a[i-1]-x;
            ans += diff;
            if(diff <= a[i]) a[i] -= diff;
            else{
                diff -= a[i];
                a[i] = 0;
                a[i-1] -= diff;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
#include <map>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define LL long long
using namespace std;
const int MAXN = 2e3+55;
string s[MAXN];
int main()
{
    int n,l;
    cin>>n>>l;
    for(int i = 0; i < n; ++i)
        cin>>s[i];
    sort(s,s+n);
    for(int i = 0; i < n;++i)
        cout<<s[i];
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll dp[2][1 << 21];
bool A[21][21];
int main() {
    init();
    ll N;
    cin >> N;
    rep(i, N) rep(j, N) cin >> A[i][j];
    dp[0][0] = 1;

    int now = 0, to = 1;
    // (i+1)人目のペアを探すときは、iビットだけ立った集合のみ見れば十分
    rep(i,N){
        rep(bit,1<<N){
            if (__builtin_popcount(bit) != i) continue;
            rep(j, N) if (!(bit & 1 << j) and A[i][j]) dp[to][bit | 1 << j] += dp[now][bit];
        }
        fill(dp[now], dp[now] + (1 << N), 0);
        rep(bit, 1 << N) if (__builtin_popcount(bit) == i + 1) dp[to][bit] %= MOD;
        now ^= 1, to ^= 1;
    }

    cout << dp[N%2][(1 << N) - 1] << endl;

}

Measured memory_bytes: 33024
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    int n, m, p, ac = 0, pe = 0;
    string s;
    cin >> n >> m;
    vector<int> a(n, 0);
    for (int i = 0; i < m; ++i) {
        cin >> p >> s;
        if (s == "AC") {
            if (a[p] != -1) {
                ac++;
                pe += a[p];
                a[p] = -1;
            }
        } else {
            if(a[p]!=-1) {
                a[p] += 1;
            }
        }
    }
    cout << ac << " " << pe << endl;
    return 0;
}


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

int main()
{
	int A,B,C,D;
	string str;
	cin >> A >> B >> C >> D;
	while (1)
	{
		C -= B;
		if (C <= 0)
		{
			cout << "Yes";
			return 0;
		}
		A -= D;
		if (A <= 0)
		{
			cout << "No";
			return 0;

		}
	}
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: usize,
        mut v: [i64;n],
    }
    v.sort();
    let mut ans:f64 = v[0] as f64;
    for i in 1..n {
        ans+=(v[i] as f64);
        ans/=2.0 as f64;
    }
    println!("{:.10}", ans);
}

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

int main() {
  int N, A, Ans, count;
  cin>>N;
  Ans=30;
  
  for (int i=0; i<N; i++){
    cin>>A;
    count=0;
    while (A%2==0){
      A/=2;
      count++;
    }
    if (Ans>count)
      Ans=count;
  }
  cout<<Ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AOJ000
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var a = int.Parse(str.Split(' ')[0]);
            var b = int.Parse(str.Split(' ')[1]);

            if (a < b)
            {
                Console.WriteLine("a < b");
            }
            else if (a > b)
            {
                Console.WriteLine("a > b");
            }
            else if(a == b)
            {
                Console.WriteLine("a == b");
            }
        }
    }
}

Measured memory_bytes: 19604
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func gcd(x, y int) int {
	if x < y {
		x, y = y, x
	}

	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

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

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	T := make([]int, N)
	for i := 0; i < N; i++ {
		T[i] = scanInt()
	}

	ans := T[0]
	for _, t := range T {
		ans = lcm(ans, t)
	}
	fmt.Println(ans)
}


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

using namespace std;

int main()
{
	int N, a;
	const int M = 100000;
	int ans;

	cin >> N;

	vector<int> table(M + 1, 0);

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

	ans = table[0] + table[1];
	for (int i = 1; i < M; i++)
	{
		int v = table[i - 1] + table[i] + table[i + 1];
		if (ans < v)
			ans = v;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640