akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define lowbit(i) i&-i
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	ull ans=0; For(i,0,5)ans=ans<<15^rand(); return ans;
}
const int N=2005,mod=1000000007;
int dp[N][N],ans;
int main(){
	int n=read(),k=read();
	dp[0][0]=1;
	For(i,1,k){
		int sum=0;
		Rep(j,i,1){
			if(i<k)sum=(sum+dp[i-1][j])%mod;
			dp[i][j]=(sum+dp[i-1][j-1])%mod;
		}
	}
	For(i,k+1,n){
		int sum=0;
		Rep(j,k,1){
			sum=(sum+dp[i-1][j])%mod;
			dp[i][j]=sum*2%mod;
		}
	}
	For(i,1,n)ans=(ans+dp[n][i])%mod;
	if(k<n)ans=(ll)ans*(mod+1)/2%mod;
	cout<<ans<<endl;
}

Measured memory_bytes: 15104
from numpy import *
N = int(input())
A = array([input().split() for _ in range(N)], dtype=int64).reshape(N,N)

fill_diagonal(A, 10**9)

ans = 0
for i in range(N):
  for j in range(i+1,N):
    d = min(A[i]+A[j])
    if A[i][j] < d:
      ans += A[i][j]
    elif d < A[i][j]:
      print(-1)
      exit()

print(ans)


Measured memory_bytes: 38356
#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e10;

int main(){
    long long int h, w;
    cin >> h >> w;

    long long int ans = INF;
    vector<vector<long long int>> 
    a = {
            { h / 3      * w, (h - h / 3)     / 2 * w},
            {(h / 3 + 1) * w, (h - h / 3 - 1) / 2 * w},
            { h / 3      * w, (h - h / 3)     * (w / 2)},
            {(h / 3 + 1) * w, (h - h / 3 - 1) * (w / 2)},
            { w / 3      * h, (w - w / 3)     / 2 * h},
            {(w / 3 + 1) * h, (w - w / 3 - 1) / 2 * h},
            { w / 3      * h, (w - w / 3)     * (h / 2)},
            {(w / 3 + 1) * h, (w - w / 3 - 1) * (h / 2)}
    };
    for(int i=0; i<8; i++){
        //cout << a[i][0] << " " << a[i][1] << " " << h * w - a[i][0] - a[i][1] << endl;
        long long int diff = max({a[i][0], a[i][1], h * w - a[i][0] - a[i][1]})
                           - min({a[i][0], a[i][1], h * w - a[i][0] - a[i][1]});
        ans = min(ans, diff);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
public class Main {
    public static void main(String[] args) {
       FS fs = new FS();
        int n = fs.nextInt();
        int a[] = new int[n];
        int max= Integer.MIN_VALUE;
        int min =Integer.MAX_VALUE;
        for(int i =0;i<n;i++){
            a[i]=fs.nextInt();
            if (a[i]>max)max=a[i];
            if (a[i]<min)min=a[i];
        }
        int mm = max - min + 1;
        int[] b = new int[mm];
        for(int i=0;i<n;i++){
            b[a[i]-min]++;
        }
        for (int i=1;i<mm;i++){
            b[i]+=b[i-1];
        }
        int[] c = new int[n];
        for (int i=n-1;i>=0;i--){
             c[b[a[i]-min]-1]=a[i];
             b[a[i]-min]--;
        }
        StringBuilder sb= new StringBuilder();
        for(int i=0;i<n;i++){
            sb.append(c[i]+" ");
        }
        sb.deleteCharAt(sb.length()-1);
        System.out.println(sb.toString());
    }
   static class FS {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        return hasNextByte() ? buffer[ptr++] : -1;
    }

    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    public boolean hasNext() {
        skipUnprintable();
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
        return (int) nextLong();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}
}


Measured memory_bytes: 189048
N, K= map(int,input().split())
A = list(map(int,input().split()))
a=A[:]
for _ in range(K):
  B=[0]*(N+1)
  for i in range(N):
    t = a[i]
    B[max(i-t,0)] +=1
    B[min(i+t+1,N)] -=1
  for i in range(N):
    B[i+1] += B[i]
  a=B[:N]        
  if min(a)==N:
    break
print(*a)

Measured memory_bytes: 169096
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int n, p = 0, o, t, i, j;
	string e;
	bool b[3] = {false};
	cin >> n;
	for (i = 0; i < n; i++)
	{
		o = p = 0;
		b[0] = b[1] = b[2] = false;
		while (o < 3)
		{
			cin >> e;
			if (e == "HIT")
			{
				if (b[2] == true)
				{
					p++;
					b[2] = false;
				}
				if (b[1] == true)
				{
					b[1] = false;
					b[2] = true;
				}
				if (b[0] == true)
				{
					b[0] = false;
					b[1] = true;
				}
				b[0] = true;
			}
			if (e == "HOMERUN")
			{
				for (j = t = 0; j < 3; j++)
				{
					if (b[j])
					{
						b[j] = false;
						t++;
					}
				}
				p += t+1;
			}
			if (e == "OUT")
				o++;
		}
		cout << p << endl;
	}
}

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

int main() {
  int N,K;
  int total=0;
  cin >> N;
  cin >> K;

  for(;N;N--){
    int x;
    int work=0;
    cin >> x;
    if(x<K)
      work = x<K-x?x:K-x;
    else
      work = x<x-K?x:x-K;
    total += work*2;
  }
  cout << total << endl;
}


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

int main(){
  int N;
  cin >> N;
  int X[70000];
  REP(i, 70000) {
    X[i] = -1;
  }
  REP(i, 50000) {
    X[i * 27 / 25] = i;
  }
  
  cout << (X[N] == -1 ? ":(" : to_string(X[N])) << endl;
}

Measured memory_bytes: 512
def solve():
    S = list(input())

    ans = len(S)
    # 0, 1
    for iro in range(2):
        cnt = 0
        for idx, s in enumerate(S):
            if idx % 2 == 0 and str(iro) != s: cnt += 1
            elif idx % 2 != 0 and str(iro) == s: cnt += 1
        # print(cnt)
        ans = min(ans, cnt)

    print(ans)
if __name__ == '__main__':
    solve()


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

#define LLINF (1LL<<60)
typedef long long ll;

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

//C++14 (GCC 5.4.1)
int main() {
    int X,Y;
    cin >>X>>Y;

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


    cout << X+Y/2 <<endl;
    return (0);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#define LL long long
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
using namespace std;

bool isPalindrome(string s)
{
	string tmp1=s, tmp2=s;
	reverse(tmp1.begin(), tmp1.end());
	if(tmp1==tmp2) return true; else return false;
}

int main()
{
	FIO;
	bool x=false, y=false, z=false;
	string s; cin>>s;
	int n=s.size();
	x=isPalindrome(s);
	string s1=s.substr(0, (n-1)/2);
	y=isPalindrome(s1);
	string s2=s.substr((n+3)/2-1, n);
	z=isPalindrome(s2);
	if(x&&y&&z) cout<<"Yes\n"; else cout<<"No\n";
}

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

typedef vector<int> veci;
typedef pair<int, int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9 + 7)
#define fi first
#define se second
#define endl '\n'

int n;
int dfs(int nd, vector<string> const& vs, vector<int>& used, int filled, int odr) {
    if (filled==n) {
        return odr;
    }

    int ret = -1;
    for (int i=0; i<n; ++i) {
        if (vs[nd][i]=='1') {
            if (!used[i]) {
                used[i] = odr + 1;
                filled += 1;
                ret = max(ret, dfs(i, vs, used, filled, odr+1));
            } else {
                if (used[i]!=odr-1 && used[i]!=odr+1) {
                    return -1;
                }
            }
        }
    }
    return ret;
}

void solve() {
    cin >> n;

    vector<string> vs(n);
    for (int i=0; i<n; ++i) {
        cin >> vs[i];        
    }

    int maxi = -1;
    vector<int> used(n, 0);
    queue<pii> q;
    for (int i=0; i<n; ++i) {
        int cur = 1;
        bool ok = true;
        fill(used.begin(), used.end(), 0);
        used[i] = 1;
        q.push({i,1});
        while (!q.empty()) {
            pii t = q.front();
            q.pop();

            cur = t.second;
            for (int j=0; j<n; ++j) {
                if (vs[t.first][j]=='1') {
                    if (!used[j]) {
                        used[j] = t.second + 1;
                        q.push({j, used[j]});
                    } else {
                        if (used[j] != t.second - 1 && used[j] != t.second + 1) {
                            ok = false;
                            break;
                        }
                    }
                }
            }

            if (!ok) break;
        }

        if (ok) {
            maxi = max(maxi, cur);
        }
    }

    cout << maxi << endl;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST
    (void)argc;
    const string strpath = string(argv[0]) + string("-test.in");
    freopen(strpath.c_str(), "r", stdin);
    int tcs;
    cin >> tcs;
    while (tcs-- > 0)
#endif
        solve();
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)

int main() {
    int n; cin >> n;
    int a, b;
    vector<vector<int>> glb(n+2, vector<int> (2, 0));
    rep(i, n)
        cin >> glb[i][0] >> glb[i][1];
    rep(i, n) {
        if(glb[i][0]   == glb[i][1] && 
           glb[i+1][0] == glb[i+1][1] && 
           glb[i+2][0] == glb[i+2][1] &&
           glb[i+1][0] != 0 && glb[i+2][0] != 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
  int N;
  vector<string> s(3);
  rep(i, 3) cin>>s[i];
  string a = s[1];
  
  
  cout<<'A'<<a[0]<<'C'<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
int main() {
    int a, b, c; cin >> a >> b >> c;
    set<int> S;
    S.insert(a); S.insert(b); S.insert(c);
    if (S.size() == 2) printf("%s\n", "Yes");
    else printf("%s\n", "No");
}


Measured memory_bytes: 256
def check(y, conds):
    if len(y) != N:
        return False
    for digit, num in conds.items():
        if y[digit] != num:
            return False
    return True


r1 = range(10)
r2 = range(10, 100)
r3 = range(100, 1000)
r = {1: r1, 2: r2, 3: r3}

N, M = map(int, input().split())
conds = {}
for _ in range(M):
    s, c = map(int, input().split())
    if s - 1 in conds:
        if conds[s - 1] != str(c):
            print(-1)
            exit()
    else:
        conds[s - 1] = str(c)

for y in r[N]:
    y_str = str(y)
    if check(y_str, conds):
        print(y_str)
        break
else:
    print(-1)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#include<algorithm>
#include<queue>
typedef long long ll;
#include<vector>
#define cin(n) scanf("%lld",&(n))
#define cout(n) printf("%lld",(n))
#define couc(c) printf("%c",(c))
#define coutn printf("\n")
#define cout_ printf(" ")
const int MAXN= 1e4 + 5 ;
char s[105];
int main()
{
    int minn=0x3f3f3f3f;
    scanf("%s",s);
    for(int i=2;i<strlen(s);i++)
    {
        int now=(s[i-2]-'0')*100+(s[i-1]-'0')*10+(s[i]-'0');
        if(abs(now-753)<minn)
        {
            minn=abs(now-753);
        }
    }
    printf("%d\n",minn);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ALDS1_6_D {
    public static class Problem {
        public static int GetMinCost(this int[] source) {
            int n = source.Length;
            int minCost = 0;
            bool[] used = new bool[n];

            int[] sorted = (int[])source.Clone();
            Array.Sort(sorted);
            int minValue = sorted[0];

            Dictionary<int, int> valueToIndex = Enumerable.Range(0, n)
                .ToDictionary(i => source[i], i => i);
            
            for(int i = 0; i < n; i++) {
                if (used[i])
                    continue;

                int minValueInGroup = sorted[i];
                int curPosition = valueToIndex[minValueInGroup];
                int sumOriginal = 0;
                int sumReplace = (minValue + minValueInGroup) * 2;

                while (curPosition != i) {
                    used[curPosition] = true;
                    int nextValue = sorted[curPosition];
                    sumOriginal += nextValue + minValueInGroup;
                    sumReplace += nextValue + minValue;
                    curPosition = valueToIndex[nextValue];
                }
                minCost += Math.Min(sumOriginal, sumReplace);
            }
            return minCost;
        }
    }

    class Program {
        static void Main(string[] args) {
            Console.ReadLine();
            int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(input.GetMinCost());
        }
    }
}

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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  K --;
  if (S.at(K) == 'A') {
    S.at(K) = 'a';
    cout << S << endl;
  } else if (S.at(K) == 'B') {
    S.at(K) = 'b';
    cout << S << endl;
  } else {
    S.at(K) = 'c';
    cout << S << endl;
  }
}

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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node *NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer i;
  for(i = nil;i->next != nil; i=i->next){
    if(i->next->key == key) return i->next;
  }
  return NULL;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->next->prev = t->prev;
  t->prev->next = t->next;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t != nil ) deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  deleteNode(t);
}

void delete(int key){
  NodePointer p;
  p = listSearch(key);
  if ( p != NULL ) deleteNode(p);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {
      insert(key);
      np++;
      size++;
    }
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      }
      else {
	delete(key);
	nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

bool IsPrime(int n){
    if (n<2) return false;
    else if(n==2) return true;
    else if(n%2==0) return false;
    double sqrtNum=sqrt(n);
    for(int i=3;i<=sqrtNum;i+=2){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

int main()
{
	ll n,x=11;
	cin >> n;
	vll ans;
	while((ll)ans.size()<n){
		if(IsPrime(x)) ans.pb(x);
		x+=10;
	}
	rep(i,SIZE(ans)) cout << ans[i] << (i==SIZE(ans)-1?"\n":" ");
	return 0;
}

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

int main (){
    int a,b,c;
    cin >> a>>b>>c;
    int d=a-b;
    if(d>=c) cout << 0 << endl;
    else cout << c-d << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
   
using namespace std;
   
int main(){
    int a,b;
    double a_d,b_d;
    scanf("%d %d",&a,&b);
    a_d = static_cast<double>(a);
    b_d = static_cast<double>(b);
    printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}


Measured memory_bytes: 2744
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();

		int k500 = x / 500;
		int k5 =(x-k500*500) / 5;

		System.out.println((k500 * 1000 + k5 * 5));

		sc.close();

	}
}

Measured memory_bytes: 35712
N, M = map(int, input().split())

A = [int(i) for i in input().split()]

list.sort(A, reverse=True)

while M>0:
    A[0] = int(A[0] / 2)
    #print(A)
    M -= 1
    if M==0:
        break
    for i in range(1,N):
        if(A[i] > A[0]):
            A[i] = int(A[i] / 2)
            #print(A)
            M -= 1
            if M == 0:
                break
        else:
            break
    list.sort(A, reverse=True)


print(sum(A))
    

Measured memory_bytes: 14224
N,M=map(int,input().split( ))

B = input()
C = []
for i in range(N-1):
    if B[i]!=B[i+1]:
        C.append(B[i])
C.append(B[N-1])

if len(C) % 2 == 1:
    print(min(M,len(C)//2)*2+N-len(C))
else:
    if M<len(C)//2:
        print(M*2+N-len(C))
    else:
        print(len(C)+N-len(C)-1)


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);	
	int h,w;
    cin>>h>>w;
    int n_colour;
    cin>>n_colour;
    vector<int> colour(n_colour);
    for(int i = 0 ; i < n_colour ; i++)
    {
        cin>>colour[i];
    }	
    int c = 0;
    queue<int> ans;
    stack<int> ans2;
    for(int i = 0 ; i < h ; i++)
    {
        for(int j = 0 ; j < w ; j++)
        {
            if(colour[c]==0)
            {
                c++;    
            }
            if(i%2==0)
            {
                ans.push(c+1);
            }
            else
            {
                ans2.push(c+1);
            }
            colour[c]--;
        }
        
        while(ans.size()>0)
        {
            cout<<ans.front()<<" ";
            ans.pop();
        }
        while(ans2.size()>0)
        {
            cout<<ans2.top()<<" ";
            ans2.pop();
        }
        
        cout<<" \n";
    }
    
    return 0;
}

Measured memory_bytes: 384
program sample
  implicit none

  integer(8) :: a,b,c

  

  ! 整数を読み込む
  read(*,*) a,b,c

  if (abs(real(b)*2-real(a)-real(c)) < 0.00000001) then 
    write(*,*) 'YES'

  else
    write(*,*)'NO'
  end if

  stop
end program sample


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

int main(){
    int n,m,x,ans=10000000;
    cin >> n >> m >> x;
    vector<int> cost(n);
    vector<vector<int>> a(n,vector<int>(m));
    rep(i,n){
        cin >> cost[i];
        rep(j,m)
            cin >> a[i][j];
    }
    for(int bit=1;bit < (1<<n);bit++){
        int sum=0;
        vector<int> xadd(m);
        rep(i,n){
            if(bit & (1<<i)){
                rep(j,m) xadd[j]+=a[i][j];
                sum+=cost[i];
            }
        }   
        bool flag=true;
        rep(i,m){
            if(xadd[i] < x){
                flag=false;
                break;
            }
        }
        if(flag){
            ans=min(ans,sum);
        }
    }
    if(ans==10000000){
        cout << -1 << endl;
        return 0;
    }else{
        cout << ans << endl;
        return 0;
    }
    /*
    rep(i,n){
        cout << cost[i] << " ";
        rep(j,m){
            cout << r[i][j] << " ";
        }
        cout << endl;
    }*/
}

Measured memory_bytes: 3636
a, b, c = map(int, input().split())
s, m, l = sorted([a, b, c])
x = l - m
y = l - s 

if x%2 == 0 and y%2 == 0:
#     print("a")
    add = (x+y)/2
elif x%2 == 1 and y%2  == 1:
#     print("b")
    add = (x+y-2)/2 + 1
else:
#     print("c")
    add = (x+y-1)/2 + 2
    
    
print(int(add))

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

int main(){
	int a=100000,b,n;
	cin>>n;
	for(int i=0;i<n;i++){
		a=a*1.05;
		b=a%1000;
		if(b!=0)a=a-b+1000;
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll a[210000];
vector<pair<ll,ll>> p;
int main(){
    ll n,ans=0;
    cin>>n;
    rep(i,0,n)cin>>a[i];
    rep(i,0,n)p.pb(mp(a[i],i+1));
    sort(p.begin(),p.end());
    rep(i,0,p.size()){
        cout<<p[i]S<<" ";
    }

}

Measured memory_bytes: 3312
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
double pie=3.14159265358979;
long long mod=998244353;
//
int main(){
	long long n;
	long long a[200000];
	cin>>n;
	long long sna=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sna^=a[i];
	}
	int c[200000];
	for(int i=0;i<n;i++){
		c[i]=sna^a[i];
	}
	for(int i=0;i<n;i++){
		cout<<c[i];
		if(i==n-1){
			cout<<endl;
		}else{
			cout<<" ";
		}
	}
	return 0;
}

Measured memory_bytes: 5888
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))

mn = 1
ans = 0
for a in As:
    if mn == 1:
        ans += a - 1
        mn = 2
    else:
        if mn == a:
            mn += 1
        else:
            ans += (a - 1) // mn
print(ans)            


Measured memory_bytes: 7120
/*
* @Author: Samson
* @Date:   2018-06-12 18:24:44
* @Last Modified by:   Samson
* @Last Modified time: 2018-06-13 12:20:56
*/
//   @URL : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_12_A
#include<bits/stdc++.h>
#include<algorithm>
#include <cstdlib>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int MAXN = 1e2+10;

int p[MAXN],color[MAXN],a[MAXN][MAXN],t,n,d[MAXN];

int prim()
{
	int minv,u,v;
	memset(p,-1,sizeof p);
	memset(d,INF,sizeof d);

	d[1] = 0;

	while(1)
	{
		minv = INF;
		u = -1;
		for(int i = 1; i <= n; ++i)
		{
			if(minv > d[i] && !color[i])
				minv = d[i],u = i;
		}
		if(u == -1)	break;
		color[u] = 1;
		for(int v = 1; v <= n; ++v)
		{
			if(!color[v] && a[u][v] != INF)
			{
				if(d[v] > a[u][v])
				{
					d[v] = a[u][v];
					p[v] = u;
				}
			}
		}
	}
	
	int ans = 0;
	for(int i = 1; i <= n; ++i)
		if(p[i] != -1)
			ans += a[i][p[i]];
	return ans;
}

int main(void)
{
	ios::sync_with_stdio(false); 
	//cin.tie(0);
	cin>>n;
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= n; ++j)
		{
			cin>>t;
			a[i][j] = t==-1?INF:t;
		}
	}
	cout<<prim()<<'\n';
	return 0;
}


Measured memory_bytes: 3152
#include <algorithm>
#include <array>
#include <bitset>
#include <chrono>
#include <complex>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

//#define _DEBUG_ 3
void run() {
	long long int n, m;
	cin >> n >> m;

	long long int ssc = 0;
	
	if (n * 2 >= m) {
		ssc = m / 2;
		cout << ssc << endl;
		return;
	}

	m -= n * 2;
	ssc = n + (m / 4);
	cout << ssc << endl;
}

int main() {
#ifdef _DEBUG_
	using std::chrono::system_clock;
	using std::chrono::duration_cast;
	system_clock::time_point  start, end;
	std::ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
	for (int i = 0; i < _DEBUG_; i++) {
		cout << "-------------------------- (cnt:" << i << ")" << endl;
		start = system_clock::now();
		run();
		end = system_clock::now();
		int elapsed = duration_cast<std::chrono::milliseconds>(end - start).count();
		cout << "-------------------------- (time:" << elapsed << "ms)" << endl << endl;
}
#else
	run();
#endif
	return 0;
}


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

int main()
{
    int n;
    cin>>n;
   
        long a[n],b[n],c[n],d1[n+1]={0},d2[n+1]={0},d3[n+1]={0};
        for(int i=0;i<n;i++)
        {
            cin>>a[i]>>b[i]>>c[i];
        }
        for(int i=0;i<n;i++)
        {
            
            d1[i+1]=max(d2[i],d3[i])+a[i];
            d2[i+1]=max(d1[i],d3[i])+b[i];
            d3[i+1]=max(d2[i],d1[i])+c[i];
            
        }
        
        long ans=max(d1[n],d2[n]);
        ans=max(ans,d3[n]);
        
        cout<<ans<<endl;
        
        
    
    return 0;
}


Measured memory_bytes: 4992
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

A = inp()
B = inp()
C = inp()
D = inp()
print(min(A,B)+min(C,D))


Measured memory_bytes: 4204
/*input
103
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	ll x;
	cin >> x;
	ll now = 100;
	int ret = 0;
	while(now < x) {
		now = now + (now / 100);
		ret++;
	}

	cout << ret << endl;
}

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


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll ans = 0;
        ll N, X, T;
        cin >> N >> X >> T;

        ll now = 0;
        while (true) {
                ans += T;
                now += X;
                if (now >= N) break;
        }

        cout << ans << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
signed main(){
  int n,m,x1,y1;
  cin>>n>>m>>x1;
  int ans1=0,ans2=0;
  for(int i=0;i<n-1;i++){
    int x2;
    cin>>x2;
    ans1=(ans1+(x2-x1)*(i+1)%mod*(n-1-i)%mod)%mod;
    x1=x2;
  }
  cin>>y1;
  for(int i=0;i<m-1;i++){
    int y2;
    cin>>y2;
    ans2=(ans2+(y2-y1)*(i+1)%mod*(m-1-i)%mod)%mod;
    y1=y2;
  }
  cout<<ans1*ans2%mod;
}

Measured memory_bytes: 3616
s = gets.strip

c_found = false
s.chars.each_with_index{|v, i|
  if i == 0 
    if v != 'A'
      puts "WA"
      exit
    end
    next
  end
  if i == 1 || i == s.length - 1
    if !v.match(/[a-z]/)
      puts "WA"
      exit
    end
    next
  end
  if v == 'C'
    if !c_found
      c_found = true
    else
      puts "WA"
      exit
    end
  else
    if !v.match(/[a-z]/)
      puts "WA"
      exit
    end
  end
}

if c_found
  puts "AC"
else
  puts "WA"
end


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

struct cake{
  int w,d,idx;
};

bool operator<(const cake& a,const cake& b){
  if(a.idx==b.idx)return a.w*a.d<b.w*b.d;
  else return a.idx<b.idx;
}

int main(){
	cin.sync_with_stdio(false);
  while(1){
    int n,W,D;
    cin>>n>>W>>D;
    if(W==0)break;
    vector<cake> cs;
    cs.push_back((cake){W,D,-1});
    rep(q,n){
      int p,s;
      cin>>p>>s;
      p--;
      cake nc=cs[p];
      cs.erase(cs.begin()+p);
      int w,d;
      w=nc.w; d=nc.d;
      s%=((w+d)*2);
      if(s<w||(s<w*2+d&&s>w+d)){
        if(s>w+d)s=2*w+d-s;
        cs.push_back((cake){s,d,q});
        cs.push_back((cake){w-s,d,q});
      }else{
        if(s>w*2+d)s=w*2+d*2-s;
        else s=s-w;
        cs.push_back((cake){w,s,q});
        cs.push_back((cake){w,d-s,q});
      }
      sort(all(cs));
    }
    vector<int> res;
    rep(i,cs.size()){
      cake c=cs[i];
      res.pb(c.w*c.d);
    }
    sort(all(res));
    rep(i,res.size()){
      printf("%d%c", res[i],i==res.size()-1?'\n':' ');
    }
  }
	return 0;
}

Measured memory_bytes: 3272
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};


signed main() {
	int n;
	int odc = 0;
	scnaf("%d", &n);
	REP(i, n) {
		int a;
		scanf("%d", &a);
		odc += a % 2;
	}
	printf(odc%2 ? "NO\n" : "YES\n");
	return 0;
}

Measured memory_bytes: 256
using System;

namespace _0073
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                double x = int.Parse(Console.ReadLine());
                double h = int.Parse(Console.ReadLine());
                if (x == 0 && h == 0)
                {
                    break;
                }
                Console.WriteLine(x * x + Math.Sqrt(x * x / 4 + h * h) * x * 2);
            }
        }
    }
}

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

int main() {
    int n; cin >> n;
    const int N = 1e5+5;
    vector<int> a(n),b(N);
    for(int i=0;i<n;i++) {
        cin >> a[i];
        b[a[i]]++;
    }
    int ans = 0;
    for(int i=0;i<N;i++) {
        ans = max(ans,b[i]+(i-1 < 0 ? 0:b[i-1])+(i+1 == N ? 0:b[i+1]));
    }
    cout << ans;
}

Measured memory_bytes: 1024
const   fi      ='';
        fo      ='';

var     f,g     :text;
        m,n     :longint;
        tro,dem,xd      :array[0..301] of longint;
        a       :array[0..301,0..301] of longint;
procedure       nhap;
var     i,j     :longint;
begin
        assign(f,fi); reset(f);
        readln(f,m,n);
        for i:=1 to m do
                for j:=1 to n do read(f,a[i,j]);
        close(f);
end;

function        min(i,j :longint):longint;
begin
        if i<j then exit(i) else exit(j);
end;

function        tinh(tt :longint):longint;
var     i,sl,vt :longint;
begin
        if tt=0 then exit(round(1e9));
        for i:=1 to n do dem[i]:=0;
        for i:=1 to m do
                begin
                        while (xd[a[i,tro[i]]]=0) and (tro[i]<=n) do inc(tro[i]);
                        if xd[a[i,tro[i]]]=1 then inc(dem[a[i,tro[i]]]);
                end;
        sl:=0;
        for i:=1 to n do if (xd[i]=1) then
                begin
                        if dem[i]>sl then
                                begin
                                        sl:=dem[i];
                                        vt:=i;
                                end;
                end;
        xd[vt]:=0;
        exit(min(sl,tinh(tt-1)));
end;
procedure       xuli;
var     i,kq    :longint;
begin
        for i:=1 to n do xd[i]:=1;
        kq:=tinh(n);
        assign(g,fo); rewrite(g);
        writeln(g,kq);
        close(g);
end;

begin
        nhap;
        xuli;
end.

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N, M, X;
int C[12];
int A[12][12];

int main() {
	cin >> N >> M >> X;
	REP(i, N) {
		cin >> C[i];
		REP(j, M) cin >> A[i][j];
	}
	
	int ans = INF;
	REP(s, 1 << N) {
		vector<int> sum(M);
		int sc = 0;
		REP(i, N) if (s >> i & 1) {
			REP(j, M) sum[j] += A[i][j];
			sc += C[i];
		}
		bool ok = true;
		REP(i, M) ok &= sum[i] >= X;
		if (ok) chmin(ans, sc);
	}
	if (ans == INF) ans = -1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
s = input()

n = len(s) - 1
ans = 0
for mask in range(0, 1 << n):
    num = int(s[0])
    cur = 0
    for i in range(0, n):
        if mask & (1 << i):
            cur += num
            num = 0
        num = num * 10 + int(s[i + 1])
    cur += num
    ans += cur

print(ans)



Measured memory_bytes: 3188
#include <stdio.h>

int main(void){
  long long n,num[100005]={0},a,b,c,q,sum[100005],summax=0;
  scanf("%lld",&n);
  for(int i=0;i<n;i++){
    scanf("%lld",&a);
    num[a-1]++;
    summax+=a;
  }
  for(int i=0;i<n;i++){
    sum[i]=summax;
  }
  scanf("%lld",&q);
  for(int i=0;i<q;i++){
    scanf("%lld %lld",&b,&c);
    sum[i]+=(c-b)*num[b-1];
    num[c-1]+=num[b-1];
    num[b-1]=0;
    sum[i+1]=sum[i];
 }
  for(int i=0;i<q;i++){
    printf("%lld\n",sum[i]);
      }

  return 0;
}

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

int main() {
    int64_t h;
    cin >> h;

    int c=0;
    while(h>0){
        c++;
        h /=2;
    }
    int64_t a=1;
    for(int i=0;i<c;i++){
        a *= 2;
    }
    a--;
    cout << a;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll N;
    cin >> N;
    set<ll> d;
    REP(i, N) {
        ll t;
        cin >> t;
        d.insert(t);
    }
    cout << d.size() << "\n";
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, const char * argv[]) {
    int h,m,s;
    std::cin >> s;
    h = s / 3600;
    s = s - (h * 3600);
    m = s / 60;
    s = s - (m * 60);
    std::cout << h << ":" << m << ":" << s << std::endl;
    return 0;
}

Measured memory_bytes: 3076
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
Hs = sorted(H)

X = (T-A)/0.006

for i in range(1, len(Hs)):
  if Hs[i] > X:
    xm = Hs[i] if abs(X - Hs[i-1]) > abs(X - Hs[i]) else Hs[i-1]
    print(H.index(xm)+1)
    exit()

Measured memory_bytes: 3064
import sys
N=int(input())
A=[int(_) for _ in input().split()]

for i in range(N):
  if A[i]%2==0:
    if (A[i]%6 ==0) or (A[i]%10==0):
      continue
    else:
      print('DENIED')
      sys.exit()
print('APPROVED')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;

int main() {
    ll n; cin >> n;
    vector<vector<ll>> to(n), cost(n);
    rep(i, n-1) {
        ll u, v, w; cin >> u >> v >> w;
        u--; v--;
        to[u].push_back(v);
        to[v].push_back(u);
        cost[u].push_back(w);
        cost[v].push_back(w);
    }
    vector<ll> ans(n, -1);
    queue<ll> q;
    ans[0] = 0;
    q.push(0);
    while (!q.empty()) {
        ll v = q.front(); q.pop();
        rep(i, to[v].size()) {
            ll u = to[v][i];
            ll w = cost[v][i];
            if (ans[u] != -1) continue;
            ans[u] = (ans[v] + w) % 2;
            q.push(u);
        }
    }
    rep(i, n) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

class Main {

    public static void main(String[] args) {
        var scaner = new Scanner(System.in);

        var n = scaner.nextInt();
        var k = scaner.nextInt();
        var p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = scaner.nextInt();
        }

        Arrays.sort(p);

        var ans = 0;
        for (int i = 0; i < k; i++) {
            ans += p[i];
        }

        System.out.println(ans);

        scaner.close();
    }

}

Measured memory_bytes: 39048
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	string s, t, c;cin >> s >> t;bool b = false;
	for (int i = s.size() - t.size();i >= 0;i--) {
		if (!b) {
			c = s.substr(i, t.size());
			for (int j = 0;j < t.size();j++) {
				if (j == t.size() - 1 && (t[j] == c[j] || c[j] == '?')) {
					b = true;int l = 0;
					for (int k = i;k < i + t.size();k++) {
						s[k] = t[l];l++;
					}
					break;
				}
				if (t[j] == c[j]) continue;
				else if (c[j] == '?') continue;
				else break;
			}
		}
	}
	if (b) {
		rep(i, s.size()) {
			if (s[i] == '?') s[i] = 'a';
		}
		cout << s << endl;
	}
	else cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(long long *)a>*(long long *)b)return 1;
    return -1;
}
int main(int argc, const char * argv[]) {
    int n;
    scanf("%d",&n);
    char s[n+1];
    scanf("%s",s);
    int l=0,r=n-1;
    int rn=0,wn=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            rn++;
        }else{
            wn++;
        }
    }
    int ra=0,wa=0;
    for(int i=0;i<rn;i++){
        if(s[i]=='W'){
            wa++;
        }
    }
    for(int i=n-1;i>=rn;i--){
        if(s[i]=='R'){
            ra++;
        }
    }
    printf("%d",ra>wa?ra:wa);
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 9999999999;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define pb push_back
#define f first
#define s second
#define pi 3.141592653589793238
using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])return cout << "Bad\n",0;cout << "Good\n";


	return 0;
}



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

sum = 0

last = -99
for i in range(0, n):
    now = a[i]

    sum += b[now - 1]

    if last + 1 == now:
        sum += c[last - 1]
    last = now

print(sum)


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	string s; cin >> s;
	int a = 0, b = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '0') a++;
		else b++;
	}
	cout << min(a, b) * 2 << '\n';
	return 0;
}

Measured memory_bytes: 512