akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
#define WHITE 0
#define BLACK 1
typedef long long ll;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
string s;
int k;
int INFi=1000000000;
ll INFl=1000000000000000;

struct UnionFind{
    vector<int> par;//初期化
    vector<int> rank;//高さ
    UnionFind(int n=0):par(n),rank(n,0){
        for(int i=0;i<n;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);//経路圧縮
    }
    void unite(int x,int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry) return;
        if(rank[rx]<rank[ry]) rank[rx]=ry;
        else rank[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
struct edge{int from,to,cost;};
vector<edge> es(100); //辺の集合
vector<int> d(100,INFi);//最短距離
int V,E;//頂点数、辺数

int main(){
    string A,B;cin>>A>>B;
    if(A.size()>B.size()){
        cout<<"GREATER"<<endl;
        return 0;
    }
    else if(A.size()<B.size()){
        cout<<"LESS"<<endl;
        return 0;
    }
    string ans="EQUAL";
    for(int i=0;i<A.size();i++){
        if(A[i]>B[i]){
            ans="GREATER";
            break;
        }else if(A[i]<B[i]){
            ans="LESS";
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s;
	cin>>s;
	int n = s.size(), posicion = n;
	ll cont = 0;
	for(int i = n - 1; i >= 0; i--){
		if(s[i] == 'W') continue;
		posicion--;
		cont += posicion - i;
	}
	cout<<cont<<endl;
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e5;
int n, a[nsz + 5], rt, lst, ans;
int ql, qr, q[2 * nsz + 5];

struct treap {
	int sz, ls[nsz + 5], rs[nsz + 5], pri[nsz + 5];
	int key[nsz + 5], mn[nsz + 5], mx[nsz + 5];
	
	int inline node(int w) {
		int u = ++sz;
		key[u] = mn[u] = mx[u] = w, pri[u] = rand();
		return u;
	}
	
	void inline up(int u) {
		mn[u] = ls[u] ? mn[ls[u]] : key[u];
		mx[u] = rs[u] ? mx[rs[u]] : key[u];
	}
	
	int merge(int v1, int v2) {
		if (!v1 || !v2)  return v1 | v2;
		if (pri[v1] < pri[v2]) {
			rs[v1] = merge(rs[v1], v2), up(v1);
			return v1;
		} else {
			ls[v2] = merge(v1, ls[v2]), up(v2);
			return v2;
		}
	}
	
	void split(int u, int w, int &v1, int &v2) {
		if (!u) { v1 = v2 = 0; return; }
		if (key[u] <= w) {
			v1 = u, split(rs[u], w, rs[u], v2), up(u);
		} else {
			v2 = u, split(ls[u], w, v1, ls[u]), up(u);
		}
	}
	
	void inline ins(int &rt, int w) {
		rt = merge(rt, node(w));
	}
	
	void inline del(int &rt, int w) {
		int v1, v2;
		split(rt, w - 1, v1, v2);
		rt = v1;
	}
};
treap tr;

void inline init() {
	cont (i, n - 1) {
		tr.ins(q[qr], a[i]);
		if (i != n && a[i] > a[i + 1])  ++qr;
	}
	tr.ins(q[qr], a[n]);
	
	lst = n;
	for (; tr.mx[q[qr]] == lst && lst; --lst) {
		tr.del(q[qr], lst);
	}
	
	++qr;
}

void inline deal() {
	for (; !q[ql] && ql != qr; ++ql);
	int u = q[ql], mx = tr.mx[u];
	q[ql] = 0, ++ql;
	
	for (int k = ql; k != qr && mx != lst; ++k) {
		if (!q[k])  continue;
		
		if (tr.mx[q[k]] > mx) {
			int v1, v2;
			tr.split(q[k], mx, v1, v2);
			q[k] = v1;
			u = tr.merge(u, v2);
			mx = tr.mx[u];
		}
		
		int &r1 = q[k - 1], &r2 = q[k];
		if (r1 && tr.mx[r1] < tr.mn[r2])  r2 = tr.merge(r1, r2), r1 = 0;
	}
	q[qr] = u;
	int &r1 = q[qr - 1], &r2 = q[qr];
	if (r1 && tr.mx[r1] < tr.mn[r2])  r2 = tr.merge(r1, r2), r1 = 0;
	
	for (; tr.mx[q[qr]] == lst && lst; --lst) {
		tr.del(q[qr], lst);
	}
	
	++qr;
	++ans;
}

int main() {
	scanf("%d", &n);
	cont (i, n) {
		scanf("%d", &a[i]);
	}
	init();
	for (; lst; deal());
	printf("%d\n", ans);
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    string S;
    cin >> S;
    int N = S.size();

    lint cost = 0;

    lint ans = 0;
    for (int i = 0; i < N;) {
        if (S[i] == 'A') {
            cost++;
            i += 1;
        } else if (S.substr(i, 2) == "BC") {
            ans += cost;
            i += 2;
        } else {
            i += 1;
            cost = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3776
#include<cstdio>

int m,d,ans;

int main() {
	scanf("%d %d",&m,&d);
	for(int i=2;i<=9;i++)
		for(int j=2;j<=9;j++)
			if(10*i+j<=d&&i*j<=m)
				ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <string>

using namespace std;

const int CMax = 100002;

int n, a, ats;

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#define N 1000
using namespace std;
int n,m;
int a[N][N],c[N];
bool bz[N];
int b[N];
void get(){
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			if (!bz[a[i][j]]){
				c[a[i][j]]++;
				break;
			}
}
int main(){
	scanf("%d %d",&n,&m);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	int top=m;
	int ans=n;
	while (top){
		get();
		int x=0,y=0;
		for (int i=1;i<=m;i++){
			if (y<c[i])x=i,y=c[i];
			c[i]=0;
		}
		bz[x]=1;
		ans=min(ans,y);
		top--;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
package main

import "fmt"

var H, W, D int
var A [][]int
var Q int
var L, R []int

func main() {
	fmt.Scanf("%d %d %d", &H, &W, &D)

	A = make([][]int, H)
	for i := 0; i < H; i++ {
		A[i] = make([]int, W)
		for j := 0; j < W; j++ {
			fmt.Scanf("%d", &A[i][j])
		}
	}

	fmt.Scanf("%d", &Q)

	L = make([]int, Q)
	R = make([]int, Q)

	for i := 0; i < Q; i++ {
		fmt.Scanf("%d %d", &L[i], &R[i])
	}

	m := make(map[int]Point, H*W)
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			m[A[i][j]] = Point{i, j}
		}
	}

	cs := make([]int, H*W+1)
	for i := D + 1; i <= H*W; i++ {
		c := m[i]
		n := m[i-D]
		cs[i] = cs[i-D] + Abs(c.x-n.x) + Abs(c.y-n.y)
	}

	for i := 0; i < Q; i++ {
		fmt.Println(cs[R[i]] - cs[L[i]])
	}
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

type Point struct {
	x int
	y int
}


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

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

    int n1 = stoi(s.substr(0,2));
    int n2 = stoi(s.substr(2,2));

    bool mm1 = (0<n1 && n1<13);
    bool mm2 = (0<n2 && n2<13);
    if(mm1 && mm2){
        cout<<"AMBIGUOUS"<<endl;
    }else if(mm1){
        cout<<"MMYY"<<endl;
    }else if(mm2){
        cout<<"YYMM"<<endl;
    }else{
        cout<<"NA"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        HashSet<Long> a = new HashSet<>();
        for (int i = 0; i < N; i++) {
            long t = scan.nextLong();
            if (!a.contains(t)) {
                a.add(t);
            } else {
                a.remove(t);
            }
        }
        System.out.println(a.size());
    }
}


Measured memory_bytes: 64884
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n;ll les,mn=1e18,ans,ans2;
int main()
{
	n=read();
	for(int i=1;i<=n;++i)
	{
		int a=read(),b=read();
		if(a<b) les+=b-a,ans+=a;
		else ans2+=a,(a>b)?mn=min(mn,(ll)b):0; 
	}
	printf("%lld\n",les?ans+ans2-mn:ans); 
	return 0;
}



Measured memory_bytes: 256
def main():
    s = input()
    k = int(input())
    
    l = []
    for i in range(0, len(s)):
        for j in range(0, min(len(s)-i, k)):
            sub = s[i:i+j+1]

            if sub not in l:
                l.append(sub)

    l.sort()
    
    print(l[k-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

const lint MAX = 1000001;
const lint MOD = 998244353;

lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

lint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint modpow(lint m, lint n){
  if(n == 0) return 1;
  else if(n % 2 == 0) return modpow(m * m % MOD, n/2);
  else{
    return modpow(m, n - 1) * m % MOD;
  }
}

signed main(){
 lint N, M, K; cin >> N >> M >> K;
 COMinit();
 lint ans = 0;
 for(lint k = 0; k <= K; k++){
   ans += ((COM(N - 1, k) * M) % MOD * modpow(M - 1, N - 1 - k)) % MOD;
   ans %= MOD; 
 }
 cout << ans << endl;
}

Measured memory_bytes: 27060
#include<stdio.h>
#include<string.h>
int main(){
	char S[256], T[256], U[256];
	int A, B;

	scanf("%s %s", S, T);
	scanf("%d %d", &A, &B);
	scanf("%s", U);

	if(strcmp(S, U)==0){
		A--;
	} else {
		B--;
	}

	printf("%d %d\n", A, B);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MAXN	5005
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int a[MAXN], ans[MAXN];
int main() {
	int n, m;
	read(n), read(m);
	int cnt = 0;
	for (int i = 1; i <= m; i++) {
		read(a[i]);
		cnt += a[i] & 1;
	}
	if (cnt > 2) {
		printf("Impossible\n");
		return 0;
	}
	if (m == 1) {
		if (a[1] == 1) printf("1\n1\n1\n");
		else printf("%d\n2\n1 %d\n", a[1], a[1] - 1);
		return 0;
	}
	for (int i = 2; i <= m - 1; i++) {
		if (a[i] & 1) {
			if (a[1] & 1) swap(a[i], a[m]);
			else swap(a[1], a[i]);
		}
	}
	for (int i = 1; i <= m; i++)
		printf("%d ", a[i]);
	printf("\n");
	int tot = 0;
	ans[++tot] = a[1] + 1;
	for (int i = 2; i <= m - 1; i++) {
		if (a[i] == 2) ans[++tot] = 2;
		else {
			int tmp = a[i] / 2;
			if (tmp & 1) {
				ans[++tot] = tmp / 2;
				ans[tot] *= 2;
				ans[++tot] = tmp - tmp / 2;
				ans[tot] *= 2;
			} else ans[++tot] = a[i];
		}
	}
	if (a[m] != 1) ans[++tot] = a[m] - 1;
	printf("%d\n", tot);
	for (int i = 1; i <= tot; i++)
		printf("%d ", ans[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
kari_result = 0
min_result = 10000000000
for i in range(len(s)-len(t)+1):
    for l in range(len(t)):
        if s[i+l] != t[l]:
            kari_result += 1
    if kari_result < min_result:
        min_result = kari_result
    kari_result = 0
print(min_result)


Measured memory_bytes: 9104
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(string, s);
    bool ok = false;
    REP(i, s.size())
    {
        for (ll j = i + 1; j < s.size(); ++j)
        {
            ok |= s[i] == 'C' and s[j] == 'F';
        }
    }
    YES(ok);
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

#define rad_to_deg(rad) (((rad)/2/PI)*360)

void solve() {
	double a, b, x;
	cin >> a >> b >> x;
	double res;
	if (x / a == a * b / 2) {
		res = 45;
	} else if (x / a < a * b / 2) {
		double s = x / a;
		double l = 2.0 * s / b;
		res = rad_to_deg(atan(b / l));
	} else {
		double s = a * b - (x / a);
		double r = 2.0 * s / a;
		res = rad_to_deg(atan(r / a));
		
	}
	printf("%.10f", res);
}

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

Measured memory_bytes: 4052
n = int(input())
a = list(map(int, input().split()))

test = True
for i in a:
  if i % 2 == 0:
    if i % 3 == 0 or i % 5 == 0:
      continue
    else:
      test = False
      break
if test:
  print('APPROVED')
else:
  print('DENIED')
      

Measured memory_bytes: 2940
import bisect

def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    t = 0
    l = len(L) - 1
    for ai, a in enumerate(L):
        ci = ai + 1
        for bi, b in enumerate(L[ai + 1:], ai + 1):
            ci = bisect.bisect_left(L, a + b, ci) - 1
            t += ci - bi
    print(t)


main()


Measured memory_bytes: 3188
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
	int a,p;
	scanf("%d%d",&a,&p);
	int pies=a*3+p;
	printf("%d\n",pies>2?pies/2:0);
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 50+10
//typedef std::pair<int,int> P;


    bool F=false;
    ll C[10];
    ll A,lo=INF,hi=-1;
int main(){
    ios_base::sync_with_stdio(false);
    REP(i,9){cin>>C[i];A+=C[i];}
    /*REP(i,9)REP(j,9){
        lo=min(C[i]+C[j]);
        hi=max(C[i]+C[j]);
    }
    if(A%3!=0){cout<<(A%3==0?"Yes":"No")<<endl;return 0;}
    FOR(i,lo,hi+1){
        FOR(i,lo,hi+1)
    }*/
    REP(i,C[0]+1){
        REP(j,C[4]+1){
            REP(k,C[8]+1){
                F=true;
                ll a[]={i,j,k};
                ll b[]={C[0]-i,C[4]-j,C[8]-k};
                REP(m,3)REP(l,3){
                    if(a[m]+b[l]!=C[m*3+l]){F=false;}
                }
                if(F){
                    cout<<(F?"Yes":"No")<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<("No")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	ll n;
	cin>>n;
	cout<<((n<1200)?"ABC":"ARC")<<endl;

	return 0;
}














Measured memory_bytes: 256
#include <iostream>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, strt, n) for (int i = (strt); i < (int)(n); i++)
using namespace std;

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

	int *A = new int[N + 1]; rep(i, N) cin >> A[i + 1];
	int *B = new int[N + 1]; rep(i, N) cin >> B[i + 1];
	int *C = new int[N    ]; rep(i, N - 1) cin >> C[i + 1];

	int satisfaction = 0;
	int prev = 0; // 直前の料理番号
	rep2(i, 1, N + 1){
		satisfaction += B[A[i]];
		if (A[i] == prev + 1)
			satisfaction += C[prev];
		prev = A[i];
	}

	cout << satisfaction << endl;

	delete[] C;
	delete[] B;
	delete[] A;

	return 0;
}


Measured memory_bytes: 256
yen500 = int(input())
yen100 = int(input())
yen50 = int(input())
target = int(input())

match_count = 0
for i in range(yen500+1):
  for j in range(yen100+1):
    for k in range(yen50+1):
      if (i*500)+(j*100)+(k*50) == target:
        match_count += 1
      
print(match_count)

Measured memory_bytes: 3060
#include <map>
#include <queue>
#include <cmath>
#include <cstdio>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define ll long long
#define inf 1000000000
#define PI acos(-1)
#define REP(i,x,n) for(int i=x;i<=n;i++)
#define DEP(i,n,x) for(int i=n;i>=x;i--)
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void Out(ll a){
    if(a<0) putchar('-'),a=-a;
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
const int N=1e5+10;
map<int,int>vis;
int a[N],b[N];
int main(){
    int n=read();
    for(int i=0;i<n;i++){
        a[i]=read();vis[a[i]]++;
    }
    sort(a,a+n);
    int pos=0;
    for(int i=0;i<n;i++){
        if(vis[a[i]]<=1||(i>0&&a[i]==a[i-1])) continue;
        b[pos++]=a[i];
    }
    if(pos<2){
        puts("0");
        return 0;
    }
    ll ans=0;
    for(int i=0;i<pos;i++){
        if(i<pos-1){
            ans=max(ans,(ll)b[i]*b[pos-1]);
        }
        if(vis[b[i]]>=4) ans=max(ans,(ll)b[i]*b[i]);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n;
  cin >> n;
  ll a=0;
  for(int i=1;i<n+1;i++){
    ll b;
    cin >> b;
    if(b!=i)a++;
  }
  if(a<=2)cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3560
#include<iostream>
#include<algorithm>
using namespace std;
int n, m, c, d, b[1440], cnt;
int main() {
	cin >> n; for (int i = 0; i < n; i++) { cin >> c >> d; b[c * 60 + d] = 1; }
	cin >> m; for (int i = 0; i < m; i++) { cin >> c >> d; b[c * 60 + d] = 1; }
	for (int i = 0; i < 1440; i++) {
		if (b[i] == 1) {
			if (cnt) { cout << ' '; }
			cnt++;
			cout << i / 60 << ':';
			if (i % 60 < 10) { cout << '0'; }
			cout << i % 60;
		}
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 3096
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int Maxn=15,inf=0x3f3f3f3f;
int c[Maxn],s[Maxn];
int a[Maxn][Maxn];
int n,m,k,ans=inf;
inline int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0' && ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
inline bool check()
{
	for(int i=1;i<=m;++i)
	if(s[i]<k)return 1;
	return 0;
}
int main()
{
//	freopen("in.txt","r",stdin);
	n=read(),m=read(),k=read();
	for(int i=1;i<=n;++i)
	{
		c[i]=read();
		for(int j=1;j<=m;++j)
		a[i][j]=read();
	}
	for(int x=0;x<(1<<n);++x)
	{
		memset(s,0,sizeof(s));
		int tot=0;
		for(int i=0;i<n;++i)
		{
			if(!((x>>i) & 1))continue;
			++i,tot+=c[i];
			for(int j=1;j<=m;++j)
			s[j]+=a[i][j];
			--i;
		}
		if(check())continue;
		ans=min(ans,tot);
	}
	if(ans==inf)puts("-1");
	else printf("%d\n",ans);
	return 0;
}


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

map<int,vector<int> > mp_e;

int func(int N,vector<int> visit){
  int v_size = visit.size();
  if(v_size==N){return 1;}
  
  int r = 0;
  vector<int> es = mp_e[visit.at(v_size-1)];
  REP(i,es.size()){
    int e = es.at(i);
    bool flag = true;
    REP(i,v_size){
      if(e==visit.at(i)){flag = false; break;}
    }
    if(flag){
	    visit.push_back(e);
    	r += func(N,visit);
    	visit.pop_back();
    }
  }
  return r;
}

int main(){
  int N,M; cin >>N>>M;
  
  for(int i=1;i<N+1;i++){
    mp_e[i] = {};
  }
  REP(i,M){
    int a,b; cin >>a >>b;
    mp_e[a].push_back(b);
    mp_e[b].push_back(a);
  }
  vector<int> start = {1};
  printf("%d\n",func(N,start));
}

Measured memory_bytes: 256
### constant

#     (+x,+y,+z,-z,-y,-x)
DICE = [0, 1, 2, 3, 4, 5]

INF = 1 << 30

### subroutines

def rot_x(dc0, n = 1)
  d = dc0.clone
  n.times do
    t = d[1]; d[1] = d[3]; d[3] = d[4]; d[4] = d[2]; d[2] = t
  end
  d
end

def rot_y(dc0, n = 1)
  d = dc0.clone
  n.times do
    t = d[2]; d[2] = d[5]; d[5] = d[3]; d[3] = d[0]; d[0] = t
  end
  d
end

def rot_z(dc0, n = 1)
  d = dc0.clone
  n.times do
    t = d[0]; d[0] = d[4]; d[4] = d[5]; d[5] = d[1]; d[1] = t
  end
  d
end

def calc_min_repaint(dcs)
  count = 0
  
  for i in (0...6)
    cs = [0] * $nc
    (0...$n).each{|k| cs[dcs[k][i]] +=1}
    count += $n - cs.max
  end

  count
end

def min_r_rec(k, dcs)
  if k >= $n
    return calc_min_repaint(dcs)
  end

  min_r = INF

  $rots.each do |rot|
    dc = (0...6).map{|i| $dices[k][rot[i]]}
    r = min_r_rec(k + 1, dcs + [dc])
    min_r = r if min_r > r
  end

  min_r
end

def min_repaint
  min_r_rec(1, [$dices.first])
end

### main

$rots = []

for zr in (0...4)
  for yr in (0...4)
    for xr in (0...4)
      $rots << rot_z(rot_y(rot_x(DICE, xr), yr), zr)
    end
  end
end
$rots.sort!.uniq!
$nrots = $rots.length
#p $rots; exit

loop do
  $n = gets.to_i
  break if $n == 0

  cnmhash = {}
  $nc = 0
  $dices = []
  
  $n.times do
    cnms = gets.strip.split
    $dices << cnms.map do |cnm|
      if cnmhash[cnm].nil?
        cnmhash[cnm] = $nc
        $nc += 1
      end
      cnmhash[cnm]
    end
  end
  #p $nc
  #p $dices

  p min_repaint
end

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

int main()
{
	int T,N;
	cin >> T;
	while(T--)
	{
		cin >> N;
		int book[10005]={0};

		for(int k=0; k<2; k++)
		{
			string str; char c;
			for(int i=0; i<2*N; i++)
			{
				cin >> c; str+=c;
			}
			str = "N" + str + "N";

			for(int i=0; i<N+1; i++)
			{
				if(str[i*2]=='Y' || str[i*2+1]=='Y')
				{
					book[i] |= (1<<k);
				}
			}
		}

		int a=0,b=1,na,nb;
		for(int i=0; i<N+1; i++)
		{
			switch(book[i])
			{
				case 0:
					na = a;
					nb = b;
					break;

				case 1:
					na = min(a+1,b+1);
					nb = min(b+1,a+1);
					break;

				case 2:
					na = min(a+3,b+2);
					nb = min(b+1,a+2);
					break;

				case 3:
					na = min(a+3,b+2);
					nb = min(b+2,a+2);
					break;
			}

			a = na+1;
			b = nb+1;
		}

		cout << a-1 << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if(a%3==0 || b%3==0 || (a+b)%3==0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;

    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void){
    int n,limitt;
    int c,t,ans=100000;
    cin >> n >> limitt;
    for(int i=0; i<n; i++){
        cin >> c >> t;
        if(t<=limitt){
            if(ans>c)ans=c;
        }
    }
    if(ans==100000){
        cout << "TLE" << endl;
    }
    else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
using Int = int64_t;
template< typename T >
T pow(T x, T n) {
  T ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
}
int main() {
    Int X;
    cin >> X;
    for (Int A = -118; A <= 119; A++) {
        for (Int B = -119; B <= 118; B++) {
            if (pow(A, (Int)5) - pow(B, (Int)5) == X) {
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define maxn 200010
using namespace std;
struct data{int l, r, x;};
int len[maxn], n;
data A[maxn];
bool check(int x)
{
	int cnt = 0;
	for (int i = 1; i <= n; i++)
	{
		if (len[i] > len[i - 1])
		{
			A[++cnt] = (data){len[i - 1] + 1, len[i], 1};
			continue;
		}
		while (A[cnt].l > len[i]) cnt--;
		A[cnt].r = len[i];
		while (cnt && A[cnt].x == x) cnt--;
		if (cnt == 0) return false;
		int pos = A[cnt].r, tp = A[cnt].x + 1;
		if (A[cnt].r == A[cnt].l) cnt--;
		else A[cnt].r--;
		A[++cnt] = (data){pos, pos, tp};
		if (pos != len[i]) A[++cnt] = (data){pos + 1, len[i], 1};
	}
	return true;
}
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &len[i]);
	int lef = 1, righ = n, res = 0;
	while (lef <= righ)
	{
		int mid = (lef + righ) / 2;
		if (check(mid)) {res = mid; righ = mid - 1;}
		else lef = mid + 1;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
using namespace std;


#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<VV> VVV;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}


int main() {
	int y1 = 0,y2=0;
	string s;
	cin >> s;
	int count = -1;
	for (int i = 0; i < s.length(); i++) {
		count += 1;
		if (((count % 2 == 1) && (s[i] == '0'))||((count % 2 == 0) && (s[i] == '1'))) {
			y1 += 1;
		}
		if (((count % 2 == 1) && (s[i] == '1')) || ((count % 2 == 0) && (s[i] == '0'))) {
			y2 += 1;
		}
	}

	cout << min(y1, y2) << endl;

}


Measured memory_bytes: 512
import std.algorithm,
       std.string,
       std.array,
       std.stdio,
       std.range,
       std.conv;

long abs(long x) {
  return x * (x < 0 ? -1 : 1);
}

void main() {
  long   N = readln.chomp.to!long;
  long[] a = readln.chomp.split.to!(long[]);
  long ans = long.max;

  long x, y;

  for (size_t i = 0; i < N - 1; i++) {
    if (i == 0) {
      x = a[i];
      y = a[1..$].sum;
    } else {
      x += a[i];
      y -= a[i];
    }

    long z = abs(x - y);

    if (z < ans) {
      ans = z;
    }
  }

  writeln(ans);
}


Measured memory_bytes: 11268
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	      String line;
	      while ((line = in.readLine()) != null) { 

			String[] ab = line.split(" ");

			int a = Integer.parseInt(ab[0]);
			int b = Integer.parseInt(ab[1]);

			 String out =Integer.toString(a+b);
			 System.out.println(out.length());
			
		}

	}
}

Measured memory_bytes: 16996
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
         s = input()
         if s == "AC":
                  ac += 1
         elif s == "WA":
                  wa += 1
         elif s == "TLE":
                  tle += 1
         elif s == "RE":
                  re += 1
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))


Measured memory_bytes: 9200
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int c = 0;
        while(X >= 500) {
            X -= 500;
            c += 1000;
        }
        while(X >= 5) {
            X -= 5;
            c += 5;
        }
        System.out.println(c);
    }
}



Measured memory_bytes: 23764
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

const int MAX_V = 1e5;
const int64_t INF = 1e18;

struct edge {
  int64_t to, cost;
};

int n;
std::vector<edge> G[MAX_V];
int64_t dis[MAX_V];

void dijkstra(int s){
  std::priority_queue<std::pair<int64_t, int64_t>,
                      std::vector<std::pair<int64_t, int64_t>>,
                      std::greater<std::pair<int64_t, int64_t>>> pq;
  std::fill(dis, dis + n, INF);
  dis[s] = 0;
  pq.push(std::pair<int64_t, int64_t>(0, s));

  while (!pq.empty()){
    std::pair<int64_t, int64_t> p = pq.top(); pq.pop();
    int64_t v = p.second;
    if (dis[v] < p.first) continue;
    for (int i = 0; i < (int) G[v].size(); ++i){
      edge e = G[v][i];
      if (dis[e.to] > dis[v] + e.cost){
        dis[e.to] = dis[v] + e.cost;
        pq.push(std::pair<int64_t, int64_t>(dis[e.to], e.to));
      }
    }
  }
}

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

  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int64 u, v, w; cin >> u >> v >> w;
    --u; --v;
    G[u].push_back({v, w});
    G[v].push_back({u, w});
  }

  dijkstra(0);
  // for (int i = 0; i < n; ++i) debug(dis[i]);

  vector<int> ans;
  for (int i = 0; i < n; ++i) {
    if (dis[i] & 1) ans.push_back(1);
    else ans.push_back(0);
  }
  for (auto x : ans) {
    print(x);
  }

  return 0;
}

Measured memory_bytes: 9212
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int a, b; cin >> a >> b;
	Cout(a*b);
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define f(n) for(i=0;i<n;i++)
using namespace std;
string b,g;
int main()
{
	cin>>b;
	if(b=="A")
	{
		cout<<"T";
	}
	else if(b=="T")
	{
		cout<<"A";
	}
	else if(b=="G")
	{
		cout<<"C";
	}
	else
	{
		cout<<"G";
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ls (x<<1)
#define rs (x<<1|1)
#define db double
#define inf 2147483647
#define llinf 9223372036854775807
#define ll long long
using namespace std;
int inline read(){
    int num=0,neg=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
    while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
    return num*neg;
}
const int maxn=510,mod=998244353;
int n,m,a[maxn][maxn],b[2][maxn][maxn];char str[maxn];
int main(){
	n=read();m=read();
	for(int i=1;i<=n;i++){
		scanf("%s",str+1);
		for(int j=1;j<=m;j++){
			if(str[j]=='#')a[i][j]=b[0][i][j]=b[1][i][j]=1;
		}
	}
	for(int i=1;i<=n;i++)b[0][i][1]=b[1][i][m]=1;
	for(int i=1;i<=n;i++)
		for(int j=2;j<m;j++)
			if(i&1)b[0][i][j]=1;else b[1][i][j]=1;
	for(int k=0;k<2;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++)
				if(b[k][i][j])cout<<"#";
				else cout<<".";
			cout<<endl;
		}cout<<endl;
	}
	return 0;
}

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

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

using namespace std;

signed main()
{
	int n, ans = 1;
	cin >> n;

	string s;
	cin >> s;

	for (int i = 1; i < s.size(); i++)
	{
   		if (s[i] != s[i-1])
   		{
   			ans++;
   		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a<b) System.out.println("a < b");
		else if(a>b) System.out.println("a > b");
		else System.out.println("a == b");
	}
}



Measured memory_bytes: 26212
#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,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back

signed main(){
    map<int,int>memo;
    REP(i,3){
        int a;cin>>a;
        memo[a]++;
    }
    int ans=0;
    for(auto v:memo)ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static int ArgMax<T>(IList<T> a) where T : IComparable<T> { var m = a[0]; var mi = 0; for (var i = 1; i < a.Count; i++) if (m.CompareTo(a[i]) < 0) { m = a[i]; mi = i; } return mi; }
	static int ArgMin<T>(IList<T> a) where T : IComparable<T> { var m = a[0]; var mi = 0; for (var i = 1; i < a.Count; i++) if (m.CompareTo(a[i]) > 0) { m = a[i]; mi = i; } return mi; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		WriteLine(I[0] - I[1] + 1);
	}
}


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

int main () {
  int64_t l, r; 
  cin >> l >> r;
  int ans = 2020;
  for (int64_t i=l;i<r;i++) {
    for (int64_t j=l;j<=r;j++) {
      if (j<=i)
        continue;
      if ((i*j)%2019 < ans)
        ans = (i*j)%2019;
      if (ans == 0) {
        cout << "0";
        return 0;
      }
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<queue>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 100000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
ll dp[100][100][100];
int main()
{
	int num, kai;
	scanf("%d%d", &num, &kai);
	string s;
	cin >> s;
	invinit();
	ll ans = 0;
	for (int p = 0; p <= kai / 2; p++)
	{
		for (int q = 0; q <= kai - p * 2; q++)
		{
			if (p + q + (p + q - 1)>num)continue;
			int d[100];
			fill(d, d + 100, 0);
			queue<int>que;
			int np = 0;
			for (int i = 0; i < s.size(); i++)
			{
				if (np == p)break;
				if (s[i] == 'r')que.push(i);
				else
				{
					if (que.empty())continue;
					int z = que.front();
					que.pop();
					d[z] = 1, d[i] = 2;
					np++;
				}
			}
			if (np != p)continue;
			int nq = 0;
			for (int i = 0; i < s.size(); i++)
			{
				if (nq == q)break;
				if (d[i] == 0 && s[i] == 'r')d[i] = 3, nq++;
			}
			if (nq != q)continue;
			//printf("%d %d ", p, q);
			//for (int i = 0; i < kai; i++)printf("%d", d[i]); printf("\n");
			vector<int>v;
			int cnt = 0;
			for (int i = s.size() - 1; i >= 0; i--)
			{
				if (d[i] == 0)cnt++;
				if (d[i] == 2)v.push_back(cnt);
			}
			for (int i = 0; i <= v.size(); i++)for (int j = 0; j <= cnt + 1; j++)for (int k = 0; k <= cnt + 1; k++)dp[i][j][k] = 0;
			dp[0][0][0] = 1;
			for (int i = 0; i <= v.size(); i++)
			{
				for (int j = 0; j <= cnt; j++)
				{
					for (int k = 0; k <= cnt; k++)
					{
						if (dp[i][j][k] == 0)continue;
						dp[i][j][k + 1] = (dp[i][j][k + 1] + dp[i][j][k]) % mod;
						for (int l = 1; i + l <= v.size(); l++)
						{
							if (v[i + l - 1] < j + k*l)break;
							dp[i + l][j + k*l][k + 1] = (dp[i + l][j + k*l][k + 1] + dp[i][j][k] * com(i + l, l)) % mod;
						}
					}
				}
			}
			ll t[100];
			for (int i = 0; i <= cnt; i++)t[i] = dp[v.size()][i][cnt + 1];
			//for (int i = 0; i <= cnt; i++)printf(" %lld", t[i]); printf("\n");
			ll sum = 0;
			for (int i = 0; i <= cnt; i++)
			{
				int ned = q + p + 2 * i + (p + q - 1);
				int add = q + 3 * p + 2 * i + (p + q + 1);
				if (ned > num)continue;
				sum += t[i] * com(num - ned + add - 1, add - 1);
				sum %= mod;
			}
			//printf(" %lld\n", sum);
			ans = (ans + sum*com(p + q, p)) % mod;
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 7424
N,X=map(int,input().split())

#レベルiにおけるそれぞれの枚数，総数
P=[1]*(N+1)
B=[0]*(N+1)
S=[1]*(N+1)

for i in range(N):
    P[i+1]=P[i]*2+1
    B[i+1]=B[i]*2+2
    S[i+1]=P[i+1]+B[i+1]
    
def rec(l,x,temp):
    if x==0:
        return temp
    if x==S[l]:
        return temp+P[l]
    if x>=2+S[l-1]:#中心を超える
        return rec(l-1,x-(S[l-1]+2),temp+P[l-1]+1)
    return rec(l-1,x-1,temp)

print(rec(N,X,0))

Measured memory_bytes: 38256
N=int(input())
W=list(map(int, input().split()))
ans = 5000000000
for T in range(N):
  if ans > abs(sum(W[0:T+1])-sum(W[T+1:N])):
    ans = abs(sum(W[0:T+1])-sum(W[T+1:N]))
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int n, k;
  cin >> n >> k;
  double ans = 0;
  vector<double> p(n, 1.0/n);

  REP(i, n){
    int score = i+1;
    while(score < k){
      score *= 2;
      p[i] /= 2;
    }
    ans += p[i];
  }
  printf("%.10f\n", ans);
  return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    cout << (double(r) * 2.0 * 3.141592) << endl;

    return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define INF 1e9
#define endl '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define FORE(i, a, b) for (int i = (a), e = (b); i < e; ++i)
#define RFORE(i, a, b) for (int i = (b)-1, e = (a); i >= e; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B;
    cin >> A >> B;
    int ans = 0;
    FOR(i, A, B + 1) {
        string s = to_string(i);
        string r = s;
        reverse(ALL(r));
        if (s == r) { ++ans; }
    }
    cout << ans << endl;
}


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

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

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

int a[1000005];
string s; 
int n;

bool check(){
    bool res = true;
    

    if(a[n-1] == 1){
        if(!((s[n-1] == 'o' && a[n-2] == a[0]) || (s[n-1] == 'x' && a[n-2] != a[0]))){
            res = false;   
        }
    }else{
        if(!((s[n-1] == 'x' && a[n-2] == a[0]) || (s[n-1] == 'o' && a[n-2] != a[0]))){
            res = false;   
        }
    }
    if(a[0] == 1){
        if(!((s[0] == 'o' && a[n-1] == a[1]) || (s[0] == 'x' && a[n-1] != a[1]))){
            res = false;   
        }
    }else{
        if(!((s[0] == 'X' && a[n-1] == a[1]) || (s[0] == 'o' && a[n-1] != a[1]))){
            res = false;   
        }
    }
    return res;
}

void p(){
    rep(i,n){
        if(a[i] == 1) cout << 'S';
        else cout << 'W';
    }
    cout << endl;
}

void make(){
    for(int i = 2; i < n; i++){
        if(a[i-1] == 1){
            if(s[i-1] == 'o') a[i] = a[i-2];
            else a[i] = (-1*a[i-2]);
        }else{
            if(s[i-1] == 'o') a[i] = (-1*a[i-2]);
            else a[i] = a[i-2];
        }
    }
}

int main()
{
    cin >> n; cin >> s;
    
    a[0] = 1; a[1] = 1;
    make();
    if(check()){
        p();
        return 0;
    }

    a[0] = 1; a[1] = -1;
    make();
    if(check()){
        p();
        return 0;
    }

    a[0] = -1; a[1] = 1;
    make();
    if(check()){
        p();
        return 0;
    }

    a[0] = -1; a[1] = -1;
    make();
    if(check()){
        p();
        return 0;
    }
    cout << -1 << endl;
}

Measured memory_bytes: 896
#include <stdio.h>
int main(void){
    int n,dice[101][6]={},w=1,x=1,m=1,y=0,t=1,f=2,r=3,d;
    scanf("%d",&n);for(int i=1;i<=n;i++){for(int l=1;l<=6;l++){scanf("%d",&dice[i][l]);}}
    for(int i=1;i<=n-1;i++){for(int l=1;i+l<=n;l++){w=1;x=1;m=1;while(1){
        if(dice[l][t]==dice[i+l][1]&&dice[l][f]==dice[i+l][2]&&dice[l][r]==dice[i+l][3]&&dice[l][7-r]==dice[i+l][4]&&dice[l][7-f]==dice[i+l][5]&&dice[l][7-t]==dice[i+l][6]){y=1;break;}
        if(w<=4){w++;d=t;t=f;f=7-d;continue;}
        if(x<=4){w=1;x++;d=r;r=t;t=7-d;continue;}
        if(m<=4){w=1;x=1;m++;d=r;r=f;f=7-d;continue;}
        if(m==5)break;
    }}}
    if(y==1)printf("No\n");
    if(y==0)printf("Yes\n");
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

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

  int ret = 0;
  for (int i=0; i<S.length(); ++i) {
    for (int j=0; j<=S.length(); ++j) {
      string s = S.substr(i,j);
      if (count(s.begin(),s.end(),'A') + count(s.begin(),s.end(),'T')
	  + count(s.begin(),s.end(),'G') + count(s.begin(),s.end(),'C') == s.length())
	ret = max(ret, (int)s.length());
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int 
ll a[100005];
int main(){
  ll i,j,k,n,m,t;
  cin>>n;
  for(i=1;i<=n;i++) cin>>a[i];
  if(n & 1){
   cout<<"0\n"; 
  }
  else {
   sort(a+1,a+n+1);
   if(a[n/2]==a[n/2+1]) cout<<"0\n";
    else {
      cout<<a[n/2+1]-a[n/2]<<"\n";
    }
  }
  
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		int a,b,c,k;
		cin>>a>>b>>c;
		cin>>k;
		while(k>0 and b <= a) {
			b *= 2;
			k--;
		}
		while(k >0 and c<=b) {
			c *= 2;
			k--;
		}
//		cout<<a<<b<<c<<k;
		if(c > b and b > a) {
			cout<<"Yes\n";
		} else {
			cout<<"No\n";
		}
 	}
 	return 0;
}


Measured memory_bytes: 3644