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

class PrintTestCases {
	private static final int ARRAY_MAX = 10000;
	private int[] data = new int[ARRAY_MAX];
	/**
	 * 
	 */
	private static int CNT_NUM = 1;
	
	public PrintTestCases() {
		Arrays.fill(data, 0);
	}
	
	private void read() {
		final int FINISH_NUMBER = 0;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		for (int i = 0; i < ARRAY_MAX; i++) {
			try {
				int addNum = Integer.parseInt(br.readLine());
				if (FINISH_NUMBER >= addNum) {
					break;
				}
				data[i] = addNum;
			} catch (IOException e) {
				System.out.println("Input error.");
			}
			
		}
	}
	
	private String toString(int val) {
		return "Case " + (CNT_NUM++) + ": " + val;
	}
	
	public void run() {
		read();
		
		for (int i = 0; i < ARRAY_MAX; i++) {
			if (0 >= data[i]) {
				break;
			}
			System.out.println(toString(data[i]));
		}
	}
}
public class Main {

	public static void main(String[] args) {

		new PrintTestCases().run();
	}

}



Measured memory_bytes: 31648
n=int(input())
a = [int(i) for i in input().split()] 
A=0
B=0
C=0
k=0
for i in range(n):
  if i%2==0:
    k=max(a)
    A += k
    del a[a.index(k)]
  else :
    k=max(a)      
    B += k
    del a[a.index(k)]   
  
C=A-B          
print(C)          

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
int y, m, d;
char c1, c2;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> y>>c1>>m>>c2>>d;
    if(m==4&&d>30)  cout <<"TBD"<< "\n";
    else if(m==4&&d<=30) cout <<"Heisei"<<"\n";
    else if(m>4) cout <<"TBD"<< "\n";
    else cout <<"Heisei"<<"\n";
}

Measured memory_bytes: 384
#include<cstdio>
#include<string>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;

/*
struct type{
    int l,r,num;
};
*/

std::string s;
//std::map<char,bool>vis;
//std::map<char,type>a;

int main(){
    std::cin>>s;
    int len=s.size();//,lens;
    for(register int i=1;i<len;i++){
        if(s[i]==s[i-1]){
            std::cout<<i<<' '<<i+1;
            return 0;
        }
        if(i>=2&&s[i]==s[i-2]){
            std::cout<<i-1<<' '<<i+1;
            return 0;
        }
    }
    /*
    //std::cout<<len<<std::endl;
    //lens=len/2+1;
    for(register int i=0;i<len;i++){
        if(!vis[ s[i] ]){
            vis[ s[i] ]=true;
            a[ s[i] ].l=a[ s[i] ].r=i+1;
            a[ s[i] ].num=1;
        }else{
            a[ s[i] ].r=i+1;
            a[ s[i] ].num++;
            //std::cout<<s[i]<<' '<<a[ s[i] ].num<<std::endl;
            if(a[ s[i] ].num>=( a[ s[i] ].r - a[ s[i] ].l + 1 )/2+1){
                std::cout<<a[ s[i] ].l<<' '<<a[ s[i] ].r;
                return 0;
            }
            if(a[ s[i] ].num<( a[ s[i] ].r - a[ s[i] ].l + 1 )/2+1&&(a[ s[i] ].r-a[ s[i] ].l+1)%2){
                a[ s[i] ].l=a[ s[i] ].r=i+1;
                a[ s[i] ].num=1;
            }
        }
    }
    */
    std::cout<<-1<<' '<<-1;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define  rep(i,n) for(li i = 0; i < (n); ++i)
#define  red(i,n) for(li i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    int x,a,b;
    cin>>x>>a>>b;
    cout<<(x-a)%b<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int MOD = 1e9 + 7;

template <class T, T MOD>
class ModuloCombination {
 private:
  std::vector<T> factrial, inverse_factrial;
  T Pow(T x, T y) {
    if (y == 0) return 1;
    if (y % 2 == 0) return Pow(x * x % MOD, y / 2);
    return x * Pow(x, y - 1) % MOD;
  }

 public:
  ModuloCombination(T n) : factrial(n + 1), inverse_factrial(n + 1) {
    inverse_factrial[0] = factrial[0] = 1;
    for (T i = 1; i <= n; i++) {
      factrial[i] = factrial[i - 1] * i % MOD;
      inverse_factrial[i] = Pow(factrial[i], MOD - 2);
    }
  }
  T operator()(T n, T k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return factrial[n] * inverse_factrial[k] % MOD * inverse_factrial[n - k] % MOD;
  }
};

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

  ModuloCombination<ll, MOD> c(n);

  ll r = 0;
  for (int i = 0; i <= min(k, n - 1); i++) {
    r += c(n, i) * c(n - 1, n - i - 1) % MOD;
    r %= MOD;
  }
  cout << r << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 5;
const int mod = 1e9 + 7;
vector<int> g[N];
int k;

int mul(int a, int b){
	return (1ll * a * b) % mod;
}
int dfs(int node, int parent){
	int rem = k - 1;
	if(parent != -1)
		rem--;
	int ans = 1;
	for(auto &child : g[node]){
		if(child == parent)
			continue;
		ans = mul(ans, rem--);
		ans = mul(ans, dfs(child, node));
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef ONLINE_JUDGE
    // freopen("", "r", stdin);
    // freopen("", "w", stdout);
#endif
	int n;
	cin >> n >> k;
	for(int i = 0; i < n - 1; i++){
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	cout << mul(k, dfs(1, -1));
	return 0;
}


Measured memory_bytes: 11648
#include <iostream>
    #include <string>
    #include <set>  
    #include <stack>
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
    #include <cassert>
    #include <iomanip>
    #include <sstream>
    #include <ctime>
    #include <bitset> 
using namespace std;
#define for1(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,maxn) for1(i,0,maxn)
#define ford(i,b,a) for(int i=(int)(b)-1;i>=a;--i)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pii > piii;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define st first
#define nd second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define dprintf(...) printf(__VA_ARGS__)
const int maxn=3412;
int n;
string s;
int id[maxn+maxn];
vector<string> ds;
void cal(string& s)
{
	string cur="";
	memset(id,-1,sizeof(id));
	int ai=0,bi=0;
	rep(i,s.length())
	{
		if(s[i]=='a')ai++,id[i]=ai;
		else bi++,id[i]=bi;
	//	cout<<id[i]<<endl;
	}
	if(s[0]=='a')
	{
		int ai=0,bi=0;
		cur.pb(s[0]);ai++;
		int nd=ai;bool ok=0;
		for1(i,1,s.length())
		{
			if(s[i]=='a')
			{
				ai++;
				if(ok)cur.pb(s[i]),nd=ai,ok=0;
			}
			else
			{
				bi++;
				if(bi==nd)cur.pb(s[i]),ok=1;
			}
		//	cout<<i<<" "<<cur<<endl;
		//	system("pause");
		}
	}
	else
	{
		int mxid=id[s.length()-1];
		for1(l,1,mxid+1)
		{
			string bst="";
			rep(i,s.length())
				if(id[i]>=l)bst.pb(s[i]);
		//	cout<<l<<" "<<bst<<endl;
			cur=max(cur,bst);
		}
	}
	s=cur;
}
int main()
{
	cin>>n>>s;
	string buf="";
	int ai=0,bi=0;
	rep(i,s.length())
	{
		buf.pb(s[i]);
		if(s[i]=='a')ai++;
		else bi++;
		if(ai==bi)ds.pb(buf),buf="";
	}
	rep(i,ds.size())
	{
	//	cout<<ds[i]<<endl;
		cal(ds[i]);
	//	cout<<ds[i]<<endl;
	//	system("pause"); 
	}
	ford(i,ds.size()-1,0)
		ds[i]=max(ds[i+1],ds[i]+ds[i+1]);
	cout<<ds[0]<<endl;
	return 0;
}

Measured memory_bytes: 10496
#include <stdio.h>

int sqr(int x){
  return x*x;
}

int main(void){

  int n,a[3],l,i;
  scanf("%d",&n);

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

    if(2*sqr(l)==sqr(a[0])+sqr(a[1])+sqr(a[2]))printf("YES\n");
    else printf("NO\n");

  }

  return 0;
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define MAXN 4005
#define mo 974711
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}

int N,fa[MAXN],son[MAXN];
vector<int> ne[MAXN];
int a[MAXN],pos[MAXN];
int que[MAXN],tot,pre[MAXN],red,bot[MAXN];
bool vis[MAXN],cov[MAXN],bl[MAXN];
int ans[25005],q;
void drag(int v) {
    if(v == 0) return;
    ans[++q] = v;
    int u = v;
    int t = a[u];
    while(fa[u] != -1) {
	int k = a[fa[u]];
	a[fa[u]] = t;
	pos[t] = fa[u];
	t = k;
	u = fa[u];
    }
    a[v] = t;pos[t] = v;
}
void Process() {
    while(red) {
	if(vis[a[0]]) {
	    int u = bot[a[0]];
	    //while(u != -1 && u == a[u]) {cov[u] = 1;u = fa[u];}
	    while(1) {
		if(!cov[u] || a[u] < a[0]) break;
		u = fa[u];
	    }
	    drag(u);
	    while(cov[u]) u = fa[u];
	    cov[u] = 1;
	    --red;
	}
	else {
	    for(int i = N - 1 ; i >= 0 ; --i) {
		if(!cov[i] && !bl[a[i]]) {
		    bl[a[0]] = 1;
		    drag(i);break;
		}
	    }
	}
    }
}
void Solve() {
    read(N);
    fa[0] = -1;
    for(int i = 1 ; i < N ; ++i) {
	read(fa[i]);son[fa[i]]++;
	ne[fa[i]].pb(i);
    }
    for(int i = 0 ; i < N ; ++i) {
	read(a[i]);
	pos[a[i]] = i;
    }
    while(1) {
	tot = 0;
	memset(pre,0,sizeof(pre));
	memset(bl,0,sizeof(bl));
	memset(bot,0,sizeof(bot));
	red = 0;
	for(int i = N - 1 ; i >= 0 ; --i) {
	    if(!vis[i]) {
		if(!son[i] || (son[i] == 1 && pre[i])) {
		    que[++tot] = i;
		    if(fa[i] != -1 && son[fa[i]] == 1) pre[fa[i]] = i;
		    if(pre[i]) bot[i] = bot[pre[i]];
		    else bot[i] = i;
		    vis[i] = 1;
		    ++red;
		}
	    }
	}
	if(!red) break;
	Process();
	for(int i = 1 ; i <= tot ; ++i) {
	    --son[fa[que[i]]];
	    /*if(a[que[i]] != que[i]) {
		puts("QAQ");
	    }*/
	}
    }
    /*for(int i = 0 ; i < N ; ++i) {
	if(!vis[i]) {
	    puts("QAQ");
	}
    } 
    for(int i = 0 ; i < N ; ++i) {
	if(a[i] != i) {
	    puts("QAQ");
	}
    }*/
    out(q);enter;
    for(int i = 1 ; i <= q ; ++i) {
	out(ans[i]);enter;
    }
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;


struct PrimeFactorization {
    int N;
    vector<int> min_factor;
    PrimeFactorization(int N): N(N) {
        // initialize
        min_factor.assign(N+1, 0);
        rep(i, 2, N+1) min_factor[i] = i;

        // find minimum prime number
        for (ll num=2; num<=N; ++num) {
            for (ll notp=num*num; notp<=N; notp+=num) {
                if (min_factor[notp] != notp) continue;
                min_factor[notp] = num;
            }
        }
    }
    vector<pair<int, int>> factorize (int num) {
        if (num <= 1) return {};
        assert (num<=N);

        vector<pair<int, int>> res;
        while (num>1) {
            int now = min_factor[num];
            int cnt = 0;
            while (num%now == 0) {
                ++cnt;
                num /= now;
            }
            res.emplace_back(now, cnt);
        }
        return res;
    }
};

int calc_gcd(int n, int m) {
    if (n<m) swap(n, m);
    if (n%m == 0) return m;
    else return calc_gcd(m, n%m);
}

int main()
{
    PrimeFactorization pf(1000009);

    int N;
    cin >> N;

    unordered_map<int, int> prime_cnt;
    int gcd;

    rep(i, 0, N) {
        int A;
        cin >> A;
        for (auto pcnt: pf.factorize(A))
            ++prime_cnt[pcnt.first];

        if (i == 0) gcd = A;
        else gcd = calc_gcd(gcd, A);
    }

    bool coprime = true;
    for (auto pcnt: prime_cnt) if (pcnt.second>1) coprime = false;

    if (coprime)
        cout << "pairwise coprime" << endl;
    else {
        if (gcd == 1) 
            cout << "setwise coprime" << endl;
        else
            cout << "not coprime" << endl;
    }
    return 0;
}


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

A+=[A[0]]
B=[None]*N
for i in range(0, N):
    if i<=N-2:
        B[i]=A[i+1]-A[i]
    if i==N-1:
        B[i]=A[i+1]+K-A[i]
#print(B)
print(sum(B)-max(B))

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,sa=0;
    cin >>N;
    vector<int> num(N);
    for(int i=0;i<N;i++) cin >> num[i];
    sort(num.begin(), num.end());
    for(int i=0;i<N;i++){
    (i%2==0) ? sa-=num[i]:sa+=num[i];
    }
    cout<<abs(sa)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
constexpr ll INF = 1LL<<60;

int main() {
    ll n, m, q;
    cin >> n >> m >> q;
    vector<ll> a(q), b(q), c(q), d(q);
    REP(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i], a[i]--, b[i]--;

    ll ans = 0;
    auto dfs = [&](auto &&self, ll idx, ll last, vector<ll> &A) -> void {
        if(idx == n) {
            ll ret = 0;
            REP(i, q) if(A[b[i]]-A[a[i]]==c[i]) ret += d[i];
            chmax(ans, ret);
            return;
        }

        FOR(i, last, m+1) {
            A[idx] = i;
            self(self, idx+1, i, A);
        } 
    };

    vector<ll> A(n);
    dfs(dfs, 0, 1, A);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int a=N,b=0;
		while(a>0) {
			b=b+a%10;
			a=a/10;
		}
		if(N%b==0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 22868
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n,x;cin >> n >> x;
    vi a(n);rep(i, n)cin >> a[i];
    sort(all(a));
    int i = 0;
    while(true) {
        if(i==n) {
            cout << i-1 << endl;
            return 0;
        }
        if(x<a[i]) {
            cout << i << endl;
            return 0;
        }
        else if(x==a[i]) {
            cout << i+1 << endl;
            return 0;
        }
        x-=a[i];
        i++;
    }
    return 0;
}

Measured memory_bytes: 3596
N=int(input())
A=sorted([int(input()) for i in range(N)])
#A=[i for i in range(50)]
#N=len(A)
value=0
B,C=A[0],A[0]
i=1
z=0

while N-1>z:

    if z%4==0:
        value+=A[-i]-B
        B=A[-i]
    if z%4==1:
        value+=A[-i-1]-C
        C=A[-i-1]
    if z%4==2:
        value+=B-A[i]
        B=A[i]
    if z%4==3:
        value+=C-A[i+1]
        C=A[i+1]
        i+=2
    #print(B,C,i,z)
    z+=1
value1=value
value=0
B,C=A[-1],A[-1]
i=0
z=0
while N-1>z:

    if z%4==0:
        value+=B-A[i]
        B=A[i]

    if z%4==1:
        value+=C-A[i+1]
        C=A[i+1]

    if z%4==2:
        value+=A[-i-2]-B
        B=A[-i-2]
    if z%4==3:
        value+=A[-i-3]-C
        C=A[-i-3]
        i+=2
    #print(B,C,i,z,value)
    z+=1
value2=value
print(max(value1,value2))


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

using namespace std;
using ll = long long;

int main(void) {
  int n;
  ll t;
  cin >> n >> t;
  ll ans = 0;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n - 1; i++) {
    if (v[i + 1] - v[i] >= t) {
      ans += t;
    } else {
      ans += v[i + 1] - v[i];
    }
  }
  ans += t;
  cout << ans << endl;
  return 0;
}

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

signed main(void)
{
	long long a, b, c, ans;
	cin >> a >> b >> c;
	ans = 0;
	if (!(a % 2 == 0 || b % 2 == 0 || c % 2 == 0))
		ans = min(a * b, min(b * c, a * c));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    var N = sc.nextInt()
    val M = sc.nextInt()

    val matchMap = mapOf(1 to 2,
                    7 to 3,
                    4 to 4,
                    5 to 5,
                    3 to 5,
                    2 to 5,
                    9 to 6,
                    6 to 6,
                    8 to 7)
    val list = mutableListOf<Pair<Int,Int>>()
    for (n in 0 until M) {
        val A = sc.nextInt()
        if (list.any { it.second==matchMap[A] && it.first>A}) continue
        list.add(A to matchMap[A]!!)
    }
    list.sortBy { it.second}

    fun max (a:String, b:String) :String{
        if (a.length > b.length) return a
        if (a.length < b.length) return b
        if (a > b) return a
        else return b
    }
    val DP = Array(N+1){""}

    for (i in 1 .. N) {
        DP[i] = "0"
        for ((a,n) in list) {
            if (i < n) continue
            if (DP[i-n] == "0") continue
            DP[i] = max(DP[i - n] + "$a", DP[i])
        }
    }
    //DP.forEachIndexed { i, s -> println("$i $s") }

    println(DP[N])
}

Measured memory_bytes: 169564
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int main() {

  int n=0;

  cin >> n;

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

    if(i%3==0 || i%10==3 || i/10==3 
      || i%100/10==3 || i%100%10==3 
      || i%1000%100==3 || i%1000/100==3
      || i%1000%100%10==3 || i%1000%100/10==3
      || i/1000==3 || i/100==3) {

      cout << " " << i;
        
      }

  }

  cout << endl;

  return 0;
  
}


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

int main() {

    int n;
    cin >> n;
    map<string, int> mps;
    rep(i, n) {
        string tmp;
        cin >> tmp;
        mps[tmp]++;
    }

    int m;
    cin >> m;
    map<string, int> mpt;
    rep(i, m) {
        string tmp;
        cin >> tmp;
        mpt[tmp]++;
    }
    
    int mini = 10000000;
    int j = 0;
    vector<int> a(max(n, m));

    for(auto x : mps) {
        a.at(j) = mps[x.first] - mpt[x.first];
        mini = (mini, a.at(j));
        j++;
    }

    int maxi = 0;

    for(auto x : a) {
        maxi = max(maxi, x);
    }

    cout << maxi << endl;

  	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))

a = 0
c = 0
ans = 0
for b in B:
  while a < N and A[a] < b:
    a += 1
  while c < N and C[c] <= b:
    c += 1
  ans += a * (N - c)
print(ans)


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

int main(){
    string s,t;
    cin >> s >> t;
    for(int i=0;i<s.size();i++){
        if(s.at(i)!=t.at(i)){
            cout <<"No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int N, M;

void check(vector<char> &v, char c){
  if(N == 1) { v[0] = c; return ; }
  if(c == 'A'){
    REP(i, v.size()) if(v[i] == '#'){ v[i] = c; return ; }
  }
  if(c == 'B'){
    if(v[N - 1] == '#' && v[N - 2] != 'A') { v[N - 1] = c; return ; }
    for(int i = N - 2; i > 1; i--) if(v[i] == '#' && v[i - 1] != 'A' && v[i + 1] != 'A') { v[i] = c; return ; }
    if(v[0] == '#' && v[1] != 'A') { v[0] = c; return ; }
    REP(i, v.size()) if(v[i] == '#'){ v[i] = c; return ; }
  }
  if(c == 'C'){
    if(v[0] != '#' && v[1] == '#') { v[1] = c; return ; }
    for(int i = 1; i < N - 1; i++){
      if(v[i] != '#' && v[i + 1] == '#') { v[i + 1] = c; return ; }
      if(v[i] != '#' && v[i - 1] == '#') { v[i - 1] = c; return ; }
    }
    if(v[N - 1] != '#' && v[N - 2] == '#') { v[N - 2] = c; return ; }
    if(N % 2) { v[(N + 1) / 2 - 1] = c; return ; }
    v[N / 2] = c;
  }
  if(c == 'D'){
    vector<int> d(N, 1e9);
    REP(i, N){
      if(v[i] == '#') continue;
      d[i] = 0;
      for(int j = i + 1, cnt = 1; j < N; ++j, ++cnt) d[j] = min(d[j], cnt);
      for(int j = i - 1, cnt = 1; j >= 0; --j, ++cnt) d[j] = min(d[j], cnt);
    }
    int tar = 0;
    REP(i, N) tar = max(tar, d[i]);
    if(tar == N) { v[0] = c; return ; }
    REP(i, N) if(d[i] == tar) { v[i] = c; return ; }
  }
}

int main() {
  while(cin >>N >>M && N && M){
    vector<char> v(N, '#');
    REP(i, M){
      char c; cin >>c;
      check(v, c);
    }
    REP(i, N) cout <<v[i]; cout <<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
N = int(input())
TA = [[int(i) for i in input().split()] for _ in range(N)]

T, A = TA[0]
for i in range(1, N) :
    t, a = TA[i]
    if T / A < t / a :
        i = 0
        while (A + i) * t % a != 0 :
            i += 1
        T = (A + i) * t // a
        A = A + i
    else :
        i = 0
        while (T + i) * a % t != 0 :
            i += 1
        A = (T + i) * a // t
        T = T + i
    
print(T + A) 

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



typedef long long ll;
#define reg register
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)


char IO;
inline ll rd(){
	ll s=0,f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}


const int N=1010;

int n;

int main(){
	int ans=0;
	rep(i,1,n=rd()) {
		int t=i,cnt=0;
		while(t) t/=10,cnt++;
		if(cnt&1) ans++;
	}
	printf("%d\n",ans);
}





Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

int lcm(int a,int b){
   return a*b/gcd(a,b);
}

bool prime_number(int n){
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   double a,sum=0;
   while(cin>>a){
      REP(i,10){
         if(i==0) sum=a;
         else if(i%2==1){
            a*=2;
            sum+=a;
         }else{
            a/=3;
            sum+=a;
         }
      }
      printf("%.8lf\n",sum);
   }
   return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std ;
const int mod = 1e9 + 7 ;
const int N = 1e5 + 5 ;
int phi[N] , tot , prime[N] , vis[N] ;
typedef long long ll ;
ll qmi(ll a ,ll b)
{
  ll res = 1;
  while(b)
   {
      if(b & 1) res = res * a % mod ;
      a = a * a % mod ;
      b >>= 1 ;
   }
   return res;
}
void init()
{
  phi[1] = 1 ;
  for(int i = 2; i < N ;i ++)
   {
     if(!vis[i]) prime[++ tot] = i , phi[i] = i - 1;
     for(int j = 1 ; j <= tot && i * prime[j] < N ;j ++)
      {
        vis[i * prime[j]] = 1;
        if(i % prime[j] == 0)
         {
           phi[i * prime[j]] = phi[i] * prime[j] ;
           break ;
         }
        phi[i * prime[j]] = phi[i] * phi[prime[j]] ;
      }
   }
}
int main()
{
  init() ;
  int n , k ;
  cin >> n >> k ;
  long long ans = 0 ;
  for(int i = 1 ; i <= k ;i ++)
   ans += qmi(k / i , n) * phi[i] % mod , ans %= mod ;
  cout << ans << endl ;
  return 0 ;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

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

const double PI=3.14159265358979323846;

const int mod = 1e9+7;

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

  vector<int> H(N);
  rep(i, N) cin >> H[i];

  int tmp_num = H[0];
  tmp_num = max(tmp_num-1, 0);

  for(int i=1; i<N; i++){
    if(H[i] < tmp_num){
      cout << "No" << endl;
      return 0;
    }else if(H[i]>tmp_num){
      tmp_num = H[i]-1;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::cmp;
use std::f64::consts;

fn main() {
    let n: i64  = read();
    let k: i64 = read();
    let mut count = 0;

    if k % 2 == 0 {
        let mut count1: i64 = 0;
        // kで割ったあまりが0の場合
        for i in 1..n+1 {
            if i % k == 0 {
                count1+=1;
            }
        }
        count+=(count1*count1*count1);

        let mut count2: i64 = 0;
        // 全部 kで割ったあまりが k/2 の場合
        for i in 1..n+1 {
            if i % k == (k/2) {
                count2+=1;
            }
        }

        // 全部 k / 2の場合
        count += (count2*count2*count2);
    } else {
        let mut count1: i64 = 0;
        // kで割ったあまりが0の場合
        for i in 1..n+1 {
            if i % k == 0 {
                count1+=1;
            }
        }
        count+=(count1*count1*count1);
    }

    println!("{}", count);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// 最大公約数
fn gcd(a: i32, b: i32) -> i32 {
    match b {
        0 => a,
        _ => gcd(b, a % b)
    }
}

// 最小公倍数
fn lcm(a: i32, b: i32) -> i32 {
    a * b / gcd(a, b)
}

// 階乗
fn kaijou(n: i32)->i32 {
    if n == 1 {
        return n;
    }
    return n * kaijou(n-1);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint l,r,min=2020;
	cin>>l>>r;
	for(lint i=l;i<=r;i++){
		if(i%2019==0){
			cout<<0<<endl;
			return 0;
		}
	}
	for(lint i=l;i<=r;i++)for(lint j=i+1;j<=r;j++){
		chmin(min,((i%2019)*(j%2019))%2019);
	}
	cout<<min<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>

#define INF 1000000000000000000
using namespace std;
typedef long long ll;

bool used[8];
vector<int> e[8];
int ans = 0;
int cnt = 0;
int n, m;

void dfs(int v) {
	cnt++;
	if (cnt == n) {
		ans++;
		return;
	}
	used[v] = true;
	for (auto &&id : e[v]) {
		if (!used[id]) {
			dfs(id);
			used[id] = false;
			cnt--;
		}
	}
	return;
}

int main(){
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		e[a - 1].push_back(b - 1);
		e[b - 1].push_back(a - 1);
	}
	dfs(0);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

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

    double x = (-1 + sqrt(1 + 8*n)) / 2;

    cout << ceil(x) << endl;
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stc++.h>
#include <bits/stdc++.h>
#include <string> 
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;

#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b

char cry(char a)
{
	return ('Z'-a)+'A';
}
int main()
{
	long long n,k;
	cin>>n;
	vector <long long> ar(n);
	for(long long i=0; i<n; i++)
	{
		cin>>ar[i];
	}
	long long m=ar[0];
	long long sum=0;
	for(long long i=0; i<n; i++)
	{
		if(m>=ar[i])
		{
			sum++;
			m=ar[i];
		}
		
	}
	cout<<sum<<endl;	

return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll t, x;
  cin >> t >> x;

  cout << ((ld)t / x) << endl;

  return 0;
}


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

int main(void) {
  int N;
  cin >> N;
  int C[MAX_N];
  int S[MAX_N];
  int F[MAX_N];
  rep(i, N - 1) { cin >> C[i] >> S[i] >> F[i]; }

  int Ans[MAX_N];
  Ans[N - 1] = 0;
  rep(i, N - 1) {
    Ans[i] = 0;
    for (int j = i; j < N - 1; j++) {
      if (Ans[i] <= S[j])
        Ans[i] = S[j] + C[j];
      else if(Ans[i] % F[j] == 0)
        Ans[i] += C[j];
      else
        Ans[i] += (F[j] - (Ans[i] % F[j])) + C[j];
    }
  }
  rep(i, N) { cout << Ans[i] << endl; }
  return 0;
}

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

ll MAX = 10e6;
vector<bool> isPrime(MAX + 1, true);
vector<int> exist(MAX + 1);

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    bool pairwise = true;
    bool setwise = true;

    for (int i = 0; i * i <= MAX; ++i) {  // sqrt(MAX)まで調べる
        if (i == 0 || i == 1) isPrime[i] = false;
        if (isPrime[i]) {
            for (int j = i * 2; j <= MAX; j += i) isPrime[j] = false;
        }
    }

    rep(i, 1000001) exist[i] = 0;
    rep(i, N)++ exist[A[i]];

    for (int i = 2; i <= MAX; ++i) {
        int cnt = 0;
        if (isPrime[i]) {
            for (int j = i; j <= MAX; j += i) cnt += exist[j];
        }
        if (cnt > 1) pairwise = false;
        if (cnt == N) setwise = false;
    }
    if (pairwise) {
        cout << "pairwise coprime" << endl;
    } else if (setwise) {
        cout << "setwise coprime" << endl;
    } else
        cout << "not coprime" << endl;
}

Measured memory_bytes: 47284
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define vl vector<long long>
using namespace std;
using ll = long long;
using ld = long double;

// ----本問について----
// 問題：
// 問題文URL：
// ------------------

// ----ここから本問のソースコード----


// グローバル変数（入力）
ll a,c;
string b;

void solve() { 
  b.erase(b.begin()+1);
  c = (ll)stoi(b);
  cout << a*c / 100 << endl;
}

int main() {
  cin >> a >> b;
  solve();
  return 0;
}


Measured memory_bytes: 3628
#! /usr/bin/env perl
use strict;
use warnings;
use POSIX qw(ceil);

my $H = <>;
chomp $H;

my $W = <>;
chomp $W;

my $N = <>;
chomp $N;

my $tmp1 = $N/$W;
my $tmp2 = $N/$H;

if($tmp1 > $tmp2){
    print ceil($tmp2);
}
else{
    print ceil($tmp1);
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#define max 90909090;
using namespace std;
int main(){
	int N,A,B,ka=0,gi=0;
	cin>>N;
	int data[N+1]={0};
	data[0]=max;
	cin>>A>>B;
	data[A]=2;
	data[B]=1;
	while(1){
		ka=0;
		gi=0;
		if (data[A+1]==0&&ka==0){
			data[A]=0;
			data[A+1]=2;
			A+=1;
			ka=1;
		}
		else if (data[A-1]==0&&ka==0){
			data[A]=0;
			data[A-1]=2;
			A-=1;
			ka=1;
		}
		else {
			cout<<"Borys"<<endl;
			return 0;
		}
		if (data[B-1]==0&&gi==0){
			data[B]=0;
			data[B-1]=1;
			B-=1;
			gi=1;
		}
		else if (data[B+1]==0&&gi==0){
			data[B]=0;
			data[B+1]=1;
			B+=1;
			gi=1;
		}
		else {
			cout<<"Alice"<<endl;
			return 0;
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (auto& x : a) {
        cin >> x;
        --x;
    }

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int j = a[i];
        if (i < j && a[j] == i) {
            ++ans;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);
            for (int i = 1; i < n; i++) {
                a[i] += a[i - 1];
            }
            int ans = a[n - 1];
            for (int i = 0; i < n; i++) {
                ans = Math.min(Math.abs(a[n - 1] - 2 * a[i]), ans);
            }
            out.println(ans);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
            this.bufPointer = 0;
            this.bufLength = 0;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int nextInt() {
            int n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

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

int main() {
  int a, b; cin >> a >> b;
  int res = 0;
  if (a >= b) {
    res += a; --a;
  } else {
    res += b; --b;
  }
  res += max(a, b);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    int h, w;
    cin >> h >> w;
    vector<vector<int>> res(h, vector<int>(w, 0));
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    int index = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (v[index] == 0) index++;
            res[i][j] = index + 1;
            v[index]--;
        }
        if (i % 2 == 1) reverse(res[i].begin(), res[i].end());
        for (auto num : res[i]) {
            cout << num << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3612
def main():
  n,k=map(int,input().split())
  num=[int(i) for i in input().split()]
  
  dp=[0]*(k+1)
  for i in range(k):
    flag=False
    for j in range(n):
      if i+1-num[j]>=0:
        if  dp[i+1-num[j]]==0:
          flag=True
          break
    if flag:
      dp[i+1]=1
    else:
      continue
  if dp[k]:
    print('First')
  else:
    print('Second')          
if __name__=='__main__':
  main()

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

#define    ll     long long int

int main( )
{
    ll s = 0, a, b, c, x, y, mn;
    cin >> a >> b >> c >> x >> y;
    mn = min(x, y);
    if (2 * c <= (a + b)) {
        s += ((2 * c) * mn);
        x -= mn;
        y -= mn;
    }
    s += min(a * x + b * y, 2 * c * x + 2 * c * y);
    cout << s << '\n';
    return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;

}

signed main() {
	ll n, m, k, s, p;
	ll x;
	ll cnt = 0;

	cin >> n >> m;

	vector<vector<ll>> v(m, vector<ll>(10, -1));
	vector<ll> vv;

	REP(i, m) {
		cin >> k;

		REP(j, k) {
			cin >> s;
			v[i][j] = s;
		}
	}

	REP(i, m) {
		cin >> p;
		vv.push_back(p);
	}

	ll ans = 0;
	x = pow(2, n);
	ll now, y;
	bool flag;

	while (cnt != x) {
		bitset<10> b(cnt);
		flag = true;

		REP(i, m) {
			now = 0;
			y = 0;
			while (now < 10 && v[i][now] > 0) {
				if (b[v[i][now] - 1]) {
					y++;
				}
				now++;
			}
			if (y % 2 != vv[i]) {
				flag = false;
				break;
			}
		}

		if (flag) {
			ans++;
		}

		cnt++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void solve()
{
    int n, d;
    scanf("%d%d", &n, &d);
    int cnt = 0;
    int i;
    for (i = 0; i < n; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        if ((ll)x*x + (ll)y*y <= (ll)d*d) {
            cnt++;
        }       

    }
    printf("%d\n", cnt);

    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
#define endl '\n'
#define for(i,s,n) for(int i=s;i<n;i++)
#define vii vector<int>
int t = 1, n, OO = 1e14;
int dp[3001][3001];
vii v;
int solve(int first = 0, int last = n - 1) {
	if (first > last) return 0;
	int& ret = dp[first][last];
	if (~ret) return ret;
	ret = -OO;
	int r1 = solve(first, last - 1);
	int r2 = solve(first + 1, last);
		ret = max({ ret,v[last] - r1,v[first] - r2 });
	
	return ret;
}
signed main()
{
	fast;

	//cin>>t;
	while (t--)
	{
		memset(dp, -1, sizeof dp);
		cin >> n;
		v = vii(n);
		for (i, 0, n) cin >> v[i];
		cout << solve() << endl;
	}
}

Measured memory_bytes: 74112