akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;

int main()
{
	int A,B,C,X,Y;
	cin>>A>>B>>C>>X>>Y;
	int sum = 0;
	if( A + B > (2*C)){
		int Z = min(X,Y);
		sum += 2*Z*C;
		X -= Z;
		Y -= Z;
	}
	if( A > 2*C){
		sum += 2*X*C;
		X = 0;
		Y = max(0,Y-X);
	}
	if( B > 2*C){
		sum += 2*Y*C;
		Y = 0;
		X = max(0,X-Y);
	}
	sum += A*X + B*Y;
	cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, n, debt;
	scanf("%d", &n);
	debt = 100000;
	for (i = 0 ; i < n; i++){
		debt *= 1.05;
		if (debt % 1000 != 0){
			debt = debt / 1000 * 1000 + 1000;
		}
		else {
			debt = debt / 1000 * 1000;
		}
		
	}
	printf("%d\n", debt);
	return (0);
}

Measured memory_bytes: 592
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s[] = new String[N];
		for (int i = 0; i < N; i++) {
			s[i] = sc.next();
		}
		String t[] = new String[N];
		for (int i = 0; i < N; i++) {
			char[] chars = s[i].toCharArray();
			Arrays.sort(chars);
			t[i] = new String(chars);
		}
		Arrays.sort(t);
		long ans = 0;
		int tmp = 0;
		for (int i = 0; i < N - 1; i++) {
			if (t[i].equals(t[i + 1])) {
				tmp++;
			} else {
				ans += ((long)(tmp+1)*tmp)/2; 
				tmp = 0;
			}
		}
			ans += ((long)(tmp+1)*tmp)/2; 
			tmp = 0;
		System.out.println(ans);
	}
}

Measured memory_bytes: 50988
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CAttackSurvival {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N, K, Q;
        cin >> N >> K >> Q;
        vector<int> w(N);
        REP(i, Q) {
            int a;
            cin >> a;
            a--;
            w[a]++;
        }
        REP(i, N) {
            int l = Q - w[i];
            cout << (l >= K ? "No" : "Yes") << endl;
        }

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CAttackSurvival solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1408
def input(f):
    V, E = map(int, f.readline().split())
    s = [None for _ in range(E)]
    t = [None for _ in range(E)]
    for i in range(E):
        s[i], t[i] = map(int, f.readline().split())
    return V, E, s, t

def solve(V, E, s, t):
    graph = [[] for _ in range(V)]
    for i in range(E):
        graph[s[i]].append(t[i])
    
    order = []
    used = [False for _ in range(V)]
    def visit(cur):
        if used[cur]:
            return
        used[cur] = True
        for nxt in graph[cur]:
            visit(nxt)
        order.append(cur)
    
    for i in range(V):
        visit(i)
    
    for v in reversed(order):
        print(v)

with open('/dev/stdin') as f:
    solve(*input(f))


Measured memory_bytes: 10256
#include <bits/stdc++.h>
using namespace std;
int minimumChar(string S1, string S2)
{
 
    int n = S1.size(), m = S2.size();

    int ans = INT_MAX;

    
    for (int i = 0; i < m - n + 1; i++) {
        int minRemovedChar = 0;
        for (int j = 0; j < n; j++) {
            if (S1[j] != S2[i + j]) {
                minRemovedChar++;
            }
        }
        ans = min(minRemovedChar, ans);
    }
return ans;
}
int main()
{
    string S1 ,S2;
    cin>>S1>>S2;

    cout << minimumChar(S2, S1);

    return 0;
}


Measured memory_bytes: 3584
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]

ans = 0
for i in 2..N-1 do
  if lines[1][i-2..i].sort[1] == lines[1][i-1] then
    ans += 1
  end
end
  
print ans

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, a, mn = 1e9;
    cin >> n;
    while (n--) {
        cin >> a;
        int cnt = 0;
        while (!(a&1)) {
            a >>= 1;
            cnt++;
        }
        mn = min(mn, cnt);
    }
    cout << mn << endl;
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  char c; cin >> c;
  if ('A' <= c && c <= 'Z') {
    cout << 'A' << endl;
  }else {
    cout << 'a' << endl;
  }

  return 0;
}



Measured memory_bytes: 3640
from collections import deque
N=int(input())
point=[list(map(int,input().split())) for _ in range(N)]
ans=float("inf")
for i in range(N):
    for j in range(i+1,N):
        x1,y1=point[i]
        x2,y2=point[j]
        vec=[x1-x2,y1-y2]
        tree=[[] for _ in range(N)]
        col=[-1]*N
        for k in range(N):
            for l in range(k+1,N):
                xa, ya = point[k]
                xb, yb = point[l]
                if ((vec[0]==xa-xb)and(vec[1]==ya-yb))or((-vec[0]==xa-xb)and(-vec[1]==ya-yb)):
                    tree[k-1].append(l-1)
                    tree[l-1].append(k-1)
        for k in range(N):
            d=deque()
            if col[k]==-1:
                d.append(k)
            while len(d)>0:
                v=d.popleft()
                col[v]=k
                for l in tree[v]:
                    if col[l]==-1:
                        d.append(l)
        #print(col)
        #print(set(col))
        ans=min(ans,len(set(col)))
if N==1:
    print(1)
else:
    print(ans)

Measured memory_bytes: 58460
#include<stdio.h>
int main(){
  int n,q,s[10000],t[500],i,j,count=0;

  scanf("%d",&n);
  for(i=0; i < n; i++){
    scanf("%d",&s[i]);
  }
   scanf("%d",&q);
  for(i=0; i < q; i++){
    scanf("%d",&t[i]);
  }

  for(i = 0; i < q; i++){
    for(j = 0; j < n; j++){
      if(t[i] == s[j]){
	count+=1;
	break;
      }
    }
  }

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

Measured memory_bytes: 640
// Try AtCoder
// author: Leonardone

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    if n % 2 != 0 {
        println!("0");
        return;
    }
    let mut f = 5;
    let mut ans = 0;
    while f < n {
        ans += n / f / 2;
        // println!("{}", ans);
        f *= 5;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
object Main {
  import scala.io.StdIn.readLine
  def main(args: Array[String]): Unit = {
    val k = readLine.trim().toInt
    val ab = readLine.split(" ").map(_.toInt)
    val a = ab(0)
    val b = ab(1)

    if((k - (a % k)) % k <= b - a) {
      println("OK")
    } else {
      println("NG")
    }
  }
}


Measured memory_bytes: 54472
#include <bits/stdc++.h>
using namespace std;
long long A,B,N;

int main(){
  cin >> A >> B >> N;
  if(N >= B){
    cout << floor((A*(B-1))/B) << endl;
  }
  else{
    cout << floor((A*N)/B) << endl;
  }
}

Measured memory_bytes: 3800
N, K, L = [int(_) for _ in input().split()]

par = [i for i in range(2 * N)]
rank = [0] * (2 * N)


def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return

    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1


def same(x, y):
    return find(x) == find(y)


for _ in range(K):
    p, q = [int(_) - 1 for _ in input().split()]
    unite(p, q)
for _ in range(L):
    r, s = [int(_) + N - 1 for _ in input().split()]
    unite(r, s)
memo = {}
for i in range(N):
    memo[find(i), find(i + N)] = memo.get(
        (find(i), find(i + N)), 0) + 1

print(' '.join(str(memo[find(i), find(i + N)])
               for i in range(N)))


Measured memory_bytes: 68512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;
typedef long long ll;

int main(){
    ll N, K, ans=0, n;
    cin >> N >> K;
    for(ll a=1; a<=N; a++){
        if(2*a%K == 0){
            n = (a+N)/K - a/K;
            ans += n*n;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));

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

    string s;
    cin >> s;
    char ans = s[s.length()-1];
    if(ans == '2' || ans == '4'||ans=='5'||ans=='7'||ans=='9' ){
        cout << "hon" << endl;
    }
    else if(ans=='3'){
        cout << "bon" << endl;
    }else{
        cout << "pon" << endl;
    }


    cout << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

struct edge{
    ll to;
    ll cost;
    edge(ll t, ll c){
        to = t;
        cost = c;
    }
};

struct fulledge{ //* u->v with cost
    ll u, v, cost;
    fulledge(){}
    fulledge(ll _u, ll _v, ll _c){
        u = _u; v = _v; cost = _c;
    }

    bool operator< ( fulledge const &e) const {
        return cost < e.cost;
    }
};

struct edgeGreater{
    bool operator()(const fulledge &e1, const fulledge &e2){
        return e1.cost > e2.cost;
    }
};

//* simplest bellman-ford shortest path calculator
bool BellmanFord(vector<fulledge> &es, vector<ll> &dist, ll s){
    ll N = dist.size();
    ll M = es.size();
    fill(dist.begin(), dist.end(), INF);
    dist[s] = 0;
    bool update;
    rep(k, N){
        update = false;
        rep(i, M){
            fulledge e = es[i];
            if(dist[e.u]!=INF && dist[e.v] > dist[e.u]+e.cost) {
                dist[e.v] = dist[e.u] + e.cost;
                update = true;
            }
        }
        if(!update) 
            break;
    }
    return update;
}
//* http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_B&lang=jp
int main(){
    ll N, M, s;
    cin >> N >> M >> s;
    vector<fulledge> es;
    ll u, v, c;
    rep(i, M){
        cin >> u >> v >> c;
        es.push_back(fulledge(u, v, c));
    }
    vector<ll> dist(N);
    bool isBad = BellmanFord(es, dist, s);
    if(isBad)
        cout << "NEGATIVE CYCLE" << endl;
    else{
        rep(i, N){
            if(dist[i]>= INF) 
                cout << "INF" << endl;
            else{
                cout << dist[i] << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3148
import java.util.Scanner;

class Main{
	public static void main(String[] args){
    	int n,m,l;
    	Scanner sc = new Scanner(System.in);
    	n = sc.nextInt();
        m = sc.nextInt();
        l = sc.nextInt();
        int [][] a = new int [n][m];
        int [][] b = new int [m][l];
        long [][] c = new long [n][l];

    	for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				a[i][j] = sc.nextInt();
			}
    	}

    	for(int i = 0; i < m; i++){
			for(int j = 0; j < l; j++){
				b[i][j] = sc.nextInt();
			}
    	}
    	sc.close();

    	for(int i = 0; i < n; i++){
			for(int j = 0; j < l; j++){
				for(int k = 0; k < m; k++){
					c[i][j] += a[i][k]*b[k][j];
				}
			}
    	}

    	for(int i = 0; i < n; i++){
			for(int j = 0; j < l; j++){
				if(j != l-1){
					System.out.print(c[i][j]+" ");
				}
				else{
					System.out.println(c[i][j]);
				}
			}
    	}

    }
}

Measured memory_bytes: 54148
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<map>
#include<stack>
using namespace std;
const int N=100000+5;
const int inf=0x3f3f3f3f;
void getint(int&num){
    char c;int flag=1;num=0;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
    while(c>='0'&&c<='9'){num=num*10+c-48;c=getchar();}
    num*=flag;
}
int A,B,m,a[N],b[N],x=inf,y=inf,c;
int main(){
	getint(A),getint(B),getint(m);
	for(int i=1;i<=A;i++)
		getint(a[i]),x=min(x,a[i]);
	for(int i=1;i<=B;i++)
		getint(b[i]),y=min(y,b[i]);
	int ans=x+y;
	while(m--){
		getint(x),getint(y),getint(c);
		ans=min(ans,a[x]+b[y]-c);
	}
	printf("%d\n",ans);
	return 0;
}
/*

*/

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<numeric>
#include<cstdint>

int const MAXN = 1e5;
int N;
int64_t M, A[MAXN], sum[MAXN+1];

int64_t count(int th) {
  int64_t c = 0;
  int j = N-1;
  for(int i = 0; i < N; ++i) {
    if(A[i]*2 < th) break;
    while(j > i && A[i]+A[j] < th) --j;
    ++j;
    c += (int64_t)(j-i)*2-1;
    j = std::min(j, N-1);
  }
  return c;
}

int64_t calc(int th) {
  int64_t res = 0;
  int j = N-1;
  for(int i = 0; i < N; ++i) {
    if(A[i]*2 < th) break;
    while(j > i && A[i]+A[j] < th) --j;
    ++j;
    res += (sum[j-1] - sum[i] + (j-i)*A[i])*2;
    j = std::min(j, N-1);
  }
  return res;
}

int main() {
  std::cin >> N >> M;
  for(int i = 0; i < N; ++i) std::cin >> A[i];
  std::sort(A, A+N, [](int l, int r){ return l > r; });
  // 
  int thH = A[0]*2, thL = A[N-1]*2;
  while(thH > thL + 10) {
    int thM = (thH+thL)/2;
    if(count(thM) >= M) thL = thM;
    else thH = thM-1;
  }
  int th[11];
  std::iota(th, th+(thH-thL+1), thL);
  thL = *(std::partition_point(th, th+(thH-thL+1), [&](int t){ return count(t)>=M; }) - 1);
  sum[0] = A[0];
  for(int i = 1; i < N; ++i) sum[i] = sum[i-1]+A[i];
  int64_t ans =  calc(thL) - (count(thL) - M)*thL;
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

int main()
{
	int n;cin>>n;
	if(n%10==7||(n/10)%10==7||n/100==7) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include<iostream>

using namespace std;


char s[100001];
long int k = 0;
int n = 0;
int main(void) {
	

	

	cin >> s;
	cin >> k;


	int Len = strlen(s)-1;

	for (int i = 0; i < Len; i++) {
		if (s[i] != 'a') {
			//aにするのに必要な数
			n = ('z' - s[i]) + 1;
			if (k - n >= 0) {
				k -= n;
			}
			else {
				cout << s[i];
				continue;
			}
		}
		cout << 'a';
	}	
	if (k != 0) {
	
		cout<< (char)('a'+(((s[Len] - 'a') + k) % 26));
	}
	else {
		cout << s[Len];
	}
	cout << '\n';

	return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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 ll INF=1e15;

int main(){
    ll n,t;
    cin >> n >> t;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    vector<ll> b(n+1,0);
    rep(i,n){
        if(i+1==1) b[i+1]=a[n-1];
        else b[i+1]=max(b[i],a[n-1-i]);
    }
    map<ll,ll> m;
    rep(i,n-1){
        ll dif=max(0LL,b[n-1-i]-a[i]);
        if(dif>0){
            m[dif]++;
        }
    }
    ll ans=0;
    for(auto x:m){
        ans=x.se;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8064
(princ 
  (let ( (y 0) (k (read)) (a (read)) (b (read)) )
    (setq y 
      (do ( (x 0) ) 
          ( (or (>= x a) (>= x b)) x) 
        (setq x (+ x k)))) 
    (if (<= y b) "OK" "NG")))


Measured memory_bytes: 23400
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,D,A;
    cin >> N >> D >> A;
    vector<P>cnt(N);
    for(int i = 0; i < N; i++) {
        cin >> cnt[i].first >> cnt[i].second;
    }
    sort(cnt.begin(),cnt.end());
    vector<int>sum(N+2);
    int ans = 0;
    for(int i = 0; i < N; i++) {
        sum[i+1]+=sum[i];
        cnt[i].second-=sum[i+1];
        if(cnt[i].second <= 0) {
            continue;
        }
        ans += (cnt[i].second+A-1)/A;
        sum[i+1] += (cnt[i].second+A-1)/A*A;
        sum[upper_bound(cnt.begin(),cnt.end(),make_pair(cnt[i].first+D*2,INF))-cnt.begin()+1]-=(cnt[i].second+A-1)/A*A;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7928
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest._600problems
{
    class Nikkei_2019_Qual_C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] aArray = ReadInts();
            int[] bArray = ReadInts();
            int[][] aSorted = new int[n][];
            int[][] bSorted = new int[n][];
            for(int i = 0; i < n; i++)
            {
                aSorted[i] = new int[2] { aArray[i], i };
                bSorted[i] = new int[2] { bArray[i], i };
            }
            Array.Sort(aSorted, (a, b) => a[0] - b[0]);
            Array.Sort(bSorted, (a, b) => a[0] - b[0]);
            for(int i = 0; i < n; i++)
            {
                if (aSorted[i][0] > bSorted[i][0])
                {
                    WriteLine("No");
                    return;
                }
            }

            for (int i = 0; i < n; i++)
            {
                if (aSorted[i][1] == bSorted[i][1])
                {
                    WriteLine("Yes");
                    return;
                }
            }

            for (int i = 0; i < n - 1; i++)
            {
                if (aSorted[i + 1][0] <= bSorted[i][0])
                {
                    WriteLine("Yes");
                    return;
                }
            }

            int[][] sets = new int[n][];
            var zipped = new Dictionary<int, int>();
            for (int i = 0; i < n; i++)
            {
                sets[i] = new int[2] { aArray[i], bArray[i] };
                zipped.Add(aSorted[i][0], i);
            }
            Array.Sort(sets, (a, b) => a[1] - b[1]);

            int cnt = 0;
            for (int i = 0; i < n - 1; i++)
            {
                if (aSorted[i][1] != bSorted[i][1])
                {
                    cnt++;
                    int to = aSorted[i][1];
                    aArray[to] = aArray[bSorted[i][1]];
                    int index = zipped[aArray[bSorted[i][1]]];
                    aSorted[index][1] = to;
                }
            }
            WriteLine(cnt == n - 1 ? "No" : "Yes");
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 47508
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    bool yymm(string s) {
        int yy = stoi(s.substr(0, 2));
        int mm = stoi(s.substr(2, 2));
        return yy >= 0 && mm > 0 && mm < 13;
    }

    bool mmyy(string s) {
        int mm = stoi(s.substr(0, 2));
        int yy = stoi(s.substr(2, 2));
        return yy >= 0 && mm > 0 && mm < 13;
    }

    void solve() {
        input();
        string s;
        cin >> s;

        if (yymm(s) && mmyy(s)) {
            cout << "AMBIGUOUS" << endl;
        } else if (yymm(s)) {
            cout << "YYMM" << endl;
        } else if (mmyy(s)) {
            cout << "MMYY" << endl;
        } else {
            cout << "NA" << endl;
        }

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 760
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def root(x):
        if par[x] == x:
            return x
        par[x] = root(par[x])
        return par[x]

    def unite(x,y):
        x = root(x)
        y = root(y)
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1

    n = I()
    p = LIR(n)
    for i in range(n):
        p[i].append(i)
    p.sort()
    v = []
    for i in range(n-1):
        x,y,c = p[i]
        a,b,d = p[i+1]
        v.append((min(abs(x-a),abs(y-b)),c,d))
    p.sort(key = lambda x:x[1])
    for i in range(n-1):
        x,y,c = p[i]
        a,b,d = p[i+1]
        v.append((min(abs(x-a),abs(y-b)),c,d))
    v.sort()
    par = [i for i in range(n)]
    rank = [0]*n
    ans = 0
    for c,a,b in v:
        if root(a) != root(b):
            ans += c
            unite(a,b)
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


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

int main() {
  int a,b,n;
  cin >> a >> b;

  if ((b % a) == 0) {
    n = a + b;
  }
  else {
    n = b - a;
  }

  cout << n << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define int long long
#define hell 998244353  
#define endl "\n"
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX_SIZE 1000000000000000


int32_t main()
{   
    io

    string s1, s2;
    cin>>s1>>s2;

    int count=0;
    for(int i=0;i<s1.length();i++)
    {
        if(s1[i]==s2[i])
            count++;
    }

    cout<<count;



    
return 0;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string A;
map<char,ll> cnt;
void input(){
    fast_io();
    cin >> A;
}

int solve(){
    for (int i = 0; i < (int)A.length(); i++)
    {
        cnt[A[i]]++;
    }
    ll ans = 1LL;
    ll N = A.length();
    ans += N*(N-1)/2;
    for (char c = 'a'; c <= 'z'; c++)
    {
        ans -= cnt[c]*(cnt[c]-1LL)/2;
    }
    cout << ans << endl;    
    return 0;
}   

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

Measured memory_bytes: 3772
import math

def solve():
    powers = []
    n = 0
    c = 0
    while n < (2 * 10 ** 20):
        n = c ** 5
        c += 1
        powers.append(n)
    for p in powers:
        for pp in powers:
            if p - pp == k:
                print(round(p ** (1/5)), round(pp ** (1/5)), sep=" ")
                exit()
            elif p + pp == k:
                print(round(p ** (1/5)), -round(pp ** (1/5)), sep=" ")
                exit()
    return


k = int(input())
solve()


Measured memory_bytes: 74728
# coding:utf-8

import sys
from collections import deque

INF = float('inf')
MOD = 10 ** 9 + 7
dy, dx = (0, -1, 0, 1), (1, 0, -1, 0)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n, m = LI()

    if max(n, m) == 1:
        print(1)
    elif n == 1:
        print(max(0, m - 2))
    elif m == 1:
        print(max(0, n - 2))
    elif n == 2 or m == 2:
        print(0)
    else:
        print((n - 2) * (m - 2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long x = scanner.nextLong();
			System.out.println((int) Math.ceil((Math.sqrt(8 * x + 1) - 1.0) / 2.0));
		}
	}
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,Q; cin >> N >> Q;
    vector<ll> A(N),left((N+1)/2+1,0),right((N+1)/2+1,0);
    for (int i=0;i<N;++i) cin >> A[i];
    for (int i=0;i<(N+1)/2;++i){
        left[i+1]=left[i]+(N&1?A[i*2]:A[i*2+1]);
        right[i+1]=right[i]+A[N-1-i];
    }
    vector<ll> border;
    for (int i=1;i<=(N+1)/2;++i) border.emplace_back(A[N-i]+A[N-2*i+1]);
    reverse(border.begin(),border.end());
    for (;Q--;){
        ll X; cin >> X;
        int r=border.end()-lower_bound(border.begin(),border.end(),2*X);
        if (!r) ++r;
        cout << left[(N+1)/2-r]+right[r] << '\n';
    }
}

Measured memory_bytes: 3832
#include<stdio.h>
int main(void){
   int i, n, m, BMI;
   double w, h;
   while(scanf("%d, %lf, %lf", &i, &w, &h) != EOF){
         BMI = w / h / h;
         if(BMI >= 25){
            printf("%d\n", i);
         }
   }
   return 0;
}

Measured memory_bytes: 1708
#include <iostream>
#include <stdio.h>

#include <vector>

using namespace std;

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

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

        if (i % 3 == 0) {
            cout << " " << i;
        }
        else if (i % 10 == 3) {
            cout << " " << i;
        }
        else {
            int calc = i;
            //先頭が3はok
            while (calc>=1) {
                calc = calc / 10;
                if (calc % 10 == 3) {
                    cout << " " << i;
                    break;
                }
            }
        }
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 3088
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long i = p; i < q; i++)
#define repd(i, p, q) for (long i = p; i >= q; i--)
#define sz(x) x.size()
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> MI;
typedef pair<int, int> PI;
typedef long long int LLI;
typedef long int LI;
typedef int I;

int main()
{
    int n;
    cin >> n;
    LLI a[n + 3];
    LLI x;
    cin >> x;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    int happy = 0;
    LLI total = 0;
    for (int i = 0; i < n; i++)
    {
        if (total + a[i] <= x)
        {
            happy++;
            total = total + a[i];
        }
        else
        {
            total = total + a[i];
        }
    }
    if (total < x)
    {
        happy--;
    }
    cout << happy;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,x,y) for(int i=x; i<=y; i++)
#define ll long long
using namespace std;

ll l[100010], h[100010], cnt, res, canh;
ll n;
pair <ll, ll> x[100010], y[100010];
struct edges
{
    ll u;
    ll v;
    ll w;
} e[200010];

bool cmp(edges x, edges y)
{
    return x.w<y.w;
}

ll tim(ll x)
{
    if (x==l[x]) return x;
    l[x]=tim(l[x]);
    return l[x];
}

void hop(ll x, ll y)
{
    ll a=tim(x), b=tim(y);
    if (h[a]<h[b])
    {
        l[a]=b;
        h[b]+=h[a];
    }
    else
    {
        l[b]=a;
        h[a]+=h[b];
    }
}

int main()
{
    cin >>n;
    FOR(i,1,n)
    {
        x[i].second=i; y[i].second=i;
        scanf("%lld%lld",&x[i].first,&y[i].first);
    }

    sort(x+1,x+n+1);
    FOR(i,1,n-1)
    {
        cnt++;
        e[cnt].u=x[i].second;
        e[cnt].v=x[i+1].second;
        e[cnt].w=x[i+1].first-x[i].first;
    }

    sort(y+1,y+n+1);
    FOR(i,1,n-1)
    {
        cnt++;
        e[cnt].u=y[i].second;
        e[cnt].v=y[i+1].second;
        e[cnt].w=y[i+1].first-y[i].first;
    }
    //FOR(i,1,cnt) cout <<e[i].u <<" " <<e[i].v <<" " <<e[i].w <<endl;
    sort(e+1,e+cnt+1,cmp);
    FOR(i,1,n)
    {
        l[i]=i;
        h[i]=1;
    }

    FOR(i,1,cnt)
    {
        ll d1=e[i].u;
        ll d2=e[i].v;
        if (tim(d1)!=tim(d2))
        {
            hop(d1,d2);
            canh++;
            res+=e[i].w;
        }
        if (canh==n-1) break;
    }
    cout <<res;

    return 0;
}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Integer K = input.nextInt();
        long sum = 0;

        for (int a = 1; a <= K; a++) {
            for (int b = 1; b <= K; b++) {
                for (int c = 1; c <= K; c++) {
                    sum += gcd_triple(a, b, c);
                }
            }
        }
        System.out.println(sum);
    }

    private static int gcd_triple(int a, int b, int c) {
        return gcd(gcd(a, b), c);
    }

    private static int gcd(int n, int m) {
        int bigger = Integer.max(n,m);
        int smaller = Integer.min(n,m);
        int sur = bigger % smaller;

        if (sur == 0) {
            return smaller;
        } else {
            return gcd(smaller, sur);
        }

    }
}

Measured memory_bytes: 27308
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	char a;
	cin >> a;
	if(a >= 'A' && a <= 'Z'){
		cout << "A" << endl;
	}else{
		cout << "a" << endl;
	}
	return 0;
}


Measured memory_bytes: 3584
///int ->(-2147483648<->2147483647)
///unsigned int(0<->4294967295)
///long long int (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)
///unsigned long long int (0 to 18,446,744,073,709,551,615)
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stdio.h>
#include<map>
#include<math.h>
#include<algorithm>
#include<string>
#include<utility>
#include<stack>
#include<cstring>
#include<iterator>
#include<unordered_map>
#include<unordered_set>
#include<set>
#include<iomanip> ///setprecision
#include<cmath>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define OPEN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","r",stdin)
#define Precision cout<<fixed, cout<<setprecision(10);
#define INF 1000000000
#define ll long long
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pcc pair<char,char>
#define pdd pair<double,double>
#define vi vector<int>
#define vll vector<long long>
#define vc vector<char>
#define vd vector<double>
#define sci(value) scanf("%d%*c",&value)
#define scl(value) scanf("%lld%*c",&value)
#define pi  (2*acos(0))
#define pb push_back
#define valid(value123,value234,limitrow,limitcol) value123>=0&&value123<limitrow&&value234>=0&&value234<limitcol
//int fx[]= {0,0,1,-1,-1,1,-1,1};//kings move
//int fy[]= {1,-1,0,0,-1,1,1,-1};//kings move
//int fx[]={-2,-2,-1,-1, 1,1, 2,2};  // Knights Move
//int fy[]={-1, 1,-2, 2,-2,2,-1,1}; // Knights Move
//ll powFunction(ll a,ll b){if(b==0)return 1;ll re=powFunction(a,b/2);re=(re*re);if(b&1)re=(re*a);return re;}
///ll digitSum(ll a){ll ans=0;while(a){ans+=(a%10);a/=10;}return ans;}

#define MX 3005
#define mod 1000000007
double probability[2][MX][1502];
bool vis[2][MX][1502];
double head[MX];
int n;
double findprobability(int mark, int pos, int tailscount)
{
    if(pos==n)
        return 1;
    if(vis[mark][pos][tailscount])
        return probability[mark][pos][tailscount];

    vis[mark][pos][tailscount] = 1;
    double q1 = 0.0, q2 = 0.0;

    q1 = findprobability(0, pos+1, tailscount) * head[pos];

    if(tailscount - 1 >=0)
    {
        q2 = findprobability(1, pos+1, tailscount - 1) * (1 - head[pos]);
    }

    return probability[mark][pos][tailscount] = q1 + q2;
}
int main()
{

    sci(n);
    for(int i=0;i<n;i++)
        cin>>head[i];
    Precision;
    cout<<findprobability(0, 0, n/2);
}



Measured memory_bytes: 79744
#coding:utf-8

def get_index(rate):
    if 1 <= rate <= 399:
        return 0
    elif 400 <= rate <= 799:
        return 1
    elif 800 <= rate <= 1199:
        return 2
    elif 1200 <= rate <= 1599:
        return 3
    elif 1600 <= rate <= 1999:
        return 4
    elif 2000 <= rate <= 2399:
        return 5
    elif 2400 <= rate <= 2799:
        return 6
    elif 2800 <= rate <= 3199:
        return 7

if __name__ == "__main__":
    N = int(input())
    rates = list(map(int, input().split(" ")))
    color_list = [0] * 8

    free_num = 0
    for rate in rates:
        if rate >= 3200:
            free_num += 1
        else:
            color_list[get_index(rate)] += 1

    color_kind = len(list(filter(lambda x: x > 0, color_list)))
    if color_kind == 0:
        print(str(1) + " " + str(free_num))
    else:
        print(str(color_kind) + " " + str(color_kind + free_num))


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

using namespace std;

#define INF 1e9

bool is_prime[10000000];

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

    int M=7368791;

    while(1){
        int m,n;
        cin>>m>>n;

        if(n==0)break;

        int p=0,ans=0;

        for(int i=m;i<=M;i++)is_prime[i]=true;

        for(int i=m;i<=M;i++){
            if(is_prime[i]){
                p++;
                for(int j=2*i;j<=M;j+=i)is_prime[j]=false;
                ans=i;
                if(p==n+1){
                    break;
                }
            }
        }

        cout<<ans<<endl;

    }

}


Measured memory_bytes: 10344
n,k=map(int,input().split())
a=list(map(int,input().split()))
a2=sorted(a)
kindnum=[]
kind=1
now=a2[0]
ren=1
for i in range(1,n):
    if now!=a2[i]:
        kindnum.append(ren)
        kind+=1
        now=a2[i]
        ren=1
        continue
    ren+=1
kindnum.append(ren)
kindnum2=sorted(kindnum)
if kind<=k:
    print(0)
else:
    ans=0
    for i in range(kind-k):
        ans+=kindnum2[i]
    print(ans)

Measured memory_bytes: 24996
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b==c+d)cout<<"Balanced"<<endl;
  else if(a+b<c+d)cout<<"Right"<<endl;
  else cout<<"Left"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;

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

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

    ll ans = (a + b * (n - 1)) - (a * (n - 1) + b) + 1;

    ans = max((ll)0, ans);

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {

        int a1, a2, a3;

        cin >> a1 >> a2 >> a3;

        if(a1 + a2 + a3 >= 22) {
            cout << "bust" << endl;
        } else {
           cout << "win" << endl;
        }
      return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
    
        String res;
        if('A' <= s[0] && s[0] <='Z'){
            res = "A";
        }else{
            res ="a";
        }
        System.out.println(res);
        }
    }

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    printf("%lld\n", min(A, B) + min(C, D));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;

int knapsack(int n, int W, vi w, vi v){
    vvi dp(n + 1, vi (W + 1, 0));
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= W; j++) {
            if(j - w[i] >= 0) {
                chmax(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
            }
            chmax(dp[i][j], dp[i - 1][j]);
        }
    }
    return dp[n][W];
}

int main() {

    int n,W;
    cin>>n>>W;
    vi w(n+1),v(n+1);
    rep(i,n)cin>>v[i+1]>>w[i+1];
    fin(knapsack(n,W,w,v));
}


Measured memory_bytes: 6776