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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H=in();int W=in();
    int h=in();
    int w=in();
    cout<<H*W-(h*W+w*H)+h*w<<endl;
    return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;

int N, M, dp[301][301][301];
Vec< pii > seg[301];

const int MOD = (int)1e9 + 7;
void updateDP(int &a, int b) {
	if (a == -1 || b == -1) return;
	a = (a + b) % MOD;
}

bool validate(int r, int g, int b) {
	for (pii p : seg[r]) {
		int cnt = 1 + (p.first <= g) + (p.first <= b);
		if (p.second != cnt) return false;
	}
	return true;
}

int main() {
	cin >> N >> M;
	for_(i,0,M) {
		int l, r, x;
		cin >> l >> r >> x;
		seg[r].push_back(pii(l, x));
	}
	
	memset(dp, 0, sizeof(dp));
	for_(mx,0,N+1) for_(a,0,mx) for_(b,0,mx) {
		if (!validate(mx, a, b)) {
			dp[mx][a][b] = -1;
			dp[a][mx][b] = -1;
			dp[a][b][mx] = -1;
		}
	}
	
	dp[0][0][0] = 1;
	for_(r,0,N) for_(g,0,N) for_(b,0,N) {
		int k = max(r, max(g, b)), num = dp[r][g][b];
		updateDP(dp[k+1][g][b], num);
		updateDP(dp[r][k+1][b], num);
		updateDP(dp[r][g][k+1], num);
	}
	
	int ans = 0;
	for_(i,0,N) for_(j,0,N) {
		updateDP(ans, dp[N][i][j]);
		updateDP(ans, dp[i][N][j]);
		updateDP(ans, dp[i][j][N]);
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 106880
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	az := "abcdefghijklmnopqrstuvwxyz"
	if len(s) < 26 {
		for _, r := range az {
			if !strings.ContainsRune(s, r) {
				fmt.Println(s + string(r))
				return
			}
		}
	} else {
		for i := len(s) - 1; i >= 1; i-- {
			if s[i-1] < s[i] {
				for _, r := range az {
					if r > rune(s[i-1]) && !strings.ContainsRune(s[:i], r) {
						fmt.Println(s[:i-1] + string(r))
						return
					}
				}
			}
		}
		fmt.Println(-1)
	}
}


Measured memory_bytes: 640
from sys import exit

N = int(input())

H = list(map(int, input().split()))

ans = 1
flag = True
for i in range(N):
    if i == 0:
        continue
    for j in range(i):
        if H[j] > H[i]:
            flag = False
    if flag:
        ans += 1
    flag = True

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int X, A; cin >> X >> A;
  if (X < A) {
    cout << 0 << endl;
  } else if (X >= A) {
    cout << 10 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N;
    string s, t;
    scan(N, s, t);
    string ans = "";
    rep(i, N) { ans += string{s[i]} + string{t[i]}; }
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int n,ans=0,sum=0,x;cin>>n>>x;
	vi a(n);
	REP(i,0,n-1)cin>>a[i];
	sort(a.begin(),a.end());
	vi s(n);
	REP(i,0,n-1){
		sum+=a[i];
		s[i]=sum;
	}
	REP(i,0,n-1){
		if(s[i]<=x)ans++;
		else break;
	}
	if(ans==n){
		if(s[n-1]!=x)ans=ans-1;
	}
	cout<<ans;
	return 0;

//   TimeTaken();
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int E, Y;
    int ans;

    cin >> E;
    if(E == 0){
        cin >> Y;

        if(1868 <= Y && Y <= 1911){
            ans = Y - 1867;
            cout << "M" << ans << endl;
        }

        else if(1912 <= Y && Y <= 1925){
            ans = Y - 1911;
            cout << "T" << ans << endl;
        }

        else if(1926 <= Y && Y <= 1988){
            ans = Y - 1925;
            cout << "S" << ans << endl;
        }

        else{
            ans = Y - 1988;
            cout << "H" << ans << endl;
        }
    }

    if(E == 1){
        cin >> Y;
        ans = Y + 1867;
        cout << ans << endl;
    }


    if(E == 2){
        cin >> Y;
        ans = Y + 1911;
        cout << ans << endl;
    }

    if(E == 3){
        cin >> Y;
        ans = Y + 1925;
        cout << ans << endl;
    }

    if(E == 4){
        cin >> Y;
        ans =Y + 1988;
        cout << ans << endl;
    }
    
}



Measured memory_bytes: 3120
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n;
	cin >> n;
	int k = 0;
	for(int i = 1;i * (i-1) <= 2*n;i++){
		if(i * (i-1) == 2 * n)k = i;
	}
	if(k == 0){
		cout << "No" << endl;
		return 0;
	}

	vector<vector<int>> ans(k);
	int now = 1;
	for(int i = 0;i < k-1;i++){
		for(int j = i + 1;j < k;j++){
			ans[i].push_back(now);
			ans[j].push_back(now);
			now++;
		}
	}

	cout << "Yes" << endl;
	cout << k << endl;
	for(int i = 0;i < k;i++){
		int sz = ans[i].size();
		cout << sz << " ";
		for(int j = 0;j < sz-1;j++)cout << ans[i][j] << " ";
		cout << ans[i][sz-1] << endl;
	}
}


Measured memory_bytes: 2304
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007// prime modulo value 
#define C 1000000001
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
double dist(ll x1, ll y1, ll x2, ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll a, b, n;
	cin >> a >> b >> n;
	ll ans = (a * min(n,b-1)) / b;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5;

char s[MAX_N + 5], t[MAX_N + 5];
int n;
int ans = 0;

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(0); cout.tie(0);
	scanf("%s%s", s, t);
	n = strlen(s);
	for (int i = 0; i < n; i++)
    {
        ans += (s[i] != t[i]);
    }
    printf("%d\n", ans);
    return 0;
}


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

typedef long long ll;
const int N = 100054;

int n, q, top = 1;
ll s[N], coef[N], ans[N];

int main() {
	int i, j; ll x; lldiv_t z;
	scanf("%d%d", &n, &q), s[1] = n;
	for (; q; s[++top] = x, --q)
		for (scanf("%lld", &x); top && s[top] >= x; --top);
	coef[top] = 1;
	for (i = top; i; ans[x] += coef[i], --i)
		for (x = s[j = i]; (j = std::upper_bound(s + 1, s + j, x) - s - 1) > 0; x = z.rem)
			z = lldiv(x, s[j]), coef[j] += z.quot * coef[i];
	for (i = n - 1; i; --i) ans[i] += ans[i + 1];
	for (i = 1; i <= n; ++i) printf("%lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
int main(void) {
    string s; cin >> s;
    int ans = 0;
    rep(i, 4) {
        if(s[i] == '+') ans++;
        else ans--;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NO -1
typedef struct Node{
  int p,l,r;
}S;
S tree[MAX];
int getdepth(int x){
  int d=0;
  while(tree[x].p!=NO){
    x=tree[x].p;
    d++;
  }
  return d;
}
int getheight(int y){
  int h1=0,h2=0;
  if(tree[y].l!=NO)h1=getheight(tree[y].l)+1;
  if(tree[y].r!=NO)h2=getheight(tree[y].r)+1;
  if(h1>h2)return h1;
  else return h2;
}
int getsibling(int x){
  if(tree[x].p==NO)return NO;
  if(tree[tree[x].p].l!=x && tree[tree[x].p].l!=NO)return tree[tree[x].p].l;
  if(tree[tree[x].p].r!=x && tree[tree[x].p].r!=NO)return tree[tree[x].p].r;
  return NO;
}
void out(int y){
  int i,j;
  printf("node %d: ",y);
  printf("parent = %d, ",tree[y].p);
  printf("sibling = %d, ",getsibling(y));
  int d=0;
  if(tree[y].l!=NO)d++;
  if(tree[y].r!=NO)d++;
  printf("degree = %d, ",d);
  printf("depth = %d, ",getdepth(y));
  printf("height = %d, ",getheight(y));
  if(tree[y].p==NO)printf("root\n");
  else if(tree[y].l==NO && tree[y].r==NO)printf("leaf\n");
  else printf("internal node\n");
}
int main(){
  int n,i,j,a,b,c;
  scanf("%d",&n);
  for(i=0;i<n;i++)tree[i].p=tree[i].r=tree[i].l=NO;
  for(i=0;i<n;i++){
    scanf("%d%d%d",&a,&b,&c);
    tree[a].l=b;
    tree[a].r=c;
    if(b!=NO)tree[b].p=a;
    if(c!=NO)tree[c].p=a;
  }
  for(i=0;i<n;i++)if(tree[i].p==NO)j=i;
  getheight(j);
  for(i=0;i<n;i++)out(i);
  return 0;
}



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

int main(void)
{
  string s, t = "";
  cin >> s;
  t += s[0];
  for (int i = 1; i < s.size(); i++){
    if (t[t.size() - 1] != s[i]) t += s[i];
  }
  cout << t.size() - 1 << "\n";

  return (0);
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstdio>
#include<stack>
#include<cstring>
#include<string.h>
#include<cmath>
using namespace std;
typedef long long ll;

int main(){
  ll x;
  scanf("%lld",&x);
  if(x%11==0) printf("%lld\n",x/11*2);
  else  if(x%11>6) printf("%lld\n",x/11*2+2);
  else printf("%lld\n",x/11*2+1);

  return 0;
}


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

int main(){
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  
  int ans = 0;
  for(int r = 0; r <= 3000; r++){
    for(int g = 0; g <= 3000; g++){
      int rem = N - (R*r + G*g);
      if(rem >= 0 && rem % B == 0) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

    static class BShiritori {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            Set<String> words = new HashSet<>();
            char last = 0;
            for (int i = 0; i < n; i++) {
                String w = in.next();
                if (words.contains(w) || (last > 0 && last != w.charAt(0))) {
                    out.println("No");
                    return;
                }
                words.add(w);
                last = w.charAt(w.length() - 1);
            }
            out.println("Yes");
        }

    }
}



Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;

using namespace std;

int main() {
    ll N;
    string s;
    cin >> N >>s;
    for(int i = 0; i < 4; i++){
        bool isSheep[N];
        for(int i= 0; i < N; i++){
            isSheep[i] = false;
        }
        if(i & (1 << 0)){
            isSheep[0] = true;
        }
        if(i  < (1 << 1)){
            isSheep[1] = true;
        }
        for(int j = 2; j < N; j++){
            if(isSheep[j - 1]){
                //羊
                if(s[j - 1] == 'x'){
                    isSheep[j] = !isSheep[j - 2];
                }else{
                    isSheep[j] = isSheep[j - 2];
                }
            }else{
                //狼
                if(s[j - 1] == 'x'){
                    isSheep[j] = isSheep[j - 2];
                }else{
                    isSheep[j] = !isSheep[j - 2];
                }
            }
        }
        //Validate
        bool validate1 = false;
        if(isSheep[N - 1]){
            //羊
            if(s[N - 1] == 'x'){
                validate1 = isSheep[N - 2] == !isSheep[0];
            }else{
                validate1 = isSheep[N - 2] == isSheep[0];
            }
        }else{
            //狼
            if(s[N - 1] == 'x'){
                validate1 = isSheep[N - 2] == isSheep[0];
            }else{
                validate1 = isSheep[N - 2] == !isSheep[0];
            }
        }
        bool validate2 = false;
        if(isSheep[0]){
            //羊
            if(s[0] == 'x'){
                validate2 = isSheep[N - 1] == !isSheep[1];
            }else{
                validate2 = isSheep[N - 1] == isSheep[1];
            }
        }else{
            //狼
            if(s[0] == 'x'){
                validate2 = isSheep[N - 1] == isSheep[1];
            }else{
                validate2 = isSheep[N - 1] == !isSheep[1];
            }
        }
        if(validate1 && validate2){
            for(int x = 0; x < N; x++){
                if(isSheep[x]){
                    cout << "S";
                }else{
                    cout << "W";
                }
            }
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const double eps = 1e-9;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ")
{ if (!v.size()) puts(""); rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

signed main() {
  int n = in();
  vector<lint> a(n);

  lint ans = linf, sum = 0;

  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }

  rep(i, n - 1) {
    sum -= 2 * a[i];
    chmin(ans, abs(sum));
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp90 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = st[0];
            int X = st[1];

            var x = Console.ReadLine().Split().Select(int.Parse).ToList();

            x.Add(X);

            x.Sort((a, b) => a.CompareTo(b));

            var diff = new int[N];

            for (int i = 0; i < N; i++) {
                diff[i] = x[i + 1] - x[i];
            }

            int ans = diff[0];

            for (int i = 0; i < N; i++) {
                ans = GCD(ans, diff[i]);
            }

            Console.WriteLine(ans);
        }

        static int GCD(int a, int b) {
            if (a == 0 || b == 0) {
                return 0;
            }

            if (a > b) {
                return GCDRecursive(a, b);
            } else {
                return GCDRecursive(b, a);
            }
        } 

        static int GCDRecursive(int a, int b) {
            if (b == 0) {
                return a;
            } else {
                return GCDRecursive(b, a % b);
            }
        }
    }
}

Measured memory_bytes: 29660
<?php
# 値の入力
fscanf(STDIN, "%d %d %d", $a,$b,$c);
fscanf(STDIN, "%d", $k);

#計算
$ans = max($a,$b,$c) * pow(2 ,$k) + $a + $b +$c -max($a,$b,$c);

echo $ans;
?>

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

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    if((a[0] == a[1] && a[1] != a[2]) || (a[1] == a[2] && a[1] != a[0]))
        cout << "Yes" << '\n';
    else
        cout << "No" << '\n';
}

Measured memory_bytes: 256
import sys

n = int(sys.stdin.readline())
inp = list(map(lambda x: int(x), sys.stdin.readline().split(" ")))


dp = [0]*(n)
dp[1] = abs(inp[1]-inp[0])

for i in range(1,n-1):
    dp[i+1] = min(abs(inp[i+1]-inp[i-1])+dp[i-1], abs(inp[i+1]-inp[i])+dp[i])

print(dp[-1])

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

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

	int A[n][m];
	int b[m][1];
	
	for (int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			int x;
			cin >> x;
			A[i][j] = x;
		}
	}
	
	for (int i = 0; i < m; i++){
		int y;
		cin >> y;
		b[i][1] = y;
	}

	for (int i = 0; i < n; i++){
		int ans = 0;
		for(int j = 0; j < m; j++){
			ans += A[i][j] * b[j][1];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
	FastIO
	string s;
	cin >> s;
	map <lld, lld> points;
	lld curr = 0;
	for(lld i = 1; i < s.length() - 1; i++){
		if (s[i] == 'L' && s[i+1] == 'R'){
			points[curr] = i;
			curr= i+1;
		}
	}
	points[curr] = s.length()- 1;
	lld A[s.length()];
	for(lld i = 0; i < s.length(); i++){
		A[i]= 0;
	}
	for(map <lld, lld> :: iterator pos = points.begin(); pos != points.end(); pos++){
		if (((pos->second)-(pos->first)+1)%2 == 0){
			for(lld i = pos->first; i < pos->second; i++){
				if (s[i] == 'R' && s[i+1] == 'L'){
					A[i] = A[i+1] = ((pos->second)-(pos->first)+1) / 2;
					break;
				}
			}
		}
		else{
			lld count_r = 0;
			lld count_l = 0;
			for(lld i = pos->first; i <=pos->second; i++){
				if (s[i] == 'R'){
					count_r++;
				}
				if (s[i] == 'L'){
					count_l++;
				}
			}
			for(lld i = pos->first; i < pos->second; i++){
					if (s[i] == 'R' && s[i+1] == 'L'){
					if (min(count_l, count_r)%2 == 0){
						if (count_l < count_r){
							A[i] = (((pos->second)-(pos->first)+1)/2) + 1;
							A[i+1]=(((pos->second)-(pos->first)+1)/2) + 0;
						}
						else{
							A[i] = (((pos->second)-(pos->first)+1)/2) + 0;
							A[i+1]=(((pos->second)-(pos->first)+1)/2) + 1;
						}
						break;
					}
					else{
						if (count_l < count_r){
							A[i] = (((pos->second)-(pos->first)+1)/2) + 0;
							A[i+1]=(((pos->second)-(pos->first)+1)/2) + 1;
						}
						else{
							A[i] = (((pos->second)-(pos->first)+1)/2) + 1;
							A[i+1]=(((pos->second)-(pos->first)+1)/2) + 0;
						}
						break;
					}
				}
			}
		}
	}
	for(lld i = 0; i < s.length(); i++){
		cout << A[i] << " ";
	}
	return 0;
}

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

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		char[] S = (sc.next()).toCharArray();
		Arrays.sort(S);
		if(S[0] == S[1] && S[2] == S[3] && S[1] != S[2]) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 21844
N,K = map(int,input().split())
x = list(map(int,input().split()))
ans = 10**17
for i in range(N-K+1):
    l,r = i,i+K-1
    ans = min(abs(x[r])+abs(x[l]-x[r]),min(ans,abs(x[l])+abs(x[r]-x[l])))
print(ans)

Measured memory_bytes: 62576
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}

int main(){
  int n, d, x;
  cin >> n >> d >> x;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int eat = 0;
  rep(i,n){
    int day = 1;
    while(day <= d){
      day += a[i];
      eat++;
    }
  }
  int ans = eat + x;
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
void ADD(LL &x,LL v){
    x+=v;
    if(x>=MOD)x-=MOD;
}
const int MATRIX_SIZE = 500;
struct Matrix_Power{
    LL AA[60][MATRIX_SIZE][MATRIX_SIZE],aa[62][MATRIX_SIZE];
    int N;
    void set(LL _A[][MATRIX_SIZE],int _N,LL bb = (LL)1e18){
        N=_N;
        REP(i,N)
            REP(j,N)AA[0][i][j]=_A[i][j];
        REPP(round,1,60){
            if((1LL<<round)>bb)break;
            REP(i,N)REP(j,N)AA[round][i][j]=0;
            REP(i,N)REP(j,N)REP(k,N){
                AA[round][i][k]+=AA[round-1][i][j]*AA[round-1][j][k];
                AA[round][i][k]%=MOD;
            }
        }
    }
    void go(LL _a[],LL v){
        MS0(aa);
        REP(i,N)aa[0][i]=_a[i];
        REP(i,61){
            if((1LL<<i)>v){
                REP(j,N)_a[j]=aa[i][j];
                return;
            }
            if((v>>i)&1){
                REP(j,N)REP(k,N){
                    aa[i+1][j]+=AA[i][j][k]*aa[i][k];
                    aa[i+1][j]%=MOD;
                }
            }
            else REP(j,N)aa[i+1][j]=aa[i][j];
        }
    }
}MM;
LL A[1000][MATRIX_SIZE];
LL a[SIZE];
int main(){
    A[0][0]=1;
    A[0][2]=1;
    A[1][0]=2;
    A[1][1]=1;
    A[1][2]=1;
    A[2][0]=2;
    A[2][1]=1;
    A[2][2]=2;
    MM.set(A,3);
    DRII(N,M);
    int lt=0;
    a[2]=1;
    REP(i,M){
        DRI(x);
        int cnt=x-lt-1;
        MM.go(a,cnt);
        {
            int v4=a[0];
            ADD(a[0],a[2]);
            ADD(a[1],a[0]);
            ADD(a[1],v4);
        }
        lt=x;
    }
    {
        int cnt=N-lt-1;
        MM.go(a,cnt);
        {
            int v4=a[0];
            ADD(a[0],a[2]);
            ADD(a[1],a[0]);
            ADD(a[1],v4);
        }
    }
    cout<<a[1]<<endl;
    return 0;
}


Measured memory_bytes: 121216
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	double k;
	cin>>a>>b;
	k=(a+b)/2.0;
	if(k-int(k)==0)	printf("%.0lf",k);
	else printf("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD 1000000007
#define INF 1000000
#define PI 3.14159265358979323846264338327950L
#define MAX_N 200010
#define lb lower_bound 

int main()
{
  int x,n;cin>>x>>n;
  vector<int> p(n);
  for (int i=0;i<n;i++)
    cin>>p[i];
  
  int mi=INF;
  int ans;
  int flag=1;
  for (int i=-200;i<=300;i++)
  {
    flag = 1;
    for (int j=0;j<n;j++)
    {
      if (i == p[j]) flag = 0;
    }
    if (flag == 1)
    {
      if (mi > abs(i-x)) 
      {
        ans = i;
        mi = abs(i-x);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
s = gets.chomp+"T"
x,y = gets.split.map(&:to_i)

dp = Array.new(2).map{Array.new(2).map{Hash.new(false)}}

d = [[],[]]
p = [0,0]

g = 0
t = 0
s.size.times do |i|
  if s[i] == "F"
    t += 1
  else
    d[g].push(t)
    t = 0
    g ^= 1
  end
end

dp[0][0][d[0].shift] = dp[1][0][0] = true

2.times do |i|
  d[i].each do |a|
    next if a == 0
    dp[i][p[i]].each do |k,v|
      dp[i][p[i]^1][k-a] = dp[i][p[i]^1][k+a] = true
    end
    dp[i][p[i]].clear
    p[i] ^= 1
  end
end

puts dp[0][p[0]][x] && dp[1][p[1]][y] ? "Yes" : "No"

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


int main() {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  
  vector<int> L(K), R(K);
  int count = 0, workday = 0;
  while (count < N && workday < K) {
    if (S[count] == 'o') {
      L[workday] = count;
      workday++;
      count += C + 1;
    } else {
      count++;
    }
  }
  count = 0, workday = 0;
  while (count < N && workday < K) {
    if (S[N - count - 1] == 'o') {
      R[K - workday - 1] = N - count - 1;
      workday++;
      count += C + 1;
    } else {
      count++;
    }
  }
  // rep(i, K)  cout << L[i] << endl;
  // cout << endl;
  // rep(i, K)  cout << R[i] << endl;
  // cout << endl;
  rep(i, K) if (L[i] == R[i]) cout << L[i] + 1 << endl;
  return 0;
}


Measured memory_bytes: 3332
import sys

import numpy as np
MOD = 10 ** 9 + 7
def cumprod(a, p):
  l = len(a); sql = int(np.sqrt(l) + 1)
  a = np.resize(a, sql ** 2).reshape(sql, sql)
  for i in range(sql - 1): a[:, i+1] *= a[:, i]; a[:, i+1] %= p
  for i in range(sql - 1): a[i+1] *= a[i, -1]; a[i+1] %= p
  return np.ravel(a)[:l]

def make_tables(n=10 ** 9, r=10 ** 7, p=MOD):
  fac = np.arange(r + 1); fac[0] = 1; fac = cumprod(fac, p)
  ifac = np.arange(r + 1, 0, -1); ifac[0] = pow(int(fac[-1]), p - 2, p)
  ifac = cumprod(ifac, p)[n::-1]
  n_choose = np.arange(n + 1, n - r, -1); n_choose[0] = 1;
  n_choose[1:] = cumprod(n_choose[1:], p) * ifac[1:r+1] % p
  return fac, ifac, n_choose

fac, ifac, n_choose = make_tables()

def choose(n, r, p=MOD):
  return fac[n] * ifac[r] % p * ifac[n-r] % p

n, k = map(int, sys.stdin.readline().split())
a = np.array(sys.stdin.readline().split(), dtype=np.int64)
a.sort()

def main():
  res = (a[k-1:] * choose(np.arange(k-1, n), k - 1) % MOD).sum() % MOD
  res -= (a[:n-(k-1)] * choose(np.arange(n-1, k-2, -1), k-1) % MOD).sum() % MOD
  res %= MOD
  print(res)
    
if __name__ == '__main__':
  main()


Measured memory_bytes: 637412
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

int main(){
  int n;cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  vector<P> p;
  for(int i = 1;i < n-1;i++){
    if(a[i]>0){
      p.emplace_back(a[0],a[i]);
      a[0] -= a[i];
    }else{
      p.emplace_back(a[n-1],a[i]);
      a[n-1] -= a[i];
    }
  }
  cout << a[n-1] - a[0] << endl;
  for(auto q:p) printf("%d %d\n",q.first,q.second);
  printf("%d %d\n",a[n-1],a[0]);
  
}

Measured memory_bytes: 4712
#include <iostream>

using namespace std;
#define ll long long
int main(){
    int ans=0;
    int a,b;
    cin >>a>>b;
    if(a*b==15){
        cout <<"*"<<endl;
    }else if(a+b==15){
        cout <<"+"<<endl;
    }else{
        cout <<"x"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
 * atcoder/dp_2nd/n.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long
#define MOD 1000000007

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX = 420;
const ll INF = 100000000000000000;
ll N;
vector<ll> A;

// [l: r) までを合体させる最小コスト
ll dp[MAX][MAX];

void input() {
  cin >> N;
  ll a;
  loop(n,0,N) {
    cin >> a;
    A.push_back(a);
  }
}

// 累積和使わなくてもO(400^3)で間に合う
void solve() {
  for (int len=1; len<=N; len++) {
    for (int l=0; l+len<=N; l++) {
      if (len == 1) { dp[l][l+1] = 0; continue; }
      ll self = 0, child = INF;
      int r = l+len;
      for (int i=l; i<r; i++) self += A[i];
      for (int cut=l+1; cut<r; cut++) {
        chmin(child, dp[l][cut] + dp[cut][r]);
      }
      dp[l][r] = self + child;
    }
  }
  cout << dp[0][N] << endl;
}

void dump() {
  for (int len=1; len<=N; len++) {
    for (int l=0; l+len<=N; l++) {
      cout << "[" << l << ": " << (l+len-1) << "] dp = " << dp[l][l+len] << endl;
    }
  }
}

int main() {
  // cout.precision(15);
  input();
  solve();
  // dump();
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	string s; cin >> s;
	rep(i,s.size()) {
		if(s[i]==',') s[i]=' ';
	}
	cout << s << endl;
}

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

using namespace std;

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

#define INF (1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

   int N,A,B;
   cin>>N>>A>>B;
   vector<ll>X(N);
   for(int i=0;i<N;i++)cin>>X[i];

   ll d;
   ll ans = 0;
   for(int i=1;i<N;i++){
     d = X[i]-X[i-1];
     if(A*d<B)ans += A*d;
     else ans += B;
   }
   cout<<ans<<endl;
   return 0;
}


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

int main() {
  long long n;
  cin>>n;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  long long sum = 0;
  for (int i=0; i<n; i++) {
    sum += a[i];
  }
  if (sum % (n * (n + 1) / 2) != 0) {
    cout<<"NO"<<endl;
    return 0;
  }
  long long k = sum / (n * (n + 1) / 2);
  for (int i=0; i<n; i++) {
    if (a[i] < k || a[i] > n * k) {
      cout<<"NO"<<endl;
      return 0;
    }
  }
  long long cnt = 0;
  for (int i=0; i<n; i++) {
    int j = (i + 1) % n;
    if (a[j] - a[i] == k) {
      continue;
    }
    long long tmp = k + a[i] - a[j];
    if (tmp % n != 0) {
      cout<<"NO"<<endl;
      return 0;
    }
    cnt += tmp / n;
  }
  if (cnt == k) {
    cout<<"YES"<<endl;
  } else {
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 640
/** Bismillahir Rahmanir Rahim **/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define Fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define print(x) cout << "x " << x;

int main()
{
    int n, m;
    cin >> n >> m;
    int tot = 0, totw = 0;

    vector<pair<int, int> > v(n + 1, {0, 0});
    for (int i = 1; i <= m; i++) {
        int x;
        cin >> x;
        char c, ch;
        cin >> c >> ch;

        if (c == 'A' and v[x].first == 0) {
            tot++;
            totw += v[x].second;
            v[x].first = 1;
        } else if (c == 'W' and v[x].first == 0) {
            v[x].second++;
        }
    }
    cout << tot << " " << totw << endl;

    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

int main(){
    int n,t;
    cin >> n >> t;
    vector<int> a(n);
    vector<int>b(n);
    int ans =10e4;
    for(int i=0;i<n;i++){
        cin >> a.at(i) >> b.at(i);
        if(b.at(i)<=t){
        ans =min (ans,a.at(i));
        }
    }
    if(ans == 10e4){
        cout <<"TLE" << endl;
    }
    else cout <<  ans << endl;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    cout << "ABC" << n << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
      
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int result = 0;
        int lower;
        int upper;

        lower = Math.max(a, c);
        upper = Math.min(b, d);

        if (upper >= lower) {
            result = upper - lower;
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int N = 10001;
 


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

    int n,m;
    cin >> n >> m;
    vvi g(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        --a;--b;
        g[a].pb(b);
        g[b].pb(a);
    } 
    /*
    rep1(i,n){
        for(auto it : g[i]) cout <<  it + 1 << " ";
        cout  << endl;
    }
    */
    vi dist(n,INF);
    vi before(n,INF);
    queue<int> q;

    auto push = [&](int v, int d,int b){
        if(dist[v] != INF) return;
        dist[v] = d;
        before[v] = b;
        q.push(v);
    };
    push(0, 0, 0);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        int d = dist[v];
        rep(i,g[v].size()){
            push(g[v][i],d+1,v);
        }    
    }

    rep(i,n){
        if(dist[i]==INF) No
    }
    cout << "Yes" << endl;
    rep1(i,n){
        cout << before[i]+1 << endl;
    }
	return 0;
}

Measured memory_bytes: 10608
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <time.h>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
//#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//


inline ll solve(int a) {
	if (a == 1)return 1;
	return a*solve(a - 1);
}

int main() {
	int n; cin >> n;
	cout << solve(n) << endl;
	return 0;
}

Measured memory_bytes: 2992
def solve():
    # ref. https://drken1215.hatenablog.com/entry/2020/06/21/225500
    N = int(input())
    ans = ''
    while N > 0:
        N -= 1
        N,digit = divmod(N,26)
        ans += chr(ord('a') + digit)
    print(ans[::-1])

if __name__ == "__main__":
    solve()

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

int main() {
  int n, m = 8;
  cin >> n;
  int r = 0;
  for (int i = 1; i <= n; i += 2) {
    int c = 0;
    for (int j = 1; j <= i; j++) {
      c += i % j == 0;
    }
    if (c == m) {
      r++;
    }
  }
  cout << r << endl;
}


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

int main(){

    int input_num;
    cin >> input_num;

    int64_t sum = 0;
    int i;

    for (i=1; i<=input_num; i++){
        
        if ((i%3 == 0) && (i%5 == 0)){
            continue;
        }
        else if (i%3 == 0) {
            continue;
        }
        else if (i%5 == 0) {
            continue;
        }
        else{
            sum += i;
        }
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3636
n = int(input())
csf = [list(map(int,input().split())) for _ in range(n-1)]

for i in range(n):
    time = 0
    while True:
        if i == n-1:
            print(time)
            break
        if time < csf[i][1]:
            time = csf[i][1] + csf[i][0]
        else:
            if time%csf[i][2] == 0:
                time += csf[i][0]
            else:
                time += csf[i][0] + csf[i][2] -  time%csf[i][2]
        i += 1


Measured memory_bytes: 9220
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int size, n;
    cin >> size >> n;
    ++ n;
    vector<int> r(n, 0);
    for(int i=1; i<n; ++i)
        cin >> r[i];

    int x1 = 0;
    int y1 = 0;
    int x2 = size;
    int y2 = size;

    int q;
    cin >> q;
    int i = 0;
    while(--q >= 0){
        int t, a;
        cin >> t >> a;

        while(i+1 < n && r[i+1] < t){
            if(i % 2 == 0){
                y1 -= r[i+1] - r[i];
                y2 -= r[i+1] - r[i];
                if(y2 < 0){
                    x1 = x2 = size;
                    y1 = y2 = 0;
                }
                else if(y1 < 0){
                    x1 += -y1;
                    y1 = 0;
                }
            }
            else{
                y1 += r[i+1] - r[i];
                y2 += r[i+1] - r[i];
                if(y1 > size){
                    x1 = x2 = 0;
                    y1 = y2 = size;
                }
                if(y2 > size){
                    x2 -= y2 - size;
                    y2 = size;
                }
            }
            ++ i;
        }

        if(a < x1)
            a = x1;
        else if(a > x2)
            a = x2;

        int ans;
        if(i % 2 == 0){
            ans = (a - x1 + y1) - (t - r[i]);
            ans = max(ans, 0);
        }
        else{
            ans = (a - x1 + y1) + (t - r[i]);
            ans = min(ans, size);
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1664
alice,bob = map(int,input().split())
if(bob == 1 or alice == 1):
    if(bob == 1 and alice == 1):
        print("Draw")
    elif(bob == 1):
        print("Bob")
    else:
        print("Alice")
else:
    if(bob < alice):
        print("Alice")
    elif(alice < bob):
        print("Bob")
    else:
        print("Draw")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, l;
  cin >> n >> l;
  string s[n], ans = "";
  for(int i=0; i<n; ++i) cin >> s[i];
  sort(s, s+n);
  for(int i=0; i<n; ++i) ans += s[i];
  cout << ans << endl;
}

Measured memory_bytes: 3632