akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e3 + 5;

int mx[MAXN][MAXN];
int d[MAXN][MAXN];
int used[MAXN][MAXN];

void solve(){
	int A, B;
	scanf("%d%d", &A, &B);
	REPN(i, 1, A){
		REPN(j, 1, B){
			scanf("%d", &d[i][j]);
		}
	}
	int lim = 100;
	REPN(i, 0, lim){
		REPN(j, 0, lim){
			REPN(k, 1, A){
				REPN(l, 1, B){
					int delta = d[k][l] - (i * k + j * l);
					mx[i][j] = max(mx[i][j], delta);
				}
			}
			REPN(k, 1, A){
				REPN(l, 1, B){
					int delta = d[k][l] - (i * k + j * l);
					if (delta == mx[i][j]){
						//printf("%d %d %d %d %d\n", i, j, k, l, d[k][l]);
						used[k][l] = 1;
					}
					/*if (k == 1 && l == 1){
						printf("%d %d %d %d\n", i, j, i * k + j * l + mx[i][j], d[1][1]);
					}*/
				}
			}
		}
	}
	
	int good = 1;
	REPN(k, 1, A){
		REPN(l, 1, B){
			//printf("%d %d %d\n", k, l, used[k][l]);
			good &= used[k][l];
		}
	}
	
	if (!good){
		printf("Impossible\n");
		return;
	}
	printf("Possible\n");
	int n = lim + lim + 2;
	printf("%d %d\n", n, (lim + 1) * (lim + 1) + lim + lim);
	REPN(i, 1, lim){
		printf("%d %d X\n", i, i + 1);
	}
	REPN(i, 1, lim){
		printf("%d %d Y\n", lim + 1 + i, lim + 1 + i + 1);
	}
	REPN(i, 0, lim){
		REPN(j, 0, lim){
			printf("%d %d %d\n", i + 1, n - j, mx[i][j]);
		}
	}
	printf("%d %d\n", 1, n);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 6528
#include <bits/stdc++.h> 
#define EB emplace_back

typedef long long ll;
typedef std::vector <int> vector;
const int N = 432, mod = 998244353;

int n;
int A[N], B[N];
int fact[N], inv[N], finv[N];
vector Z[N];
vector buf_[4][N], *cf = *buf_, *nf = buf_[1], *cg = buf_[2], *ng = buf_[3];

inline void fma(int &x, const int y, const int z) {x = (x + (ll)y * z) % mod;}
ll PowerMod(ll a, int n, ll c = 1) {for (; n; n >>= 1, a = a * a % mod) if (n & 1) c = c * a % mod; return c;}

void init() {
	int i;
	for (inv[1] = 1, i = 2; i < N; ++i) inv[i] = ll(mod - mod / i) * inv[mod % i] % mod; 
	for (*finv = *fact = i = 1; i < N; ++i) fact[i] = (ll)fact[i - 1] * i % mod, finv[i] = (ll)finv[i - 1] * inv[i] % mod;
}

void conv_add(vector &ret, const vector &f, const vector &g) {
	int i, j, n = f.size(), m = g.size();
	if ((int)ret.size() < n + m - 1) ret.resize(n + m - 1);
	for (i = 0; i < n; ++i) for (j = 0; j < m; ++j) fma(ret[i + j], f[i], g[j]);
}

void single_add(vector &ret, const vector &f, int offset, int coeff) {
	int i, n = f.size();
	if ((int)ret.size() < n + offset) ret.resize(n + offset);
	for (i = 0; i < n; ++i) fma(ret[i + offset], f[i], coeff);
}

int main() {
	int i, j, r, S = 0, ans = 0;
	scanf("%d", &n), init();
	for (i = 0; i < n; ++i) {
		scanf("%d%d", A + i, B + i), Z[i].reserve(B[i]);
		for (r = mod - 1, j = 0; j < B[i]; r = (ll)r * A[i] % mod * inv[++j] % mod) Z[i].EB(r);
	}
	nf[0].EB(1);
	for (i = 0; i < n; S += A[i], ++i) {
		std::copy(nf, nf + (S + 1), cf), std::copy(ng, ng + (S + 1), cg);
		for (j = 0; j <= S; ++j)
			conv_add(nf[j + A[i]], cf[j], Z[i]), conv_add(ng[j + A[i]], cg[j], Z[i]),
			single_add(ng[j + A[i]], cf[j], B[i] - 1, (ll)A[i] * Z[i].back() % mod);
	}
	for (j = 1; j <= S; ++j) {
		for (r = 0, i = ng[j].size() - 1; i >= 0; --i) r = (r + (ll)fact[i + 1] * ng[j][i]) % mod * inv[j] % mod;
		ans = (ans + (ll)r * inv[j]) % mod;
	}
	printf("%d\n", ans = ll(mod - ans) * S % mod);
	return 0;
}

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

b = sorted([(i+1, a[i]) for i in range(n)], key=lambda x: -x[1])
ans = [0]*(n+1)
m = float('inf')
for i in range(n-1):
    m = min(m, b[i][0])
    if b[i][1] == b[i+1][1]:
        continue
    ans[m] += (i+1)*(b[i][1]-b[i+1][1])
ans[1] += sum(a) - sum(ans)
for i in range(1, n+1):
    print(ans[i])

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

const int INF = 1e9 + 5;

int main(int argc, char const *argv[])
{
	// ios_base::sync_with_stdio(false);
 //    cin.tie(NULL);
    ll int n;
    cin>>n;
    ll int arr[n][3];
    // for(ll int& i: arr){
    // 	scanf("%lld",&i);
    // }
    for(ll int i=0;i<n;i++){
    	cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }    
    // cout<<"h\n";
    ll int dp[n][3];
    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];
    for(ll int i=1;i<n;i++){
    	for(ll int j=0;j<3;j++){
    		ll int min1 = 0;
    		for(ll int k=0;k<3;k++){
    			if(k!=j)
    			min1 = max(min1,dp[i-1][k]);
    		}
    		dp[i][j] = min1+arr[i][j];
    		// if(i==n-1)
    		// cout<<dp[i][j]<<endl;
    	}
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}

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

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end())); }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    cums(T& v){ T r; r.push_back(v[0]); for(int i=1; i<v.size(); i++) r.push_back(r[i-1] + v[i]); return r; }
TEMP_T void maxe(T& v, T m){ v = max(v, m); }
TEMP_T void mine(T& v, T m){ v = min(v, m); }

static inline int in(){ int x; scanf("%d", &x); return x; }

struct Solver {
  Solver(){}
  int read_input(){
    w = in();
    h = in();
    memset(field, 0, sizeof(field));
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        field[i + 1][j + 1] = in();
      }
    }
    w += 2;
    h += 2;
    return (0);
  }
  int solve(){
    int sums[128][128] = {};
    queue<pair<int, int> > Q;
    set<pair<int, int> > vis;
    Q.push(make_pair(0, 0));
    vis.insert(make_pair(0, 0));
    while (!Q.empty()){
      queue<pair<int, int> > nQ;
      while (!Q.empty()){
        pair<int, int> p = Q.front();
        Q.pop();
        for (int d = 0; d < 6; d++){
          static const int edx[] = {-1,-1,-1, 0, 1, 0};
          static const int edy[] = {-1, 0, 1,-1, 0, 1};
          static const int odx[] = { 0,-1, 0, 1, 1, 1};
          static const int ody[] = {-1, 0, 1,-1, 0, 1};
          int nx = p.first + ((p.second % 2) ? odx[d] : edx[d]);
          int ny = p.second + ((p.second % 2) ? ody[d] : edy[d]);
          if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
          if (field[ny][nx]){
            sums[ny][nx]++;
            continue;
          }
          if (vis.find(make_pair(nx, ny)) != vis.end()) continue;
          vis.insert(make_pair(nx, ny));
          nQ.push(make_pair(nx, ny));
        }
      }
      swap(Q, nQ);
    }
    int ret = 0;
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        ret += sums[i][j];
      }
    }

    return ret;
  }
  int field[128][128];
  int w, h;
};

int main()
{
  Solver solver;
  solver.read_input();
  printf("%d\n", solver.solve());
  return (0);
}

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

int main() {
  string str;
  cin >> str;
  int flag = 0;
  for(int i=1; i<4; i++) {
    if(str[i-1] == str[i])
      flag = 1;
  }

  if(flag == 1)
    cout << "Bad" << endl;
  else
    cout << "Good" << endl;
  return 0;
  	  
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

void f(int n,int m,string str){
//cout<<n<<" "<<m<<" "<<str<<endl;
	if(n==0){
		cout<<str;
		return;
	}
	int i;
	for(i=min(n,m);i>0;i--){
		ostringstream st;
		st<<i;
		f(n-i,i,str+st.str()+(i==n?"\n":" "));
	}
}

int main() {
	int n;
	while(n=in()){
		f(n,n,"");
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
using namespace std;
typedef long long ll;
#define mp make_pair;
#define pb push_back;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;
  ll N;
  cin >> N >> x;
  ll a[N];
  rep(i, N) cin >>a[i];
  ll ta[N];
  ll ans=0;
  ll ans_tmp=0;
  rep(i,N) ta[i] = a[i];
  rep(i,N) ans+=ta[i];

  rep1(k,N){
    rep(i,N){
      ta[i] = min(ta[i], a[((i-k)+N)%N]);
    }
    ans_tmp=0;
    rep(i,N){
      ans_tmp+=ta[i];
    }
    ans_tmp+=x*k;
    ans=min(ans,ans_tmp);
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
s = input()
n = len(s)

def check(s):
    m = len(s)
    return all(s[i] == s[m-1-i] for i in range((m+1)//2))

t = s[:(n-1)//2]
u = s[(n+3)//2-1:]
if check(s) and check(t) and check(u):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38448
#include<cstdio>

int main(){
	int n;
	scanf("%d", &n);
	int a[n];
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}

	for(int i = n - 1; i > 0; i--){
		printf("%d ", a[i]);
	}
	printf("%d\n", a[0]);
}

Measured memory_bytes: 1028
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    static int n;
    static long[] a, sum, sum2;
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        int Q = sc.nextInt();
        a = new long[n+1]; sum = new long[n+1]; sum2 = new long[n+1];
        for(int i=1;i<=n;i++) {
            a[i]=sc.nextLong();
            sum[i] = sum[i-1]+a[i];
        }
        sum2[1] = a[1];
        for(int i=2;i<=n;i++) sum2[i] = sum2[i-2]+a[i];
        PrintWriter out = new PrintWriter(System.out);
        while(Q>0){
            Q--;
            long x = sc.nextLong();
            out.println(query(x));
        }
        out.flush();
    }
    static long query(long X){
        if(n<=2) return a[n];
        int hi = (n-1)/2;
        if(Math.abs(X-a[n-2*hi])<=Math.abs(X-a[n-hi])){
            return sum[n]-sum[n/2];
        }
        int lo = -1;
        while(hi-lo>1){
            int mid = (hi+lo)/2;
            if(Math.abs(X-a[n-2*mid])>Math.abs(X-a[n-mid])) hi=mid;
            else lo = mid;
        }
        long ans = sum2[n-2*hi];
        ans += sum[n]-sum[n-hi];
        return ans;
    }
}


Measured memory_bytes: 96388
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		HashMap<Integer,Integer>hm = new HashMap<Integer, Integer>();
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		for(int i = 0; i< n ; i++) {
			int a = sc.nextInt();
			if(!hm.containsKey(a)) {
				hm.put(a,1);
			}
			else {
				hm.put(a, hm.get(a) + 1);
			}
		}
		
		sc.close();
		int p = hm.size();
		int []b = new int [p];
		int j = 0;
		
		for(int num : hm.keySet()) {
		    b[j] = hm.get(num);
		    j++;
		}
		
		Arrays.sort(b);
		
		int ans = 0;
		int temp = p;
		for(int i = 0 ; i < p; i++) {	
		if(k < temp) {
				ans += b[i];
				temp--;
		}
		else {
			break;
		}
		
	}
		System.out.println(ans);
	}

}


Measured memory_bytes: 101380
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;


int main()
{
    
    long long int a;
    cin >> a;
    string p;
    string t = "abcdefghijklmnopqrstuvwxyz";
    while (a) {
        int r = a % 26;
        char b = 'a';
        b += r-1;
        if (r == 0) {
            b = 'z';
            a--;
        }
        p.push_back(b);
        a /= 26;
       
    }
    reverse(p.begin(), p.end());
    cout << p << endl;
    return 0;

}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = (int)1e9+7;
const double PI = 3.14159265359;

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


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	//ctrl + /cin>>t;
	t = 1;
	while(t--){
		int n;
		cin>>n;
		ll ans = 0;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				for(int k=1;k<=n;k++){
					ans += gcd(gcd(i,j),k);
				}
			}
		}
		cout<<ans;
	}
	return 0;
}
































Measured memory_bytes: 3652
import heapq

n, m = map(int, input().split())
a_list = [a*(-1) for a in list(map(int, input().split()))]

heapq.heapify(a_list)
for _ in range(m):
  min_n = heapq.heappop(a_list)
  heapq.heappush(a_list, (min_n//2 if min_n%2 == 0 else min_n//2+1))
print(sum(a_list) * (-1))

Measured memory_bytes: 14180
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args)throws Exception{
		
		int i = 1;
        String str;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        while(true){
        	str = br.readLine();
        	if(str.equals("0")){
        		break;
        	}
        	System.out.println("Case " + i + ": " + str);
        	i++;
        }
        
	}
}

Measured memory_bytes: 31600
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    int n;cin>>n;
    map<string, int> w;
    string s, t;
    bool b = true;
    for(int i = 0; i < n; i++){
        cin>>s;
        if(w[s] != 0 || (s[0] != t[t.size() - 1] && i)) {
            b = false;
            break;
        }
        w[s]++;
        t = s;
    }
    cout << (b ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define upb upper_bound
#define lwb lower_bound
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y){
    if(y<=0) return 1;
    ll ans = 1;
    x %= mod;
    while(y){
        if(y&1)
            ans = (x * ans) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = (a - b); if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = (a + b); if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//------------------------------------------------------------------------------------------

//const ll N = 2e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

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

	ll n;
	cin>>n;
	ll x[n], y[n];
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i];
	}
	ll ma = -inf, mi = inf;
	for(int i=0;i<n;i++){
		ma = max(ma, x[i]+y[i]);
		mi = min(mi, x[i]+y[i]);
	}
	ll ans = ma-mi;
	ma = -inf, mi = inf;
	for(int i=0;i<n;i++){
		ma = max(ma, x[i]-y[i]);
		mi = min(mi, x[i]-y[i]);
	}
	cout<<max(ans, ma-mi);
    return 0;
}


Measured memory_bytes: 6772
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int an[]=new int[a];
	for(int i=0;i!=b;i++) {
		int c=scan.nextInt();
		int d=scan.nextInt();
		an[c-1]++;
		an[d-1]++;
	}
	for(int i=0;i!=a;i++) {
		System.out.println(an[i]);
	}
}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector <T> v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

bool visit[10];
bool graph[10][10];
int dfs(int p,int n,bool * visit){
    bool all_vis=true;
    for (int i = 0; i < n; i++)
    {
        if(!visit[i]){
            all_vis=false;
        } 
    }
    if(all_vis) {
        return 1;
    } 
    int res=0;
    for (int i = 0; i < n; i++)
    {
        if(!graph[p][i]) continue;
        if(visit[i]) continue;
        visit[i]=true;
        res+=dfs(i,n,visit);
        visit[i]=false;
    }
    return res;
}

signed main(){
    int n,m;
    cin>>n>>m;
   
    for (int i = 0; i < m; i++)
    {
        int a,b;
        cin>>a>>b;
        a--,b--;
        graph[a][b]=graph[b][a]=true;       
    }
    visit[0]=true;
    cout<<dfs(0,n,visit)<<endl;
   
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int h = scanner.nextInt();
		int w = scanner.nextInt();
		
			System.out.println(a*b-(h*b+a*w-h*w));
		
			
		
	}
 
}

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

#define null               ""
#define endl               '\n'
#define all(dat)           dat.begin(), dat.end()
#define over(msg)          cout << msg << endl, exit(0);
#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, fr, to)    for (int i = fr; 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;

int n, m, w[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[10005];
vector<int> d;

bool inline operator < (const string &a, const string &b) {
    if (a.size() != b.size())  return a.size() < b.size();
    loop (i, a.size()) {
        if (a[i] != b[i])  return a[i] < b[i];
    }
    return 0;
}

int main() {
    cin >> n >> m;
    cont (i, m) {
        int a;
        cin >> a;
        d.push_back(a);
    }
    cont (i, n) {
        for (int j : d) {
            if (i - w[j] >= 0 && (dp[i - w[j]] != null || i - w[j] == 0)) {
                string tmp = dp[i - w[j]];
                tmp += j + '0';
                if (dp[i] < tmp) {
                    dp[i] = tmp;
                }
            }
        }
    }
    cout << dp[n] << endl;
}


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

int W, H, N;
int x[110], y[110], a[110];
int field[110][110];

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

    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i] >> a[i];
    }

    for (int i = 0; i < W; i++)
    {
        for (int j = 0; j < H; j++)
        {
            field[i][j] = 0;
        }
    }

    for (int i = 0; i < N; i++)
    {
        if (a[i] == 1)
        {
            for (int j = 0; j < x[i]; j++)
            {
                for (int k = 0; k < H; k++)
                {
                    field[j][k] = 1;
                }
            }
        }
        else if (a[i] == 2)
        {
            for (int j = x[i]; j < W; j++)
            {
                for (int k = 0; k < H; k++)
                {
                    field[j][k] = 1;
                }
            }
        }
        else if (a[i] == 3)
        {
            for (int j = 0; j < y[i]; j++)
            {
                for (int k = 0; k < W; k++)
                {
                    field[k][j] = 1;
                }
            }
        }
        else
        {
            for (int j = y[i]; j < H; j++)
            {
                for (int k = 0; k < W; k++)
                {
                    field[k][j] = 1;
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < W; i++)
    {
        for (int j = 0; j < H; j++)
        {
            if(field[i][j] == 0) ans++;
        }
        
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int top, south, east;
    int n;
    int ans;
    string action;

    while (scanf("%d", &n) * n != 0){
        top = 1;
        south = 2;
        east = 3;
        ans = 1;

        for (int i = 0; i < n; i++){
            cin >> action;

            if (action == "North"){
                swap(top, south);
                south = 7 - south;
            }
            if (action == "East"){
                swap(top, east);
                top = 7 - top;
            }
            if (action == "West"){
                swap(top, east);
                east = 7 - east;
            }
            if (action == "South"){
                swap(top, south);
                top = 7 - top;
            }
            if (action == "Right"){
                swap(east, south);
                east = 7 - east;
            }
            if (action == "Left"){
                swap(east, south);
                south = 7 - south;
            }

            ans += top;
        }
        printf("%d\n", ans);
    }
    return (0);
}

Measured memory_bytes: 1248
N=int(input())
S=[input() for i in range(N)]
cnt={}
maxCnt=0
for s in S:
    if s in cnt:
        cnt[s]+=1
    else:
        cnt[s]=1
    if(cnt[s]>maxCnt):
        maxCnt=cnt[s]
for s in sorted(cnt.keys()):
    if cnt[s]==maxCnt:
        print(s)


Measured memory_bytes: 35220
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            String S = sc.next();
            String T = sc.next();

            int min = (int) 1e9;
            for (int start = 0; start + T.length() <= S.length(); start++) {
                int count = 0;
                for (int i = 0; i < T.length(); i++) {
                    if (T.charAt(i) != S.charAt(start + i)) {
                        count++;
                    }
                }
                min = Math.min(min, count);
            }
            System.out.println(min);
        }
    }
}


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

int main() {
	cin >> n;
	int data[n+1][n+1];
	for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= n; ++j) {
				data[i][j]=900000;
			}
	}
	for (int i = 0; i < n; ++i) {
		cin >> a>>b;
		for (int j = 0; j < b; ++j) {
			cin >> c;
			data[a][c]=1;
		}
	}


	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			for (int k = 1; k <= n; ++k) {
				data[j][k]=min(data[j][k],data[j][i]+data[i][k]);
			}
		}
	}
	/*for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= n; ++j) {
				cout<<i<<" "<<j<<" "<<data[i][j]+1<<endl;
			}
	}*/


	cin>>n;
	for (int i = 0; i < n; ++i) {
		cin>>a>>b>>c;
		if(data[a][b]+1<=c){cout<<data[a][b]+1<<endl;}
		else{cout<<"NA"<<endl;}
	}
return 0;

}

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

long long mod = 1e9 + 7;


int main()
{
	int h, w;
	cin >> h >> w;
	char grid[h][w];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> grid[i][j];
		}
	}
	long long ans[h][w] = {};
	ans[0][0] = 1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (grid[i][j] == '#')
				continue;
			if (i) {
					ans[i][j] += ans[i-1][j];
			}
			if (j) {
					ans[i][j] += ans[i][j-1];
			}
			ans[i][j] %= mod;
		}
	}
	cout << ans[h-1][w-1];
}






Measured memory_bytes: 9088
module Main where

import Data.Functor

main :: IO()
main = do
  { [a,b,c] <- getInts
  ; let result = junban (a,b,c)
  ; putStrLn result
  }

junban :: (Int, Int, Int) -> String
junban (x,y,z)
 | x < y && y < z  = "Yes"
 | otherwise = "No"

getInts :: IO [Int]
getInts = map read . words <$> getLine

Measured memory_bytes: 3604
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long; 
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) sort(x.begin(),x.end())
#define RALL(x) sort(x.rbegin(),x.end())
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
constexpr long double pi = 3.141592653589793238462643383279;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll fact_mod(ll n, ll mod) {
    ll f = 1; for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
ll keta(ll n) {
    if (n == 0) return 1;
    ll count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll mch(ll n) {
    if (n == 1) return 1;
    else return n * mch(n - 1);
}
ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}
ll inv_mod(ll a, ll mod) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
//関数とか

//宣言とか
ll ans;
/*signed*/int main(void) {
    ll n, x;
    cin >> n >> x;
    vector<ll> vec(n);
    rep(i, n) {
        cin >> vec[i];
        ans = gcd(ans, abs(vec[i]-x));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define xrep(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define vl vector<long long>
#define vs vector<string>
#define SORT(A) sort(A.begin(),A.end())

int main() {
    ll X,K,D; cin >> X >> K >> D;

    X = abs(X);

    ll a = K - X / D;
    if(a < 0){
        cout << X - K * D;
    }
    else{
        if(a % 2 == 1){
            cout << - X % D + D << endl;
        }
        else {
            cout << X % D << endl;
        }
    }
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

using namespace std;

int main()
{
	char buf[128];
	while (scanf("%s", buf) != EOF)
	{
		for (int i = 0; buf[i] != '\0'; ++i)
		{
			if (buf[i] == '@')
			{
				for (int j = 0; j < buf[i+1]-'0'; ++j)
					putchar(buf[i+2]);
				i += 2;
			}
			else
				putchar(buf[i]);
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 0
def main():
    n=int(input())
    ans=[0]*8
    other = 0
    for a in map(int,input().split()):
        if a >= 3200:
            other+=1
        else:
            ans[a//400] = 1
    a = ans.count(1)
    print(a if a != 0 else 1, a+other)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9072
# -*- coding: utf-8 -*-
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)


n = 10**6
minfac = list(range(n+1))
for i in range(2, int(n**0.5) + 1):
    if minfac[i] < i:
        continue
    for j in range(i, n + 1, i):
        if minfac[j] > i:
            minfac[j] = i

"""nの素因数の種類を求める"""
def osa_k(n):
    temp = set()
    while n > 1:
        temp.add(minfac[n])
        n = n//minfac[n]
    return temp


N = int(input())
A = list(map(int, input().split()))

check = [0]*(10**6)
flag = 0
for a in A:
    for i in osa_k(a):
        if check[i]:
            flag = 1
        else:
            check[i] = 1
    if flag:
        break
        
if gcd_list(A) > 1:
    print("not coprime")
elif flag:
    print("setwise coprime")
else:
    print("pairwise coprime")
    


Measured memory_bytes: 206628
var
s,a:ansistring;
i:longint;
begin
read(s);
for i:=1 to length(s) do
  if s[i]='0' then a:=a+'0'
    else if s[i]='1' then a:=a+'1'
      else if s[i]='B' then
        if length(a)>0 then delete(a,length(a),1);
write(a);
end.

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

using namespace std;

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

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



int main(){
    long long n,m;
    cin >> n >> m;
    vector<long long> a(n);
    bool flag=true;
    for(int i=0;i<n;i++){
        long long s;
        cin >> s;
        a[i]=s/2;
    }
    if(n==1){
        long long v=m/a[0];
        cout << (v+1)/2 << endl;
        return 0;
    }
    long long t=a[0];
    for(int i=1;i<n;i++){
        t=lcm(t,a[i]);
    }
    //cout << t << endl;
    
    for(int i=0;i<n;i++){
        long long u=t/a[i];
        if(u%2==0){
            flag=false;
        }
    }
    if(flag==false){
        cout << 0 <<endl;
        return 0;
    }
    long long ans = 0;
    long long v=m/t;
    //cout << v << endl;
    ans=(v+1)/2;
    
    cout << ans << endl;
}

Measured memory_bytes: 1024
s = list(input())
s2 = s.copy()
s2.reverse()
n = len(s)
k = int((n-1) /2)

if s != s2:
    print("No")
else:
    first = s[:k]
    first2 = first.copy()
    first2.reverse()
    second = s[k+1:]
    second2 = second.copy()
    second2.reverse()
    if first == first2 and second == second2:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3060
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package here;

/**
 *
 * @author sokumar
 */
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter w = new PrintWriter(System.out);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int []h = new int[n+1];
        for(int i=1;i<=n;i++)
        {
            h[i] = sc.nextInt();
        }
        int []c = new int[n+1];
        c[1] = 0;
        for(int i=2;i<=n;i++)
        {
            int min = Integer.MAX_VALUE;
            for(int j=i-1;j>=Math.max(1, i-k);j--)
            {
      
               min = Math.min(min,c[j] + Math.abs(h[i]-h[j]));
            
            }
            c[i] = min;
           // w.print(c[i] + " ");
        }
       w.println(c[n]);
        
        w.close();
    }
    
}


Measured memory_bytes: 49860
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

const int mod = 1e9 + 7;

int n;
long double p[3000],dp[3000][3000],ans;

int32_t main(){_
    //freopen("in","r",stdin);
	cin >> n;
	for(int i = 1;i <= n;i++)
	{
		cin >> p[i];
	}
	dp[0][0] = 1;
	for(int i = 1;i <= n;i++)
	{
		for(int j = 0;j <= i;j++)
		{
			dp[i][j] = dp[i - 1][j] * (1.0 - p[i]) + dp[i - 1][j - 1] * p[i];
			if(i == n && j > n/2) ans += dp[i][j];
		}
	}
	rc(fixed << setprecision(10) << ans);
}

Measured memory_bytes: 139136
k,s = map(int, input().split())
ans = 0
for i in range(k+1):
    for j in range(k+1):
        l = s - i - j
        #print('{} {} {}'.format(i,j,l))
        if  l >= 0 and k >= l:
            ans +=  1
            
print(ans)

Measured memory_bytes: 2940
from collections import deque
s = input()
q = int(input())
queue = deque([s])

tmp = 1
for i in range(q):
    x = input()
    if x[0]==str(1):
        tmp*=-1
    else:
        t,f,c = x.split()
        t,f = int(t),int(f)
        if tmp==-1:
            if f==1:
                queue.append(c)
            if f==2:
                queue.appendleft(c)
        if tmp==1:
            if f==1:
                queue.appendleft(c)
            if f==2:
                queue.append(c)

print(''.join(queue)[::tmp])

Measured memory_bytes: 6900
l, r = map(int, input().split())

ans = 2019
end_flag = False

for i in range(l, r):
    for j in range(i+1, r+1):
        mod = (i*j)%2019
        if mod < ans:
            ans = mod

        if ans==0:
            end_flag = True
            break

    if end_flag:
        break

print(ans)

Measured memory_bytes: 3060
# coding: utf-8
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))



def main():
    s = ns()
    t = ns()
    if s == t[:-1]:
        print('Yes')
    else:
        print('No')
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 61680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque> 
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype> 
using namespace std;

int main(){
    int N;
    cin >> N;
    long long cnt=1;
    for (long long i=1; i<=N; i++) {
        cnt*=i;
        if (cnt > 1e9+7) {
            cnt%=(long long)(1e9+7);
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 888
from collections import defaultdict
N=int(input())
A=list(map(int,input().split()))

MOD=10**9+7

LCM=defaultdict(int)
def f(n):
    ret=defaultdict(int)
    p=2
    while n%p==0:
        ret[p]+=1
        n//=p
    LCM[p]=max(LCM[p],ret[p])
    p=3
    while p*p<=n:
        while n%p==0:
            ret[p]+=1
            n//=p
        LCM[p]=max(LCM[p],ret[p])
        p+=2
    if n>1:
        ret[n]=1
        LCM[n]=max(LCM[n],ret[n])
    return ret

F=[]
for a in A:
    F.append(f(a))

l=1
for p,n in LCM.items():
    l=l*pow(p,n,MOD)%MOD

ans=0
for a in A:
    ans+=l*pow(a,MOD-2,MOD)
    ans%=MOD

print(ans)

Measured memory_bytes: 517768
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int d[n][3];
  int arr[n][3];
  for(int j=0;j<3;j++)
  {
    cin>>arr[0][j];
    d[0][j]=arr[0][j];
  }
  
  for(int i=1;i<n;i++)
  {
    for(int j=0;j<3;j++)
    {
      cin>>arr[i][j];
      int k=0;
      int y=0;
      while(k<3)
      { 
        if(k==j)
        {
          k++;
        }
        if(k<3)
        {
        y=max(arr[i][j]+d[i-1][k],y);
        }
        k++;
      }
      d[i][j]=y;
      
       
    }
    
  }
  int h=max(d[n-1][0],max(d[n-1][1],d[n-1][2]));
  cout<<h<<endl;
}
  

Measured memory_bytes: 2560
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;

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








ll POW(ll n, ll m, ll p){
    ll res = 1, x = n;
    for(ll i = m; i > 0; i >>= 1){
        if(i & 1){
            res *= x;
            res %= p;
        }
        x *= x;
        x %= p;
    }
    return res;
}

ll dp[305][90005], dp2[305][90005];

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    
    sort(a.begin(), a.end());

    dp[0][0] = 1;
    ll sum = 0;
    REP(i, n){
        REP(j, sum + 1){
            dp[i + 1][j] += dp[i][j] * 2;
            dp[i + 1][j] %= MOD;
            dp[i + 1][j + a[i]] += dp[i][j];
            dp[i + 1][j + a[i]] %= MOD;
        }
        sum += a[i];
    }
    
    dp2[0][0] = 1;
    sum = 0;
    REP(i, n){
        REP(j, sum + 1){
            dp2[i + 1][j] += dp2[i][j];
            dp2[i + 1][j] %= MOD;
            dp2[i + 1][j + a[i]] += dp2[i][j];
            dp2[i + 1][j + a[i]] %= MOD;
        }
        sum += a[i];
    }
    
    ll res = 0;
    for(ll i = (sum + 1) / 2; i <= sum; i++){
        res += dp[n][i];
        res %= MOD;
    }
    res *= 3;
    res %= MOD;
    
    cout << (POW(3, n, MOD) - res + ((sum % 2 == 0)? dp2[n][sum / 2] * 3 : 0) + MOD) % MOD << endl;
}

Measured memory_bytes: 426240
/* Coached by Dukkha */
#include <stdio.h>

#define N 200000

int main() {
	static int aa[N];
	int n, i, i1, i2;

	scanf("%d", &n);
	i1 = i2 = -1;
	for (i = 0; i < n; i++) {
		scanf("%d", &aa[i]);
		if (i1 == -1 || aa[i1] < aa[i])
			i2 = i1, i1 = i;
		else if (i2 == -1 || aa[i2] < aa[i])
			i2 = i;
	}
	for (i = 0; i < n; i++)
		printf("%d\n", i == i1 ? aa[i2] : aa[i1]);
	return 0;
}


Measured memory_bytes: 2304
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int a, b, c;
    readf("%s %s %s", &a, &b, &c);
    readln;
    
    auto sm = a + b + c;
    if (sm >= 22) {
        writeln("bust");
    } else {
        writeln("win");
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll A[200010];
ll cnt[200010];
int main()
{
	int N; cin >> N;
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		ans += cnt[A[i]];
		cnt[A[i]]++;
	}
	for (int i = 0; i < N; i++) {
		cout << ans - cnt[A[i]] + 1 << endl;
	}
}

Measured memory_bytes: 6760
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=1005;
int map[MAXN][MAXN];
int n,k;
int main()
{
	scanf("%d %d",&n,&k);
	int mi=n,ma=0;
	for(int i=1;i<=n;i++)
	{
		long long xx=0,yy=0;
		char c;
		bool t;
		scanf("%I64d %I64d %c",&xx,&yy,&c);
		xx%=2*k;
		yy%=2*k;
		t=(c=='W')?0:1;
		if((xx<k&&k<=yy)||(k<=xx&&yy<k))
			t^=1;
		xx%=k;
		yy%=k;
		if(t==0)
		{
			map[xx][0]+=1;
			map[0][yy+1]+=1;
			map[xx][yy+1]-=2;
		}
		else
		{
			map[0][0]+=1;
			map[xx][0]-=1;
			map[0][yy+1]-=1;
			map[xx][yy+1]+=2;
		}
	}
	for(int i=0;i<k;i++)
	{
		for(int j=0;j<k;j++)
		{
			if(i>0)
				map[i][j]+=map[i-1][j];
			if(j>0)
				map[i][j]+=map[i][j-1];
			if(i>0&&j>0)
				map[i][j]-=map[i-1][j-1];
			ma=max(map[i][j],ma);
			mi=min(map[i][j],mi);
		}
	}
	int ans=max(ma,n-mi);
	printf("%d\n",ans);
}

Measured memory_bytes: 4096
n = int(input())
*a, = map(int, input().split())
q = int(input())
d = {}
for i in a:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
ans = sum(a)
for _ in [0]*q:
    b, c = map(int, input().split())
    if b in d:
        if c in d:
            d[c] += d[b]
        else:
            d[c] = d[b]
        ans += (c-b)*d[b]
        d[b] = 0
    print(ans)

Measured memory_bytes: 20636
import sys
import math
import numpy as np
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    a, b, c, x, y = I2()
    ans = float("inf")
    for i in range(2*max(x,y)+1):
        cost = c * i + a * max(0,x - i // 2) + b * max(0,y - i // 2)
        ans = min(cost,ans)
    print(ans)

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int, int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;

inline int updiv(int a,int b){ return (a + b - 1) / b; }
 
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    int n;
    cin >> n;

    int sk = sqrt(n * 2);
    int k = sk + 1;

    if(k * sk != n * 2){
        cout << "No\n";
    }else{
        vector<vector<int> > res(n, vector<int>(2));
        int pos = 0;
        rep(i, k - 1){
            rep(j, sk - i){
                res[pos][0] = i;
                ++pos;
            }
        }
        pos = 0;
        for(int i = 1; i < k; ++i){
            for(int j = i; j < k; ++j){
                res[pos][1] = j;
                ++pos;
            }
        }
        vector<vector<int> > ans(k);
        rep(i,n){
            rep(j,2){
                ans[res[i][j]].emplace_back(i + 1);
            }
        }
        cout << "Yes\n";
        cout << k << '\n';
        rep(i,k){
            cout << sk << ' ';
            rep(j,sk){
                cout << ans[i][j] << (j == sk-1 ? "\n" : " ");
            }
        }
    }

    return (0);
}

Measured memory_bytes: 10596
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long A[] = new long[5];
		long min = Long.MAX_VALUE;
		for(int i = 0; i < 5; i++) {
			A[i] = sc.nextLong();
			min = Math.min(min, A[i]);
		}
		long ans = 5 + (N / min);
		if(N % min == 0) {
			ans--;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FASTIO ios::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int main() {
    FASTIO;
    int x;
    cin >> x;
    cout << (x < 30 ? "No\n" : "Yes\n");
}


Measured memory_bytes: 3664
from math import fsum
from functools import lru_cache
N, K = map(int, input().split())

@lru_cache(maxsize=None)
def f(x):
    return f(x * 2) * 0.5 if x < K else 1

ans = fsum(f(i + 1) for i in range(N)) / N
print(ans)

Measured memory_bytes: 15584
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a[100005]={0};
int main()
{
	 string s;
	 cin>>s;
	 int ans=0;
	 for(int i=0;i<s.length();i++)
	 if(s[i]=='2')ans++;
	 cout<<ans;
 } 

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
  int N,M;
  cin>>N>>M;
  vector<int>a(M),b(M);
  vector<bool>P(N,false),Q(N,false);
  for(int i=0;i<M;i++){
    cin>>a[i]>>b[i];
    if(b[i]==N){P[a[i]]=true;}
    if(a[i]==1){Q[b[i]]=true;}
  }
  for(int i=0;i<N;i++){
    if(Q[i]&&P[i]){cout<<"POSSIBLE"<<endl;return 0;}
  }
  cout<<"IMPOSSIBLE"<<endl;
 return 0;
}

Measured memory_bytes: 4772