akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) throws IOException {
        OutputStream outputStream = System.out;
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(1, in, out);
        out.close();
    }


    static class Solver {

        public void solve(int testNumber, FastReader in, PrintWriter out) throws IOException {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] arr = new int[n];
            boolean[] p = new boolean[n];
            for (int i = 0; i < m; i++) {
                int index = in.nextInt() - 1;
                int val = in.nextInt();
                if (!p[index] || arr[index] == val) {
                    p[index] = true;
                    arr[index] = val;
                } else {
                    out.print(-1);
                    return;
                }
            }
            if (arr.length == 1) {
                out.print(arr[0]);
                return;
            }
            if (!p[0]) {
                arr[0] = 1;
            }
            if (arr[0] == 0) {
                out.print(-1);
                return;
            }
            for (int i = 0; i < n; i++) {
                out.print(arr[i]);
            }

        }

    }


    static class FastReader implements AutoCloseable {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        @Override
        public void close() throws Exception {

        }
    }
}

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


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(10)<<fixed;
	
	int n,k;
	cin>>n>>k;
	if(n>=10)
		cout<<k<<endl;
	else
		cout<<k+100*(10-n)<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1e6+5
#define quick_pow_mod 1e9+7
#define PII pair<int,int>
const int factor_N = 1e7 + 5;
const int tree_arr_N = 1e6 + 5;
using namespace std;
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
	return x * f;
}
int n, ans, cntw;
string s;
int main() {
	n = read();
	cin >> s;
	for (auto ch : s) if (ch == 'W') cntw++;
	ans = cntw;
	for (int i = n - 1; i >= n - cntw; --i)
		if (s[i] == 'W') ans--;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

set<int> s;

int main(){
	int n; scanf("%d", &n);
	REP(i, n){
		int a; scanf("%d", &a);
		s.emplace(a);
	}
	if(s.size() == n)
		printf("YES\n");
	else
		printf("NO\n");
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define xx first
#define yy second
 
#define pii pair <int, int >
#define pll pair < ll, ll >
#define xx first
#define yy second
#define vi vector < int >
#define vl vector < ll >
#define vp vector < pii >
 
#define inf  100000000
 
#define f(i, c, n) for(int i = c; i < n; i++)
#define fe(i, c, n) for(int i = c; i <= n; i++)
#define fr(i, n, c) for(int i = n - 1; i >= c; i--)
 
#define be(a) a.begin(), a.end()
#define vsort(a) sort(a.begin(), a.end())
#define mem(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define srti(a, n) sort(a, a + n)
#define srtd(a, n) sort(a, a + n, greater<int>())
#define LB(a, x) (lower_bound(vbe(a), x) - a.begin())
#define UB(a, x) (upper_bound(vbe(a), x) - a.begin())
#define S " "
#define N "\n"

//cout << "Case " << ++cs << ": " <<
#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FILE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);


void solve() {
	int x, a, b;
	cin >> x >> a >> b;
	x -= a;
	cout << x % b << N;
}

int main() {
    // FILE;
    fast;
    // int t; cin >> t; while(t--)
    solve();
}

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

x = 0
tmp = 0
for i in range(N):
    tmp += A[i]
    if i & 1 == 0:
        if tmp < 1:
            x += 1-tmp
            tmp = 1
    else:
        if tmp > -1:
            x += 1+tmp
            tmp = -1
y = 0
tmp = 0
for i in range(N):
    tmp += A[i]
    if i & 1:
        if tmp < 1:
            y += 1-tmp
            tmp = 1
    else:
        if tmp > -1:
            y += 1+tmp
            tmp = -1
print(min(x,y))


Measured memory_bytes: 14468
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[200010];
ll kai[200010];
ll m;
ll beki(ll n,ll k){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=m;
    }
    now*=now;
    now%=m;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n){
  return beki(n,mod-2);
}
void nckinit(ll n){
  kai[0]=1;
  kai[1]=1;
  for(int i=2;i<=n;i++){
    kai[i]=kai[i-1]*i;
    kai[i]%=mod;
  }
  gya[n]=gyaku(kai[n]);
  for(int i=n-1;i>=1;i--){
    gya[i]=gya[i+1]*(i+1);
    gya[i]%=mod;
  }
  gya[0]=1;
}    
ll nck(ll n,ll k){
  if(k<0)return 0;
  if(k==0||n==k)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=mod;
  ret*=gya[k];
  ret%=mod;
  return ret;
}
ll npk(ll n,ll k){
  if(k<0)return 0;
  if(k==0)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=mod;
  return ret;
}
random_device rnd;
mt19937 mt(rnd());
uniform_real_distribution<double> ra(1,6);
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;cin>>n>>m;
  string s[n];
  rep(i,0,n)cin>>s[i];
  vector<int> v[m+1];
  rep(i,0,n-1){
    rep(j,0,m-1){
      int cnt=0;
      if(s[i][j]=='#')cnt++;
      if(s[i+1][j]=='#')cnt++;
      if(s[i][j+1]=='#')cnt++;
      if(s[i+1][j+1]=='#')cnt++;
      if(cnt%2==1)v[j+1].push_back(i+1);
    }
  }
  rep(i,0,m+1){
    v[i].push_back(n);
    sort(v[i].begin(),v[i].end());
  }
  int now[m+1];
  fill(now,now+m+1,0);
  int ans=0;
  rep(i,0,n){
    rep(j,0,m+1){
      if(v[j][now[j]]==i)now[j]++;
      //cout<<v[j][now[j]]<<" ";
    }
    
    deque<pii> dq;
    dq.push_back({0,0});
    rep(j,1,m+1){
      int f=v[j][now[j]];
      f-=i;
      while(dq.back().first>=f){
        int y=dq.size();
        ans=max(ans,((int)j-dq[y-2].second)*dq[y-1].first);
        dq.pop_back();
      }
      ans=max(ans,((int)j-dq.back().second)*f);
      dq.push_back({f,j});
    }
    while(dq.size()>1){
      int y=dq.size();
      ans=max(ans,(m-dq[y-2].second)*dq[y-1].first);
      dq.pop_back();
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 15872
N = int(input())
A = [int(i) for i in input().split()]

print(*A)
for i in range(1, N):
    v = A[i]
    j = i - 1
    
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    
    A[j+1] = v
    print(*A)



Measured memory_bytes: 5976
//AnkitCode99 here....
#include<bits/stdc++.h>
#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)
using namespace std;

const ll sz=100005;
const ll szz=1000006;

int main()
{
    fast;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("op.txt","w",stdout);
    // #endif

    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;

}//Goodbye...

Measured memory_bytes: 256
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

a,b = farr()
a,b = int(a),int(b*100+ .5)
ans = (a*b) //100
print(ans)


Measured memory_bytes: 37688
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
for i in range(N):
  ans += B[ A[i]-1 ]
  if i > 0 and A[i] == A[i-1] + 1:
    ans += C[ A[i-1] - 1 ]
print(ans)


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

int main() {
	string p;
	stack<int> s;
	while (cin >> p) {
		//if (p == "a")break;
		if (p == "+") {
			int a = s.top(); s.pop();
			int b = s.top(); s.pop();
			s.push(a + b);
		}
		else if (p == "-") {
			int a = s.top(); s.pop();
			int b = s.top(); s.pop();
			s.push(b - a);
		}
		else if (p == "*") {
			int a = s.top(); s.pop();
			int b = s.top(); s.pop();
			s.push(a * b);
		}
		else {
			int a = stoi(p);
			s.push(a);
		}
	} 
	cout << s.top() << endl;
}



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


int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a==5&&b==7&&c==5)||(a==5&&b==5&&c==7)||(a==7&&b==5&&c==5))  cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


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

// nCk
ll comb(ll n, ll k) {
  ll ret = 1;
  ll x = min(n-k, k);
  for(ll cnt = 1; cnt <= x; cnt++) {
    ret *= (n-x+cnt);
    ret /= cnt;
  }
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  ll n, p;
  cin >> n >> p;
  
  ll odd = 0;
  ll even = 0;
  
  vector<ll> a(n);
  rep(i, 0, n) {
    cin >> a[i];
    if(a[i]%2==0) even++;
    else odd++;
  }
  
  ll ans = 0;
  if(p%2==0) {
    for(ll i=0; i<=odd; i+=2) ans += comb(odd, i);
    ans *= (ll)pow(2, even);
  }
  else {
    for(ll i=1; i<=odd; i+=2) ans += comb(odd, i);
    ans *= (ll)pow(2, even);
  }
  
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>
using namespace std;
#define int long long
#define veb vector<bool>
#define vveb vector<veb>
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
void sor(vel &v) { sort(v.begin(), v.end()); }
void rev(vel &v) { reverse(v.begin(), v.end()); }
int zero(void) { return 0; }
int gcd(int a, int b) {
	if (b > a) { swap(a, b); }
	if (b == 0) { return a; }
	int r = a % b;
	return gcd(b, r);
}
signed main() {
	int h, w;
	cin >> h >> w;
	vvel a(h, vel(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) { cin >> a[i][j]; }
	}
	int n = 0;
	vel x(h*w);
	vel y = x; vel xp = x; vel yp = y;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w - 1; j++) {
			if (a[i][j] % 2 != 0) {
				y[n] = i;
				x[n] = j;
				yp[n] = i;
				xp[n] = j + 1;
				n++;
				a[i][j]--;
				a[i][j + 1]++;
			}
		}
	}
	for (int i = 0; i < h-1; i++) {
		if (a[i][w - 1] % 2 != 0) {
			y[n] = i;
			x[n] = w - 1;
			yp[n] = i + 1;
			xp[n] = w - 1;
			n++;
			a[i][w - 1]--;
			a[i + 1][w - 1]++;
		}
	}
	cout << n << endl;
	for (int i = 0; i < n; i++) {
		cout << y[i]+1 << " " << x[i]+1 << " " << yp[i]+1 << " " << xp[i]+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 11904
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
int main()
{
	sync;
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<min(b/a,c);
}
	

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	try {
    		final int N = sc.nextInt();
    		final int R = sc.nextInt();

    		if (N >= 10) {
    			System.out.println(R);
    		} else {
    			System.out.println(R+100*(10-N));
    		}

    	} finally {
    		sc.close();
    	}
    }
}


Measured memory_bytes: 21844
S = input()

N = len(S)
#ODD = 0
#EVEN = 1
cnt = [[0, 0], [0, 0]]
for i in range(N):
    cnt[int(S[i])][(i % 2)] += 1
ans = 0
cnt0o1e = cnt[0][0] + cnt[1][1]
cnt0e1o = cnt[0][1] + cnt[1][0]

print(min(cnt0o1e, cnt0e1o))


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		long h = kb.nextLong();
		long count = 0;
		long number = 0;
		while (h != 0) {
			if (h == 1) {
				h = 0;
				count += (long) Math.pow(2, number);
				number += 1;
			} else {
				h = (long) Math.floor(h/2);
				count += (long) Math.pow(2, number);
				number += 1;
			}
		}
		System.out.println(count);
		kb.close();
	}

}


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

using namespace std;

#define ff first
#define ss second
#define pb push_back

using ll = long long;
using ii = pair<int, int>;

const int oo = 1e9;
const int N = 1e5 + 5;

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	int ans = 0;
	for(int i = 0; i < n; i++){
		int h;
		scanf("%d", &h);
		ans += h >= k;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a[5]={1,5,10,25},b,i,c=0;
scanf("%d\n",&b);
for(i=3;i>=0;i--){
c=c+b/a[i];
b=b%a[i];
}
printf("%d\n",c);
return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int N,M;
int S,T;
vector<int> g[100010];

int dist[100010][3];

int dijkstra(){
  for(int i=0;i<=N;i++) for(int j=0;j<3;j++) dist[i][j]=MOD;
  queue<pair<int,int>> Q;
  Q.push(mkp(S,0));
  dist[S][0]=0;
  while(!Q.empty()){
    int tp,rest;
    tie(tp,rest)=Q.front();
    Q.pop();

    for(int i=0;i<g[tp].size();i++){
      int nex=g[tp][i];
      int neco=(rest+1)%3;
      if(dist[nex][neco]>dist[tp][rest]+1){
        dist[nex][neco]=dist[tp][rest]+1;
        Q.push(mkp(nex,neco));
      }
    }
  }

  if(dist[T][0]==MOD) return -1;
  else return dist[T][0]/3;
}

int main(){
  cin>>N>>M;
  for(int i=0;i<M;i++){
    int u,v;
    cin>>u>>v;
    g[u].push_back(v);
  }
  cin>>S>>T;

  cout<<dijkstra()<<endl;
  return 0;
}


Measured memory_bytes: 6912
S = gets.chomp
T = gets.chomp

S_CODES = S.codepoints
T_CODES = T.codepoints

S_SIZE = S.size
T_SIZE = T.size
dp = Array.new(S_SIZE + 1) { Array.new(T_SIZE + 1, 0) }

S_SIZE.times do |s|
  dp_cur = dp[s]
  dp_next = dp[s+1]
  T_SIZE.times do |t|
    if S_CODES[s] == T_CODES[t]
      dp_next[t+1] = dp_cur[t] + 1
    else
      dp_next[t+1] = dp_cur[t+1]
      dp_next[t+1] = dp_next[t] if dp_next[t+1] < dp_next[t]
    end
  end
end

lcs = ''
s = S_SIZE
t = T_SIZE
while s > 0 && t > 0
  if dp[s][t] == dp[s-1][t]
    s -= 1
  elsif dp[s][t] == dp[s][t-1]
    t -= 1
  else
    lcs << S[s-1]
    s -= 1
    t -= 1
  end
end

puts lcs.reverse

Measured memory_bytes: 74236
from networkx import *
 
n,m = map(int, input().split())
G = Graph()
 
for i in range(m):
    a,b = map(int, input().split())
    G.add_edges_from([(a, b)])
 
m3 = list(connected_components(G))

count = 0
 
if len(max(connected_components(G), key=len)) == n:
    print(0)
    exit()
else:
    for i in m3:
        count += len(i)
 
sub = n - count
 
print((len(m3)-1)+sub)
 

Measured memory_bytes: 149312
tot = int(input())
while(True) :
    c = input()
    
    if c == '+' :
        tot += int(input())
    elif c == '-' :
        tot -= int(input())
    elif c == '*' :
        tot *= int(input())
    elif c == '/' :
        tot //= int(input())
    else :
        print(tot)
        break
    


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

int x[16], y[16];

int memo[1 << 16];

int m;

int calc(int s) {
	if (s == 0) return 0;
	if (__builtin_popcount(s) <= 3) return 0;
	if (memo[s] != -1) return memo[s];
	int res = 0;
	for (int i = 0; i < m; i++) if (s & (1 << i)) {
		s -= 1 << i;
		for (int j = i + 1; j < m; j++) if (s & (1 << j)) {
			s -= 1 << j;
			int cnt = 1;
			int tmp = s;
			for (int k = 0; k < m; k++) if (s & (1 << k)) {
				for (int l = k + 1; l < m; l++) if (s & (1 << l)) {
					if ((x[i] - x[j]) * (y[k] - y[l]) == (x[k] - x[l]) * (y[i] - y[j])) {
						++cnt;
						tmp -= 1 << k;
						tmp -= 1 << l;
					}
				}
			}
			res = max(res, cnt * (cnt - 1) / 2 + calc(tmp));
			s += 1 << j;
		}
		s += 1 << i;
	}
	return memo[s] = res;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> x[i] >> y[i];
	}
	for (int i = 0; i < (1 << m); i++) memo[i] = -1;
	cout << calc((1 << m) - 1) << endl;
	return 0;
}



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

int main(){
  int X, N;
  cin >> X >> N;
  set<int> p;
  int a;
  rep(i, N) {
    cin >> a;
    p.insert(a);
   }
  
  rep(i, 100){
   if(!p.count(X-i)){
    cout << X-i << endl;
     return 0;
   }else if(!p.count(X+i)){
    cout << X+i << endl; 
     return 0;
   }
  }         
}


Measured memory_bytes: 3544
import collections

n = int(input())
v = list(map(int, input().split()))
odd = []
even = []
for i in range(0, n - 1, 2):
	odd.append(v[i])
	even.append(v[i + 1])
N = n // 2
co = collections.Counter(odd)
ce = collections.Counter(even)
omost = co.most_common(2)
emost = ce.most_common(2)
if len(omost) == 1 and len(emost) == 1:
	if omost[0][0] != emost[0][0]:
		print(0)
	else:
		print(N)
elif len(omost) == 1:
	print(N - emost[0][1])
elif len(emost) == 1:
	print(N - omost[0][1])
else:
	if omost[0][0] != emost[0][0]:
		print(n - omost[0][1] - emost[0][1])
	else:
		print(min(n - omost[0][1] - emost[1][1], n - omost[1][1] - emost[0][1]))


Measured memory_bytes: 19040
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

BC = [list(map(int, input().split())) for _ in range(M)]
BC.sort(key=lambda x:x[1], reverse=True)

s = 0
b,c = BC.pop(0)
for i,a in enumerate(A):
    if b>=1:
        if c > a:
            s += c
            b -= 1
        else:
            s += a
    if b<=0:
        if len(BC)==0:
            s += sum(A[i+1:])
            break
        else:
            b,c = BC.pop(0)

print(s)

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin >> n >> k;

    ll ans=0;

    if(k==0){
        cout << n*n << "\n";
        return 0;
    }

    for(int b = k+1; b <= n; b++) {
        ll tans=(b-k)*(n/b)+max(ll(0),n%b-k+1);
//        cout << b << ":" << tans << "\n";
        ans+=tans;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3616
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}

const int maxn = (int) 1e5 + 10;
int a[maxn];

int n;

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  return 1;
}

void solve() {
  a[n] = 0;

  long long res = 0;
  for (int i = 0; i < n; ++i) {
    res += a[i] / 2;
    a[i] &= 1;

    if (a[i] && a[i + 1]) {
      --a[i], --a[i + 1], ++res;
    }
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

int main(){
  int n;cin >> n;
  int a;
  int ans=0;
  int num=1;
  
  for(int i=0; i<n; i++){
    cin >> a;
    if(a==num){
      num++;
    }else ans++;
  }
  
  if(ans==n)
    cout << -1 << endl;
  else
    cout << ans << endl;
}

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

using namespace std; 

int main()
{
    string s,t;

    cin>>s;
  	cin>>t;
  
    t.pop_back();
    if ( s == t) cout<<"Yes";
    else cout<<"No";

    return 0;
}



Measured memory_bytes: 3556
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pair<ll,ll>
#define MAX 200001
using namespace std;
int main()
{
	ll n,i,j,k,l;
    string st;
    cin>>st;
    l=st.size();
    ll cnt=0,s=0;
    for(i=l-1;i>=0;i--){
        if(st[i]=='W')
            cnt++;
        else
            s=s+cnt;
    }
    cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 640
/**
 *    author:  math2do
 *    created: 12.04.2020 17:36:36
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int k;
  cin >> k;
  long long ans = 0;
  for (int a = 1; a <= k; a++) {
    for (int b = 1; b <= k; b++) {
      for (int c = 1; c <= k; c++) {
        int res = __gcd(a, __gcd(b, c));
        ans += res;
      } 
    } 
  }

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


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int k,n,p[1001],ans=0;
   cin>>n>>k;
   for(int i=0;i<n;i++)
   {
       cin>>p[i];
   }
   sort(p,p+n);
   for(int i=0;i<k;i++)
   {
       ans=ans+p[i];
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <sstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

int main()
{
	int x = 100000, y, z;
	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		x *= 1.05;
		y = x / 1000;
		z = x % 1000 > 0 && x % 1000 < 1000 ? 1000 : 0;
		x = y * 1000 + z;
	}

	cout << x << endl;
}


Measured memory_bytes: 3012
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

vector<pii> PS;
 
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int K, X, Y;
	cin >> K >> X >> Y;
	if (K % 2 == 0 && (abs(X) + abs(Y)) % 2 == 1)
	{
		cout << -1 << endl;
		return 0;
	}
 
	int PX = 0, PY = 0;
 
	while (abs(X - PX) + abs(Y - PY) >= 2 * K)
	{
		int t = min(K, abs(X - PX));
		if (t != 0)
		{
			PX += t * (X - PX) / abs(X - PX);
		}
		t = min(K - t, abs(Y - PY));
		if (t != 0)
		{
			PY += t * (Y - PY) / abs(Y - PY);
		}
		PS.push_back(mp(PX, PY));
	}
 
	if (abs(X - PX) + abs(Y - PY) == K)
	{
		PS.push_back(mp(X, Y));
	}
	else
	{
		if ((abs(X - PX) + abs(Y - PY)) % 2 == 1)
		{
			if (abs(PX - X) >= abs(PY - Y))
			{
 
				int t = min(K, abs(Y - PY));
				if (t != 0)
				{
					PY += t * (Y - PY) / abs(Y - PY);
				}
				t = K - t;
				if (t != 0)
				{
					PX += t * (X - PX) / abs(X - PX);
				}
				PS.push_back(mp(PX, PY));
			}
			else
			{
 
				int t = min(K, abs(X - PX));
				if (t != 0)
				{
					PX += t * (X - PX) / abs(X - PX);
				}
				t = K - t;
				if (t != 0)
				{
					PY += t * (Y - PY) / abs(Y - PY);
				}
				PS.push_back(mp(PX, PY));
			}
		}
 
		if ((abs(X - PX) + abs(Y - PY)) % 2 == 1)
		{
			int a = 0;
			a = 1 / a;
		}
 
		int mh = (abs(PX - X) + abs(PY - Y)) / 2;
		int mv = K - mh;
 
		int k[2];
		if (X < PX)k[0] = 1;
		else k[0] = -1;
		if (Y < PY)k[1] = -1;
		else k[1] = 1;
		if (abs(PX - X) >= abs(PY - Y))
		{
			PS.push_back(mp(X + k[0] * mh, Y + k[1] * mv));
			PS.push_back(mp(X, Y));
		}
		else
		{
			PS.push_back(mp(X - k[0] * mv, Y - k[1] * mh));
			PS.push_back(mp(X, Y));
		}
	}
 
	cout << SZ(PS) << endl;
	for (auto& p : PS)
	{
		cout << p.first << " " << p.second << endl;
	}
 
	return 0;
}

Measured memory_bytes: 6256
require 'prime'

n =  10 ** 7
table = Array.new(n+1, false)
Prime.each(n) {|prime| table[prime] = true }
ps = (1..55555).select { |i| i % 5 == 4 && table[i] }

n = gets.to_s.to_i

puts ps[0...n].join(" ")


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

using namespace std;

#define int long long

const int mod = 998244353;

int pow_2[1000001];
int fact[1000001], re_fact[1000001];

int p(int a, int b)
{
	if (b == 0)
		return 1;
	int tmp = p(a, b / 2);
	if (b % 2 == 0) return (tmp * tmp) % mod;
	return ((tmp * tmp) % mod * a) % mod;	
}

int comb(int n, int k)
{
	if (n < 0 || k < 0 || k > n)
		return 0;
	return ((fact[n] * re_fact[k]) % mod * re_fact[n - k]) % mod;
}

int sides, numbers;

int solve(int sum, int elements)
{
	return comb(sum + elements - 1, sum);	
}

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

	fact[0] = 1;
	for (int i = 1; i <= 1000000; i++)
		fact[i] = (fact[i - 1] * i) % mod;
	re_fact[1000000] = p(fact[1000000], mod - 2);
	for (int i = 1000000; i >= 1; i--)
		re_fact[i - 1] = (re_fact[i] * i) % mod;	

	pow_2[0] = 1;
	for (int i = 1; i <= 1000000; i++)		
		pow_2[i] = (pow_2[i - 1] * 2)%mod;

	cin >> sides >> numbers;
	for (int sum = 2; sum <= 2 * sides; sum++)
	{
		int pairs = 0;
		for (int i = 1; i <= sum / 2; i++)
		{
			int j = sum - i;
			if (1 <= j && j <= sides && i != j)
				pairs++;
		}
		int answer = 0;
		for (int choose = 0; choose <= pairs; choose++)
			if (sum % 2 == 1)
				(answer += comb(pairs, choose) * pow_2[choose] % mod * solve(numbers - choose, choose + sides - 2 * pairs) % mod) %= mod;
			else
			{
				(answer += comb(pairs, choose) * pow_2[choose] % mod * solve(numbers - choose, choose + sides - 2 * pairs - 1) % mod) %= mod; 
				(answer += comb(pairs, choose) * pow_2[choose] % mod * solve(numbers - choose - 1, choose + sides - 2 * pairs - 1) % mod) %= mod; 				
			}
		cout << answer << '\n';	
	}
}

Measured memory_bytes: 27068
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define srep(i) for(int i = 0; i < s.size(); i++)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 1e9
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int N, W;
int w[105] = {}, v[105] = {};
ll dp[105][100005];

template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

ll all_search(int i, int j) {
    ll res = 0;
    if(i - 1 == N) {
        return 0;
    } else if(j < w[i]) {
        res = all_search(i + 1, j);
    } else {
        res = max(all_search(i + 1, j), all_search(i + 1, j - w[i]) + v[i]);
    }
    return res;
}

ll dp_recursive(int i, int j) {
    if(dp[i][j] != -1) {
        return dp[i][j];
    }

    ll res = 0;
    if(i - 1 == N) {
        return 0;
    } else if(j < w[i]) {
        res = all_search(i + 1, j);
    } else {
        res = max(all_search(i + 1, j), all_search(i + 1, j - w[i]) + v[i]);
    }

    return dp[i][j] = res;
}

void dp_for(int N, int W) {

    for(int i = 0; i < N; i++)
        dp[i][0] = 0;
    for(int i = 0; i < W; i++)
        dp[0][i] = 0;

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

int main() {
    cin >> N >> W;
    rep(i, N) cin >> w[i] >> v[i];
    memset(dp, -1, sizeof(dp));
    dp_for(N, W);
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 82304
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int N;
string S;

LL calc(int K) {
    VL m_sum(N + 1);// Mの累積和
    VL c_sum(N + 1);//Cより前のMの数の累積和
    VL d_sum(N + 1);//Dより前のMの数の累積和
    VL c_cnt(N + 1);//Cの数の累積和
    {
        REP(i, N) {
            m_sum[i + 1] = m_sum[i] + (S[i] == 'M');
        }
        REP(i, N) {
            if (S[i] == 'C') {
                c_sum[i + 1] = m_sum[i + 1];
                c_cnt[i + 1] = 1;
            }
            c_sum[i + 1] += c_sum[i];
            c_cnt[i + 1] += c_cnt[i];
            if (S[i] == 'D') {
                d_sum[i + 1] = m_sum[i + 1];
            }
            d_sum[i + 1] += d_sum[i];
        }
    }
    // cerr << "d_sum: ";REP(i, N + 1) cerr << d_sum[i] << " ";cerr<<endl;
    // cerr << "m_sum: ";REP(i, N + 1) cerr << m_sum[i] << " ";cerr<<endl;
    // cerr << "c_sum: ";REP(i, N + 1) cerr << c_sum[i] << " ";cerr<<endl;
    // cerr << "c_cnt: ";REP(i, N + 1) cerr << c_cnt[i] << " ";cerr<<endl;
    LL ans = 0;
    REP(i, N) {
        if (S[i] == 'D') {
            LL add = c_sum[min(i + K, (int)c_sum.size() - 1)] - c_sum[i + 1] - m_sum[i + 1] * (c_cnt[min(i + K, (int)c_cnt.size() - 1)] - c_cnt[i + 1]);
            ans += add;
            //DEBUG(ans)
        }
    }
    return ans;
}

int main(void) {
    cin >> N;
    cin >> S;
    int Q;
    cin >> Q;
    REP(i, Q) {
        int K;
        cin >> K;
        cout << calc(K) << endl;
    }
}


Measured memory_bytes: 34572
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int x[5];
  for (int i = 0; i < 5; ++i)
    cin >> x[i];


  for (int i = 0; i < 5; ++i) {
    if (x[i] == 0) {
      cout << i + 1 << endl;
      break;
    }
  }


  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,a[N],b[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int sum=1;b[sum]=a[1];
	for(int i=2;i<=n;i++)
		if(a[i]!=a[i-1])b[++sum]=a[i];
	for(int i=2;i<sum;i++)
		if(b[i]>b[i+1]&&b[i]<b[i-1])
		{
			puts("No");
			return 0;
		}
	for(int i=2;i<=sum;i++)
		if(b[i-1]-b[i]>1)
		{
			puts("No");
			return 0;
		}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)

        {
            var n = int.Parse(Console.ReadLine());

            var ans = 0;

            ans = n / 2;
            if (n % 2 == 1) ans++;

            Console.WriteLine(ans);
        
            
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define NIL -1
typedef long long ll;
const ll INF = 1LL<<60;
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; }
const ll MOD = 1000000007;

void solve() {

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

    if (a <= b){
        rep(i, b) cout << a;
    } else {
        rep(i, a) cout << b;
    }
    return;
}

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

}

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

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

int main(){
  ll A,B;
  cin >>A>>B;
  ll AB = gcd(A,B);
  ll stop = sqrt(AB);
  vector<int> fact(1,1);
  ll i = 2;
  while(AB>1){
    if(i > stop){
      fact.push_back(i);
      break;
    }
    if(AB%i == 0){
      fact.push_back(i);
      while(AB%i == 0) AB /= i;
    }
    i += (i == 2) ? 1 : 2;
  }
  cout << fact.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define endl '\n'
#define pi 3.1415926536
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
signed main()
{
    SPEED;
  	int a,b;
  	cin>>a>>b;
    cout<<a*b/__gcd(a,b);
}

Measured memory_bytes: 256
A, B, Q = gets.chomp.split.map(&:to_i)
Inf = 10**12
as = 0.upto(A-1).map{|i| gets.to_i}
as.unshift(-Inf); as.push(Inf)
bs = 0.upto(B-1).map{|i| gets.to_i}
bs.unshift(-Inf); bs.push(Inf)
qs = 0.upto(Q-1).map{|i| [gets.to_i, i]}.
  sort{|q1, q2| q1[0] <=> q2[0]}

qsH = Hash.new{|h,k| h[k] = {}}

ai = bi = 0
qs.each do |x, i|
  if as[ai] <= x
    while ai <= A
      ai += 1
      if x < as[ai]
        break
      end
    end
  end
  if x < as[ai]
    if ai == 0
      qsH[i]["wa"] = nil
    else
      qsH[i]["wa"] = as[ai-1]
    end
    qsH[i]["ea"] = as[ai]
  else      
    qsH[i]["wa"] = as[ai]
    qsH[i]["ea"] = nil
  end
  if bs[bi] <= x
    while bi <= B
      bi += 1
      if x < bs[bi]
        break
      end
    end
  end
  if x < bs[bi]
    if bi == 0
      qsH[i]["wb"] = nil
    else
      qsH[i]["wb"] = bs[bi-1]
    end
    qsH[i]["eb"] = bs[bi]
  else      
    qsH[i]["wb"] = bs[bi]
    qsH[i]["eb"] = nil
  end    
end

#p qsH

ans = Array.new(Q)
qs.each do |x, i|
  wa = qsH[i]["wa"]; ea = qsH[i]["ea"]
  wb = qsH[i]["wb"]; eb = qsH[i]["eb"]
  ans_ww = x - [wa, wb].min
  ans_we = [(x - wa) + (eb - wa), (x - wb) + (ea - wb)].min
  ans_ee = [ea, eb].max - x
  ans_ew = [(ea - x) + (ea - wb), (eb - x) + (eb - wa)].min
  ans[i] = [ans_ww, ans_we, ans_ee, ans_ew].min
end

puts ans

Measured memory_bytes: 48616
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

int n,m, p;
const int sz = 10;
int board [sz][sz][sz];
int height[sz][sz];

bool win(int _x, int _y, int _z, int c){
  for(int dx = -1; dx <= 1; dx++){
    for(int dy = -1; dy <= 1; dy++){
      for(int dz = -1; dz <= 1; dz++){
        if(dx == 0 && dy == 0 && dz == 0) continue;
        int x = _x, y = _y, z = _z;
        int count = -1;
        
        while(board[x][y][z] == c && count < m){
          x += dx;
          y += dy;
          z += dz;
          count++;
        }
        x = _x, y = _y, z = _z;
        while(board[x][y][z] == c && count < m){
          x -= dx;
          y -= dy;
          z -= dz;
          count++;
        }
        if(count == m) return true;
      }
    }
  }
  return false;
}

void solve(const vector<int> &xs, const vector<int> &ys){
  REP(i, xs.size()){
    int x = xs[i];
    int y = ys[i];
    board[x][y][++height[x][y]] = i % 2;
    if(win(x, y, height[x][y], i % 2)){
      cout << (i % 2 == 0 ? "Black " : "White ") << i + 1<< endl;
      return;
    }
  }
    cout << "Draw" << endl;
}

int main(){
  while(cin >> n >> m >> p && n + m + p > 0){
    int x, y;
    memset(board, -1, sizeof(board));
    memset(height, 0, sizeof(height));
    vector<int> xs;
    vector<int> ys;
    REP(i, p){
      cin >> x >> y;
      xs.push_back(x);
      ys.push_back(y);
    }
    solve(xs, ys);
  }
  return 0;
}

Measured memory_bytes: 1228
n = gets.chomp.to_i
s = gets.chomp.split(" ").map(&:to_i)
q = gets.chomp.to_i
t = gets.chomp.split(" ").map(&:to_i)

c = 0
t.each { |i|
	s.each{ |j|
		if i == j
			c+=1
			break
		end
	}
}
puts c

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

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

Measured memory_bytes: 3628
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define VI vector<int>
#define VL vector<lint>
#define VB vector<bool>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVL vector<VL>
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector< pair<int, int> > s(n), c(m);
    rep(i, n){
        int a, b;
        cin >> a >> b;
        s[i] = make_pair(a, b);
    }
    rep(i, m){
        int a, b;
        cin >> a >> b;
        c[i] = make_pair(a, b);
    }
    rep(i, n){
        int mi = IINF, ans;
        rep(j, m){
            int dis = abs(s[i].first - c[j].first) + abs(s[i].second - c[j].second);
            if(dis < mi){
                mi = dis;
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

int main() {
  string s;
  cin >> s;
  int ans = 700;
  rep(i, 3) {
    if (s[i]=='o') ans += 100;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    int N;
    int X[101] = {};
    int M;
    int A[101]= {};
    
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> X[i];
    }

    cin >> M;
    for(int i = 1; i <= M; i++){
        cin >> A[i];
        //cout << X[A[i]]+1 <<" != " << X[A[i]+1] << "  &&  " << X[A[i]]+1 <<" != " << 2020 << endl;
        if(X[A[i]]+1 != X[A[i]+1] && X[A[i]]+1 != 2020) {
            X[A[i]]++;
        }
        
    }
    
    for(int i = 1; i <= N; i++){
        cout << X[i] << endl;
    }
    
}



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

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

  int w[n],v[n];
  for(int i=0;i<n;i++) cin>>w[i]>>v[i];

  int col = 1000*n; 	
  int dp[n][col+1];

  memset(dp,1e6,sizeof(dp));

  dp[0][v[0]] = w[0];
  dp[0][0] = 0;

  for(int i=1;i<n;i++){

  	   for(int j=0;j<=col;j++){
           
  	   	   dp[i][j] = dp[i-1][j];

  	   	   if(j >= v[i]) {
  	   	   	   if(dp[i-1][j-v[i]] != -1) dp[i][j] = min(dp[i][j], w[i] + dp[i-1][j-v[i]]);
  	   	   }
  	   }
  } 

  int res = 0;
  for(int j=col;j>=0;j--){
  	  if(dp[n-1][j] <= W && dp[n-1][j] != -1){
  	  	 res = j;
  	  	 break;
  	  }
  }
  
  // for(int i=0;i<n;i++){
  // 	 for(int j=0;j<=10;j++) cout<<dp[i][j]<<" ";
  // 	 cout<<endl; 	
  // }

  cout<<res;
  
return 0;	
}

Measured memory_bytes: 42584