akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<string>
#include<utility>

using namespace std;

int main(){
    int n, q, time, ptime=0;
    string str;
    queue< pair<string,int> > que;
    pair<string, int> tmp_p;
    cin >> n >> q;
    for(int i=0; i < n; i++){
        cin >> str >> time;
        que.push(make_pair(str,time));
    }

    while(!que.empty()){
        tmp_p = que.front();
        que.pop();
        if(tmp_p.second > q){
            tmp_p.second -= q;
            ptime += q;
            que.push(tmp_p);
        } else {
            ptime += tmp_p.second;
            cout << tmp_p.first << " " << ptime << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6176
#include<bits/stdc++.h>
#define P pair<int,int>
#define int long long
using namespace std;

P a[300000];
signed main(){
    int b;
    cin>>b;
    for(int c=0;c<b;c++){
	scanf("%lld%lld",&a[c].first,&a[c].second);
	}
   sort(a,a+b,[](P n,P m){if(n.first!=m.first)return n.first<m.first;return n.second>=m.second;});
   double sum=0;int MIN=LLONG_MAX/3;
   auto k=[](P n,P m){if(n.first!=m.first)return n.first>m.first;return n.second<=m.second;};
   priority_queue<P,vector<P>,decltype(k)>Q(k);
   int MAX=0;
   for(int i=0;i<b;i++){
       sum+=a[i].first;Q.push(P(a[i].second,a[i].first));
       MIN=min(MIN,a[i].second);
       while(sum/Q.size()>MIN){
	   P t=Q.top();Q.pop();
	   sum-=t.second;
	   if(Q.size()==0){MIN=LLONG_MAX/3;break;}
	   P w=Q.top();MIN=w.first;
	   }
	   MAX=max(MAX,(int)Q.size());
       }
       cout<<MAX<<endl;
    }

Measured memory_bytes: 15860
import math
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
#def LI(): return list(map(int, input().split())
n=I()
bls=list(MI())
ls=sorted(bls, reverse=True)
trans=0
for i in range(n-2):
    answer=0
    for j in range(i+1,n-1):
        l1=ls[i]
        l2=ls[j]
        l,r = j,n
#あえて左右一つ分ずつ広く取る
        while l+1 < r:
#この条件で探索の終点がうまく定められる
            mid = (l+r)//2
            if l1<l2+ls[mid]:
                l = mid
            else:
                r = mid
        ansij=l-j
        #print(ansij)
        answer+=ansij
    trans+=answer
print(trans)

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

const int MOD = 1000000007;
int dp[101][4][4][4]; //[現文字数][最後から1文字目][2文字目][3文字目]


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

    //A=0, G=1, C=2, T=3
    //長さ0の文字列をカウントしてスタート。必ず条件を満たす3文字(ここではTTT)が
    //先頭にあると仮定することで、長さ0の文字列の状態を1つ作る
    dp[0][3][3][3] = 1;

    //AGCTのいずれかを末尾に加えた場合のdpを求めていく
    for(int len=0; len<N; len++) {

        //現在の最後から1文字目
        for(int i=0; i<4; i++) {

            //現在の最後から2文字目
            for(int j=0; j<4; j++) {

                //現在の最後から3文字目
                for(int k=0; k<4; k++) {

                    //現在の最後から3文字を見たとき、条件を満たす文字列が存在しない場合、無視する
                    if(dp[len][i][j][k] == 0) continue;

                    //新しく末尾に追加する文字
                    for(int a=0; a<4; a++) {
                        
                        if(a==2 && i==1 && j==0) continue; //AGC
                        if(a==2 && i==0 && j==1) continue; //GAC
                        if(a==1 && i==2 && j==0) continue; //ACG
                        if(a==2 && i==1 && k==0) continue; //A?GC
                        if(a==2 && j==1 && k==0) continue; //AG?C
                        
                        dp[len+1][a][i][j] += dp[len][i][j][k];
                        dp[len+1][a][i][j] %= MOD;
                    }
                }
            }
        }
    }
    int ans = 0;
    for(int i=0; i<4; i++) {
        for(int j=0; j<4; j++) {
            for(int k=0; k<4; k++) {
                ans += dp[N][i][j][k];
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
Vi accum(Vi v){Vi ret((v).size());ret[0]=v[0];REP(i,1,(v).size()) ret[i]=ret[i-1]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}



void solve(long long n, std::vector<std::string> s){
    map<string,int> ma;
    REP(i,0,n){
        ma[s[i]]++;
    }
    int maxnum=0;
    for(auto x : ma){
        chmax(maxnum,x.second);
    }
    Vs ans;
    for(auto x : ma){
        if(x.second==maxnum) ans.pb(x.first);
    }
    sort(ALL(ans));
    REP(i,0,ans.size()) cout<<ans[i]<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 28404
N, A, B = map(int, input().split())
S = input()
 
ok_count = 0
ok_fcount = 0
for i in range(N):
  if S[i] == 'a':
    if ok_count < A+B:
      print('Yes')
      ok_count +=1
      
    else:
      print('No')
      
  elif S[i] == 'b':
    if ok_count < A+B and ok_fcount < B:
      print('Yes')
      ok_count+=1
      ok_fcount+=1
      
    else:
      print('No')
      
  else:
    print('No')

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n, k;
    cin >> n >> k;
    vector<i64> as(n);
    for (auto& e : as) cin >> e, e--;
    vector<i64> path;
    vector<i64> visited(n);

    i64 a = 0;
    for (; k > 0; k--) {
        if (visited[a]) break;
        visited[a] = 1;
        path.emplace_back(a);
        a = as[a];
    }

    if (k == 0) {
        cout << a + 1 << endl;
        return;
    }

    i64 idx = find(all(path), a) - begin(path);
    k %= path.size() - idx;
    cout << path[idx + k] + 1 << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 8344
#include <iostream>
#include <vector>
#include <map>
#include <string>
using namespace std;

int main(){
	int n, m, money;
	string number;
	
	while( cin >> n >> m , n || m ){
		vector<string> vc;
		map<string,int> f;
		int ans = 0;
		
		for(int i=0 ; i<n ; i++ ){
			cin >> number >> money;
			f[number] = money;
			vc.push_back( number );
		}
		for(int i=0 ; i<m ; i++ ){
			cin >> number;
			for(int j=0 ; j < (int)vc.size() ; j++ ){
				bool flag = true;
				for(int k=0 ; k < (int)number.size() ; k++ ){
					if( vc[j][k] == '*' ) continue;
					if( vc[j][k] != number[k] )
						flag = false;
				}
				if( flag ){
					ans += f[ vc[j] ];
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 944
N, K = map(int, input().split())
S = input()

s = S[K-1]

if s == 'A':
    S = S[:K-1] + 'a' + S[K:]
elif s == 'B':
    S = S[:K-1] + 'b' + S[K:]
else:
    S = S[:K-1] + 'c' + S[K:]

print(S)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define f1 first
#define s2 second
#define pb push_back
#define mp make_pair
#define ll long long
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const int N=1e5+4;

int a,b,c;

int main(){
	//fri("in.txt");
	//fro("out.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>a>>b>>c;
	if(a+b+c>=22)cout<<"bust"<<endl;
	else cout<<"win"<<endl;


return 0;
}

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

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

    int i = x / 100;
    if (x % 100 > 5 * i) {
        cout << 0 << endl;
    } else cout << 1 << endl;
}

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

int main() {
	while (true) {
		int x, y;
		cin >> x >> y;
		if (x == 0&&y == 0)break;
		if (x > y)cout << y << ' ' << x << endl;
		else cout << x << ' ' << y << endl;
	}
}


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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i], A[i]--;
	long long NOW = 0, ANS, MIN = 0;
	for (int i = 0; i < N - 1; i++) {
		if (A[i] > A[i + 1]) NOW += A[i + 1] + 1, MIN++;
		else NOW += A[i + 1] - A[i];
	}
	ANS = NOW;
	vector<pair<int, int> > L(N - 1), R(N - 1);
	for (int i = 0; i < N - 1; i++) {
		L[i] = { A[i], i };
		R[i] = { A[i + 1], i };
	}
	sort(L.begin(), L.end()), sort(R.begin(), R.end());
	int LN = 0, RN = 0;
	for (int i = 0; i < M; i++) {
		NOW -= MIN;
		while (LN < N - 1 && L[LN].first == i) {
			MIN++;
			LN++;
		}
		while (RN < N - 1 && R[RN].first == i) {
			MIN--;
			NOW += (A[R[RN].second + 1] - A[R[RN].second] + M) % M;
			RN++;
		}
		ANS = min(ANS, NOW);
	}
	cout << ANS << endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
    ll n, w;
    cin >> n >> w;
    vector<ll> W(110), V(110); //余裕をもって　
    vector<vector<ll>> dp(110, vector<ll>(100100));
    rep(i, n) cin >> W[i] >> V[i];

    rep(i, n)
    {
        rep(j, w + 1)
        {
            if (j - W[i] >= 0)
            {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - W[i]] + V[i]);
            }
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }

    cout << dp[n][w] << endl;
}
//表を埋めるコードを書くことを意識

Measured memory_bytes: 90364
#include <stdio.h>
using namespace std;
 
int n,m,a[200005],b[200005];
bool f[200005];
 
int main(){
scanf("%d %d",&n,&m);
for(int i=0;i<m;i++){
scanf("%d %d",a+i,b+i);
a[i]--;b[i]--;
if(b[i]==n-1)f[a[i]]=true;
}
for(int i=0;i<n;i++)if(a[i]==0 && f[b[i]]){
printf("POSSIBLE\n");
return 0;
}
printf("IMPOSSIBLE\n");
return 0;
}

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

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

    if((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3])) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

#define deb(x) cout << #x << ':' << x << endl; 
#define loop3(i, k, n) for(i=k; i<n; i++)
#define ll  long long int
#define loop(i,n) for(int i=0;i<n;i++)
#define loop2(i,n) for(int i = 1;i<=n;i+=1)
#define pb push_back
#define mp make_pair
#define v1d vector<ll> 
#define v2d vector<vector<ll>>

const int INF = 1e9 +5 ; 


int main()
{
    ll n;
    cin>>n;
    v1d v(n);
    ll i;
    loop(i,n)
        cin>>v[i];
    v1d dp(n,INF);
    dp[0] = 0;
    loop(i,n)
    {
        for(int j : {i+1,i+2})
        {
            if(j<n)
            {
                //deb(j);
                dp[j] = min(dp[j],dp[i] + abs(v[i] - v[j]));
            
            }
        }
    
    }
    cout<<dp[n-1];
    

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
char in[2];
int main() {
  int ans=7;
  string s;
  cin >> s;
  if(s=="MON") ans--;
  if(s=="TUE") ans-=2;
  if(s=="WED") ans-=3;
  if(s=="THU") ans-=4;
  if(s=="FRI") ans-=5;
  if(s=="SAT") ans-=6;
  cout << ans << endl;
}

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

void f(long x, long &l, long &h, vector<long> &s) {
  int hh=s.size()-1;
  int ll=0;
  int p;
  //cout << "Initial:" << ll << ":" << hh << endl;
  while (hh-ll>1) {
    p=(hh+ll)/2;
    if (s.at(p)<x) ll=p;
    else hh=p;
  }
  //cout <<ll <<":" <<hh << endl;/////
  l=s.at(ll);
  h=s.at(hh);
  //cout << x <<":" << l << ":" << h << endl;///
  return;
}

int main() {
  int A, B, Q;
  cin >>A >>B >>Q;
  vector<long> s(A+2);
  for (int i=1; i<=A; i++) cin >> s.at(i);
  vector<long> t(B+2);
  for (int i=1; i<=B; i++) cin >> t.at(i);
  s.at(0)=-1000000000000;// lower guard
  s.at(A+1)=1000000000000;// upper guard
  t.at(0)=-1000000000000;// lower guard
  t.at(B+1)=1000000000000;// upper guard
  long x, ss;
  long a1, a2, b1, b2;
  long a11, a12, a21, a22;
  long b11, b12, b21, b22;
  for (int i=0; i<Q; i++) {
    cin >> x;
    f(x, a1, a2, s);
    f(a1, b11, b12, t);
    f(a2, b21, b22, t);
    f(x, b1, b2, t);
    f(b1, a11, a12, s);
    f(b2, a21, a22, s);
    ss=min(abs(b11-a1), abs(b12-a1))+abs(a1-x);
    ss=min(ss, min(abs(b21-a2), abs(b22-a2))+abs(a2-x));
    ss=min(ss, min(abs(a11-b1), abs(a12-b1))+abs(b1-x));
    ss=min(ss, min(abs(a21-b2), abs(a22-b2))+abs(b2-x));
    cout << ss << endl;
  }
  return 0;
}


Measured memory_bytes: 2944
#include<cstdio>
#include<algorithm>
using namespace std;
int n,ans=99999999;
int main()
{
	scanf("%d",&n);
	for(int i=1;i*2<=n;i++)
	{
		int a=i,b=n-i,s=0;
		while(a)
		{
			s+=a%10;
			a/=10;
		}
		while(b)
		{
			s+=b%10;
			b/=10;
		}
		ans=min(ans,s);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

const int INF = 1<<28;

template<class T>
ostream& operator<<(ostream& os, const vector<T> xs) {
    if (xs.empty()) return os << "[]";
    os << "[" << xs[0];
    for (int i = 1; i < xs.size(); i++) os << " " << xs[i];
    return os << "]";
}

struct Edge {
    int from, to, cost;
    Edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
};

int N;
vector< vector<Edge> > G;
void calcDist(int v, vector<int>& D) {
    D.clear(); D.resize(N, INF);
    D[v] = 0;
    queue<int> Q;
    Q.push(v);
    while (!Q.empty()) {
        int c = Q.front(); Q.pop();
        for (int i = 0; i < G[c].size(); i++) {
            Edge& e = G[c][i];
            if (D[e.to] > D[c] + e.cost) {
                D[e.to] = D[c] + e.cost;
                Q.push(e.to);
            }
        }
    }
}
// vの最遠点のひとつを返す
int farthest(int v) {
    static vector<int> D; calcDist(v, D);
    int ret = -1, dist = -1;
    for (int i = 0; i < N; i++) {
        if (dist < D[i]) {
            ret = i;
            dist = D[i];
        }
    }
    return ret;
}
int diameter() {
    int u = farthest(0);
    int v = farthest(u);
    static vector<int> D; calcDist(v, D);
    return D[u];
}

int main() {
    cin >> N;
    G.clear(); G.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int s, t, w; cin >> s >> t >> w;
        G[s].push_back(Edge(s, t, w));
        G[t].push_back(Edge(t, s, w));
    }
    cout << diameter() << endl;
    return 0;
}

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

int main() {
    int x; cin >> x;
    int a = 0;
    int i = 0;
    while (a < x) {
        i++;
        a += i;
    }
    cout << i << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan =new Scanner(System.in);
        int i = 0;
        while(true){
            int num = scan.nextInt();
            i++;
            if(num == 0){
                break;
            }else{
                System.out.println("Case "+i+":"+" "+num);
            }
        }
    }
}


Measured memory_bytes: 41356
import java.util.*;
public class Main {
	public static ArrayList<Integer> list;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		list = new ArrayList<Integer>();
		makeList();
		while(true) {
			int a = stdIn.nextInt();
			int d = stdIn.nextInt();
			int n = stdIn.nextInt();
			
			if(a == 0 && d == 0 && n == 0) break;
			int count = 0;
			int c = 0;
			while(true) {
				int tmp = a + d * c++;
				if(Collections.binarySearch(list, tmp) >= 0) {
					count++;
					if(count == n) {
						System.out.println(tmp);
						break;
					}
 				}
			}
		}
	}
	public static void makeList() {
		boolean[] isPrime = new boolean[1000001];
		for(int i = 2; i < isPrime.length; i++) {
			isPrime[i] = true;
		}
		for(int i = 2; i < isPrime.length; i++) {
			if(isPrime[i]) {
				list.add(i);
				for(int j = i + i; j < isPrime.length; j+=i) {
					isPrime[j] = false;
				}
			}
		}
	}
}

Measured memory_bytes: 27836
def pow(x, n , mod):
    res = 1
    while n > 0:
        if  bin(n & 1) == bin(1) :
            res = res * x % mod
        x = x*x % mod
        n = n >>1
    return res   

def combination(n,a):
    x = 1
    for i in range(a):
        x = x * (n-i) % mod
    y = 1
    for i in range(a):
        y = y * (a-i) % mod
    y = pow(y, mod-2, mod)
    return (x*y % mod)
n, a, b = map(int, input().split())
mod = 1000000007
print((pow(2,n,mod) - 1 - combination(n,a) - combination(n,b)) % mod)

Measured memory_bytes: 3064
A,B=map(int,input().split())

mat=[]
for i in range(100):
  array=[True]*50+[False]*50
  mat.append(array)

for i in range(B-1):
  j=2*(i//25)
  k=2*(i%25)
  mat[j][k]=False
for i in range(A-1):
  j=2*(i//25)
  k=2*(i%25)+51
  mat[j][k]=True
  
print(100,100)
for i in range(100):
  array=["." if x else "#" for x in mat[i]]
  print("".join(array))

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    cout << n*n*n << endl;

    return 0;
}


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

using namespace std;

#define N 3001

int n; char c[N];
int f[N][N];

const int mod = 1000000007;

int solve()
{
    f[1][1] = 1;

    for (int i=2; i<=n; ++i)
    {
        if (c[i-1] == '<')
        {
            int p = f[i-1][1];
            for (int j=2; j<=i; ++j)
            {
                f[i][j] = p;
                p = (p + f[i-1][j]) % mod;
            }
        }
        else
        {
            int p = 0;
            for (int j=n; j>=1; --j)
            {
                p = (p + f[i-1][j]) % mod;
                f[i][j] = p;
            }
        }
    }

    int rr = 0;
    for (int i=1; i<=n; ++i)
        rr = (rr + f[n][i]) %mod;
    return rr;
}

int main()
{
    #ifdef DEBUG
    freopen("t.txt","r",stdin);
    #endif // DEBUG

    scanf ("%d %s", &n, c+1);
    cout << solve();
    return 0;
}


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

using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<string> grid(n);
  for (int i = 0; i < n; i++) {
    cin >> grid[i];
  }
  vector<vector<int>> a(n, vector<int>(m));
  vector<vector<int>> b(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    a[i][0] = 1;
    b[i][m - 1] = 1;
    for (int j = 0; j < m - 1; j++) {
      if (i % 2 == 0) {
        a[i][j] = 1;
      } else {
        b[i][j + 1] = 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (grid[i][j] == '#') {
        a[i][j] = 1;
        b[i][j] = 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 1) {
        cout << '#';
      } else {
        cout << '.';
      }
    }
    cout << '\n';
  }
  cout << '\n';
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (b[i][j] == 1) {
        cout << '#';
      } else {
        cout << '.';
      }
    }
    cout << '\n';
  }
  return 0;
}

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

int main()
{
    int X,A;

    scanf("%d %d",&X,&A);

    if(0<=X,A<=9)
    {
        if(X<A)
        {
            printf("0");
        }
        if(X>=A)
        {
            printf("10");
        }

    }
    return 0;
}


Measured memory_bytes: 1704
#include <iostream>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>

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

	std::vector<std::pair<int, int>> A;
	for (int i = 0; i < N; ++i)
	{
		int a;
		std::cin >> a;

		A.emplace_back(a, i + 1);
	}

	std::sort(std::begin(A), std::end(A), [](std::pair<int, int>& a, std::pair<int, int>& b) {return a.first < b.first; });

	for (int i = 0; i < N; ++i)
	{
		std::cout << A.at(i).second << " ";
	}

	return 0;
}

Measured memory_bytes: 1780
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let a: Vec<u32> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
    let mut sum = 0;
    for i in 1..n {
        for j in 0..i {
            sum += a[i] * a[j];
        }
    }
    println!("{}", sum);
}

fn main() {
    run();
}

Measured memory_bytes: 4352
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

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

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long X = sc.nextLong();
        long[] x = new long[N + 1];
        for (int i = 0; i < N; i++) {
            x[i] = sc.nextLong();
        }
        x[N] = X;
        Arrays.sort(x);
        Set<Long> set = new HashSet<>();
        for (int i = 1; i <= N; i++) {
            set.add(x[i] - x[i - 1]);
        }
        List<Long> list = new ArrayList<>(set);
        long ans = list.get(0);
        for (int i = 1; i < list.size(); i++) {
            ans = gcd(ans, list.get(i));
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 60344
#-String Palindrome
import math
character = input()
re_character = character[::-1]
 
num = int(len(character))
middle = math.ceil(num/2.0)
#print(middle)
#print(character[0:middle-1], re_character[middle:num])
#print(character[0:num], re_character[0:num])
#print (character[middle:num], re_character[0:middle-1])

if (character[middle:num] == re_character[0:middle-1]):
  if (character[0:num] == re_character[0:num]):
    print("Yes")
  else:
    print("No")
else:
  print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> que;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        que.push({b, a});
    }
    ll sum_time = 0;
    while(!que.empty()) {
        pair<ll, ll> next_work = que.top();
        if ( sum_time + next_work.second > next_work.first ) {
            puts("No");
            return 0;
        }
        sum_time += next_work.second;
        que.pop();
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 6384
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct edge{
    int to,next;
}e[200010];
int n,head[100010];
int dfs(int u,int fa){
    int flag=0;
    for(int i=head[u];~i;i=e[i].next){
        int v=e[i].to;
        if(v==fa)
            continue;
        flag+=dfs(v,u);
    }
    if(flag>=2){
        puts("First");
        exit(0);
    }
    return flag^1;
}
int main(){
    memset(head,-1,sizeof(head));
    scanf("%d",&n);
    for(int i=1,cnt=-1;i<n;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        e[++cnt]=(edge){v,head[u]};
        head[u]=cnt;
        e[++cnt]=(edge){u,head[v]};
        head[v]=cnt;
    }
    if(dfs(1,0))
        puts("First");
    else
        puts("Second");
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;
long long int maxi(long long int A, long long int B) {
	return (A > B) ? A : B;
}
int main() {
	long long int N, A, B;
	cin >> N >> A >> B;
	cout << maxi(0,((B*(N - 1) + A) - (B + A*(N - 1)) + 1));
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head) << " ";
  print(tail...);
}

int main() {
  GS(S);
  int r = 0, b = 0;
  FOR(i, S.size()) {
    if (S[i] == '0') {
      r++;
    } else {
      b++;
    }
  }
  print(S.size() - abs(r - b));
  return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		try (Scanner cin = new Scanner(System.in)) {

			int N = cin.nextInt();
			int M = cin.nextInt();
			int K = cin.nextInt();

			for (int i = 0; i <= N; i++) {
				for (int j = 0; j <= M; j++) {
					if (N * j + (M - j - j) * i == K) {
						System.out.println("Yes");
						return;
					}
				}
			}

			System.out.println("No");
		} finally {
		}
	}

}


Measured memory_bytes: 23764
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;

      cin>>a>>b;

      cout<<max3(a+b,a-b,a*b)<<endl;













}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
const int P=1e9+7;
const int N=305;
#define fi first
#define se second
int n,m,f[N][N][N];
vector<pair<int,int> >a[N];
bool check(int i,int j,int k){
	int si=a[i].size();
	for(int d=0;d<si;d++){
		int p=1+(j>=a[i][d].fi)+(k>=a[i][d].fi);
		if(a[i][d].se!=p)	return false;
	}
	return true;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int l,r,x;
		scanf("%d%d%d",&l,&r,&x);
		a[r].push_back(make_pair(l,x));
	}
	f[0][0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<=i;j++)
			for(int k=0;k<=j;k++)
				if(f[i][j][k]){
					if(!check(i,j,k)){
						f[i][j][k]=0;
						continue;
					}
					(f[i+1][j][k]+=f[i][j][k])%=P;
					if(!i)	continue;
					(f[i+1][i][k]+=f[i][j][k])%=P;
					if(!j)	continue;
					(f[i+1][i][j]+=f[i][j][k])%=P;
				}
	int ans=0;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=i;j++)
			if(f[n][i][j]&&check(n,i,j)){
				if(i&&j)	ans=(ans+1LL*f[n][i][j]*6)%P;
				else	if(!i&&!j)	ans=(ans+1LL*f[n][i][j]*3)%P;
				else	ans=(ans+1LL*f[n][i][j]*6)%P;
			}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 108800
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N,M;
    cin>>N>>M;
    if(N==1){
        if(M==1){
            cout<<1<<endl;
        }else{
            cout<<(M-2)<<endl;
        }
        
    }else if(M==1){
        cout<<(N-2)<<endl;
    }else{
        cout<<(N*M-2*(N+M-2))<<endl;
    }
    
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
int main() {
	while (1) {
		long long int A, B, D; cin >> A >> B >> D;
		if (!A)break;
		pair<long long int, long long int >ans = make_pair(1e9, 1e9);
		for (int i = -1e4; i < 1e4; ++i) {
			const int anum = abs(i);
			if (!((D - A*i)%B)) {
				long long int bnum = abs((D - A*i) / B);
				if (anum + bnum < ans.first + ans.second|| anum*A + bnum*B < ans.first*A + ans.second*B)ans = make_pair(anum, bnum);
			}
		}
		cout << ans.first << " " << ans.second << endl;
	}
	return 0;
}

Measured memory_bytes: 3000
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> int Factor_L(T N, T fac[]){
  T i;
  int sz = 0;
  if(N%2==0){
    fac[sz] = 2;
    N /= 2;
    while(N%2==0){
      N /= 2;
    }
    sz++;
  }
  for(i=3;i*i<=N;i+=2){
    if(N%i==0){
      fac[sz] = i;
      N /= i;
      while(N%i==0){
        N /= i;
      }
      sz++;
    }
  }
  if(N > 1){
    fac[sz] = N;
    sz++;
  }
  return sz;
}
template<class T> inline T GCD_L(T a,T b){
  T r;
  while(a){
    r=b;
    b=a;
    a=r%a;
  }
  return b;
}
long long A;
long long B;
int fs;
long long f[100];
int main(){
  rd(A);
  rd(B);
  fs =Factor_L(GCD_L(A, B), f);
  wt_L(fs + 1);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190928-1

// --- original code ---
// ll A, B;
// int fs; ll f[100];
// {
//   rd(A,B);
//   fs = Factor(gcd(A,B), f);
//   wt(fs + 1);
// }


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  map<string,int64> mp;
  REP(i,n){
    string s;
    cin >> s;
    sort(ALL(s));
    mp[s]++;
  }
  int64 ans = 0;
  for(auto p : mp){
    ans += p.second * (p.second - 1) / 2;
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define mod 1000000007
int main(void){
    ll n,m;
    cin>>n>>m;
    vector<bool>T(n+1);
    rep(0,i,n+1){
        T[i]=true;
    }
    rep(0,i,m){
        ll a;
        cin>>a;
        T[a]=false;
    }
    ll dp[n+1];
    dp[0]=1;
    rep(1,i,n+1)dp[i]=0;
    rep(1,i,n+1){
        if(!T[i])continue;
        if(i==1)dp[i]=(dp[i-1])%mod;
        else dp[i]=(dp[i-1]+dp[i-2])%mod;
        //cout<<dp[i]<<" ";
    }
    //cout<<endl;
    cout<<dp[n]%mod;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int n;
	scanf("%d",&n);
	
	int a[100];
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		
	}
	
	for(int i = 0; i < n; i++){
		printf("%d", a[n-1-i] );
		if(i != n-1){
			printf(" ");
		}
	}
	
	printf("\n");
	
  return 0;
}

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

int main() {
	long long N, COUNT = 0;
	vector<pair<string, long long> > V;
	bool check = false;
	string X;
	cin >> N;
	V.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> V[i].first >> V[i].second;
	}
	cin >> X;
	for (int i = 0; i < N; i++) {
		if (check) COUNT += V[i].second;
		if (V[i].first == X) check = true;
	}
	cout << COUNT << endl;
}

Measured memory_bytes: 256
card = list(map(int, input().split()))

if card[0] > card[1]:
    if card[1] == 1:
        print('Bob')
    else:
        print('Alice')
elif card[0] < card[1]:
    if card[0] == 1:
        print('Alice')
    else:
        print('Bob')
else:
    print('Draw')


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;
int main(void){
    
    string S;
    cin >> S;
    
    for(int i = 0; i < S.size(); i++){
        if(i % 2 != 1) cout << S[i]; 
    }
    cout << endl;

}


Measured memory_bytes: 3136
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  cin >> n;
  while(n!=0){
    int k[101]={},i,j;
    for(i=0;i<n;i++) cin >> k[i];
    string str;
    cin >> str;
    for(i=0;i<str.size();i++){
      for(j=0;j<k[i%n];j++){
	str[i]--;
      if(str[i]<'A') str[i]+=58;
      else if(str[i]>'Z'&&str[i]<'a') str[i]-=6;
      }
      cout << str[i];
    }
    cout << endl;
    cin>>n;
  }
  return 0;
}

Measured memory_bytes: 1204
import scala.io.StdIn.{readInt, readLine};
import scala.annotation.tailrec;
object Main {
    def main(args: Array[String]): Unit = {
        (0 until readInt).foreach { i =>
            val y = readLine;
            val x = readLine;
            println(longestCommonSubsequence(y, x));
        }
    }
    def longestCommonSubsequence(strY: String, strX: String): Int = {
        val sizeX = strX.length;
        val sizeY = strY.length;
        val arr = Array.ofDim[Int](sizeY + 1, sizeX + 1);
        (1 to sizeY).foreach { y => (1 to sizeX).foreach { x => arr(y)(x) = -1}}
        def go(y: Int, x: Int): Int = arr(y)(x) match {
            case -1 => {
                val lcs1 = go(y - 1, x - 1);
                val lcs2 = go(y - 1, x);
                val lcs3 = go(y, x - 1);
                arr(y)(x) = if (strX(x - 1) == strY(y - 1)) {
                    max(lcs1 + 1, lcs2, lcs3);
                } else  {
                    max(lcs1, lcs2, lcs3);
                }
                arr(y)(x);
            }
            case lcs => lcs;
        }
        go(sizeY, sizeX);
    }

    def max(a: Int, b: Int, c: Int): Int = {
        if (a > b)
            if (a > c) a else c;
        else
            if (b > c) b else c;
    }
}


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

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

    int x, y, z;
    x = y = z = 0;
    int sum = 0;
    int count = 0;

    for(int x = 0; x <= k; x++){
        for (int y = 0; y <= k; y++){
            int z = s - x - y;
            if(z >= 0 && z <= k){
                count++;
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
//#define M 998244353
const int inf=4e18;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n,k;cin>>n>>k;
	cout<<min(n%k,abs(n%k-k))<<endl;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
N=int(input())
a=list(map(int,input().split()))

col=[]
cnt=1
for i in a:
    col.extend([cnt]*i)
    cnt+=1

ans=[[0]*W for _ in range(H)]
idx=0
for h in range(H):
    if h%2==0:
        for w in range(W):
            ans[h][w]=col[idx]
            idx+=1
    elif h%2==1:
        for w in range(W-1,-1,-1):
            ans[h][w]=col[idx]
            idx+=1

for h in range(H):
    print(*ans[h])


Measured memory_bytes: 9572
#include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;

int main() {
	map<string, int>s;
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		string c; int d;
		cin >> c >> d;
		char f = c.length() + 96;
		c = f + c;
		s[c];
		s[c] += d;
	}
	for (auto e = s.begin(); e != s.end(); e++) {
		for (int h = 1; h < e->first.length(); h++)cout << e->first[h];
		cout << " " << e->second << endl;
	}
}

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

#ifdef DONLINE_JUDGE
//freopen("a.in", "r", stdin);
//freopen("a.out","w",stdout); // console output is better (in most cases)
#else
// add i/o method of specific testing system
#endif

using namespace std;

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

    int x, y;
    while (cin >> x >> y, x || y)
    {
        if (x > y)
            swap(x, y);
        cout << x << " " << y << endl;
    }

    return 0;
}


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

#define pb push_back
#define inf 0x3f3f3f3f
int v[100100];
int memo[100100];
int n;

int go(int i) {
	if (i == n-1) return 0;
	if (memo[i] != -1) return memo[i];

	int ans = inf;

	if(i+1 <= n-1) ans = min(ans, go(i+1) + abs(v[i+1] - v[i]));
	if(i+2 <= n-1) ans = min(ans, go(i+2) + abs(v[i+2] - v[i]));

	return memo[i] = ans;
}

int main(){
	cin >> n;
	for(int i = 0; i < n; i++) cin >> v[i];

	memset(memo, -1, sizeof(memo));
	cout << go(0) << endl;
}

Measured memory_bytes: 5760
package main
 
import (
  "fmt"
  "os"
  "bufio"
  "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func expectedValue(k float64, sum float64) float64 {
  var exp float64 = (k + sum) / 2
  return exp
}

func main() {
  sc.Split(bufio.ScanWords)
  n := nextInt()
  k := nextInt()
  a := make([]int, n)
  for i := range a {
    a[i] = nextInt()
  }
  
  sum := 0
  for i := 0; i < k; i++ {
    sum += a[i]
  }
  
  var max int = sum
  var ans float64 = expectedValue(float64(k), float64(sum))

  //隣接するk個のサイコロの目が最大の時に期待値も最大となる
  for i := k; i < n; i++ {
    sum = sum - a[i-k] + a[i]
    if sum > max {
      max = sum
      ans = expectedValue(float64(k), float64(sum))
    }
  }
  
  fmt.Printf("%.12f\n", ans)
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; i++) {
        scanf("%d", &A[i]);
    }

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

    if (N - sum >= 0) {
        cout << N - sum << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3716
NUM = int(10**9 + 7)

n, m = map(int, input().split())
nums = [int(input()) for _ in range(m)]

if m > 0:
    split = [[0, nums[0] - 1]]
    for i in range(1, m):
        split.append([nums[i - 1] + 1, nums[i] - 1])
    split.append([nums[-1] + 1, n])
else:
    split = [[0, n]]

n_steps = [h - l for l, h in split]

counts = [1, 1]
for _ in range(max(n_steps) - 1):
    c = counts[-1] + counts[-2]
    counts.append(c)

if min(n_steps) < 0:
    print(0)
else:
    res = 1
    for s in n_steps:
        res *= counts[s]
        res %= NUM
    print(res)

Measured memory_bytes: 471688
import java.io.*;

class Main {
	public static void main(String[] arg)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){	
			String ini = br.readLine();
			if(ini.equals("-"))break;
			int m = Integer.parseInt(br.readLine());
			for(int i=0; i<m; i++){
				String str = br.readLine();
				int h =  Integer.parseInt(str);
				ini = ini.substring(h,ini.length()) + ini.substring(0,h);
			}
			System.out.println(ini);
		}
	}
}

Measured memory_bytes: 17040
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,k,i,s=0;
  cin>>n>>k;
  vector<long long> a(n);
  for(i=0;i<n;i++)
    cin>>a[i];
  if(k>=n)
    cout<<"0";
  else
  {
  sort(a.begin(),a.end());
  for(i=0;i<(n-k);i++)
    s=s+a[i];
    cout<<s;
  }
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int> v;int main(){int m,a,b,i,j;for(i=2;i<50000;i++){bool ok=1;for(j=0;j<v.size();j++)if(i%v[j]==0)ok=0;if(ok)v.push_back(i);}while(cin>>m>>a>>b&&m){int p=-1,q=0;for(i=0;i<v.size();i++){for(j=i;j<v.size();j++){if(v[i]*v[j]>m)break;if(v[j]<=b*v[i]/a&&p*q<v[i]*v[j])p=v[i],q=v[j];}}cout<<p<<" "<<q<<endl;}return 0;}

Measured memory_bytes: 3136
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

//ここから

void solve(){
  int m,k;
  cin>>m>>k;
  if((int)pow(2,m)-1<k){
    cout<<-1<<"\n";
  }
  else if(m==0){
    if(k==0)cout<<0<<" "<<0<<"\n";
  }
  else if(m==1){
    if(k==1)cout<<-1<<"\n";
    else {
      cout<<0<<" "<<0<<" "<<1<<" "<<1<<"\n";
    }
  }
  else {
      cout<<k;
      int x=(int)pow(2,m)-1;
      rep(i,pow(2,m)-1){
        if(x==k)--x;
        cout<<" "<<x;
        x--;
      }
      cout<<" "<<k;
      x=0;
      rep(i,pow(2,m)-1){
        if(x==k)++x;
        cout<<" "<<x;
        x++;
      }
  }
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}

Measured memory_bytes: 1792
while True:
    N = input()
    if N == 0: break
    L = [input() for i in range(N)]
    c = 0
    for i in range(len(L[:])-1):
        for i in range(len(L)-1):
            if L[i] > L[i+1]:
                L[i], L[i+1] = L[i+1], L[i]
                c += 1
        else:
            del L[-1]
    else:
        print c

Measured memory_bytes: 4228
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  long int N, M;
  cin >> N >> M;
  long int ans;
  if(M == 1 && N == 1){
    ans = 1;
  } else if(M == 1){
    ans = N-2;
  } else if(N == 1){
    ans = M-2;
  } else {
    ans = (N-2)*(M-2);
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	int K;
	cin >> K;
	int num=0;
	while(B<=A){
		B*=2;
		num++;
	}
	while(C<=B){
		C*=2;
		num++;
	}
	if(num<=K) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3616