akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
    
k, t = invr()
ips = sorted(list(invr()))
rest_sum = sum(ips[:-1])
if rest_sum > ips[-1]:
    print(0)
else :
    print(ips[-1]-rest_sum-1)


Measured memory_bytes: 9096
#include<iostream>
#include<queue>
#include<limits>
// #include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<cmath>
#include<math.h>
#include<iomanip>  
#include<deque> 
#include<stack>
#include<string> 
#include<string.h>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#define ll long long
#define tc(t)  while(t--)
#define V vector
#define Vp vector< pair<int,int> >
#define pb push_back
#define UM unordered_map
#define IT iterator
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define PQ priority_queue
#define _FI ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

 char ar[140000];
vector<ll> SieveOfEratosthenes(ll n) 
{ 
  vector<ll> result;
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
    int count=1;
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        {  
            for (ll i=p*p; i<=n; i += p) 
                {
                  prime[i] = false; 
                }
            count++;
        } 
    } 
  
    for (ll p=2; p<=n; p++) 
       if (prime[p]) 
          {
            result.push_back(p);
          }
    return result;
}



vector<ll> Divisors (ll n)
{
  vector<ll> res;
  for(ll i=1;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      if(n/i==i)
      {
        res.pb(i);
      }
      else
      {
        res.pb(i);
        res.pb(n/i);
      }
    }
  }

  return res;
}

int a[4][2]={ {1,0}, {1,-1}, {1,1}, {2,0} } ;
bool validPoint(int x,int y, int N)
{
    return (x>=0 && x<N && y>=0 && y<N);
}

int findAngle(int hour, int min, int sec)
{
  int h = (hour * 360) / 12 + (min * 360) / (12 * 60) + (sec * 1 ) / 120;

  int m = (min * 360) / (60) + (sec * 6 ) /10;

  int angle = abs(h - m);

  if (angle > 180)
    angle = 360 - angle;

  return angle;
}
 
int main()
{
  _FI 
  int n;
  cin>>n;
  map<string,int> mp;
  mp["AC"]=mp["WA"]=mp["TLE"]=mp["RE"];
  while(n--)
  {
    string s;
    cin>>s;
    mp[s]++;
  }

  cout<<"AC x "<<mp["AC"]<<endl;
  cout<<"WA x "<<mp["WA"]<<endl;
  cout<<"TLE x "<<mp["TLE"]<<endl;
  cout<<"RE x "<<mp["RE"]<<endl;
  
  return 0;
}















Measured memory_bytes: 3228
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

int main(){
    int X;cin>>X;
    if(X==7){
        cout<<"YES"<<endl;return 0;}
    if(X==5){
        cout<<"YES"<<endl;return 0;
    }
    if(X==3){
        cout<<"YES"<<endl;return 0;
    }
    cout<<"NO";
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;


//int main() {
//	long long n;
//
//	int keta = 0;
//	long long x = 0;
//	cin >> n;
//
//	while (x < n) {
//		keta++;
//		if (keta >= 16)break;
//		x += pow(26, keta);
//	}
//
//	int c[100] = { 0 };
//	long long nanban;
//	if (keta != 16) nanban = n - (x - pow(26, keta));
//	else  nanban = n - x;
//	int i = 0;
//
//	//if (nanban == 0) {
//	//	for (int i = keta - 1; i >= 0; i--) {
//	//		printf("%c", 'z');
//	//	}
//	//	return 0;
//	//}
//	while (1) {
//		int  amari = nanban % 26;
//		//cout << nanban << endl;
//		 nanban = nanban / 26;
//		
//		c[i] = amari;
//		i++;
//		if (nanban <26)break;
//	}
//	c[i] = nanban;
//	bool ok = true;
//	for (int i = keta - 1; i >= 0; i--) {
//		if (c[i] != 0)ok = false;
//
//	}
//	if (ok) {
//		for (int i = keta - 1; i >= 0; i--) {
//			printf("%c", 'z');
//
//		}
//		return 0;
//	}
//
//	for (int i = keta - 1; i >= 0; i--) {
//		if (i != 0) {
//			printf("%c", 'a' + c[i]);
//			//cout << c[i] << endl;
//		}
//
//		if (i == 0) {
//			if (c[i] == 0) {
//				printf("z");
//			}
//			else {
//				printf("%c", 'a' + c[i] - 1) ;
//			}
//		}
//	}
//	cout << endl;
//	return 0;
//
//
//
//}

//string f(long long n) {
//	if (n == 0)return "";
//	n--;
//
//	return f(n / 26) + string(1,'a' + n % 26);
//
//}
//int main() {
//	long long n;
//	cin >> n;
//	cout << f(n) << endl;
//
//	return 0;
//}

int main() {
	long long n;
	cin >> n;
	string ans;
	while (n) {
		n--;
		ans += 'a' + n % 26;
		n /= 26;
	
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
package main

import (
  "os"
  "bufio"
  "fmt"
  "strings"
)

func main() {
  reader := bufio.NewReader(os.Stdin)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  s, _ := reader.ReadString('\n')
  s = strings.TrimSpace(s)
  score, balance := 0, 0
  for _, ch := range s {
    if ch == 'p' {
      if balance > 0 {
        balance--
      } else {
        score--
        balance++
      }
    } else {
      if balance > 0 {
        balance--
        score++
      } else {
        balance++
      }
    }
  }
  writer.WriteString(fmt.Sprintf("%d\n", score))
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

    vector<int> v(n);

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

    std::sort(v.begin(), v.end(), std::greater<int>());

    int sum_Alice = 0, sum_Bob = 0;

    for (int i = 0; i < v.size(); i++)
    {
        if (i % 2 == 0)
        {
            sum_Alice += v[i];
        }
        else
        {
            sum_Bob += v[i];
        }
    }

    cout << sum_Alice - sum_Bob << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){

	while(1){
		int n;
		cin>> n;
		if(!n) break;
		
		vector<int> a(n,0);
		for(int i=0;i<n;i++){
			cin>> a[i];
		}
		
		int sum = -100000;
		for(int i=0;i<n;i++){
			int sum2 = a[i];
			if(sum < sum2) sum = sum2;
			for(int j=i+1;j<n;j++){
				sum2 += a[j];
				if(sum < sum2) sum = sum2;
			}
		}
		
		cout<< sum<< endl;
	}
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

Measured memory_bytes: 1204
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int m;cin>>m,m;){
		int n; cin>>n;
		vi d(n+2); rep(i,n) cin>>d[i+1];
		
		vvi dp(n+2,vi(n+2)); // 0:ふりだし,m+1:あがり
		rep(i,n+2) dp[i][i]=1;
		rep(i,n+2) repi(j,1,m+1) if(i+j<=n+1)
			dp[i][min(max(i+j+d[i+j],0),n+1)]=1;
		
		rep(k,n+2) rep(i,n+2) rep(j,n+2)
			dp[i][j]|=dp[i][k]&dp[k][j];
		
		bool res=true;
		rep(i,n+2) if(dp[0][i] && !dp[i][n+1]) res=false;
		cout<<(res?"OK":"NG")<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1336
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,k,ans=0,time=0;cin>>n>>m>>k;
  lvector A(n),B(m),SA(n+1,0),SB(m+1,0);rep(i,n) cin>>A[i];rep(i,m) cin>>B[i];
  rep(i,n) SA[i+1]=A[i]+SA[i];
  rep(i,m) SB[i+1]=B[i]+SB[i];
  for(ll apos=n;apos>-1;--apos) {
    if(SA[apos]>k) continue;
    ll bpos=upper_bound(ALL(SB),k-SA[apos])-SB.begin();
    ll tmp=apos+bpos-1;
    ans=max(ans,tmp);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 9532
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif
	vl a(3);
	rep(i, 3) cin >> a[i];
	sort(all(a));
	rep(i, 3) if(a[i]%2 == 0) {
		cout << 0 << endl;
		return 0;
	}
	cout << a[0] * a[1] << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())
sumE = [0]
sumW = [0]
for i, s in enumerate(S):
    if S[len(S)-1-i] == 'E':
        e = 1
    else:
        e = 0
    if S[i] == 'W':
        w = 1
    else:
        w = 0
    
    sumE.append(sumE[i]+e)
    sumW.append(sumW[i]+w)
min = len(S)
for i in range(N):
    sum = sumE[len(S)-1-i] + sumW[i]
    if sum < min:
        min = sum
print(min)

Measured memory_bytes: 29860
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var A = input[0];
  var B = input[1];
  var tmpGcd = gcd(A, B);
  if(tmpGcd == 1){
     myout("1");
    return;
     }
  var list = [];
  for(var i = 1; i * i <= tmpGcd; i++){
    if(A % i == 0 && B % i == 0){
       list.push(i);
      if(i * i != tmpGcd){
         list.push(tmpGcd / i);
         }
    }
  }
  
  list.sort(function(a,b){
  	return a - b;
  });
  
  //myout(list);
  var output = 1;
  for(var j = 1; j < list.length; j++){
    var tmp = list[j];
    if(isPrime(tmp)){
      output++;
    }
  }
  myout(output);
}

//最大公約数
function gcd(m, n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
}

function isPrime(n){
    if(false===Number.isInteger(n)){
        return false;
    }
    if(n<=1){
        return false;
    }
    if(2===n){
        return true;
    }
    if(0===n%2){
        return false;
    }
    var square_root = Math.floor(Math.sqrt(n));
    for(var i=3; i<=square_root; i+=2){
        if(0===n%i){
            return false;
        }
    }
    return true;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 9404
#import<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL i,j,k,m,n,r,w[100005];
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	for(;n;i++)n/=k;
	cout<<i;
	
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#define debug(x) cout<<"***"<<x<<"***"<<endl;
using namespace std;

int main()
{
	long long k,len,i,cnt=1,ans=0,extra1=1,extra2=1;
	string s;
	cin>>s>>k;len=s.length();
	for(i=len-1;i>=1;i--)
	{
		if (s[i]==s[i-1]) cnt++;
		else
		{
			if (cnt>1)
			{
				ans=ans+cnt/2;
				cnt=1;
			}
		}
	}
	if (cnt>1)
	{
		ans=ans+cnt/2;
		cnt=1;
	}
	if(s[0]==s[len-1])
	{
	
		for(i=len-2;i>=0;i--)
		{
			if (s[i]==s[len-1]) extra1++;
			else	break;
		}
		if(extra1==len || len==1)
		{
			cout<<len*k/2;
			return 0;
		}
		for(i=1;i<=len-1;i++)
		{
			if (s[i]==s[0]) extra2++;
			else	break;
		}

		if ((extra1+extra2)%2==0 && extra1%2==1)
				cout<<ans*k+k-1;
		else cout<<ans*k;
		return 0;
	}
	cout<<ans*k;



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

/*
author: Basel
*/

using namespace std;

int a,b;

int main()
{
    cin >> a >> b;
    cout << max(a+b,max(a-b,a*b)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int i = 0,j;
    int count = 0;
    double mou,temp;
    double a[100];
    while(scanf("%lf",&a[i]) != EOF){
        i++;
        count++;
    }
    for(i = 0; i < count; i++){
        for(j = 0; j < count; j++){
            if(a[i] < a[j]){
                temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
        }
    }
    mou = a[count-1] - a[0];
    printf("%.1lf\n",mou);

    return 0;
}

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

using namespace std;

#define max 1000000

//正四面体数を返す
int getRt(int n){
	return (n) * (n + 1) * (n + 2) / 6;
}
int min(int p, int q) {
	if( p > q ) return q;
	return p;
}

int main(void){
//	FILE* fp_in = freopen("data.txt", "r", stdin);
	
	vector<int> Rtlist;
	vector<int> Rtlist2;
	vector<int> vn;
	vector<int> vo;
	//正四面体数テーブル
	for(int i = 1; getRt(i) <= max; i++) {
		Rtlist.push_back( getRt(i) );
		if( getRt(i) % 2 != 0 ) Rtlist2.push_back( getRt(i) );
	}
	//答えのテーブル
	for(int i = 0; i <= max; i++) {
		vn.push_back(i);
		vo.push_back(i);
	}
	for(int i = 0; i < Rtlist.size(); i++)
		vn.at( Rtlist.at(i) ) = 1;
	for(int i = 0; i < Rtlist2.size(); i++)
		vo.at( Rtlist2.at(i) ) = 1;
	
	//動的計画法を用いる
	/*
		正四面体数p
		vn(n+p) = min( vn(n) + 1, vn(n+p) ) 
	*/
	for(int i = 1; i <= max; i++ )
		for(int j = 0; j < Rtlist.size() && i + Rtlist.at(j) <= max ; j++)
			vn.at( i + Rtlist.at(j) ) = min( vn.at( i ) + 1, vn.at( i + Rtlist.at(j) ) );
	for(int i = 1; i <= max; i++ )
		for(int j = 0; j < Rtlist2.size()  && i + Rtlist2.at(j) <= max ; j++)
			vo.at( i + Rtlist2.at(j) ) = min( vo.at( i ) + 1, vo.at( i + Rtlist2.at(j) ) );

	
	while(1){
		int n, tmp;
		cin >> n;
		if( n == 0 ) break;

		cout << vn.at(n) << " " << vo.at(n) << endl;

	}

//	while(1){}

	return 0;
}

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


int main(){
    string s;
    int a,z;
    cin >> s;
    rep(i,s.size()) 
        if(s[i]=='A'){
            a=i;
            break;
        } 
    reverse(s.begin(),s.end());
    rep(i,s.size()) 
        if(s[i]=='Z'){
            z=i;
            break;
        }
    cout << s.size()-z-a << endl; 
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long long w[1000], v[1000];
long long dp[100001][101];
int main() {
	int n, weight;
	cin >> n >> weight;
	for (int i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}
	for (int i = 1; i <= 100000; i++) {
		for (int j = 0; j <= n; j++) {
			dp[i][j] = 1e9+1;
		}
	}
	for (int i = 1; i <= 100000; i++) {
		for (int j = 1; j <= n; j++) {
			dp[i][j] = dp[i][j - 1];
			if (v[j] <= i) {
				dp[i][j] = min(dp[i - v[j]][j - 1] + w[j], dp[i][j]);
			}
			//cout << dp[i][j] << " ";
		}
		//cout << endl;
	}
	int ans = 0;
	for (int i = 0; i <= 100000; i++) {
		if (dp[i][n] <= weight) {
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 79104
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	vector<int> a(n);

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

	vector<int> sum(n+1);
	sum[0] = 0;

	for (int i = 0; i < n; i++) {
		sum[i+1] = (sum[i] + a[i])%m;
	}

	map<int, int> map;

	LL ans = 0;
	for (int i = 0; i < n+1; i++) {
		ans += map[sum[i]]++;
	}

	cout << ans << endl;
	


	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
const int n=1e5+1;
int c[n],s[n]; 
int main()
{
    for(int i=2;i<n;i++)
    {
        if(!c[i])
        {
            if(i!=2&&!c[(i+1)/2])
                s[i]=1;
            for(int j=i+i;j<n;j+=i)
                c[j]=1;
        }
    }
    for(int i=2;i<n;i++)
    {
        s[i]+=s[i-1];
    }
    int q;
    cin>>q;
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        cout<<s[r]-s[l-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

#define INPUT_NUMBER 3

int main(void){
    int num[10000];
    int not_zero=1;
    int i=0;

    while(not_zero){
        scanf("%d",&num[i]);
        if(num[i]==0){
            not_zero=0;
        }
        i++;
    }

    for(int h=0;h<i-1;h++){
        printf("Case %d: %d\n",h+1,num[h]);
    }

    return 0;
}


Measured memory_bytes: 1804
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String s = sc.nextLine();
      String p = sc.nextLine();
      String ss = s + s;
      int OK = 0;
      int[] check = new int[s.length()];
      for(int i = 0; i < s.length(); i++){
        for(int j = 0; j < p.length(); j++){
          char pj = p.charAt(j);
          char ssj = ss.charAt(j+i);
          if (pj == ssj) check[i] ++; 
        }
      }
      for (int i = 0; i < s.length(); i++) {
        if (check[i] == p.length()) {
        System.out.println("Yes");
        OK = 1;
        break;
        }
      }
      if (OK == 0) System.out.println("No");
    }
}


Measured memory_bytes: 26288
N = int(input())

A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))

can_list=[]

for i in range(N) :
    A_1_can = sum(A_1[0:i+1])
    A_2_can = sum(A_2[i:N])

    can_list.append(A_1_can+A_2_can)

print(max(can_list))


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

bool flag = false;
string ABCD;

void dfs(int count, string op) {
    if (flag == true) return;
    if (count == 3) {
        int sum = 0;
        sum += stoi(ABCD.substr(0, 1));

        string output = ABCD.substr(0, 1);

        rep(i, op.length()) {
            string s = ABCD.substr(i + 1, 1);
            if (op[i] == '+') {
                sum += stoi(s);
                output = output + "+" + s;
            }
            else {
                sum -= stoi(s);
                output = output + "-" + s;
            }
        }
        if (sum == 7) {
            cout << output + "=7" << endl;
            flag = true;
        }
        return;
    }

    count += 1;
    dfs(count, op + "+");
    dfs(count, op + "-");
}

int main() {
    cin >> ABCD;
    dfs(0, "");
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

const ll INF = 1LL << 50;

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

  ll add = k / 50;
  ll mod = k % 50;

  const ll n = 50;
  vll ans(n);
  for (ll i = 0; i < n; i++) {
    ans[i] = add + i;
  }

  for (ll j = 0; j < mod; j++) {
    ans[j] += n;
    for (ll k = 0; k < n; k++) {
      if (k == j) continue;
      ans[k] -= 1;
    }
  }

  cout << n << endl;
  rep(i, n) cout << ans[i] << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cstdio>
using namespace std;
 
bool prov(string a,string b, int i)
{
	int n=a.size();
	int m=b.size();
	bool y=1;
	for(int j=0;j<m;j++){
		if(a[i+j]!=b[j]&&a[i+j]!='?')	
			y=0;
	}
	return y;
}
typedef long long ll;
 
int main()
{
	string s0,t;
	bool tr[100];
	cin>>s0>>t;
	int n = s0.size();
	int m = t.size();
	bool x=0;
	for(int i=0;i<=n-m;i++){
		tr[100]=prov(s0,t,i);
		if(prov(s0,t,i)==1)
			x=1;
	}
	if(x==0){
		cout<<"UNRESTORABLE";
	}
	else{
		int min=0;
		for(int i=0;i<=n-m;i++){
			if(prov(s0,t,i)==1)
				min=i;	
		}
		for(int i=0;i<min;i++){
			if(s0[i]!='?')
				cout<<s0[i];
			else
				cout<<'a';
		}
		for(int i=0;i<m;i++){
			cout<<t[i];
		}
		for(int i=min+m;i<n;i++){
			if(s0[i]!='?')
				cout<<s0[i];
			else
				cout<<'a';
		}
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

loop{

  a, op, b = STDIN.gets.split(' ')
  a = a.to_i
  b = b.to_i

  case op
  when "+" 
    puts a + b
  when "-" 
    puts a - b
  when "*" 
    puts a * b
  when "/" 
    puts a / b
  else
    break
  end
}

Measured memory_bytes: 8704
extern crate itertools;

use itertools::Itertools;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut v = vec![0; n];
    let it = (1..=((n as f64).sqrt() as usize)).combinations_with_replacement(3);
    for i in it {
        let a = i[0];
        let b = i[1];
        let c = i[2];
        let x = a * a + b * b + c * c + a * b + b * c + a * c;
        if n >= x {
            let mut inc = 1;
            let l = i.into_iter().unique().count();
            if l == 2 {
                inc = 3;
            }
            if l == 3 {
                inc = 6;
            }
            v[x - 1] += inc;
        }
    }
    for i in v {
        println!("{}", i);
    }
}


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


int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    int all_vote = 0;
    rep(i, N) {
        cin >> A[i];
        all_vote += A[i];
    }

    int cnt = 0;
    double border = 1.0 * all_vote / (4 * M);
    for(int i = 0; i < N; i++){
        if(A[i] >= border){
            cnt++;
        }
    }
    if(cnt >= M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

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

    cin >> a >> b >> c;

    if ( c == 1 || a == 1 && b == 1 ) {
        cout << "Open" << endl;
    } else {
        cout << "Close" << endl;
    }

    return ( 0 );
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define allof(a)        a.begin(),a.end()
#define mset(a)         memset(a,0,sizeof(a))
#define int             int64_t
#define fi              first
#define se              second
#define pb              push_back
#define F(i,a,b)        for(int i=a;i<=b;i++)
#define D(i,a,b)        for(int i=a;i>=b;i--)
#define inf             0x3f3f3f3f3f3f3f3f
#define mn              262144
#define mp              make_pair
using namespace std;
typedef pair<int,int>   ii;
int n;
int a[mn];
struct holder
{
    int l1=-inf,l2=-inf;
    void push(int val)
    {
        if(l1<val)l2=l1,l1=val;
        else if(l2<val)l2=val;
    }
}pq[mn];

int res[mn];
int32_t main()
{
    ios::sync_with_stdio(0);
    #ifdef _TPR_
        freopen("t.inp","r",stdin);
        freopen("t.out","w",stdout);
    #endif
    cin>>n;
    F(i,0,(1<<n)-1)cin>>a[i];
    F(i,0,(1<<n)-1)pq[i].push(a[i]);

    F(k,0,n-1)F(x,0,(1<<n)-1)if((x&(1<<k))==0)
    {   
        pq[x|(1<<k)].push(pq[x].l1);
        pq[x|(1<<k)].push(pq[x].l2);
    }
    F(i,1,(1<<n)-1)res[i]=max(res[i-1],pq[i].l1+pq[i].l2);
    F(x,1,(1<<n)-1)cout<<res[x]<<'\n';
}

Measured memory_bytes: 11788
import java.util.Scanner;

public class Main {

	Scanner scan = new Scanner(System.in);
	
	void compute() {
		int n = scan.nextInt();
		
		int[] p = new int[n+1];
		int[] array = new int[n+1];
		int num = 0;
		
		for (int i=1;i<=n;i++) {
			p[i] = scan.nextInt();
		}
		
		for (int i=n;i>0;i--) {
			int sum = 0;
			for (int j=2;i*j<=n;j++) {
				sum += array[i*j];
			}
			sum = sum % 2;
			array[i] = sum == p[i] ? 0 : 1;
			num += array[i];
		}
		
		System.out.println(num);
		for (int i=1;i<=n;i++) {
			if (array[i] > 0) {
				System.out.print(i);
				System.out.print(--num == 0 ? "\n" : " ");
			}
		}
	}
	
	
	public static void main(String...arg) {
		new Main().compute();
	}
}


Measured memory_bytes: 86292
n,y = map(int,input().split())
ans = [-1,-1,-1]
if 10000 * n >= y:
    for i in range((y//10000)+1):
        for j in range(n-i+1):
                if 10000 * i + 5000 * j + 1000 * (n-i-j) == y:
                    ans = [i,j,n-i-j]
print(*ans)

Measured memory_bytes: 8868
#include <iostream>

#include <vector>

#include <cassert>

#include <algorithm>

#include <functional>

#include <cmath>
#include <stdio.h>
#include <iomanip>
#include <string>
#include <limits>
#include <bits/stdc++.h>
#include<queue>
#include<type_traits>
#include<cstdint>
using namespace std;
using ll=long long;

int main(){
    string S;
    cin >> S;
    ll reg=1e9;
    for(int i=0;i<S.size()-2;i++){
        string a =S.substr(i,3);
        ll b=atoi(a.c_str());
        reg=min(reg,abs(b-753));
    }
    cout << reg << endl;
}

Measured memory_bytes: 256
N = int(input())
sub_yes = 0
max_yes = 0
for i in range(N):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        sub_yes += 1
        if sub_yes > max_yes:
            max_yes = sub_yes
    else:
        if sub_yes > max_yes:
            max_yes = sub_yes
        sub_yes = 0
if max_yes >= 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9084
// #include <algorithm>
// #include <cctype>
// #include <climits>
// #include <cmath>
// #include <cstdio>
// #include <iostream>
// #include <locale>
// #include <numeric>
// #include <queue>
// #include <stack>
// #include <string>
// #include <unordered_map>
// #include <utility>
// #include <vector>
// #include <numeric>
// #include <limits>
 
// using namespace std;

// long gcd(long c, long d){
//     if(c < d){
//         long tem = c;
//         c = d;
//         d = tem;
//     }
//     long r = c % d;

//     while(!r){
//         d = c;
//         c = r;
//         r = c % d;
//     }
//     cout<<d<<endl;
//     return d;
// }

// long lcm(long c, long d){
//     return c*d / gcd(c,d);
// }

// int main(){
//     long long A;cin>>A;
//     long long B;cin>>B;
//     long C;cin>>C;
//     long D;cin>>D;

//     long x = A/ C;
//     if(A % C != 0 )x++;

//     long xEnd = B/C;
//     xEnd++;

//     long y = A/D;
//     if(A%D != 0)y++;

//     long yEnd = B/D;
//     yEnd++;

//     long temp = lcm(C,D);

//     long z= A/(temp);
//     if(A%(temp != 0))z++;

//     long zEnd = B/(temp);
//     zEnd++;

//     cout<<B - A - ( x - xEnd + y - yEnd - (z - zEnd))<<endl;


// }

#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
 
using namespace std;

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

    vector<int> apple(N);
    int sum = L;
    apple[0] = L;
    bool flag = false;
    for(int i =1;i < N; i++){
        apple[i] = L + i;
        // if(apple[i] == 0)flag = true;
        sum += apple[i];
    }
    int pi = INT_MAX;
    int ans ;
    for(int i = 0; i < N; i++){
        if(abs(apple[i]) <  pi){
            pi = abs(apple[i]);
            ans = sum - apple[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
from itertools import combinations

antennae = [int(input()) for _ in range(5)]
k = int(input())

com = [True if antennae[j] - antennae[i] <= k else False for i, j in combinations(range(5), 2)]
if sum(com) == len(list(combinations(range(5), 2))):
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace	std;
int r=0;
void dfs(int n,int s){
  if(s==1){
    r++;
    return;
  }
  for(int i=0;i*s*s<=n;i++) dfs(n-i*s*s,s-1);
}

int main(){
  for(int n;cin>>n,n;r=0){
  dfs(n,17);
  cout<<r<<endl;
  }
  return 0;
}

Measured memory_bytes: 3072
#include <iostream>

int main(void){
 int N,A;
 std::cin >> N >> A;
 if(N%500==0){
  std::cout << "Yes"; 
 }else if(N%500<=A){
   std::cout << "Yes";
 }else{
  std::cout << "No";
 }
std::cout << std::endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	double input;
	int answer[6];
	int n;

	for( int i = 0;i < 6;i++ ) answer[i] = 0;

	cin >> n;

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

		if( input < 165.0 ) answer[0]++;
		else if( input >= 165.0 && input < 170.0 ) answer[1]++;
		else if( input >= 170.0 && input < 175.0 ) answer[2]++;
		else if( input >= 175.0 && input < 180.0 ) answer[3]++;
		else if( input >= 180.0 && input < 185.0 ) answer[4]++;
		else if( input >= 185.0 ) answer[5]++;
	}

	for( int i = 0;i < 6;i++ ){
		cout << i + 1 << ":";
		for( int j = 0;j < answer[i];j++ ) cout << "*";
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int digitsum(ll n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int main(){
	int n;cin>>n;
	int ans=INF;
	for(int i=1;i<n;i++){
		ans=min(ans,digitsum(i)+digitsum(n-i));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#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;
	scnaf("%d", &n);
	vector<ll> pow(n*3);
	REP(i, n*3) {
		scanf("%lld", &pow[i]);
	}

	sort(ALL(pow));
	ll ans = 0;
	REP(i, n) {
		ans += pow[n + i * 2];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    double thre = 0.5 * a * a * b;

    if (thre >= x) {
        double y = 2.0 * x / (a * b);
        double rad = atan(b / y);
        double ans = 180 * rad / M_PI;
        printf("%.10lf\n", ans);
    } else {
        double z = 2.0 * x / (a * a) - b;
        double rad = atan((b - z) / a);
        double ans = 180 * rad / M_PI;
        printf("%.10lf\n", ans);
    }

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define ALL(_a) _a.begin(), _a.end()
#define EPS 1e-9
#define PI acos(-1.0)
#define MAX 200005
#define MOD 1000000007
#define INF (1 << 31)
#define nl '\n'
#define ms0(x) memset((x), 0, sizeof((x)));
#define ms1(x) memset((x), -1, sizeof((x)));
#define pqmin(x) priority_queue<x, vector<x>, greater<x>>
#define pqmax(x) priority_queue<x>
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) __lcm(x, y)
#define fact(x) factorial(x)
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
#define fast ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0)
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef pair<int, int> pii;
typedef pair<int, pii> tii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;

//*    Aauzubillaahi minaash shaaitwanir razeem
//*        Bismillaahir rahmaanir raheem
//*            Raabbi Zidnee Ilmaa
//!code starts from here.............................................
int main()
{
    fast;
    int n,m;
    cin>>n>>m;
    if(n==m){
        for(int i=0;i<n;i++){
            cout<<n;
        }
    }
    if(n>m){
        for(int i=0;i<n;i++){
            cout<<m;
        }
    }
    if(n<m){
        for (int i = 0; i < m; i++)
        {
            cout << n;
        }
    }
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A=[]
for i in range(M):
    a=int(input())
    if i!=0 and a==A[-1]:
        continue
    if i!=0 and a==A[-1]+1:
        print(0)
        quit()
    A.append(a)
INF=10**9+7
B=[]
tmp=0
A.append(N+1)
for i in A:
    B.append(i-tmp)
    tmp=i+1
dp=[0]*(N+3)
dp[0]=1
dp[1]=1
dp[2]=1
for i in range(2,N+2):
    dp[i+1]=dp[i]+dp[i-1]
    dp[i+1]%=INF
ans=1
for i in B:

    ans*=dp[i]
    ans%=INF
print(ans)


Measured memory_bytes: 9468
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int X = scn.nextInt(), Y = scn.nextInt();
		int ans = 0;
		if (X == 1 && Y == 1) {
			ans = 1000000;
		} else {
			switch (X) {
			case 1:
				ans += 300000;
				break;
			case 2:
				ans += 200000;
				break;
			case 3:
				ans += 100000;
				break;
			default:
				break;
			}
			switch (Y) {
			case 1:
				ans += 300000;
				break;
			case 2:
				ans += 200000;
				break;
			case 3:
				ans += 100000;
				break;
			default:
				break;
			}
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 21844
import sys

lines = sys.stdin.readlines()

X = lines[0].split(' ')
N = int(X[0])
K = int(X[1])

S =[]
for i in range(N):
    S.append(0)


for j in range(K):
    d = int(lines[2*j +1])
    A = lines[2*j +2].split(' ')
    for k in range(d):
        S[int(A[k])-1] +=1

P = 0
for i in range(N):
    if S[i] == 0:
        P += 1

print(P)

Measured memory_bytes: 9204
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); 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; }
typedef pair<int, int>P;
const int INF = 1e15;

signed main() {
	int A, B, C;
	cin >> A >> B >> C;
	int sum = A;
	int cnt = 0;
	while (cnt!= B + 1) {
		if (sum % B == C) {
			cout << "YES";
			return 0;
		}
		sum += A;
		cnt++;
	}
	cout << "NO";
}

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

int main() {
	// your code goes here
	int N;
	cin >> N;
	int A[N];
	for(int i = 0; i < N; ++i){
		cin >> A[i];
	}
	
	int cnt = 0;
	for(int i = 0; i < N; ++i){
		int minj = i;
		for(int j = i; j < N; ++j){
			if(A[j] < A[minj]) minj = j;
		}
		if(i != minj){
			++cnt;
			swap(A[i], A[minj]);
		}
	}
	
	for(int i = 0; i < N - 1; i++) cout << A[i] << " ";
	cout << A[N - 1] << endl;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>

using namespace std;

static const int MAX = 100;

void insertionSort(int A[], int N);
void output(int A[],int N);


int main() {

	int A[MAX], N;
	
	//input
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	output(A,N);
	insertionSort(A, N);
	return 0;
}

void insertionSort(int A[],int N) {
	int v = -1;
	int j = -1;
	for (int i = 1; i < N; i++) {
		v = A[i];
		j = i-1;
		while (j >= 0 && A[j] > v)
		{
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		output(A, N);
	}
}

void output(int A[],int N) {
	for (int i = 0; i < N-1; i++)
	{
		cout << A[i]<<" "<<flush;
	}
	cout << A[N - 1] << endl;
}


Measured memory_bytes: 3068
(let* ((n (read))
       (x (read))
       (y (read))
       (ans (make-array (list n))))
  (loop :for i :from 1 :to (1- n)
        :do (loop :for j :from (1+ i) :to n
                  :do (let ((d (min (+ (min (abs (- i x)) (abs (- i y)))
                                       (min (abs (- j x)) (abs (- j y)))
                                       1)
                                    (- j i))))
                        (incf (aref ans d)))))
  (loop :for d :from 1 :to (1- n)
        :do (format t "~A~%" (aref ans d))))


Measured memory_bytes: 24520
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <time.h>
#define INF 1000000000000LL

using namespace std;
typedef long long int ll;

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
  if(m==n-1){
    printf("%d\n", 0);
    return 0;
  }
	ll a[100000];
	multiset<ll> ast;
	for(int i=0; i<n; i++){
		scanf("%lld", &a[i]);
		ast.insert(a[i]);
	}
	vector<int> v[100000];
	for(int i=0; i<m; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	vector<int> conn[100000];
	int c=0;
	set<int> st;
	for(int i=0; i<n; i++){
		st.insert(i);
	}
	while(!st.empty()){
		int b=*st.begin();
		st.erase(st.begin());
		vector<int> w;
		w.push_back(b);
		conn[c].push_back(b);
		while(!w.empty()){
			int x=w.back();
			w.pop_back();
			for(int i=0; i<v[x].size(); i++){
				if(st.find(v[x][i])==st.end()) continue;
				w.push_back(v[x][i]);
				conn[c].push_back(v[x][i]);
				st.erase(v[x][i]);
			}
		}
		c++;
	}
	ll ans=0;
	for(int i=0; i<c; i++){
		ll m=INF;
		for(int j=0; j<conn[i].size(); j++){
			if(m>a[conn[i][j]]) m=a[conn[i][j]];
		}
		ans+=m;
		ast.erase(ast.lower_bound(m));
	}
	auto itr=ast.begin();
	for(int i=0; i<c-2; i++){
		if(itr==ast.end()){
			printf("Impossible\n");
			return 0;
		}
		ans+=(*itr);
		itr++;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 18948
#include<stdio.h>
#define max 300000

typedef struct process{
  char name[256];
  int time;
} p;

int  head = 0, tail = 0, n;
p Q[max];

void enqueue(p);
p dequeue(void);

int main(){
  int i, q, temp, passage = 0;
  p dq;

  scanf("%d%d", &n, &q);

  head = 1; 
  tail = n + 1;

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

  while( tail != head){
    dq = dequeue();
    if(q > dq.time)   temp = dq.time;
    else                    temp = q;
    passage += temp;
    dq.time -= temp;
    if(dq.time > 0)   enqueue(dq);
    else                     printf("%s %d\n", dq.name, passage);
  }
      
  return 0;
}

void enqueue(p x){
  Q[tail] = x;
  if(tail + 1 == max)    tail = 0;
  else                           tail++;
}

p dequeue(void){
  p x = Q[head];
  if(head + 1 == max)    head = 0;
  else                              head++;
  return x;
}

Measured memory_bytes: 49748
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
const int maxn = 2e5 + 10;
vi v[maxn];
ll ans[maxn];
int n;
ll fac[maxn];
ll sz[maxn];
ll faci[maxn];
ll dpup[maxn];
ll par[maxn];
void dfs(int u,int p){
	sz[u] = 1;
	par[u] = p;
	for(auto x:v[u]){
		if(x != p){
			dfs(x,u);
			sz[u] += sz[x];
		}
	}
	ll num = 1;
	ll den = 1;
	ans[u] = fac[sz[u]-1];
	for(auto x:v[u]){
		if(x != p){
			num *= ans[x];
			num %= mod;
			den *= fac[sz[x]];
			den %= mod;
		}
	}
	ans[u] *= num;
	ans[u] %= mod;
	if(den != 1)den = inverse(den);
	ans[u] *= den;
	ans[u] %= mod;
}
void reroot(int u,int p){
	for(auto x:v[u]){
		if(x == p)continue;
		dpup[x] = ans[u];
		int left = n - sz[x];
		dpup[x] *= faci[sz[u] - 1];
		dpup[x] %= mod;
		dpup[x] *= fac[sz[x]];
		dpup[x] %= mod;
		dpup[x] *= inverse(ans[x]);
		dpup[x] %= mod;
		if(u != 1){
			dpup[x] *= dpup[u];
			dpup[x] %= mod;
			dpup[x] *= faci[n-sz[u]];
			dpup[x] %= mod;
		}
		dpup[x] *= fac[left-1];
		dpup[x] %= mod;
		reroot(x,u);
	}
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	fac[0] = 1;
	repa(i,1,maxn){
		fac[i] = fac[i-1] * i;
		fac[i] %= mod;
	}
	repa(i,0,maxn){
		faci[i] = inverse(fac[i]);
	}
	rep(I,n-1){
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}	
	dfs(1,-1);
	reroot(1,-1);
	cout<<ans[1]<<"\n";
	repa(i,2,n+1){
		ll res = fac[n-1];
		for(auto x:v[i]){
			if(x == par[i]){
				res *= dpup[i];
				res %= mod;
				res *= faci[n-sz[i]];
				res %= mod;
			}
			else{
				res *= ans[x];
				res %= mod;
				res *= faci[sz[x]];
				res %= mod;
			}
		}
		cout<<res<<'\n';
	}
	return 0;
}

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

int main() {
    int N, M;
	cin >> N >> M;
    priority_queue<int> q;
    rep(i, N) {
        int A;
        cin >> A;
        q.push(A);
    }
    rep(i, M) {
        int a = q.top(); q.pop();
        q.push(a/2);
    }
    ll ans = 0;
    rep(i, N) {
        ans += q.top(); q.pop();
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
 /* #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll a,b,c,d;
  cin>>a>>b;
  if(a==b)
  {
    cout<<"Draw"<<endl;
  }
 else if((a==1)||(a>b&&b!=1))
  {
    cout<<"Alice"<<endl;
  }
  else if(b==1 ||(b>a))
  {
    cout<<"Bob"<<endl;
  }
  
  

}
return 0;
}


Measured memory_bytes: 256