akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>

int main(){

  // read problem
  long long int N, K, tmp;
  std::vector<long long int> a;
  
  scanf("%lld%lld", &N, &K);
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    a.push_back(tmp);
  }
  
  // solve problem
  std::vector<long long int> dp_table(K+1);
  
  for(long long int i = 0; i <= K; i++){
    for(long long int j = 0; j < N; j++){
      // if there is no more a_j to check
      if(i-a[j] < 0) break;
      // if it is possible to move to "lost" pattern
      if(dp_table[i-a[j]] == 0){
        dp_table[i] = 1;
        break;
      }
    }
  }
  
  if(dp_table[K] == 1){
    std::cout << "First" << std::endl;
  }
  else{
    std::cout << "Second" << std::endl;
  }
  
  return 0;
}



Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>

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

using namespace std;

int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d\n",max({a+b,a-b,a*b}));

	return 0;
}


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

using namespace std;

int main() {

	long long int N;
	cin >> N;

	long long int hh, nn, ww;

	hh = nn = ww = 0;

	for (long long int h = 1; h <= 3500; h++) {
		for (long long int n = h; n <= 3500; n++) {
			long long int shi = N * n * h;
			long long int bo = 4 * h * n - N * (h + n);
			if (bo != 0 && shi % bo == 0 && shi >= bo) {
				hh = h;
				nn = n;
				ww = shi / bo;
			}
		}
	}

	cout << hh << ' ' << nn << ' ' << ww << endl;

	return 0;
}

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

int main() {
	int N, P;
	cin >> N >> P;
	string S;
	cin >> S;

	long long ans = 0;
	if (P == 2) {
		for (int i = 0; i < N; i++) {
			if (stoi(S.substr(i, 1)) % 2 == 0) {
				ans += i + 1;
			}
		}

		cout << ans << endl;
	}
	else if (P == 5) {
		for (int i = 0; i < N; i++) {
			if (stoi(S.substr(i, 1)) % 5 == 0) {
				ans += i + 1;
			}
		}

		cout << ans << endl;
	}
	else {
		vector<int> U(P, 0);
		U[0]++;
		
		int t = 0;
		int x = 1;
		for (int i = N - 1; i >= 0; i--) {
			t = (t + stoi(S.substr(i, 1)) * x) % P;
			x = (x * 10) % P;
			ans += U[t];
			U[t]++;
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,d,f,c;
    cin>>a>>b;
    if(a==b)
        cout<<2*a;
    else if(a<b)
        cout<<2*b-1;
    else
        cout<<2*a-1;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final long l = sc.nextLong();
    final long r = sc.nextLong();
    //final List<Integer> list = new ArrayList<>();
    long min = 10000;
    long min2 = 10000;
    long hoge1 = 0;
    long hoge2 = 0;
    long ans = 0;

    long check = r - l + 1;
    if(check >= 2019){
        System.out.println(0);
    }else{
        for(long i = l ; i <= r ; i++){
            for(long j = i + 1; j <= r ; j++){
                hoge1 = i;
                hoge2 = j;
                hoge1 = hoge1 % 2019;
                hoge2 = hoge2 % 2019;

                ans = hoge1 * hoge2;

                while(ans >= 2019){
                    ans = ans % 2019;
                }
                if(min >= ans){
                    min = ans;
                }
            }
        }
        System.out.println(min);
    }
    


    



    





}
}

Measured memory_bytes: 35876
N, M = map(int, input().split())

AB = []

for i in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

AB.sort()

ans = 0
cnt = 0

for ab in AB:
    for b in range(ab[1]):
        ans += ab[0]
        cnt += 1
        if cnt==M:
            break
    if cnt==M:
        break

print(ans)

Measured memory_bytes: 58968
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = sS[0].Substring(0, 1)+ sS[1].Substring(0, 1) + sS[2].Substring(0, 1);

            //出力
            Console.WriteLine("{0}", sOut.ToUpper());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;
 
int main()
{
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        cout << ((s[i] == '1') ? '9' : '1');
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include  <set>
#include <cmath>
using namespace std;
typedef long long ll;


int main() {
	int a, b, c, d, e, f, g, h, i, j, n, m, l, sum = 0;
	int z[10], k[10], s[10][10], p[10];

	ll  aa, bb;

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

		for (j = 0; j < k[i]; j++) {
			cin >> s[i][j];
			s[i][j]--;
		}

	}
	for (i = 0; i < m; i++) cin >> p[i];



	for (i = 0; i < (1 << n); i++) {
		e = 0;
		do {

			h = 0;
			for (f = 0; f < k[e]; f++) {
				g = s[e][f];
				
				if (i & (1 << g))h++;
	
				
			}

			e++;
		} while (h % 2 == p[e - 1] && e < m);
		if (h % 2 == p[e - 1])sum = sum + 1;
	}



	cout << sum;


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
typedef struct{
  int A;
  char B;
  int No;
}cards;

cards card[100000];

int partition(int, int);
void quickSort(int, int);
int stateJudge(int);
main(){
  int k, r, mid, p = 0;
  int i;

  scanf("%d", &k );

  for(i = 0; i < k; i++){

    scanf("%s%d",&card[i].B, &card[i].A);

    card[i].No = i;
    
    // printf("%c %d", card[q].B, card[q].A);
    
  }
  
  
  r = k - 1;
  
  
  quickSort(p, r);
  
  if( stateJudge(r) == 1 )printf("Stable\n");
  else printf("Not stable\n");

  
  for(i = 0; i < k; i++){
    
    printf("%c %d\n", card[i].B, card[i].A);
  
  }
  
  return 0;
  
}


int partition(int p, int r){
  
  int i = 0 , j;
  cards ch;
  i = p;
  
  for(j = p; j < r; j++){
    // printf("%d\n",i);
    if(card[j].A <= card[r].A ){
      
      ch = card[i];
      card[i] = card[j];
    card[j] = ch;
    i++;
    
    } 
  }
  ch = card[r];
  card[r] = card[i];
  card[i] = ch;
  //  printf("%d\n",i);
  return i;
  
}


void quickSort(int p, int r){
  int q;
  if(p < r){q = partition(p, r);
    //    printf("%c %d\n", card[q].B, card[q].A);
    quickSort(p, q-1) ;
    
    quickSort(q+1, r);
    
  }
}

int stateJudge(int r){
  int i;
  for(i = 0; i < r; i++){
    
    if(card[i].A == card[i+1].A){
      
      if(card[i].No > card[i+1].No)
	{
	  return 0;
	}   
    }
  }
 return 1;
}

Measured memory_bytes: 1784
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
	Character objChar1;
	String str;
	char c;
	int i,num,sum;
	Scanner scan = new Scanner(System.in);
	while(true) {
	str=scan.next();
	if(str.equals("0"))
		break;
	sum=0;

	for (i=0;i<str.length();i++){
		c=str.charAt(i);
		num=Character.digit(c,10);
		sum+=num;
	}
	System.out.println(sum);
	}
}
}

Measured memory_bytes: 26244
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)



main :: IO ()
main = do
    [s,t] <- words <$> getLine
    putStrLn $ t++s



Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  if((abs(a - c) <= d) || (abs(a - b) <= d && abs(b - c) <= d)) cout << "Yes";
  else cout << "No";
  return 0;
}


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

#define endl "\n"
#define int long long

int32_t main() {
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  double tot = w * h;
  tot /= 2;
  cout << tot << " ";
  if (x * 2 == w && y * 2 == h)
    cout << 1;
  else
    cout << 0;
  return 0;
}


Measured memory_bytes: 256
/// awoooooo

# include <bits/stdc++.h>

# define sz(x) (int)((x).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

const int N = (int)2e5 + 5;
const int inf = (int)1e9 + 7;

ll f(ll a, ll b){
  if(a > b) swap(a, b);
  if(b % a == 0){
    return 2 * (b / a) * a - a;
  }
  return 2 * a * (b / a) + f(a, b % a);
}

int main(){
  ll n, x;
  scanf("%lld %lld", &n, &x);
  printf("%lld\n", f(n - x, x) + n);
  return 0;
}


Measured memory_bytes: 256
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  200007
const int M=1000006;
ll f[M],inv[M];
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
void compute(){
	f[0]=1;
	rep(i,1,M){
		f[i]=(1LL*i*f[i-1])%hell;
	}
	inv[0]=1;
	rep(i,1,M)
	{
		inv[i]=expo(i,hell-2,hell);
	}
}
ll C(ll n,ll r){
	return (1LL*((1LL*f[n]*inv[r])%hell)*inv[n-r])%hell;
}
ll add(ll a,ll b)
{
	return ((a%hell)+(b%hell))%hell;
}
ll sub(ll a,ll b)
{
	return ((a%hell)-(b%hell)+hell)%hell;
}
ll mul(ll a,ll b)
{
	return ((a%hell)*(b%hell))%hell;
}
ll n;
std::vector<ll> adj[N];
ll sz[N];
ll res[N];
ll vis[N];
void dfs(ll node)
{
	vis[node]=1;
	sz[node]=1;
	for(auto i:adj[node])
	{
		if(!vis[i])
			{
				dfs(i);
				sz[node]+=sz[i];
			}
	}
}

void dfs1(ll node,ll curr)
{
	vis[node]=1;
	res[node]=curr;	
	for(auto i:adj[node])
	{
		if(!vis[i])
			{
				ll fs=mul(curr,mul(sz[i],inv[n-sz[i]]));
				dfs1(i,fs);
			}
	}
}
int main()
{
	
	io
	compute();
	cin>>n;
	rep(i,0,n-1)
	{
		ll x,y;
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	dfs(1);
	res[1]=f[n];
	rep(i,1,n+1)
	{
		// cout<<sz[i]<<" ";
		// ll zz=expo(sz[i],hell-2,hell);
		res[1]=mul(res[1],inv[sz[i]]);
		// cout<<zz<<endl;
	}
	memset(vis,0,sizeof(vis));
	dfs1(1,res[1]);
	rep(i,1,n+1)
	{
		cout<<res[i]<<endl;
	}

	
}

Measured memory_bytes: 35056
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s, r="abcdefghijklmnopqrstuvwxyz";
    while(getline(cin,s))
    {
        int i,j,k,cnt[26]={0},c=0;
        sort(s.begin(),s.end());

        for(i=0; i<r.size(); i++)
        {
            for(j=0; j<s.size(); j++)
            {
                if(r[i]==s[j])
                {
                    cnt[i]=1;
                    break;
                }

            }
        }
        int l=0;
        for(k=0;k<26 ;k++)
        {
            if(cnt[k]==0){
                    l=1;
           cout<<r[k]<<endl;
           break;
            }

        }

        if(l!=1 ) cout<<"None"<<endl;

    }

    return 0;
}


Measured memory_bytes: 512
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	int n;
	vector<ld> a;
	cin >> n;
	for (int i = 0; i < n; i++) {
		ld t;
		cin >> t;
		a.push_back(t);
	}
	sort(a.begin(), a.end());
	ld cur = a[0];
	for (int i = 1; i < n; i++) {
		cur = (cur + a[i]) / 2;
	}
	cout << cur << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int w,h,n;cin >>w>>h>>n;
    vector<int>x(w,0);
    vector<int>y(h,0);
    for (int i = 0; i < n; ++i) {
        int a,b,c;cin >>a>>b>>c;
        if(c==1){
            for (int j = 0; j <a; ++j) {
                x[j]++;
            }
        }
        if(c==2){
            for (int j = a; j <w;++j) {
                x[j]++;
            }
        }
        if(c==3){
            for (int j = 0; j <b ; ++j) {
                y[j]++;
            }
        }
        if(c==4){
            for (int j =b; j <h; ++j) {
                y[j]++;
            }
        }
    }
    int ans=0;
//    for (int i = 0; i < w; ++i) {
//        cout <<x[i]<<" ";
//    }
//    cout <<endl;
    for (int i = 0; i < w; ++i) {
        for (int j = 0; j < h; ++j) {
            if(x[i]==0&&y[j]==0)ans++;
        }
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 3556
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

	for (long long i = 0; i < n; i++)
	{
		for (long long j = 0; j < s.size(); j++)
		{
			if (s[j] == 'Z')
				s[j] -= 25;
			else
				s[j]++;
		}
	}

	cout << s << endl;
}

Measured memory_bytes: 256
n = int(input())
b = list(map(int,input().split()))
balls = [0]*(n+1)
for i in range(n):
    balls[b[i]] += 1

su = 0
for i in range(n+1):
    su += (balls[i]*(balls[i]-1))//2


for i in range(n):
    bb = balls[b[i]]
    print(su - bb+1)




Measured memory_bytes: 26012
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int pn = 0;
	if (*ci == '-') {
		pn = 1;
		ci++;
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	if (pn) tmp = -tmp;
	return tmp;
}

ll A[200001];
void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	rep1(i, N) {
		A[i] = getint() + A[i - 1];
	}

	pakuri_sort(N + 1, A);

	ll kotae = 0;
	int kazu = 1;
	rep(i, N) {
		if (A[i + 1] != A[i]) kazu = 1;
		else kotae += kazu++;
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 6388
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
#include<cstring>
using namespace std;
template<class _T>inline void read(_T &_a)
{
    bool f=0; char _c=getchar(); _a=0;
    while(_c<'0'||_c>'9'){ if(_c=='-') f=1; _c=getchar(); }
    while(_c>='0'&&_c<='9'){ _a=(_a<<3)+(_a<<1)-'0'+_c; _c=getchar(); }
    if(f) _a=-_a;
}

const int MAXN=1000002;
unsigned long long a,b,n,ans,x;

int main()
{
    read(a); read(b); read(n);
    if(b-1<=n) ans=a*(b-1)/b;
    else ans=a*n/b;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll   long long int
#define T int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define PI 3.141592653589793238462643383
#define pb push_back
#define all(s) s.begin(),s.end()

int main (){
    fast;
    
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(b*d,max(a*c,max(a*d,b*c)))<<endl;
    
}

Measured memory_bytes: 3648
unittest
{
	assert( [ "4", "1 2 3 4" ].parse.expand.solve == "4 2 1 3" );
	assert( [ "3", "1 2 3" ].parse.expand.solve == "3 1 2" );
	assert( [ "1", "1000000000" ].parse.expand.solve == "1000000000" );
	assert( [ "6", "0 6 7 6 7 0" ].parse.expand.solve == "0 6 6 0 7 7" );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto ts = new long[ as.length ];
	auto ti = as.length / 2;
	
	foreach( ai, a; as )
	{
		ts[ ti ] = a;
		
		// 次の要素を入れる場所を計算
		if( as.length % 2 == 0 )
		{
			// Aの長さが偶数のときは左、右の順で追加していく
			if( ai % 2 == 0 ) ti -= ai + 1;
			else              ti += ai + 1;
		}
		else
		{
			// Aの長さが奇数のときは右、左の順で追加していく
			if( ai % 2 == 0 ) ti += ai + 1;
			else              ti -= ai + 1;
		}
	}
	
	return ts.to!( string[] ).join( " " );
}


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

//DataStructure/UnionFind
struct UnionFind{
	vector<int> rnk,par;

	UnionFind(int sz) : rnk(sz,0),par(sz){
		for(int i = 0;i < sz;i++) par[i] = i;
	}

	int find(int x){
		if(par[x] == x) return x;
		return par[x] = find(par[x]);
	}

	void unite(int x,int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rnk[x] < rnk[y]) swap(x,y);
		par[y] = x;
		if(rnk[x] == rnk[y]) rnk[x]++;
	}
	
	bool same(int x,int y){
		return (find(x) == find(y));
	}
};

//Graph/Template
template<class T>
struct Edge{
	int from,to;
	T cost;
	Edge(int to,T cost) : to(to),cost(cost){}
	Edge(int from,int to,T cost) : from(from),to(to),cost(cost){}
};

template<class T>
using WeightedGraph = vector<vector<Edge<T>>>;
using Graph = vector<vector<int>>;
template<class T>
using Matrix = vector<vector<T>>;

//Graph/Kruskal
template <class T>
T kruskal(int n,vector<Edge<T>> &edges){
	T ret = 0;
	sort(edges.begin(),edges.end(),[](const Edge<T> &e1,const Edge<T> &e2){
		return e1.cost < e2.cost;
	});
	UnionFind uf(n);
	for(const Edge<T> &e : edges){
		if(!uf.same(e.from,e.to)){
			ret += e.cost;
			uf.unite(e.from,e.to);
		}
	}
	return ret;
}

signed main(){
	int n,m;
	scanf("%d %d",&n,&m);
	vector<Edge<int>> edges;
	for(int i = 0;i < m;i++){
		int s,t,w;
		scanf("%d %d %d",&s,&t,&w);
		edges.emplace_back(s,t,w);
	}
	printf("%d\n",kruskal(n,edges));
}



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

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

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

using namespace std;

int main(){
  int d;
  string s;
  cin >> d;
  if(d==25){
    s="Christmas";
  }
  else if(d==24){
    s="Christmas Eve";
  }
  else if(d==23){
    s="Christmas Eve Eve";
  }
  else{
    s="Christmas Eve Eve Eve";
  }
  cout << s << endl;
}


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

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;
 	
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 	
 	ll a,b,n;

 	scanf("%lld %lld %lld",&n,&a,&b);

 	printf("%lld\n",(n/(a+b)) * a + min(n%(a+b),a) );
 	
}		


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>

#define REP(i, n) for (int i=0;i<(n);i++)
#define FOR(i, a, b) for (int i=(a);i<(b);i++)

using namespace std;

int N;
int A[100002];

int main()
{
    scanf("%d", &N);
    A[0] = 0;
    A[N+1] = 0;
    FOR(i, 1, N+1)
        scanf(" %d", &A[i]);

    int all = 0;
    REP(i, N+1)
        all += abs(A[i+1]-A[i]);

    FOR(i, 1, N+1) {
        if(A[i]>=A[i-1] && A[i]<=A[i+1])
            printf("%d\n", all);
        else {
            int tmp;
            tmp = abs(A[i]-A[i-1]) + abs(A[i+1]-A[i]);
            tmp = tmp - abs(A[i+1]-A[i-1]);
            printf("%d\n", all-tmp);
        }
    }
    return 0;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];

    int ans = 0;
    REP(i, N) {
        ans += a[i] - 1;
    }
    print(ans);
}

signed main() {
    solve();
}


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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

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

    int n;
    cin >> n;
    vector<ll> vec(n);
    rep (i, n)
        cin >> vec[i];

    ll cnt = 0;
    rep (i, n) {
        while (vec[i] % 2 == 0) {
            vec[i] /= 2;
            cnt++;
        }
    }
    print(cnt);

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    vector<ll> z(n);
    for (int i = 0; i < n; i++) {
        cin >> z[i];
        z[i] -= i;
    }
    sort(z.begin(), z.end());
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += abs(z[i] - z[n / 2]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4772
def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))
    # 式 f の末尾に "+" を追加するかしないかして次の数字を追加
    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])
s = input()
n = len(s)
print(dfs(0, s[0]))  

Measured memory_bytes: 3060
n = int(input())
a = list(map(int,input().split()))
b = [None]*n
j = 0
x = a[::2]
y = a[1::2]
if n % 2 == 1:
    x.reverse()
    x = x+y
    print(*x)
else:
    y.reverse()
    y = y + x
    print(*y)

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

int main(void)
{
    int N, M, C, B[21], A[21][21];
    cin >> N >> M >> C;
    for (int i=0; i<M; ++i) {
        cin >> B[i];
    }
    for (int i=0; i<N; ++i) {
        for (int j=0; j<M; ++j) {
            cin >> A[i][j];
        }
    }
    int correct_code = 0;
    for (int i=0; i<N; ++i) {
        int result = 0;
        for (int j=0; j<M; ++j) {
             result += A[i][j] * B[j];
        }
        if ((result + C) > 0) {
            correct_code++;
        }
    }
    cout << correct_code << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        long sum = 0;
        for (int i = 1; i <= k; i++) {
            for (int j = 1; j <= k; j++) {
                for (int l = 1; l <= k; l++) {
                    sum += gcd(i, gcd(j, l));
                }
            }
        }
        System.out.println(sum);
    }

}


Measured memory_bytes: 35816
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;
int const MAXN=510;
long long int cnt=0, k, sum=0LL, n, v[MAXN], resto[MAXN];
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>v[i];
		sum+=v[i];
	}
	vector<long long int> f;
	long long int res=1;
	for(long long int i=1;i*i<=sum;i++)
		if(sum%i==0)
			f.push_back(i);
	int dim=f.size();
	for(int i=dim-1;i>=0;i--)
		f.push_back(sum/f[i]);
	
	for(auto val:f){
		long long int cnt=0;
		for(int i=0;i<n;i++)
			resto[i]=v[i]%val;
		sort(resto,resto+n);
		deque<int> d;
		for(int i=0;i<n;i++)
			d.push_back(resto[i]);
		while(!d.empty()){
			if(d.front()+d.back()==val){
				cnt+=d.front();
				d.pop_front();
				d.pop_back();
			}
			else if(d.front()+d.back()>val){
				cnt+=val-d.back();
				d[0]-=val-d.back();
				d.pop_back();
			}
			else{
				cnt+=d.front();
				d[d.size()-1]+=d.front();
				d.pop_front();
			}
		}
		if(cnt<=k)	
			res=val;
	}
	cout<<res;
}

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

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11


int main()
{
    string s; cin >> s;
    int n = s.size();
    bool f[n];
    rep(i,n){
        char c = s[i];
        if(c == 'A' || c == 'C' || c == 'G' || c == 'T') f[i] = true;
        else f[i] = false;
    }
    int ans = 0;
    int tmp = 0;
    rep(i,n){
        if(f[i]){
            tmp++;
            ans = max(ans,tmp);
        }else{
            tmp = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    for(;;) {
        int m, n;
        bool check[7368800];
        fill(check, check + 7368800, false);
        cin >> m >> n;
        if(m == 0 && n == 0) {
            break;
        }
        int cnt = 0;
            while(true) {
                if(cnt == n + 1) {
                cout << m - 1 << endl;
                break;
                }
                if(check[m]) {
                    m++;
                    continue;
                }
                if(check[m] == false) {
                    cnt ++;
                    for(int j = m ; j <= 7368800 ; j += m) {
                        check[j] = true;
                    }
                    m ++;
                    continue;
                } 
            }
            
        }
    
	return 0;
}


Measured memory_bytes: 10300
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.io.IOException;
import java.util.Deque;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.ArrayDeque;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CPushpush solver = new CPushpush();
        solver.solve(1, in, out);
        out.close();
    }

    static class CPushpush {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            Deque<Integer> deque = new ArrayDeque<>();

            for (int i = 0; i < n; i++) {
                int a = in.nextInt();
                if (i % 2 == 0) {
                    deque.addLast(a);
                } else {
                    deque.addFirst(a);
                }
            }

            StringBuilder sb = new StringBuilder();
            if (n % 2 == 1) {
                while (!deque.isEmpty()) {
                    sb.append(deque.pollLast() + " ");
                }
            } else {
                while (!deque.isEmpty()) {
                    sb.append(deque.pollFirst() + " ");
                }
            }
            sb.deleteCharAt(sb.length() - 1);

            out.println(sb);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 72408
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 +7;

int main() {


    
    string s;
    cin >> s;
    
    ll ret = 0;
    for (int i = 0; i < s.size(); ++i)
    {
        ll len = 0;
        for (int j = i; j < s.size(); ++j)
        {
            if (s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T')
            {
                len++;
            }
            else
            {
                break;
            }
        }
        ret = max(ret, len);
    }
    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 256
def submit():
    n = int(input())
    d = [1 for _ in range(n + 1)]
    d[0] = 0

    # エラトステネスの篩風
    for i in range(2, n + 1):
        coef = 1
        while i * coef <= n:
            d[i * coef] += 1
            coef += 1

    ans = 0
    for k in range(1, n + 1):
        ans += k * d[k]

    print(ans)


if __name__ == "__main__":
    submit()
    

Measured memory_bytes: 224556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const int INF = INT_MAX / 2;

int main(){
    int N; cin >> N;
    int ans; cin >> ans;
    for (int i = 1; i < N; i++)
    {
        int a; cin >> a;
        ans = __gcd(ans, a);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
# from web
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(int(n))
  return table

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

    divisors.sort()
    return divisors

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    b = sorted(make_divisors(a[0]), reverse = True)
    res = b[0]
    for i in b:
        c = [_ % i != 0 for _ in a]
        if sum(c) <= 1:
            res = i
            break
    a2 = a[1:]
    a2.sort()
    b2 = sorted(make_divisors(a2[0]), reverse = True)
    res2 = b2[0]
    for i in b2:
        c = [_ % i != 0 for _ in a]
        if sum(c) <= 1:
            res2 = i
            break
    print(max(res,res2))

Measured memory_bytes: 14076
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;

void main() {
	auto ip = readln.split.to!(int[]), A = ip[0], B = ip[1];
	auto S = readln.chomp;
	if(S[A] != '-') {
		writeln("No");
		return;
	}
	auto regex_a = regex(format("^[0-9]{%d}", A));
	if(matchFirst(S, regex_a).empty) {
		writeln("No");
		return;
	}
	auto regex_b = regex(format("[0-9]{%d}$", B));
	if(matchFirst(S, regex_b).empty) {
		writeln("No");
		return;
	}
	writeln("Yes");
}


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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

int a, b;

int main()
{
    cin >> a >> b;
    cout << (a + b + 1) / 2;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<ctime>
#include<cctype>


using namespace std;

string S;
int sums,sumt;

int main()
{
    cin>>S;
    for(int i=0;i<S.size();i++)
    {
        if(S[i] == 'S') sums++;
        if((sums)&&(S[i]=='T'))
        {
            sums--;
            sumt+=2;        }
    }
    cout<<S.size()-sumt<<"\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, A, B);
  VAR(string, S);
  rep(i, 0, A) {
    if (S[i] < '0' || S[i] > '9') {
      print("No");
      return;
    }
  }
  if (S[A] != '-') {
    print("No");
    return;
  }
  rep(i, A + 1, A + 1 + B) {
    if (S[i] < '0' || S[i] > '9') {
      print("No");
      return;
    }
  }
  print("Yes");
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int a,b;
        a=scan.nextInt();
        b=scan.nextInt();
        if(a<=9&&b<=9){
            System.out.println(a*b);
        }
        else System.out.println(-1);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#define MAX 100000

using namespace std;

int parent(int i) { return i / 2; }
int left(int i) { return i * 2; }
int right(int i) { return i * 2 + 1; }

int main() {
    int H, A[MAX + 1];

    cin >> H;
    for (int i = 1; i <= H; i++) {
        cin >> A[i];
    }

    /*for (int i = 1; i <= H; i++) {
        cout << "node" << i << ": key = " << A[i] << ", ";
        if (parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
        if (left(i) <= H) cout <<  "left key = " << A[left(i)] << ", ";
        if (right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
    */
    for (int i=1; i<=H; i++)
	{
		cout << "node " << i << ": key = " << A[i] << ", ";
		if (parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
		if (left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
		if (right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
		cout << endl;
	}
	
    return 0;
}


Measured memory_bytes: 3056
import fractions
A, B = map(int, input().split())
c = fractions.gcd(A,B)

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 len(arr)+1

if c == 1:
    print(1)
else:
    print(factorization(c))


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

int main(){
	string s,t;
	cin>>s>>t;
	int n=s.size();
	int m=t.size();
	vector<vector<int> > dp(n+1,vector<int>(m+1));
	vector<vector<pair<int,int> > > par(n+1,vector<pair<int,int> >(m+1,pair<int,int>(0,0)));
	string ans;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i-1]==t[j-1]){
				par[i][j]=pair<int,int>(i-1,j-1);
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else if(dp[i][j-1]>dp[i-1][j]){
				dp[i][j]=dp[i][j-1];
				par[i][j]=pair<int,int>(i,j-1);
			}
			else{
				dp[i][j]=dp[i-1][j];
				par[i][j]=pair<int,int>(i-1,j);
			}
		}
	}
	int x=n;
	int y=m;
	while(x!=0||y!=0){
		if(s[x-1]==t[y-1])
			ans.push_back(s[x-1]);
		int tempx,tempy;
		tempx=par[x][y].first;
		tempy=par[x][y].second;
		x=tempx;
		y=tempy;
	}
	reverse(ans.begin(), ans.end());
	cout<<ans<<endl;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll H, W, N; cin >> H >> W >> N;
  
  //main
  ll M = max(H,W);
  cout << (N+M-1)/M << endl;
  
  // output

  return 0;
}

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

int64_t gcd(int64_t a,int64_t b){
    if(a < b)
    {
        int64_t temp = a;
        a = b ;
        b = temp;
    }
    int64_t copya = a;
    int64_t copyb = b;
    int64_t r = a%b ;
    while (r != 0)
    {
        a = b ;
        b = r ;
        r = a%b ;
    }
    return b ;
    
}


int main(){
    int n ;
    cin >> n ;
    int64_t ans = 0 ;
    for (size_t a = 1; a < n+1; a++)
    {
        for (size_t b = 1; b < n+1; b++)
        {
            for (size_t c = 1; c < n+1; c++)
            {
                ans += gcd(gcd(a,b),c) ;
            }
            
        }
        
    }
    
    cout << ans << endl ;
}

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

using namespace std;

int num[105] ;
void bubbleSort(int n )
{
    int ans= 0 ;
    for(int i=0 ;i<n;i++){
        for(int j = n-1;j>i;j--){
            if(num[j-1]>num[j]){
                swap(num[j-1],num[j]) ;
                ans++;
            }
        }
    }
    printf("%d",num[0]) ;
    for(int i=1;i<n;i++){
        printf(" %d",num[i]) ;
    }
    printf("\n") ;
    printf("%d\n",ans);
}
int main()
{
    int n ;
    while(~scanf("%d",&n)){
        for(int i = 0 ;i<n ;i++){
            scanf("%d",&num[i]) ;
        }
        bubbleSort(n);
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

double getTime() { 
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int main() {
  int n, m; read(n, m);
  int k; read(k);
  print((k + max(n, m) - 1) / max(n, m));
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int N, A, B, mult;
    scanf("%d%d%d", &N, &A, &B);

    mult = N*A;

    if(mult <= B) {
        printf("%d\n", mult);
    }
    else {
        printf("%d\n", B);
    }

    return 0;
}


Measured memory_bytes: 128
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <utility>
#include <set>
#include <unordered_set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>
#include <functional>

using namespace std;

typedef long long ll;
typedef pair<int,int> i2;
typedef pair<ll,ll> ll2;

int main()
{
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    int a, b, c, x, y;
    
    cin >> a >> b >> c >> x >> y;
    c *= 2;
    
    int ret = 0;
    
    if (c <= a+b)
    {
        int use = min(x,y);
        ret += use*c;
        x -= use;
        y -= use;
    }
    ret += x*min(a,c);
    ret += y*min(b,c);
    
    cout << ret << '\n';
    
    return 0;
    
}




Measured memory_bytes: 256