akhauriyash/Code-Regression huggingface dataset:
def main():
    N, A, B, C = map(int, input().split())
    d = {'A':A, 'B':B, 'C':C}
    l = []
    for _ in range(N):
        s = input()
        l.append(s)
    r = []
    for i in range(N):
        x, y  = l[i][0], l[i][1]
        z = 'A'
        for j in d:
            if j not in l[i]:
                z = j
        if d[x] > d[y]:
            d[x] -= 1
            d[y] += 1
            r.append(y)
        elif d[y] > d[x]:
            d[x] += 1
            d[y] -= 1
            r.append(x)
        else:
            if d[x] > 1 or i == N-1:
                d[x] += 1
                d[y] -= 1
                r.append(x)
            elif set(l[i]) == set(l[i+1]):
                d[x] += 1
                d[y] -= 1
                r.append(x)
            else:
                x2 = 'A'
                for j in l[i+1]:
                    if j != z:
                        if j == y:
                            x, y = y, x
                if d[z] > 1:
                    d[x] -= 1
                    d[y] += 1
                    r.append(y)
                else:
                    d[x] += 1
                    d[y] -= 1
                    r.append(x)
            if d[x] < 0 or d[y] < 0 or d[z] < 0:
                return False, r
    return True, r
x, y = main()
if x:
    print('Yes')
    for i in y:
        print(i)
else:
    print('No')


Measured memory_bytes: 16992
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(int n, int k) {
    if (n == 2) {
        if (k == 0) {
            writeln(1);
            writeln("1 2");
        }
        else writeln(-1);
        return;
    }
    else if (n == 3) {
        if (k == 1) {
            writeln(2);
            writeln("1 2");
            writeln("2 3");
        }
        else writeln(-1);
        return;
    }

    int e = (n - 1) * (n - 2) / 2;
    if (e < k) {
        writeln(-1);
        return;
    }

    long[][] edges;
    for (int i = 2; i <= n; i++) {
        edges ~= [1, i];
    }

    int del = e - k;
    for (int i = 2; i <= n; i++) {
        if (del == 0) break;
        for (int j = i + 1; j <= n; j++) {
            edges ~= [i, j];
            if (--del == 0) break;
        }
    }

    writeln(edges.length);
    foreach (x; edges) {
        writeln(x[0], " ", x[1]);
    }

}

void main() {
    int n, k; scan(n, k);
    calc(n, k);
}


Measured memory_bytes: 508
#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(){
  string s;
  cin >> s;
  string ans = "AC";
  int l = s.size();
  if(s[0] != 'A') ans = "WA";
  int cnt = 0;
  REP(i,l){
    if(isupper(s[i])){
      if(i < 2 || i == l-1) ans = "WA";
      if(s[i] == 'C') cnt++;
      else ans = "WA";
    }
  }
  if(cnt != 1) ans = "WA";
  cout << ans << endl; 
}



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

#define ll long long
#define endl '\n'
#define pii pair<ll,ll>
#define N 100007
#define mod 1000000007
#define pb push_back;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    ll n,k;
    cin>>n>>k;
    ll i,x;
    vector<ll> v;
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    k--;
    for(i=k;i<n-1;i++)
    {
        if(v[i-k]<v[i+1])
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<string, pair<int, int>> P;

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

  vector<P> v(N);
  for (int i = 0; i < N; i++)
  {
    cin >> v[i].first >> v[i].second.first;
    v[i].second.second = i + 1;
    v[i].second.first *= -1;
  }

  sort(v.begin(), v.end());

  for (int i = 0; i < N; i++)
  {
    cout << v[i].second.second << endl;
  }
}

Measured memory_bytes: 256
/*
                                Bismillahi-r-Rahmani-r-Rahim
                                        RhIeyAaD
                                    IIT-7th Batch,JU
*/
#include<bits/stdc++.h>
using namespace std;

#define debug(args...){ string _s = #args;replace(_s.begin(),_s.end(),',', ' ');stringstream _ss(_s);istream_iterator<string>_it(_ss);err(_it, args);}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << "=" << a << ", "; err(++it, args...);}

#define ll              long long int
#define MAX             2134567891
#define fr(i,n)         for(i=0;i<n;i++)
#define rep(i,n)        for(i=1;i<=n;i++)
#define rev(i,a,n)      for(i=n;i>=a;i--)
#define FOR(i,a,n)      for(i=a;i<=n;i++)
#define ALL(n)          n.begin(),n.end()
#define mem(x,n)        memset(x,n,sizeof(x))
#define TC(t)           printf("Case %lld: ",t)
#define ans(t,c)        printf("Case %lld: %lld\n",t,c)
#define SETP(n)         cout<<setprecision(n)<<fixed
#define READ            freopen("F:\\Project\\Test_Case.txt","r",stdin)
#define WRITE           freopen("F:\\Project\\Output_Test.txt","w",stdout)
#define IO              ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define PAIR            pair<ll,ll>
#define MP              make_pair
#define pb              push_back
#define eb              emplace_back
#define ff              first
#define ss              second
#define NL              printf("\n");
#define bug(a)          cout<<#a<<" "<<a<<" ";
#define hlw             printf("hlw\n");
#define NN              111
#define MOD             1000000007///10^9
#define N               1000007 ///10^6->6 zero after 1 **



ll x[N],y[N],z[N],n;
string s,S;
vector<ll>v;
bitset<N>B;
map <ll,ll> mp;

int main()
{
    //IO;
    //while(1)
    //READ;WRITE;
{
    ll a=0,b=0,c=0,d,e,f,g,i,j,k,l,m,p,q,r,u,w,t,tc=1,in,loc,val,sz,lo,hi,mid,mn=MAX,mx=0,sum=0,ans=0;
//cin>>tc;
rep(t,tc)
{
    cin>>s;
    l=s.size();
    reverse(ALL(s));
    a=0,mp[0]=p=1;
    fr(i,l)
    {
        a=(a+(s[i]-'0')*p)%2019;
        ans+=mp[a];
        mp[a]++;
        p=(p*10)%2019;
        //debug(p,a,ans);NL
    }
    cout<<ans<<endl;

}
}
    return 0;
}

/*


*/
/// Check for constraint 0 or 1?
/// Division MOD needs BigMod(a,n-2)
/// long long or double? sqrt or division will work fine??
/// sort(begin(v), end(v), [] (int a, int b) { return a > b; });    /// Lambda Function for manual Sort


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

typedef long long ll;
typedef vector < int > vi;
typedef pair <int , int > pi;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fr(i,a,b) for(int i=a;i<b;i++)




int isprime(ll n)
{
    int flag=0;
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            flag=1;;
            break;
        }
    }
    return flag;
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int arr[n];
    map<int , int >m;
    ll sum1 =0;
   
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        m[arr[i]]++;
        sum1+=arr[i];

    }

    ll w = m.size();
    
    int q;
    cin>>q;
    ll sum[q+1];
    memset(sum,0,sizeof(sum));
    sum[0]=sum1;
    
    for(int i=1;i<=q;i++)
    {
        int a,b;
        cin>>a>>b;
        if(m[a])
        {
            sum[i]+=(sum[i-1]+((b-a)*m[a]));
            m[b]+=m[a];
            m[a]=0;
        }
        else
        {
            sum[i]=sum[i-1];
        }
        

        
    }

    for(int i=1;i<=q;i++)
    {
        cout<<sum[i]<<"\n";
    }



  
  
    return 0;
}


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,m,tot,now;
int v[200005],nxt[200005],h[100005],siz[100005],f[200005],son[100005],col[200005],a[100005],b[100005],ans[100005];
bool vis[200005];
vector<int> gar;

int getf(int x){return x==f[x]?x:f[x]=getf(f[x]);}

void addedge(int x,int y){
	v[++tot]=y; nxt[tot]=h[x]; h[x]=tot;
	v[++tot]=x; nxt[tot]=h[y]; h[y]=tot;
}

void dfs1(int u,int fa){
	siz[u]=1;
	for(int p=h[u];p;p=nxt[p]){
		if(v[p]==fa) continue;
		dfs1(v[p],u);
		if(siz[v[p]]>siz[son[u]]) son[u]=v[p];
		siz[u]+=siz[v[p]];
	}
}

void change(int x,int y){
	if(!col[x]) gar.pb(x),col[x]=1;
	if(!col[y]) gar.pb(y),col[y]=1;
	int fx=getf(x),fy=getf(y);
	if(fx==fy){
		if(!vis[fx]) now++,vis[fx]=1;
		return;
	}
	f[fx]=fy;
	if(!vis[fx]&&!vis[fy]){
		now++;
		return;
	}
	if(vis[fx]&&vis[fy]) return;
	vis[fy]=1,now++;
}

void add(int u,int fa){
	change(a[u],b[u]);
	for(int p=h[u];p;p=nxt[p]){
		if(v[p]==fa) continue;
		add(v[p],u);
	}
}

void dfs2(int u,int fa,bool kp){
	for(int p=h[u];p;p=nxt[p]) if(v[p]!=fa&&v[p]!=son[u]) dfs2(v[p],u,0);
	if(son[u]) dfs2(son[u],u,1);
	for(int p=h[u];p;p=nxt[p]) if(v[p]!=fa&&v[p]!=son[u]) add(v[p],u);
	change(a[u],b[u]);
	ans[u]=now;
	if(!kp){
		for(auto x:gar) f[x]=x,vis[x]=0,col[x]=0;
		gar.clear();
		now=0;
	}
}

int main(){
	n=readint(); m=readint();
	for(int i=1;i<=m;i++) f[i]=i;
	for(int i=1;i<n;i++) addedge(readint(),readint());
	for(int i=1;i<=n;i++) a[i]=readint(),b[i]=readint();
	dfs1(1,-1);
	dfs2(1,-1,1);
	for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 13316
#include <stdio.h>
#include <stdlib.h>

#define MAX 1000000
struct unk{
   int time;
   char name[10];
} ;

void intialize();
int isEmpty();
int isFull();
void enqueue(struct unk);
struct unk dequeue();

int head,tail;

struct unk Q[MAX];
struct unk A[MAX];

int main(){
    int n,q,i,sum=0;
    struct unk a;
    scanf("%d%d",&n,&q);

    for(i=0;i<n;i++){
        scanf("%s%d",A[i].name,&A[i].time);
        enqueue(A[i]);
    }

    while(isEmpty()-1){
        a = dequeue();
     
    if(a.time<=q){
               sum += a.time;
              
               printf("%s %d\n",a.name,sum);
        }

        else{
            a.time = a.time -q;
            enqueue(a);
            sum += q;
        }
   
    }
     
     return 0;

}



void intialize()
{
    head = tail = 0;
}

int isEmpty()
{
    if (head == tail)
    {
        return 1;
    }

    else{
         return 0;
    }
       
}

int isFull()
{
    if (head == (tail +1)%MAX)
    {
        return 1;
    }

    else{
     return 0;
    }
     
}

void enqueue(struct unk x){
     if (isFull())
    {
        printf("エラー\n");
    }
    Q[tail] = x;
    if( tail +1 == MAX){
        tail = 0;
    }

    else{
        tail++;
    }
}

struct unk dequeue(){
    struct unk x;
    if (isEmpty())
    {
        printf("エラー\n");
    }

    x = Q[head];
    if(head +1==MAX){
        head = 0;
    }

    else {
        head++;
    }

    return x;
}


Measured memory_bytes: 5428
w = gets.strip.chars

h = {}

w.each do |char|
  if h[char]
    h[char] += 1
  else
    h[char] = 1
  end
end

h.each do |k,v|
  if v.odd?
    puts 'No'
    exit 0
  end
end

puts 'Yes'


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;

#define mod (1000000007)

int saijouiNum(ll num)
{
    int saijoui;
    while (num > 0) {
        saijoui = num;
        num = num / 10;
    }
    return saijoui;
}

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

    ll count = 0;
    map<pair<int, int>, int> freq;
    for (int i = 1; i <= n; i++) {
        pair<int, int> tmp;
        tmp.first = i % 10;
        tmp.second = saijouiNum(i);
        freq[tmp]++;
    }
    for (int i = 1; i <= n; i++) {
        pair<int, int> tmp;
        tmp.second = i % 10;
        tmp.first = saijouiNum(i);
        count += freq[tmp];
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>//本当は必要なヘッダファイルだけインクルードするべきです
using namespace std;//本当は個別にusingするか変数や関数ごとにstd::をつけるべきです
//本当は関数内に宣言し明示的に初期化するべきです
string x;
long a,l,i;
int main(void){
  while(cin>>x){
    if(x=="0")break;
    a=0;
    l=x.size();
    for(i=0;i<l;i++)a+=(x[i]-'0');
    cout<<a<<endl;
  }
  return 0;
}



Measured memory_bytes: 3172
#include <stdio.h>
#include <math.h>
int main(void){
    double x,h,S,m;
    
    while(1){
        scanf("%lf %lf",&x,&h);
        if(x==0 && h==0)break;
        
        S=x*x;
        m=sqrt(h*h+x*x/4);
        S+=2*x*m;
        
        printf("%lf\n",S);
    }
    return 0;
}

Measured memory_bytes: 644
import java.util.*;

public class Main{
	public static void main(String[] main){
		try(Scanner sc = new Scanner(System.in)){
			long n = sc.nextLong(), T = sc.nextLong();
			String S = sc.next();
			double num = 0;
			for(int i = 2; i < S.length(); i+=4){
				num += Math.pow(n, Character.getNumericValue(S.charAt(i)));
			}
			if(num * T > 1e9){
				System.out.println("TLE");
			} else {
				System.out.println((long)num * T);
			}
		}
	}
}

Measured memory_bytes: 26344
N, M = map(int, input().split())
L, R = [], []

for i in range(M):
    l, r = map(int, input().split())
    L.append(l), R.append(r)

if max(L) <= min(R):
    print(min(R) - max(L) + 1)
else:
    print(0)


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

void write(int rest, char used, string s) {
    if (rest == 0) {
        cout << s << endl;
        return;
    }
    for (char c = 'a'; c <= used + 1; c++) {
        write(rest - 1, max(c, used), s + c);
    }
}

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

    write(n, 'a' - 1, "");

    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;

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

	if (b - a == c - b)
		cout << "YES";
	else
		cout << "NO";
}

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

int main() {
	int n,a,b;
	cin>>n>>a>>b;
	
	cout<<min(n*a,b);
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		int a = 0;
		int b = 0;
		int c = 0;
		for(int i = 0;i < s.length;i++){
			if(s[i].equals("a")){
				a++;
			} else if(s[i].equals("b")){
				b++;
			} else if(s[i].equals("c")){
				c++;
			}
		} 
		if(a == 1 && b == 1 && c == 1){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21972
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        mut k: usize,
    }
    if k % 7 == 0 {
        k /= 7;
    }

    if k == 1 {
        println!("1");
        return;
    }

    let mut rems = vec![0; 1000001];
    rems[1] = 1;
    for i in 2..rems.len() {
        rems[i] = rems[i-1] * 10 % k;
    }
    for i in 1..rems.len() {
        rems[i] += rems[i-1];
        rems[i] %= k;
    }

    for i in 1..rems.len() {
        if rems[i] == 0 {
            println!("{}", i);
            return;
        }
    }
    println!("-1");

}


Measured memory_bytes: 9996
A = int(input())  # 500
B = int(input())  # 100
C = int(input())  # 50
X = int(input())  

count = 0
total_price = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            total_price = 500 * i + 100*j + 50*k
            if total_price == X:
                count += 1
print(count)

Measured memory_bytes: 9052
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**19
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
x = []
y = []
for i in range(n):
    xx,yy = inm()
    x.append(xx)
    y.append(yy)
mn = BIG
for i in range(n-1):
    for j in range(i+1,n):
        xn = min(x[i],x[j])
        xx = max(x[i],x[j])
        for ii in range(n-1):
            for jj in range(ii+1,n):
                yn = min(y[ii],y[jj])
                yx = max(y[ii],y[jj])
                cnt = 0
                for m in range(n):
                    if xn<=x[m]<=xx and yn<=y[m]<=yx:
                        cnt += 1
                if cnt>=k:
                    mn = min(mn, (xx-xn)*(yx-yn))
print(mn)


Measured memory_bytes: 52188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 200005;
const long long MOD = 1000000007;
const long long MODMOD = 998244353;
const double PI = acos(-1);

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

void COMinit() {
    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;
    }
}

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

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
  vector<int> p;
  vector<int> s;
  void init(int n) {
    p.resize(n, -1);
    s.resize(n, 1);
  }
  int find(int n) {
    if(p[n] == -1) return n;
    else return find(p[n]);
  }
  int size(int n) {
    return s[find(n)];
  }
  void unite(int n, int m) {
    int pn = find(n);
    int pm = find(m);
    if(pn == pm) return;
    if(s[pn] > s[pm]) {
      s[pn] = s[pn] + s[pm];
      p[pm]= pn;
    } else {
      s[pm] = s[pm] + s[pn];
      p[pn] = pm;
    }
  }
};

long long gcd(long long a, long long b) {
  if(a % b == 0) return b;
  else return gcd(b, a % b);
}
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  ll ans = 0;
  ll tmp = 0;
  rep(i, n) {
    cin >> a[i];
    if(a[i] == 0) {
      ans += tmp / 2;
      tmp = 0LL;
    }
    tmp += a[i];
  }
  ans += tmp / 2;
  cout << ans << endl;
} 


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;

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

    int A[M];
    for(int i=0; i<M; i++){
        cin >> A[i];
    }

    long sum = 0;
    for(int i=0; i<M; i++){
        sum = sum + (long long)A[i];
    }

    if(sum <= N) cout << N-sum << endl;
    else cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define lld long long int
int main()
{
	int n;
	cin>>n;
	vector<lld>arr;
	for(int i=0;i<n;i++)
	{
		lld x;
		cin>>x;
		arr.push_back(x);
	}
	if(n==1)
	{
		cout<<0<<"\n";
		return 0;
	}
	sort(arr.begin(), arr.end());
	reverse(arr.begin(), arr.end());
	lld res = 0;
	res += arr[0];
	int ct = (n-2);
	for(int i=1;i<n;i++)
	{
		if(ct==0)
		{
			break;
		}
		else if(ct>=2)
		{
			ct -= 2;
			res += 2*arr[i];
		}
		else if(ct==1)
		{
			ct -= 1;
			res += arr[i];
		}
	}
	cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 5320
/**
*Keep
**Moving
***Forward
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
#define pb push_back
#define all(c) (c).begin(),(c).end()



int main() {
    int q,h,s,d;
    cin >>q >> h >>s >> d;
    int n;
    cin >> n;
    long long ans = 0;
    if(n>=2){
        long long a = n/2;
        int da = d;
        int sa = 2*s;
        int ha = 4*h;
        int qa = 8*q;
        int mn = min(da,min(sa,min(ha,qa)));
        n-=a*2;
        a*=mn;
        ans+=a;
    }
    if(n>=1){
        long long a = n;
        int sa = s;
        int ha = 2*h;
        int qa = 4*q;
        int mn = min(sa,min(ha,qa));
        n-=a;
        a*=mn;
        ans+=a;
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>


int main(void)
{
    int i,j,n,k,l,top,dice[10],dice2[10];

    scanf("%d",&n);

    for(i=0;i<6;i++){
        scanf("%d",&dice[i]);
    }

    for(k=0;k<n;k++){
        for(l=0;l<6;l++){
        scanf("%d",&dice2[l]);
        }
    for(i=0;i<8;i++){
        if(memcmp(dice,dice2,sizeof(dice))==0)break;
        if(dice[0]==dice2[0]){
            for(j=0;j<4;j++){
                top=dice2[1];
                dice2[1]=dice2[2];
                dice2[2]=dice2[4];
                dice2[4]=dice2[3];
                dice2[3]=top;
                if(memcmp(dice,dice2,sizeof(dice))==0) goto OUT;
            }
        }
        if(i<4){
                top=dice2[0];
                dice2[0]=dice2[1];
                dice2[1]=dice2[5];
                dice2[5]=dice2[4];
                dice2[4]=top;
        }else{
                top=dice2[0];
                dice2[0]=dice2[2];
                dice2[2]=dice2[5];
                dice2[5]=dice2[3];
                dice2[3]=top;
        }
    }
    }
    OUT:

    if(memcmp(dice,dice2,sizeof(dice))!=0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}




Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    vector<int> a(N);
    ll total = 0, st = 0, ans = __LONG_LONG_MAX__;
    
    rep(i, N) {
        cin >> a[i];
        total += a[i];
    }
    
    rep(i, N) {
        st += a[i];
        
        if (i < (N - 1)) {
            ans = min(ans, abs(total - 2 * st));
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>
using ll = long long;
using namespace std;


int main() {

    int n;
    cin >> n;
    cout << pow(n, 3) << endl;
    return 0;
}


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

#define rep( i, n, m ) for (int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for (int i = ( n ); i < ( m ); i--)

int main( void ){
	std::string str;
	std::cin >> str;
	if (str == "Sunny") printf( "Cloudy\n" );
	else if (str=="Rainy") printf( "Sunny\n" );
	else if (str=="Cloudy") printf( "Rainy\n" );
	return 0;
}


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

int main() {
  ll N,M;
  cin>>N>>M;
  rep(i,M){
ll a;
cin>>a;
N-=a;
  }
  if(N>=0){
    cout<<N<<endl;
  }else{
    cout<<-1<<endl;
  }
}


Measured memory_bytes: 3632
N = int(input())
xl = []
for i in range(N):
    x,l = list(map(int,input().split()))
    xl.append([x - l, x + l])
    
#xl = [[1,2],[3,4],[5,6]]
xl.sort(key=lambda x:x[1])
ans = 1
tmp = xl[0][1]
for i in range(1,N):
    if xl[i][0] >= tmp:
        ans += 1
        tmp = xl[i][1]
print(ans)

Measured memory_bytes: 21800
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
ll a,b;
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> a >> b;
	cout << lcm(a,b) << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

Measured memory_bytes: 256
a,b,c = map(int, input().split())

num = min(b, c)
num2 = 0
c -= num
if num > 0:
    num2 = min(c, a)
c -= num2

sum = num*2 + num2
b -= num
if b > 0:
    sum += b
if c > 0:
    sum += 1

print(sum)

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

int main(){
    vector<int> time(5);
    int mod10 = 10;
    int index;
    
    for(int i=0; i<5; i++){
        cin>>time[i];
        if(time[i]%10 < mod10 && time[i]%10 != 0){
            mod10 = time[i]%10;
            index = i;
        }
    }

    for(int i=0; i<5; i++){
        if(i != index){
            if(time[i]%10 != 0){
                time[i] = time[i]-time[i]%10+10;
            }
        }
    }

    int ans = 0;
    for(int i=0; i<5; i++){
        //cout<< time[i] <<endl;
        ans += time[i];
    }

    cout<< ans <<endl;
    return 0;
}

Measured memory_bytes: 3624
import Foundation

let n = Int(readLine()!)!
let scanner = Scanner(string: readLine()!)
let a = (0..<n).map { _ in scanner.scanInt()! }

var acc = 0
//var min = scanner.scanInt()!
var min = 0

// for _ in 1..<n {
//   let num = scanner.scanInt()!
for num in a {
  if min > num {
    acc += min - num
  } else {
    min = num
  }
}

print(acc)


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

int main()
{
    int num[3];
    for(int i=0; i<3; i++)
        cin >> num[i];
    for(int i=0; i<2; i++){
        for(int j=i+1; j<3; j++){
            if(num[i] > num[j]){
                int tmp = num[i];
                num[i] = num[j];
                num[j] = tmp;
            }
        }
    }
    cout << num[0] << ' ' << num[1] << ' ' << num[2] << endl;
    
    return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin>>n;
	string s;
	s="";
	if(n==0){
		s+='0';
	}
	long long i;
	i=1;
	while(n){
		if(n%(2*abs(i))){
			s+='1';
			n-=i;
		}
		else{
			s+='0';
		}
		i*=-2;
	}
	reverse(s.begin(),s.end());
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  long double a,b,c; cin >> a >> b >> c;
  if(sqrt(a*b)<(c-b-a)/2.0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

long long PRIME = 1e9 + 7;
using namespace std;


int main(){ 
    long long N, M;
    string S, T;

    cin >> N;

    vector<int> a(N);
    for(int i = 0; i < N; ++i){
        cin >> a.at(i);
    }

    for(int i = N-1; i > 0; --i){
        cout << a[i] << " ";
    }
    cout << a[0] << endl;

}




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

// Ai/sum < 1/4M
// Ai * 4M < sum

const int MAX_N = 110;
int A[MAX_N];
int N, M;

int main() {
    scanf("%d %d", &N, &M);
    int S = 0;
    for(size_t i = 0; i < N; ++i) {
        scanf("%d", &A[i]);
        S += A[i];
    }
    int res = 0;
    for(size_t i = 0; i < N; ++i) {
        if(A[i] * 4 * M < S) continue;
        ++res;
    }
    if(res < M) printf("No\n");
    else printf("Yes\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
#define f first
#define s second
#define MOD 1000000007
#define fast ios::sync_with_stdio(0),cout.tie(0),cin.tie(0)
#define pb push_back
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define mkt make_tuple
typedef long long ll;
typedef unsigned long long ull;
class solution{
public:
	void solve(){
		int n;
		cin>>n;
		vector<int> v(n+1,0);
		int a;
		cin>>a;
		for(int i=1;i<=n;i++){
			cin>>v[i];
		}
		sort(v.rbegin(),v.rend());
		ll sum =0;
		for(int i=a;i<n;i++){
			sum += v[i];
		}
		cout<<sum;
		
	}

};

int main()
{
    fast;
	ll i=0;
	solution s;
	s.solve();

 return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#define re register int
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if(a>0)
	{
		printf("Positive\n");
		return 0;
	}
	else if((a<0&&b>0)||a==0||b==0)
	{
		printf("Zero\n");
		return 0;
	}
	else if(a<0&&b<0)
	{
		if((b-a+1)%2==0)
		{
			printf("Positive\n");
			return 0;
		}
		else
		{
			printf("Negative\n");
			return 0;
		}
	}
}

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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
//const int inf = pow(2, 62);
const int inf = pow(2, 30);
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alpha = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


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




/* main */







signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s = raw_input();

    if(s == "zyxwvutsrqponmlkjihgfedcba"){
        print("-1");
        return 0;
    }

    for(char e : alpha){
        if(count(all(s), e) == 0){
            cout << s << e << endl;
            return 0;
        }
    }

    string t = s; next_permutation(all(t));

    rep(i,0,s.size()){
        cout << t[i];
        if(t[i] != s[i]) break;
    }
    cout << endl;

    




    











    

    

    



    
    



    







    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010;
int dx[5]={0,1,0,-1,0};
int dy[5]={1,0,-1,0,0};
struct edge{int to;ll cost;};
vector<ll> dijkstra(int s,vector<edge> g[]){
    vector<ll> d(100010,LINF);
    priority_queue<P,vector<P>,greater<P>> q;
    d[s]=0;
    q.push(P(0,s));
    while(!q.empty()){
        P p=q.top();q.pop();
        int v=p.second;
        for(int i=0;i<g[v].size();i++){
            edge e=g[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                q.push(P(d[e.to],e.to));
            }
        }
    }
    return d;
}
vector<edge> G1[100010],G2[100010];
vector<ll> d1,d2;
int main(){
    int n,m,s,t;cin>>n>>m>>s>>t;s--;t--;
    while(m--){
        int u,v;cin>>u>>v;u--;v--;
        ll a,b;cin>>a>>b;
        G1[u].push_back({v,a});
        G2[u].push_back({v,b});
        G1[v].push_back({u,a});
        G2[v].push_back({u,b});
    }
    d1=dijkstra(s,G1);
    d2=dijkstra(t,G2);
    ll mi[100010];
    fill(mi,mi+n+2,LINF);
    for(int i=n-1;i>=0;i--){
        ll s=d1[i]+d2[i];
        mi[i]=min(mi[i+1],s);
    }
    for(int i=0;i<n;i++){
        cout<<1000000000000000-mi[i]<<endl;
    }
}


Measured memory_bytes: 19476
#include <bits/stdc++.h>
using namespace std;
 
long long gcd(long x,long y){
    if(y==0)return x;

    return gcd(y,x%y);
}
long long lcm(long x,long y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

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

    cout<<lcm(a,b)<<endl;

    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;

//////////////////ここの値は必ず確認！！！！！////////////////////
//---------------------------------------------------------//
const int MOD = 1e9+7;
const int MAXR = 510000;
//---------------------------------------------------------//

template<ll mod> class modint{
public:
    ll val=0;
    //コンストラクタ
    modint(ll x=0){while(x<0)x+=mod;val=x%mod;}
    //コピーコンストラクタ
    modint(const modint &r){val=r.val;}
    //算術演算子
    modint operator -(){return modint(-val);} //単項
    modint operator +(const modint &r){return modint(*this)+=r;}
    modint operator -(const modint &r){return modint(*this)-=r;}
    modint operator *(const modint &r){return modint(*this)*=r;}
    modint operator /(const modint &r){return modint(*this)/=r;}
    //代入演算子
    modint &operator +=(const modint &r){
        val+=r.val;
        if(val>=mod)val-=mod;
        return *this;
    }
    modint &operator -=(const modint &r){
        if(val<r.val)val+=mod;
        val-=r.val;
        return *this;
    }
    modint &operator *=(const modint &r){
        val=val*r.val%mod;
        return *this;
    }
    modint &operator /=(const modint &r){
        ll a=r.val,b=mod,u=1,v=0;
        while(b){
            ll t=a/b;
            a-=t*b;swap(a,b);
            u-=t*v;swap(u,v);
        }
        val=val*u%mod;
        if(val<0)val+=mod;
        return *this;
    }
    //等価比較演算子
    bool operator ==(const modint& r){return this->val==r.val;}
    bool operator <(const modint& r){return this->val<r.val;}
    bool operator !=(const modint& r){return this->val!=r.val;}
};

using mint = modint<MOD>;

//入出力ストリーム
istream &operator >>(istream &is,mint& x){//xにconst付けない
    ll t;is >> t;
    x=t;
    return (is);
}
ostream &operator <<(ostream &os,const mint& x){
    return os<<x.val;
}

//累乗
mint modpow(const mint &a,ll n){
    if(n==0)return 1;
    mint t=modpow(a,n/2);
    t=t*t;
    if(n&1)t=t*a;
    return t;
}

//二項係数の計算
mint fac[MAXR+1],finv[MAXR+1],inv[MAXR+1];
//テーブルの作成
void com_init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    FOR(i,2,MAXR){
        fac[i]=fac[i-1]*mint(i);
        inv[i]=-inv[MOD%i]*mint(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}
//演算部分
mint com(ll n,ll k){
    if(k==0) return 1;
    if(n<k)return 0;
    if(n<0)return 0;
    if(k<0)return 0;
    return fac[n]*finv[k]*finv[n-k];
}

int main() {
    com_init();
    int S; cin >> S;
    mint ans = 0;
    int i = 1;
    while(S - 3*i >= 0){
        ans += com(S-2*i-1, i-1);
        i++;
    }
    cout << ans << endl;

    return 0;
}

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

int main()
{
	long long x;
	cin >> x;
	long long sum = 0;
	long long cnt = 0;
	while(x--){
		long long t;
		cin >> t;
		sum += t;
		cnt += t * t;
	}
	cout << ((sum * sum - cnt) >> 1) << endl;
	return 0;	
} 

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(Math.min(a,b) + " " + Math.max(0, a+b-n));
    }
}

Measured memory_bytes: 23252
/*
  AUTHOR:SOURABH
  CREATED:25:03:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pll , null_type, less< pll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 998244353
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen(2 "out.txt","w",stdout);

    ll t,n,x,y,a,b,c,i,v,sum,l,r;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>x>>y>>a>>b>>c;
        vll d,e,f;
        fn(i,a)
        {
            cin>>v;
            d.pb(v);
        }
        sort(d.begin(),d.end());
        fn(i,b)
        {
            cin>>v;
            e.pb(v);
        }
        sort(e.begin(),e.end());
        fn(i,c)
        {
            cin>>v;
            f.pb(v);
        }
        sort(f.begin(),f.end());
        l=a-x,r=b-y;
        sum=0;
        fr(i,c-1)
        {
            if(l<a && r<b && f[i]>=d[l] && f[i]>=e[r])
            {
                if(d[l]<=e[r])
                    l++;
                else
                    r++;
                sum+=f[i];
            }
            else if(l<a && f[i]>=d[l])
            {
                l++;
                sum+=f[i];
            }
            else if(r<b && f[i]>=e[r])
            {
                r++;
                sum+=f[i];
            }
            else
                break;
        }
        fs(i,l,a)
        sum+=d[i];
        fs(i,r,b)
        sum+=e[i];
        cout<<sum<<"\n";
    }
    return 0;
}










Measured memory_bytes: 3316
#include <stdio.h>

char S[105];

int main() {

	int N;

	scanf("%d",&N);

	scanf("%s",S);

	int i;

	int x = 0;

	int ans = 0;

	for (i = 0; i < N; i++) {

		if (S[i] == 'I') { x++; }
		else { x--; }

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

	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 1145141919
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)

using namespace std;

int main(void){
  int N,M,count=1;
  cin >> N >> M;
  pair<pair<int,int>,int> city[M];
  pair<int,int> ans[M];
  rep(i,M) cin >> city[i].first.first >> city[i].first.second;
  rep(i,M) city[i].second=i;
  sort(city,city+M);
  rep(i,M){
    city[i].first.second=count;
    if(i<M-1){
      if(city[i].first.first==city[i+1].first.first) count++;
      else count=1;
    }
  }
  rep(i,M){
    ans[city[i].second].first=city[i].first.first;
    ans[city[i].second].second=city[i].first.second;
  }
  rep(i,M) printf("%06d%06d\n",ans[i].first,ans[i].second);
}

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

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

	double ans = 0;
	if (k % 3 == 0) {
		ans = k/3*k/3*k/3;
	}
	else {
		double leng = static_cast<int>(k)/3.0;
		ans = leng*leng*leng;
	}
	cout << fixed << setprecision(6) << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i, j;
  
  cin >> N;
  
  vector<int> d(N);
  vector<int> order(N);
  
  for (i = 0; i < N; i++) cin >> d.at(i);

  int max = 0;
  int maxj = 0;
  
  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
      if (max < d.at(j)) {
        max = d.at(j);
        maxj = j;
      }
    }
    order.at(i) = max;
    d.at(maxj) = 0;
    max = 0;
  }
  
  int cnt = 1;

  for (i = 1; i < N; i++) {
    if(order.at(i) == order.at(i - 1));
    else cnt++;
  }
  
cout << cnt << endl;
  
}

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

using namespace std;

int main(){
  int n, max_move=0, cnt=0;
  cin >> n;
  vector<int> h(n);

  for(int i=0; i<n; ++i)
    cin >> h[i];

  for(int i=0; i<n; ++i){
    if(h[i] >= h[i+1] && i != n-1){
      cnt++;
    }else{
      max_move = max(cnt, max_move);
      cnt = 0;
    }
    // cout << "i: " << i << "\ncnt: " << cnt << "\nmax: " << max_move << '\n';
  }
  max_move = max(cnt, max_move);
  cout << max_move << '\n';
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,a[100001];
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    int ans=1e9;
    for(int i=1;i<=n;i++)
        if(i+k-1<=n) ans=min(ans,a[i+k-1]-a[i]);
    printf("%d\n",ans);
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;


	public class abc122_a
	{
		public static void Main(string[] args)
		{
			Dictionary<string, string> map = new Dictionary<string, string>() {
				{"A", "T"},
				{"T", "A"},
				{"C", "G"},
				{"G", "C"},
			};

			var input = Console.ReadLine();

			Console.WriteLine($"{map[input]}");
		}
	}

Measured memory_bytes: 11104
#include <iostream>
using namespace std;
typedef long long lli;

int main() {
  int n;
  cin >> n;
  lli sum = 0;
  for(int i = 0; i < n; ++i) {
    lli v;
    cin >> v;
    sum += v;
  }
  cout << sum/n << endl;
  return 0;
}

Measured memory_bytes: 1164