akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template<class T>
vector<T> divisor(T n){
    vector<T> ret;
    for(T i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return(ret);
}

int main() {
    int n;
    cin >> n;
    vector<int> ts(n);
    for (auto &&i : ts) scanf("%d", &i);
    int mx = *max_element(ts.begin(),ts.end());
    auto d = divisor(mx);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int val = INF<int>;
        for (auto &&x : d) {
            if(x >= ts[i]) val = min(val, x-ts[i]);
        }
        ans += val;
    }
    cout << ans << "\n";
    return 0;
}


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

int N,A,B,C;
vector<int>l;
int inf=1e9;
int dfs(int i,int a,int b,int c){
	if(i==N){ 
		if(a==0||b==0||c==0)return inf;
		else return abs(a-A)+abs(b-B)+abs(c-C);
	}
	int ret1,ret2,ret3,ret4;
	ret1=dfs(i+1,a,b,c);
	ret2=dfs(i+1,a+l[i],b,c)+((a==0)?0:10);
	ret3=dfs(i+1,a,b+l[i],c)+((b==0)?0:10);
	ret4=dfs(i+1,a,b,c+l[i])+((c==0)?0:10);
	return min({ret1,ret2,ret3,ret4});

}

int main(){
cin>>N>>A>>B>>C;
l.assign(N,0);
for(auto&& w:l)cin>>w;
cout<<dfs(0,0,0,0)<<endl;

}

Measured memory_bytes: 256
x,y = map(int,input().split())
MOD = 10**9+7

def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n, k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD

if (2*y-x) % 3 != 0 or (2*x-y) % 3 != 0:
  print(0)
else:
  k,l = (2*y-x)//3,(2*x-y)//3
  f_mod=[1]*(10**6)
  f_mod_inverse=[1]*(10**6)
  for i in range(1,10**6):
    f_mod[i]=f_mod[i-1]*i%MOD
    f_mod_inverse[i]=f_mod_inverse[i-1]*inv_mod(i)%MOD
  print(comb_mod(k+l,l))


Measured memory_bytes: 107520
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		while(solve());
	}
	
	public static int INF = 1 << 29;
	public static int[] D = {1,0,-1,0};
	
	public static boolean solve() {
		int w = sc.nextInt();
		int h = sc.nextInt();
		if (w == 0) {
			return false;
		}
		char[][] m = new char[h][];
		for(int i=0;i<h;i++) {
			m[i] = sc.next().toCharArray();
		}
		int si = -1,sj = -1;
		int n = 1;
		int[] oi = new int[11];
		int[] oj = new int[11];
		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				if (m[i][j] == 'o') {
					si = i;
					sj = j;
				}else if(m[i][j] == '*') {
					oi[n] = i;
					oj[n] = j;
					n++;
				}
			}
		}
		oi[0] = si;
		oj[0] = sj;
		int[][] dist = new int[n][n];
		for(int i=0;i<n;i++) {
			int[][] d = new int[h][w];
			for(int j=0;j<h;j++) {
				Arrays.fill(d[j], INF);
			}
			Queue<Integer> q = new ArrayDeque<>();
			q.offer(oi[i] * 100 + oj[i]);
			d[oi[i]][oj[i]] = 0;
			while (!q.isEmpty()) {
				int c = q.poll();
				int ci = c / 100;
				int cj = c % 100;
				int cd = d[ci][cj];
				for(int k=0;k<4;k++) {
					int ni = ci + D[k];
					int nj = cj + D[k^1];
					if (ni < 0 || ni >= h || nj < 0 || nj >= w || m[ni][nj] == 'x' || d[ni][nj] <= cd + 1) {
						continue;
					}
					d[ni][nj] = cd + 1;
					q.offer(ni * 100 + nj);
				}
			}
			for(int j=0;j<n;j++) {
				dist[i][j] = d[oi[j]][oj[j]];
			}
		}
//		System.out.println(Arrays.deepToString(dist));
		int[][] dp = new int[n][1<<n];
		for(int i=0;i<n;i++) {
			Arrays.fill(dp[i], INF);
		}
		dp[0][1] = 0;
		for(int j=0;j<1<<n;j++) {
			for(int i=0;i<n;i++) {
				if (dp[i][j] == INF) {
					continue;
				}
				for(int k=0;k<n;k++) {
					if ((j >> k & 1) == 1) {
						continue;
					}
					int nj = j | (1 << k);
					dp[k][nj] = Math.min(dp[k][nj], dp[i][j] + dist[i][k]);
				}
			}
		}
		int ans = INF;
		for(int i=0;i<n;i++) {
			ans = Math.min(ans, dp[i][(1 << n) - 1]);
		}
		System.out.println(ans == INF ? -1 : ans);
		return true;
	}

}

Measured memory_bytes: 52260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;
    cin >> a >> b;
    if (a%2 == 0 || b%2 == 0)
    {
	    cout << "Even" << endl;
    }
    else
    {
	    cout << "Odd" << endl;
    }

		   

}


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

//
// O(N)で二項係数(mod)を求める
//
// ref: http://drken1215.hatenablog.com/entry/2018/06/08/210000
// verify: https://atcoder.jp/contests/abc145/tasks/abc145_d
struct Comb {
  const int64_t mod;
  std::vector<int64_t> fact;     // a!
  std::vector<int64_t> factinv;  // (a!)^-1
  std::vector<int64_t> inv;
  Comb(int maximum, int64_t m)
      : mod(m), fact(maximum, 0), factinv(maximum, 0), inv(maximum, 0) {
    // テーブルを作る前処理
    fact[0] = factinv[0] = 1;
    fact[1] = factinv[1] = 1;
    inv[1] = 1;
    for (int64_t i = 2; i < maximum; ++i) {
      fact[i] = fact[i - 1] * i % mod;
      inv[i] = mod - inv[mod % i] * (mod / i) % mod;
      factinv[i] = factinv[i - 1] * inv[i] % mod;
    }
  }
  int64_t comb(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fact[n] * (factinv[k] * factinv[n - k] % mod) % mod;
  }
};

using namespace std;
using i64 = int64_t;
int main() {
  i64 x, y;
  cin >> x >> y;
  i64 s, t;
  bool flag = false;
  for (i64 a = 0; a < x + 1; ++a) {
    if (a % 2 == 0 && (x - a) * 2 + a / 2 == y) {
      s = a / 2;
      t = x - a;
      flag = true;
    }
  }
  if (!flag) {
    cout << 0 << endl;
    return 0;
  }
  i64 n = s + t;
  i64 k = s;
  Comb c(1'000'100, 1'000'000'007);
  cout << c.comb(n, k) << endl;

  return 0;
}

Measured memory_bytes: 23808
using System;
class main
{
    static void Main(String[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int b = 100000;
        for (int i = 0; i < n; i++)
        {
            b = (((int)((double)b * 1.05)+999)/1000)*1000;
        }
        Console.WriteLine(b);
    }
}

Measured memory_bytes: 5600
#include <iostream>
#include <cmath>

using namespace std;

int wa(long long num)
{
  int dig = 0;
  int sum = 0;
  while (num)
  {
    if (num / 10 == 0)
    {
      sum += num;
      break;
    }
    dig = num % 10;
    if (dig != 9)
    {
      sum += 9;
      num = num / 10;
      num -= 1;
    }
    else
    {
      sum += 9;
      num = num / 10;
    }
  }
  return sum;
}

int main()
{
  long long N;
  long long result = 0;
  cin >> N;
  if (N / 10 == 0)
  {
    result = N;
  }
  else
  {
    result = wa(N);
  }

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=105;
int f[N];
int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,k,i,j,t=0;
    scanf("%d",&n);j=n|1;k=n>>1;
    rep(i,1,k)f[  i]=i;
    rep(i,1,k)f[j-i]=i;
	rep(i,2,n)REP(j,1,i)if(f[i]!=f[j])++t;
	printf("%d\n",t);
	rep(i,2,n)REP(j,1,i)if(f[i]!=f[j])printf("%d %d\n",i,j);
    return 0;
}

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

a = [0] * (N + 1)

if P != 2 and P != 5:
    tenfactor=1
    for i in range(1,N+1):
        a[i] = ((int(S[N-i])*tenfactor+a[i-1])%P)
        tenfactor*=10
        tenfactor%=P

    ans = 0
    from collections import Counter
    C=Counter(a)
    for v,i in C.items():
        ans += (i * (i - 1) // 2)
elif P == 2:
    ans = 0
    for i in range(N):
        if int(S[i]) % 2 == 0:
            ans += i + 1
elif P == 5:
    ans = 0
    for i in range(N):
        if int(S[i]) == 0 or int(S[i]) == 5:
            ans += i + 1

print(ans)



Measured memory_bytes: 12004
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);
function main(){
  var n = o.a();
  var a = o.l();
  var b = o.l();
  var c = xArray(0,n,n+1);
  for(var i = 0; i < n; i++){
    for(var j = 0; j < n; j++){
      if((i+j)&1){
        c[i][j+1] = b[i];
      }else{
        c[i][j+1] = a[i];
      }
    }
  }
  var m = 1 << n;
  var dp = xArray(1e9,n,m);
  for(var i = 1; i < m; i++){
    var bc = 0, x = i, bj = -1;
    while(x){
      if(x&1)bc++;
      bj++;
      x>>=1;
    }
    if(bc > 1){for(var j = 0; j < n; j++){
      if((i & (1<<j)) === 0)continue;
      bj = j;
      var bit = 0;
      for(var k = n; k--;){
        if(j === k){bit++;continue;}
        var bk = 1<<k;
        if((i & bk) === 0)continue;
        var bx = i^bk;
        if(dp[k][i] > dp[j][bx]+bit && c[j][bc-1] <= c[k][bc])dp[k][i] = dp[j][bx]+bit;
        bit++;
      }
    }}else dp[bj][i] = 0;
  }
  var ans = 1e9;
  for(var i = 0; i < n; i++)if(dp[i][m-1] < ans)ans = dp[i][m-1];
  return ans === 1e9 ? -1 : ans;
}

Measured memory_bytes: 82436
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	double r;
	cin >> r;
	double pi = 3.1415926;
	cout << setprecision(10) << 2*r*pi << endl;

  return 0;
}


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

using namespace std;

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

#define N 100010
#define M 200010
#define endl "\n"
#define mod 1000000007 

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	ll n;
	double d, a, b;
	int ans = 0;
	
	cin >> n >> d;
	for(int i = 0; i < n; i++){
		cin >> a >> b;
		
		a = a * a, b = b * b;
		a = sqrt(a + b);
		
		if(a <= d) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3860
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
ll po(ll a, ll b){
    ll res = 1;
    while(b){
        if(b & 1) res = res * a;
        a = a * a;
        b >>= 1LL;
    }
    return res;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll x;
    cin >> x;
    vector<pair<ll, int>> v;
    for(ll i = -1000; i <= 1000; i++){
        v.PB(MP(po(i, 5), i));
    }
    for(int i = 0; i < SZ(v); i++){
        for(int j = 0; j < SZ(v); j++){
            if(v[i].F - v[j].F == x){
                cout << v[i].S << ' ' << v[j].S;
                return 0;
            }
        }
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const int maxN = 2 * 1e5 + 5;
ll dp[maxN][3][2][4];
char s[maxN];
int val, N;
bool same() {
	N = strlen(s + 1);
	for(int i = 1; i <= N; ++i) val = (val + s[i] - 'a') % 3;
	for(int i = 2; i <= N; ++i)
	if(s[i] != s[1]) return 0;
	return 1;
}
int main() {
	scanf("%s", s + 1);
	if(same()) {
		printf("1\n"); return 0;
	}
	if(N==2)puts("2"),exit(0);
	if(N==3) {
		if(s[1]!=s[2]&&s[1]!=s[3]&&s[2]!=s[3])puts("3"),exit(0);
		if(s[1]==s[2]||s[2]==s[3])puts("6");
		if(s[1]==s[3])puts("7");
		exit(0);
	}
	dp[0][0][0][3] = 1;
	for(int i = 0; i < N; ++i) {
		for(int mo = 0; mo < 3; ++mo)
		for(int j = 0; j < 2; ++j) {
			for(int k = 0; k <= 3; ++k) {
				if(dp[i][mo][j][k] == 0) continue;
				for(int k_ = 0; k_ < 3; ++k_) {
					ll& t = dp[i + 1][(mo + k_) % 3][j | (k_ == k)][k_];
					t += dp[i][mo][j][k];
					t %= mod;
				}
			}
		}
	}
	ll ans = 0;
	for(int i = 0; i < 3; ++i)
	ans = (ans + dp[N][val][1][i]) % mod;
	ans++;
	for(int i = 1; i <= N - 1; ++i) {
		if(s[i] == s[i + 1]) {
			ans--; break;
		}
	}
	ans = (ans + mod) % mod;
	printf("%lld\n", ans);
	return 0;
} 

Measured memory_bytes: 37888
n = gets.to_i
ans = case n
  when 1..9
    n
  when 10..99
    9
  when 100..999
    9 + (n-99)
  when 1000..9999
    909
  when 10000..99999
    909 + (n-9999)
  when 100000
    90909
end

puts ans

Measured memory_bytes: 1788
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

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

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] A = new int[N];
            long width = 0, breadth = 0;
            int i = 0;
            while (N > i) {
                A[i] = in.nextInt();

                i++;
            }
            Arrays.sort(A);
            long num1 = 0, num2 = 0;
            for (i = N - 1; i > 0; i--) {
                if (A[i] == A[i - 1]) {
                    num2 = num1;
                    num1 = A[i];
                    i--;
                }
                if (num2 != 0)
                    break;
            }
            out.println(num1 * num2);
        }

    }
}



Measured memory_bytes: 53112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    map<char, pair<ll, bool>> mp;
    for(int i=0;i<n;++i) {
      string s; cin >> s;
      if((int)(s.size()) > 1) mp[s[0]].second = true;
      reverse(s.begin(), s.end());
      ll now = 1;
      for(int j=0;j<(int)(s.size());++j) {
        if(i == n-1) mp[s[j]].first -= now;
        else mp[s[j]].first += now;
        now *= 10;
      }
    }
    int sz = (int)(mp.size());
    int cnt = 0;
    vector<ll> v;
    vector<bool> notzerov;
    for(auto &e: mp) {
      notzerov.emplace_back(mp[e.first].second);
      v.emplace_back(e.second.first);
      cnt++;
    }
    ll ans = 0;
    vector<int> perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    for(int i=0;i<3628800;++i) {
      ll now = 0;
      bool ok = true;
      for(int j=0;j<(int)(v.size());++j) {
        if(perm[j] == 0 && notzerov[j]) {
          ok = false;
          break;
        }
        now += v[j] * perm[j];
      }
      ans += ok && (now == 0);
      next_permutation(perm.begin(), perm.end());
    }
    for(int i=1;i<=10-sz;++i) {
      ans /= i;
    }
    cout << ans << endl;
  }
}



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

long long int solve(vector<long long int> &weights, vector<long long int> &values, long long int w, long long int idx, vector<vector<long long int> > &dp){
  if(w == 0 || idx == weights.size())
    return 0;

  if(dp[idx][w] != -1)
    return dp[idx][w];

  long long int &ans = dp[idx][w];

  if(weights[idx] > w)
    ans = solve(weights, values, w, idx+1, dp);
  else
    ans = max(values[idx] + solve(weights, values, w - weights[idx], idx+1, dp), solve(weights, values, w, idx+1, dp));

  return ans;
}

int main(){
  long long int n, w;

  cin >> n >> w;

  vector<long long int> weights(n, 0);
  vector<long long int> values(n, 0);

  for(long long int i=0; i<n; i++){
    cin >> weights[i] >> values[i];
  }

  vector<vector<long long int> > dp(n+1, vector<long long int> (w+1, -1));
  
  cout << solve(weights, values, w, 0, dp) << endl;;

  return 0;
}


/*

6 15
6 5
5 6
6 4
6 6
3 5
7 2

*/

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

int main() {
  int N;
  cin >> N;
  int P = 1;
  
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    
      if (S == "Y") {
        P *= 0;
      }
    
      else if (S != "Y") {
        P *= 1;
      }
  }
    if (P == 0)
      cout << "Four" << endl;
    
    else if (P == 1)
      cout << "Three" << endl;
}


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

int main(){
  int n, count=0; string s; cin >> n >> s;
  for(int i=0;i<n-2;i++){
    if(s.substr(i, 3) == "ABC") count++; 
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <math.h>
using namespace std;

int main()
{
	string str;
	cin >> str;

	int start = str.size(), end;

	bool f = true;

	for (int i = 0; i < str.size() - 3; ++i)
	{
		if (str.size() > 3)
		{
			if (str[i] != str[i + 3] && str[i + 1] != str[i + 2])
			{
				str.erase(i + 1, 2);
				i = max(0, i - 3);
			}
		}
		else
			break;
	}
	for (int i = 0; i < str.size() - 3; ++i)
	{
		if (str.size() > 3)
		{
			if (str[i] != str[i + 3] && str[i + 1] != str[i + 2])
			{
				str.erase(i + 1, 2);
				i = max(0, i - 3);
			}
		}
		else
			break;
	}
	for (int i = 0; i < str.size() - 1; ++i)
	{
		if (str.size() > 1)
		{
			if (str[i] != str[i + 1])
			{
				str.erase(i, 2);
				--i;
			}
		}
		else
			break;
	}
	end = str.size();

	cout << start - end << endl;

	return 0;
}

Measured memory_bytes: 512
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (a, b, c) = get!(i32, i32, i32);
    if a * c <= b {
        println!("{}", c);
    } else {
        println!("{}", b / a);
    }
}


Measured memory_bytes: 4352
n = gets.chomp.to_i
hold = { S:(1..13).to_a, H:(1..13).to_a, C:(1..13).to_a, D:(1..13).to_a }

n.times do
  type, num = gets.chomp.split
  case type
  when "S"
    hold[:S] -= [num.to_i]
  when "H"
    hold[:H] -= [num.to_i]
  when "C"
    hold[:C] -= [num.to_i]
  when "D"
    hold[:D] -= [num.to_i]
  end
end

hold.each do |index, array|
  array.each{ |value| puts "#{index} #{value}"}
end

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

int main()
{
	int K, T;
	cin >> K >> T;
	vector<int> a( T );
	for( int i = 0; i < T; i++ ) {
		cin >> a[i];
	}

	int ma = *max_element( a.begin(), a.end() );
	int r = K - ma;
	int ans = max( 0, ma - r - 1 );

	cout << ans << endl;
}


Measured memory_bytes: 3588
n,m = map(int,input().split())

ans_l = 0
ans_r = 100001

for i in range(m):
    tmp_l,tmp_r = map(int,input().split())
    if ans_l < tmp_l:
        ans_l = tmp_l
    if tmp_r < ans_r:
        ans_r = tmp_r
        
if ans_l <= ans_r:
    print(ans_r-ans_l+1)
else:
    print(0)

Measured memory_bytes: 3060
n=int(input())
s_str=[]
for i in range(2):
    s_str.append(input().split())
s_int=[]
for i in s_str:
    s_int.append([int(s) for s in i])
manh=0
yu=0
p_3=0
che=[]
for i in range(n):
    manh+=abs(s_int[0][i]-s_int[1][i])
    yu+=(s_int[0][i]-s_int[1][i])**2
    p_3+=(abs(s_int[0][i]-s_int[1][i]))**3
    che.append(abs(s_int[0][i]-s_int[1][i]))
print(manh)
print(yu**(1/2))
print(p_3**(1/3))
print(max(che))


Measured memory_bytes: 5648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=mod;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%mod;
	return modpow(a,b/2)*modpow(a,b/2)%mod;
}
int h,w,a,b,k[200010],ans;
int comb(int x,int y){
	if(y==0)return 1;
	return k[x]*modpow(k[x-y],mod-2)%mod*modpow(k[y],mod-2)%mod;
}
signed main(){
	cin>>h>>w>>a>>b;
	k[0]=1;
	for(int i=1;i<=h+w;i++){
		k[i]=k[i-1]*i;
		k[i]%=mod;
	}
	for(int i=b;i<w;i++){
		ans+=comb(i+h-a-1,i)*(comb(w-i-1+a-1,w-i-1)+mod)%mod;
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int M  = 100005;
long long int N = 1e9 + 7;
long long int Z = 998244353;
/*int fac[M]={0};*/
//int dp[M]={0};
#define ll long long 
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a%b); 
} 
// Use __gcd(int, int) as inbuilt function.
/*int spf[M];
void sieve(int MaxN){
	spf[1] = 1;
	for(int i = 2; i<MaxN; i++){
		spf[i] = i;
	}
	for(int i = 4; i<MaxN; i+=2){
		spf[i] = 2;
	}
	for(int i = 3; i*i <MaxN; i++){
		if(spf[i]==i){
			for(int j = i*i; j<MaxN; j+=i){
				if(spf[j]==j){
					spf[j] = i;
				}
			}
		}
	}
}
vector<int> factorise(int x){
	vector<int> factor;
	while(x!=1){
		factor.push_back(spf[x]);
		x = x / spf[x];
	}
	return factor;
}*/
void precompute(){

}
int max3(int x, int y, int z){
    return max(x, max(y,z));
}
long long int power(long long int x, unsigned int y, int p) 
{ 
    long long int res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 
long long int modinv(long long int x, int p){
    return (power(x, p-2, p));
}
bool compare(const pair<int, int> &p1, const pair<int, int> &p2){
    return (p1.first> p2.first);
}
/*long long int nCrModP(long long int n, long long int r, long long int p) 
{ 
   if (r==0) 
      return 1;  
    return (fac[n] * modinv(fac[r], p) % p * modinv(fac[n-r], p) % p) % p; 
}*/

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
   	int n; 
   	cin>>n;
   	long long int sum = 0;
   	for(int i  = 1; i<=n; i++){
   		if((i%3)&&(i%5)){
   			sum+=i;
   		}
   	}
   	cout<<sum<<"\n";
   	return 0;
}


Measured memory_bytes: 3552
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int c = s.nextInt();

        int n = 0;
        for(int i = a; i <= b; i++){
            if( c % i == 0) n++;
        }

        System.out.println(n);
    }

}

Measured memory_bytes: 17356
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int x;
	cin>>x;
	long long int h=0;
	long long int y=(x/500);
	if(y>0)
	{
		h+=(y*1000);
		x=(x)-500*y;
	}
	//cout<<x<<endl;
	long long int f=(x/5);
	if(f > 0)
	{
		h+=(f*5);
		//x=(x)-500*y;
	}
	cout<<h;
}

Measured memory_bytes: 256
m,d=map(int,input().split())
c=0
for i in range(1,d+1):
    if i>9:
        d1=i%10
        d2=i//10
        for j in range(1,m+1):
            if d1*d2==j and d1>1 and d2>1:
                c+=1
print(c)

Measured memory_bytes: 2940
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
# define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 998244353;
//const int mod = 1000000007;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef map<int, int> mii;
typedef set<int> si;
typedef queue<int> qi;


const int N = 2e5 + 5;



void solve() {

	int n, s;
	cin >> n >> s;
	vvi dp(n + 1, vi(s + 1));
	vi a(n + 1);
	fr(i, 1, n)
		cin >> a[i];
	dp[0][0] = 1;
	fr(i, 1, n) {
		int x = a[i];
		fr(j, 0, s) {
			dp[i][j] = 2 * dp[i - 1][j] % mod;
			if (j >= x)
				dp[i][j] = (dp[i][j] + dp[i - 1][j - x]) % mod;
		}
	}
	cout << dp[n][s] << endl;

}


signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout << fixed << setprecision(15);
	int t = 1;
	//cin >> t;

	while (t--)
		solve();
#ifdef aa
	cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


int norm(int a) {
	while (a >= mod) a -= mod;
	while (a < 0) a += mod;
	return a;
}

int powm(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1)
			res = (res * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return res;
}


int divide(int a, int b) {
	return (a % mod) * powm(b, mod - 2) % mod;
}


Measured memory_bytes: 73652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl //小数をn桁で出力

int main() {
    IN(int, a);
    IN(int, b);
    IN(int, c);
    cout << c << " " << a << " " << b << endl;
}


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

int main(){
    int a,b,ans;
    cin >> a>> b;
    if(a<=5){
        ans = 0;
    }
    else if(a<=12){
        ans = b / 2;
    }
    else{
        ans = b;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [input() for i in range(N)]
import collections
c = collections.Counter(A)
#print(c)
max = c.most_common()[0][1]
#print(max)
#print(c.most_common()[0][0])
li = list(c)
#print(li)
keys = [k for k, v in c.items() if v == max]
#print(keys)
keys.sort()
for i in keys:
    print(i)

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

int main() {
    int a, b;
    cin >> a >> b;
    if( (b-1)%(a-1) == 0){
        cout << (b-1)/(a-1) << endl;
    } else {
        cout << (b-1)/(a-1)+1 << endl;
    }
}

Measured memory_bytes: 256
def main():
    w, h, n = map(int, input().split())

    corners = [0, 0, w, h]

    for i in range(n):
        x, y, a = map(int, input().split())

        if a == 1:
            if x > corners[0]:
                corners[0] = x
        elif a == 2:
            if x < corners[2]:
                corners[2] = x
        elif a == 3:
            if y > corners[1]:
                corners[1] = y
        else:
            if y < corners[3]:
                corners[3] = y
    
    width = corners[2] - corners[0]
    height = corners[3] - corners[1]

    if width < 0 or height < 0:
        print(0)
    else:
        print(width * height)

if __name__ == '__main__':
    main()

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

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

  int array[n];
  for (int i=0; i<n; i++) cin >> array[i];

  int counter;
  for (int i=0; i<1000000; i++) {
    int j = i % n;
    if (array[j] == 0) break;
    if (array[j] % 2 != 0) break;
    int tmp = array[j] / 2;
    ++counter; array[j] = tmp;
  }
  cout << counter / n << endl;
}


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

int main(){
   string s1,s2,s3;
   cin >> s1 >> s2 >> s3;
   char a,b,c;
   a=s1.front()-'a'+'A';
   b=s2.front()-'a'+'A';
   c=s3.front()-'a'+'A';
   cout << a << b << c << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    string s;
    cin >> s;
    cout << s[0] << distance(s.begin(), s.end())-2 << s[s.size()-1] << endl;
}

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

int N,M;
int Q;
int fid[2020][2020] = {0};
int H[2020][2020] = {0},W[2020][2020] = {0};

int main()
{
    scanf("%d%d%d",&N,&M,&Q);
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < M; j++)
        {
            char s;
            scanf(" %c",&s);
            if(s == '1')
            {
                fid[i + 1][j + 1] = 1;
            }
            else
            {
                fid[i + 1][j + 1] = 0;
            }
            if(s == '1')
            {
                if(fid[i + 1][j] == 1)
                {
                    W[i + 1][j + 1] = 1;
                }
                if(fid[i][j + 1] == 1)
                {
                    H[i + 1][j + 1] = 1;
                }
            }
        }
    }
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < M; j++)
        {
            fid[i + 1][j + 1] += fid[i + 1][j];
            W[i + 1][j + 1] += W[i + 1][j];
            H[i + 1][j + 1] += H[i + 1][j];
        }
    }
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < M; j++)
        {
            fid[i + 1][j + 1] += fid[i][j + 1];
            W[i + 1][j + 1] += W[i][j + 1];
            H[i + 1][j + 1] += H[i][j + 1];
        }
    }
    for(int i = 0; i < Q; i++)
    {
        int x1,y1,x2,y2;
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        int node =
        fid[x2][y2] - fid[x1 - 1][y2] - fid[x2][y1 - 1] + fid[x1 - 1][y1 - 1],
        edgeH = H[x2][y2] - H[x1][y2] - H[x2][y1 - 1] + H[x1][y1 - 1],
        edgeW = W[x2][y2] - W[x1 - 1][y2] - W[x2][y1] + W[x1 - 1][y1];
        printf("%d\n",node - edgeW - edgeH);
    }
    return 0;
}


Measured memory_bytes: 49408
#include <stdio.h>

int main()
{
    int i,j, n[3],tempmax,rowcount;
	long temp;
	scanf("%d\n",&rowcount);
	for(i=0;i<rowcount;i++){
		scanf("%d%d%d",&n[0],&n[1],&n[2]);
		tempmax=0;
		for(j=1;j<3;j++){
			if(n[tempmax]<n[j]) tempmax=j;
		}
		switch(tempmax){
			case 0:
				temp=(n[1]*n[1])+(n[2]*n[2]);
				break;
			case 1:
				temp=(n[0]*n[0])+(n[2]*n[2]);
				break;
			case 2:
				temp=(n[0]*n[0])+(n[1]*n[1]);
		}

		if(n[tempmax]*n[tempmax]==temp){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    long long int a,b,c,x,y,sum,sum1,sum2,sum3,sum4,f1,f2;
    cin>>a>>b>>c>>x>>y;
    if(x==y)
    {
        sum1=a*x+b*y;
        sum2=c*x*2;
        sum=min(sum1,sum2);
    }
    if(x<y)
    {
        sum1=a*x+b*y;
        sum2=c*y*2;
        sum3=a*x+b*x+(y-x)*c*2;
        sum4=c*x*2+(y-x)*b;
        f1=min(sum1,sum2);
        f2=min(sum3,sum4);
        sum=min(f1,f2);
    }
     if(y<x)
    {
        sum1=a*x+b*y;
        sum2=c*x*2;
        sum3=a*y+b*y+(x-y)*c*2;
        sum4=c*y*2+(x-y)*a;
        f1=min(sum1,sum2);
        f2=min(sum3,sum4);
        sum=min(f1,f2);
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
def linear_search(li, value):
    for x in li:
        if x == value:
            return True
    return False

input() # n
S = [int(x) for x in input().split()] 
input() # q
T = [int(x) for x in input().split()]

ans = 0

for x in T:
    if linear_search(S, x):
        ans += 1

print(ans)

Measured memory_bytes: 8436
package main
 
import (
  "fmt"
)
 
func main() {
  var n int
  fmt.Scan(&n)
  d := make([]int, n)
  
  for i := range d {
    fmt.Scan(&d[i])
  }
  
  recv := 0
  for i := 0; i < n-1; i++ {
    for j := i+1; j < n; j++ {
      recv += d[i] * d[j]
    }
  }
  fmt.Println(recv)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long MOD = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
#define N 100010

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;
}

struct UnionFind
{
  vector<int> d;
  UnionFind(int n = 0) : d(n, -1){};

  int find(int x)
  {
    if (d[x] < 0)
      return x;
    return d[x] = find(d[x]);
  }

  bool unite(int x, int y)
  {
    x = find(x);
    y = find(y);
    if (x == y)
      return false;
    if (-d[x] < -d[y])
      swap(x, y);
    // x に y をくっつける
    // x のサイズの方が大きくなければいけないので、そうでない場合は上でswap
    d[x] += d[y];
    d[y] = x;
    return true;
  }

  bool same(int x, int y) { return find(x) == find(y); };

  int size(int x) { return -d[find(x)]; };
};

int deg[100005];
vector<int> to[100005];

int main()
{
  int n, m, k;
  cin >> n >> m >> k;

  UnionFind uf(n); // 初期化

  rep(i, m)
  {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    deg[a]++;
    deg[b]++;
    uf.unite(a, b);
  }

  rep(i, k)
  {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  rep(i, n)
  {
    int ans = uf.size(i) - 1 - deg[i];

    for (int u : to[i])
    {
      if (uf.same(i, u))
        --ans;
    };

    cout << ans << " ";
  }
  cout << endl;

  return 0;
}


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

int main() {

    int a,b;
    string ans;
    cin >> a >> b;

    if(a > b){
        for(int i=0;i<a;i++){
            ans += to_string(b);
        }
    }else{
        for(int i=0;i<b;i++){
            ans += to_string(a);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    string L;cin>>L;
    int N=L.size();
    int dpk[N+1];
    int dpm[N+1];
    REPS(i,N){
        int d=L[i-1]-'0';
        if(i==1){
            dpk[1]=1;
            dpm[1]=2;
        }
        else{
            dpk[i]=dpk[i-1]*3%MOD;
            dpm[i]=dpm[i-1];
            if(d==1){
                dpk[i]+=dpm[i-1];
                dpm[i]+=dpm[i-1];
                dpk[i]%=MOD;
                dpm[i]%=MOD;
            }
        }
    }
    cout<<(dpk[N]+dpm[N])%MOD<<endl;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<pii>>;
using mat = vector<vector<int>>;
const int MOD = 1e9 + 7;

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

    int N, Z, W;
    cin >> N >> Z >> W;
    vector<int> a(N);
    for (int i = 0; i < N; ++i)
        cin >> a[i];

    vector<int> dp1(N + 1), dp2(N + 1);
    for (int i = 1; i <= N; ++i) {
        int tmp = (i < N ? a[N - i - 1] : W);
        dp1[i] = abs(tmp - a[N - 1]);

        tmp = (i < N ? a[N - i - 1] : Z);
        dp2[i] = abs(tmp - a[N - 1]);

        for (int j = 1; j < i; ++j) {
            dp1[i] = max(dp1[i], dp2[j]);
            dp2[i] = min(dp2[i], dp1[j]);
        }
    }

    cout << dp1[N] << endl;

    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;
static const int MAX_N = 100;

int n, w, d;
vector<P> memo, memo2;

int main(){
	for(;;){
		scanf("%d %d %d", &n, &w, &d);
		if(n == 0 && w == 0 && d == 0) break;
		memo.push_back(P(0, 0));
		memo2.push_back(P(w, d));
		for(int i = 1; i < n + 1; i++){
			int p, s;
			scanf("%d %d", &p, &s);
			p--;
			P p1 = memo[p], p2 = memo2[p];
			memo.erase(memo.begin() + p);
			memo2.erase(memo2.begin() + p);
			int v = abs(p1.first - p2.first);
			int h = abs(p1.second - p2.second);
			s %= 2 * (v + h);
			P np1, np2;
			if(s < v || (s > (h + v) && s < h + 2 * v)){
				if(s > (h + v) && s < h + 2 * v){
					s -= h + v;
					s = v - s;
				}
				np1 = P(p1.first + s, p1.second);
				np2 = p2;
				p2 = P(p1.first + s, p2.second);
				if(s > v / 2){
					swap(p1, np1);
					swap(p2, np2);
				}
			}else{
				if(s > h + 2 * v){
					s -= h + 2 * v;
					s = h - s;
				}else{
					s -= v;
				}
				np1 = P(p1.first, p1.second + s);
				np2 = p2;
				p2 = P(p2.first, p1.second + s);
				if(s > h / 2){
					swap(p1, np1);
					swap(p2, np2);
				}
			}
			memo.push_back(p1);
			memo2.push_back(p2);
			memo.push_back(np1);
			memo2.push_back(np2);
		}
		vector<int> res;
		for(int i = 0; i < n + 1; i++){
			res.push_back(abs(memo[i].first - memo2[i].first) * abs(memo[i].second - memo2[i].second));
		}
		sort(res.begin(), res.end());
		for(int i = 0; i < res.size(); i++) printf("%d%c", res[i], i == res.size() - 1 ? '\n' : ' ');
		memo.clear();
		memo2.clear();
	}
	return 0;
}



Measured memory_bytes: 2596
import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())))
ans=sum(np.abs(a))
if 0 in a:
    print(ans)
else:
    b=np.where(a<0)
    if np.size(b)%2==0:
        print(ans)
    else:
        ans-=2*min(np.abs(a))
        print(ans)

Measured memory_bytes: 23300
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    A, B, C, D = Scanner.map_int()
    while True:
        C -= B
        if C <= 0:
            print('Yes')
            return
        A -= D
        if A <= 0:
            print('No')
            return


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


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


int main()
{
	int a[10000];
	int i=0;
	while (1) {
		cin >> a[i];
		
		if (a[i] == 0) {
			break;
		}
		cout << "Case " << i + 1 << ": " << a[i] << endl;
		i++;
	}
	return 0;
}

Measured memory_bytes: 3112
A,B,C,X,Y = map(int,input().split())
a,b,c = 0,0,0
if (A+B)/2 > C:
  c = min(X,Y)*2
  a = X-min(X,Y)
  b = Y-min(X,Y)
  if a*A > a*2*C:
    c += a*2
    a = 0
  if b*B > b*2*C:
    c += b*2
    b = 0
else:
  a = X
  b = Y
print(a*A+b*B+c*C)

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
    int S[10010], n, q, x, k, cnt = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &x);
        S[n] = x;
        k = 0;
        while (S[k++] != x);
        if (k < n) {
            cnt++;
        }
    }
    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 2752
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);

		int M=1000000;
		boolean a[]=new boolean[M+1];
		Arrays.fill(a, true);
		a[0]=a[1]=false;
		for(int i=0;i*i<=M;i++)
		{
			if(!a[i])
				continue;
			for(int j=i*2;j<=M;j+=i)
				a[j]=false;
		}

		for(;;)
		{
			int N=in.nextInt(),P=in.nextInt();
			if(N==-1&&P==-1)
				return;

			ArrayList<Integer> al1=new ArrayList<Integer>();	
			ArrayList<Integer> al2=new ArrayList<Integer>();
			int cnt=0;
			for(int i=N+1;;i++)
			{
				if(a[i])
				{
					al1.add(i);
					cnt++;
				}
				if(cnt>=P)
				break;
			}
//			for(int i=N;i<=N+1000;i++)
//				if(a[i])
//					al1.add(i);
			for(int i=0;i<al1.size();i++)
				for(int j=i;j<al1.size();j++)
					al2.add(al1.get(i)+al1.get(j));
			Collections.sort(al2);
			System.out.println(al2.get(P-1));
		}
	}
}

Measured memory_bytes: 14000