akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int main()
{
	int a;
	bool first = true;
	while(scanf("%d", &a) != EOF){
		if(!first)
			puts("");
		else
			first = false;

		char num[8];
		sprintf(num, "%05d", a);
		rep(i, 5)
			num[i] -= '0';
		
		rep(i, 5)
			putchar(num[i]<5 ? '*' : ' ');
		puts("");
		rep(i, 5)
			putchar(5<=num[i] ? '*' : ' ');
		puts("");
		rep(i, 5)
			putchar('=');
		puts("");
		
		rep(i, 5){
			rep(j, 5)
				putchar(num[j]%5 == i ? ' ' : '*');
			puts("");
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

int main(){
  ll n;
  cin >> n;
  ll ans = 1;
  vll A(n);
  rep(i,n) cin >> A[i];
  sort(A.begin(),A.end());
  bool judge = true;
  if(n % 2 == 0){
    ll key = 1;
    for(int i = 0;i < n-1;i += 2){
      if(A[i] == key && A[i+1] == key){
        key += 2;
        ans *= 2;
        ans %= 1000000007;
      }
      else{
        judge = false;
        break;
      }
    }
  }
  else{
    ll key = 0;
    if(A[0] != 0){
      judge = false;
    }
    else{
      key+= 2;
    }
    for(int i = 1;i < n-1;i += 2){
      if(A[i] == key && A[i+1] == key){
        key += 2;
        ans *= 2;
        ans %= 1000000007;
      }
      else{
        judge = false;
        break;
      }
    }
  }
  if(judge) cout << ans << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 1024
class Main {
	public static void main(String[] args){
		String N = new java.util.Scanner(System.in).nextLine();
		String[] Narray = N.split("");
		int Nnum = Integer.parseInt(N);
		int Sn = 0;
		for (int i = 0; i < Narray.length; i++) {
			Sn += Integer.parseInt(Narray[i]);
		}
		if (Nnum % Sn == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
package main

import "fmt"

var as []int

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

	am := make(map[int]int)
	for i := 0; ; i++ {
		aa := a(s, i)
		as = append(as, aa)

		if _, ok := am[aa]; ok {
			break
		}
		am[aa] = i
	}

	fmt.Println(len(as))
}

func f(n int) int {
	if n%2 == 0 {
		return n / 2
	}
	return 3*n + 1
}

func a(s, i int) int {
	if i == 0 {
		return s
	}
	return f(a(s, i-1))
}


Measured memory_bytes: 640
using System;
using System.Globalization;
using System.Threading;
using System.Linq;

public static class ProblemA
{
    #region Common routines

    private static int _currentTokenNumber;

    private static string[] _tokens;

    private static void StartReading()
    {
        _currentTokenNumber = 0;

        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

        _tokens = Console.In.ReadToEnd().Split(new[] { ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
    }

    private static string NextString()
    {
        return _tokens[_currentTokenNumber++];
    }

    private static int NextInt()
    {
        return int.Parse(NextString());
    }

    private static long NextLong()
    {
        return long.Parse(NextString());
    }

    #endregion

    private static void Main(string[] args)
    {
        StartReading();

        int n = NextInt();
        var result = int.MaxValue;
        for (int a = 1; a < n; a++)
        {

            var newResult = GetSum(a) + GetSum(n - a);
            if (newResult < result) result = newResult;
        }
        Console.WriteLine(result);

    }

    private static int GetSum(int a)
    {
        int result = 0;
        while (a > 0)
        {
            result += a % 10;
            a /= 10;
        }

        return result;
    }
}

Measured memory_bytes: 13140
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;


#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define all(x) x.begin(),x.end()

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}

const ll MOD =998244353;
const ll hell=1000000007;
const int INF=1e15;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

const int N=3005;

int dp[10005][101];
int d;

int cal(string s)
{
    int ans=0;
    int n=s.length();
    int cr=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<(s[i]-'0');j++)
        {
            int z=(cr+j)%d;
            ans=(ans%hell+dp[n-i-1][(d-z)%d]%hell)%hell;
            
        }
        cr=(cr+(s[i]-'0'))%d;
    }
    if(!(cr%d))
        ans=(ans+1)%hell;
   // if(ans>0)
    ans=(ans-1+hell)%hell;
    return ans;
}
void solve()
{

    string s;
    cin>>s;
    cin>>d;
    int n=s.length();
    dp[0][0]=1;
    for(int i=1;i<=n+1;i++)
    {
        for(int j=0;j<d;j++)
        {
            for(int k=0;k<10;k++)
            {
                dp[i][j]=(dp[i][j]%hell+dp[i-1][(j-k%d+d)%d]%hell)%hell;
            }
        }
    }
    //debug(1);
    cout<<cal(s)<<endl;
    
    
        

}


int32_t main()
{
    
    IOS;
   
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    int t;
    t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}



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

int main() {
  int N;
  scanf("%d", &N);
  vector<int64_t> lucas(N + 1);
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  for (int i = 2; i <= N; i++) {
    lucas.at(i) = lucas.at(i - 1) + lucas.at(i - 2);
  }
  printf("%ld", lucas.at(N));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
inline void add(long long &x, long long y) {
	x += y;
	if(x >= mod) x -= mod;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int h, w, k;
	cin >> h >> w >> k;
	vector<vector<long long>> dp(h + 1, vector<long long>(w));
	dp[0][0] = 1;
	for(int i = 1; i <= h; i++) {
		for(int j = 0; j < (1 << (w - 1)); j++) {
			bool valid = true;
			for(int l = 0; l < w - 2; l++) {
				if(((j >> l) & 1) && (j >> (l + 1)) & 1) valid = false;
			}
			if(!valid) continue;
			vector<int> c(w);
			for(int l = 0; l < w; l++) {
				c[l] = l;
			}
				/*for(int l = 0; l < w; l++) {
					cerr << c[i] << " ";
				}
				cerr << endl;*/
			for(int l = 0; l < w - 1; l++) {
				if((j >> l) & 1) swap(c[l], c[l + 1]);
			}
			for(int l = 0; l < w; l++) {
				add(dp[i][c[l]], dp[i - 1][l]);
			}
			/*for(int l = 0; l < w; l++) {
				cerr << c[i] << " ";
			}
			cerr << endl;*/
		}
	}
		/*for(int i = 0; i <= h; i++) {
			cerr << "h " << i << endl;
			for(int j = 0; j < w; j++) {
				cerr << dp[i][j] << " ";
			}
			cerr << endl;
		}*/
	cout << dp[h][k - 1] << endl;
	return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll K;

int main()
{
	cin >> K;
	if(K==0){
		puts("4");
		puts("3 3 3 3");
		return 0;
	}
	ll A = 50 + (K-1)/50; //max
	ll Bl = (K-1)%50;
	int B = (int)Bl;
	puts("50");
	ll ng = A-B;
	rep(i,0,50){
		if(i!=0)printf(" ");
		printf("%lld",A-i-(B<i?1:0));
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    count = 1
    now = 0
    visited = [1]
    set_v = set()
    set_v.add(1)
    l = -1
    while count < N:
        x = A[now]
        if x in set_v:
            l = visited.index(x)
            break
        else:
            count += 1
            visited.append(x)
            set_v.add(x)
            now = x-1
    r = count
    # print(l,r,visited)
    
    if K < l:
        print(visited[K])
    else:
        print(visited[l + (K-l) % (r-l)])

if __name__ == '__main__':
    main()


Measured memory_bytes: 125044
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		Integer num[] = new Integer[105];
		for (int i = 0; i < N; i++) {
			num[i] =sc.nextInt();
		}

		List<Integer> li = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			if (!li.contains(num[i])) {
				li.add(num[i]);
			}
		}

		System.out.println(li.size());
	}
}

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

using namespace std;

#define IOS                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define Debug(x) cout << #x " = " << (x) << endl
#define SORT(a) sort(a.begin(), a.end())
#define SORTR(a) sort(a.rbegin(), a.rend())

int main()
{
    IOS;
	
  	string s;
  cin >> s;
  
  if((s[2]==s[3])&&(s[4]==s[5]))
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
  
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
//↓✟MLE魔、TLE魔✟
#define int long long
//↑✟MLE魔、TLE魔✟
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
signed main(){
    int x,y;
    cin>>x>>y;
    if(x<0&&y>0||x>=0&&y<=0)cout<<abs(x+y)+1<<endl;
    else if(x<y)cout<<y-x<<endl;
    else{
        cout<<x-y+2<<endl;
    }
}

Measured memory_bytes: 256
from queue import Queue
h,w = map(int, input().split(' '))
s = [list(input()) for _ in range(h)]
num_w = 0
for i in range(h):
    num_w += s[i].count("#")
for i in range(h):
    s[i] = ["#"]+s[i]+["#"]
s.insert(0,["#" for i in range(w+2)])
s.append(["#" for i in range(w+2)])
q = Queue()
cnt = 0
q.put([1,1,0])
s[1][1]="#"
Z = -1
while (not q.empty()):
    x,y,cnt = q.get()
    if (x,y) == (h,w):
        Z = cnt
        break
    for (i,j) in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]:
        if s[i][j] != "#":
            s[i][j] = "#"
            q.put([i,j,cnt+1])
if Z == -1:
    print(-1)
else:
    print(h*w-Z-1-num_w)

Measured memory_bytes: 43752
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main(){

	int n,count=0;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	while(1){
		for(int i = 0; i < n; i++){
			if(a[i]%2!=0){
				cout <<count <<endl;
				return 0;
			}
			a[i] = a[i]/2;
			if(a[i]==0){
				cout << count <<endl;
				return 0;
			}
		}
		count++;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
  
#define MAXLINE 1000
#define CMD_LEN 9
  
void
flip(char *, int, int);
  
void
pri(char *, int);
  
int
main(void)
{
    char str[MAXLINE + 1];
    char rep[MAXLINE + 1];
    char cmd[CMD_LEN];
    int cmdCnt, param1, param2;
    scanf("%s", str);
    for (scanf("%d", &cmdCnt); cmdCnt > 0; cmdCnt--) {
        scanf("%s %d %d", cmd, &param1, &param2);
        if (!strcmp(cmd, "reverse"))
            flip(str, param1, param2);
        else if (!strcmp(cmd, "replace")) {
            scanf("%s", rep);
            strncpy(str + param1, rep, strlen(rep));
        } else if (!strcmp(cmd, "print"))
            pri(str + param1, param2 - param1);
    }
  
    return 0;
}
  
void
flip(char *str, int st, int end)
{
    char tmp;
    for ( ; st < end; st++, end--) {
        tmp = str[st];
        str[st] = str[end];
        str[end] = tmp;
    }
}
  
void
pri(char *str, int l)
{
    int i;
    for (i = 0; i <= l; i++)
        putchar(str[i]);
    putchar('\n');
}


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

long long x, y, z, k, a[1009], b[1009], c[1009];
vector<long long>vec;

int main()
{
    cin >> x >> y >> z >> k;
    for(int i = 0; i < x; ++i) { cin >> a[i]; }
    sort(a, a+x, greater<long long>());
    for(int i = 0; i < y; ++i) { cin >> b[i]; }
    sort(b, b+y, greater<long long>());
    for(int i = 0; i < z; ++i) { cin >> c[i]; }
    sort(c, c+z, greater<long long>());

    for(int l = 0; l < x; ++l) {
        for(int m = 0; m < y; ++m) {
            for(int n = 0; n < z; ++n) {
                if((l+1)*(m+1)*(n+1) <= k) {
                    vec.push_back(a[l] + b[m] + c[n]);
                }
                else { break; }
            }
        }
    }

    sort(vec.begin(), vec.end(), greater<long long>());
    for(int i = 0; i < k; ++i) { cout << vec[i] << "\n"; }
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li x[100100];
li p[100100];

int main() {
    li n, s;
    cin >> n >> s;
    rin{
        cin >> x[i] >> p[i];
    }
    li left = 0, right = n - 1;
    li now = s;
    li res = 0;
    bool prev_left = false;
    bool prev_right = false;
    rep(i, n) {
        if (s <= x[left]) {
            res += x[right] - s;
            break;
        } else if (s >= x[right]) {
            res += s - x[left];
            break;
        }
        if (p[left] >= p[right]) {
            if (!prev_left) {
                res += x[right] - x[left];
            }
            // left wins
            p[left] += p[right];
            p[right] = 0;
            --right;
            prev_left = true;
            prev_right = false;
        } else {
            if (!prev_right) {
                res += x[right] - x[left];
            }
            p[right] += p[left];
            p[left] = 0;
            ++left;
            prev_right = true;
            prev_left = false;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
using namespace std;

bool ice[92][92];
int max;
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
int m, n;

void solve(int x, int y, int cnt){
	if (cnt > max)max = cnt;
	for (int i = 0; i < 4; i++){
		int nx = x + dx[i], ny = y + dy[i];
		if (ice[nx][ny]){
			ice[nx][ny] = 0;
			solve(nx, ny, cnt + 1);
			ice[nx][ny] = 1;
		}
	}
}
int main(){
	while (scanf("%d%d", &m, &n), m){
		max = 0;
		memset(ice, 0, sizeof(ice));
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= m; j++){
				scanf("%d", &ice[j][i]);
			}
		}
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= m; j++){
				if (ice[j][i]){
					ice[j][i] = 0;
					solve(j, i, 1);
					ice[j][i] = 1;
				}
			}
		}
		printf("%d\n", max);
	}
	return 0;
}

Measured memory_bytes: 1044
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int T;
  cin>>T;
  map<string,Int> ms;
  vector<string> vs({"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" });
  for(Int i=0;i<12;i++) ms[vs[i]]=i;
  while(T--){
    Int n,m;
    cin>>n>>m;
    vector<Int> t(n+1,0),s(m);
    for(Int i=0;i<n;i++){
      string x;
      cin>>x;
      t[i+1]=ms[x];
    }
    for(Int i=0;i<m;i++){
      string x;
      cin>>x;
      s[i]=ms[x];
    }

    vector<Int> dp(1,n+1);
    for(Int i=m;i>=0;i--){
      vector<Int> nx;
      for(Int x: dp){
	if(x-1>=0&&(i==m||t[x]==s[i])) nx.emplace_back(x-1);
	if(x-2>=0&&(i==m||t[x]==(s[i]+11)%12)) nx.emplace_back(x-2);
	if(x+1<=n&&(i==m||t[x]==(s[i]+1)%12)) nx.emplace_back(x+1);
      }
      sort(nx.begin(),nx.end());
      nx.erase(unique(nx.begin(),nx.end()),nx.end());
      swap(dp,nx);
      if(dp.empty()) break;
    }
    
    cout<<(!dp.empty()&&dp.front()==0?"Yes":"No")<<endl;
  }
  return 0;
}



Measured memory_bytes: 3648
loop do
    a = []
    a << gets.to_i
    break if a[0] == 0
    4.times { a << gets.to_i }
    case a.uniq.map{|i| 1 << i-1}.inject(:|)
    when 1, 2, 4, 7
        puts [3] * 5
    when 3
        puts a
    when 6
        puts a.map {|x| x - 1}
    when 5
        puts a.join.tr("31", "12").split("")
    end
end

Measured memory_bytes: 8620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayDeque;

public class Main{

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] t = br.readLine().split(" ");
        int n = Integer.parseInt(t[0]);
        int q = Integer.parseInt(t[1]);
        ArrayDeque<P> Q = new ArrayDeque<P>();
        for(int i = 0; i < n; i++){
            t = br.readLine().split(" ");
            P p = new P();
            p.name = t[0];
            p.time = Integer.parseInt(t[1]);
            Q.addLast(p);
        }
        int sumTime = 0;
        StringBuilder sb = new StringBuilder();
        while(!Q.isEmpty()){
            P p = new P();
            p = Q.pollFirst();
            //p.time = p.time - q;                                                   
            if(p.time - q <= 0){
                sumTime += p.time;
                sb.append(p.name).append(" ").append(sumTime).append("\n");
            }else if(p.time - q > 0){
                p.time = p.time - q;
                Q.addLast(p);
                sumTime = sumTime + q;
            }
        }
        System.out.print(sb);
    }

}

class P{
    String name;
    int time;
}

Measured memory_bytes: 61728
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    c = min(c, a + b + 1);
    cout << b + c;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<queue>
#include<string>

using namespace std;

int main(){
  int n, k, q; cin >> n >> k >> q;
  vector<int> com(n, 0);
  for(int i = 0; i < q; i++){
    int t; cin >> t;
    t--;
    com[t]++;
  }
  for(int i = 0; i < n; i++){
    if(k - (q-com[i]) > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
typedef pair<int, double> P;
typedef pair<double, int> P2;

int N;
double x[1010], y[1010], r[1010];
vector<P> G[1010];

vector<double> dijkstra() {
    priority_queue<P2, vector<P2>, greater<P2>> q;
    vector<double> d(N+2);
    rep(i, N+2) d[i] = 1000000000000000.0;
    d[0] = 0.0;
    q.push(P2(d[0], 0));
    while (!q.empty()) {
        P2 p = q.top(); q.pop();
        int v = p.second;
        if (d[v]<p.first) continue;
        rep(i, G[v].size()) {
            int nv = G[v][i].first;
            double w = G[v][i].second;
            if (d[nv]>d[v]+w) {
                d[nv] = d[v]+w;
                q.push(P(d[nv], nv));
            }
        }
    }
    return d;
}

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> x[0] >> y[0] >> x[1] >> y[1];
    cin >> N;
    rep(i, N) cin >> x[i+2] >> y[i+2] >> r[i+2];
    rep(i, N+2) for (int j=i+1; j<N+2; j++) {
        double d = max(0.0, sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j]);
        G[i].pb(P(j, d));
        G[j].pb(P(i, d));
    }
    vector<double> dist = dijkstra();
    cout << fixed << setprecision(12) << dist[1] << endl;
}

Measured memory_bytes: 22788
import Queue
n,q=map(int,raw_input().strip().split())
name=[]
time=[]
qu=Queue.Queue()
class task:
    def __init__(self,name,time):
        self.name=name
        self.time=time
        self.total=0
for i in xrange(n):
    inp=raw_input().strip().split()
    qu.put(task(inp[0],int(inp[1])))
curtime=0

while not qu.empty():
    tmp=qu.get()
    if tmp.time>q:
        tmp.time-=q
        curtime+=q
        qu.put(tmp)
    else:

        curtime+=tmp.time
        ed='' if qu.qsize()==0 else '\n'
        print tmp.name,curtime
#    print curtime





Measured memory_bytes: 25688
n,x,y=[int(i) for i in input().split()]
l=[0 for i in range(n-1)]
for i in range(1,n):
    for j in range(i+1,n+1):
        #print(i,j)
        index=min(abs(y-j)+abs(x-i)+1,j-i)-1
        #print(index+1)
        l[index]=l[index]+1
for i in range(len(l)):
    print(l[i])


Measured memory_bytes: 3444
import java.util.*;
import java.io.*;

public class Main {	
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		String N = fs.next();
		
		if(N.contains("7")){
		System.out.println("Yes");
		}else{
		System.out.println("No");
		}

		

	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");

		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) {
				a[i]=nextInt();
			}
			return a;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}
}


Measured memory_bytes: 32840
#include<stdio.h>
int main(void){
   double t, k, sum = 0, sum_k = 0, n = 0;
   while ( scanf("%lf,%lf", &t, &k ) != EOF ) {
      sum += t * k;
      sum_k += k;
      n++;
   }
   printf("%.lf\n%.lf\n", sum, sum_k / n + 0.5);
   return 0;
}

Measured memory_bytes: 1756
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll num[2000000],sum[2000000]={0};
int main()
{
    ll n,i,j,k,a,b,dif,mini;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&num[i]);
    }

    if(n==2)
    {
        dif=num[1]-num[0];
        if(dif<0)
            dif=-dif;
        printf("%lld",dif);
        return 0;
    }
    sum[0]=num[0];
    for(i=1;i<n;i++)
    {
        sum[i]=sum[i-1]+num[i];
    }
    mini=10000000000000000;
    for(i=0;i<(n-1);i++)
    {
        a=sum[i];
        b=sum[n-1]-sum[i];
        if(a>=b)
        {
            dif=a-b;
        }
        else dif=b-a;
        mini=min(mini,dif);

    }
    printf("%lld",mini);






    return 0;
}




Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  uint64_t n,a,b;
  cin >> n >> a >> b;
  uint64_t a1=0,a2=0;
  a1 = n / (a + b) * a;
  a2 = n % (a + b);

  a1 += min(a, a2);
  cout << a1;  
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
#include<functional>
using namespace std;
int x=9;
int n;
int main()
{
	cin>>n;
	while(n>0)
	{
		if(n%10==9)
		{
			cout<<"Yes";
			return 0;
		}
		n=n/10;
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int n, k;
	cin >> n >> k;
	if (n%k == 0)print(0);
	else print(1);



	return 0;
}

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

// colours
#define RESET   "\033[0m"
#define BLACK   "\033[30m"
#define RED     "\033[31m"
#define GREEN   "\033[32m"
#define YELLOW  "\033[33m"
#define BLUE    "\033[34m"
#define MAGENTA "\033[35m"
#define CYAN    "\033[36m"
#define WHITE   "\033[37m"

// debugging : values of variables
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << YELLOW << "debug statement : " << *it << " = " << a << RESET << endl;
    err(++it, args...);
} 

int main(){
    int a, b, c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
from sys import stdin
input = stdin.readline
N, K = [int(x) for x in input().rstrip().split()]
D = [int(x) for x in input().rstrip().split()]
ok = [x for x in range(10) if x not in D]
tmp = N
while 1:
	for y in str(tmp):
		if int(y) in ok:
			pass
		else:
			break
	else: # すべて使用可能
		print(tmp)
		break
	tmp += 1

Measured memory_bytes: 3064
n, m=map(int, input().split())
a = list(map(int, input().split()))
sum = 0
cnt = 0
for i in a:
  sum += i
for j in a:
  if ( j >= sum/(4*m)):
    cnt += 1
if ( cnt >= m ):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
class UnionFind:
    def __init__(self, size):
        self.table = [-1] * size
    
    def find(self, x):
        while self.table[x] >= 0:
            x = self.table[x]
        return x
    
    def union(self, x, y):
        x_root = self.find(x)
        y_root = self.find(y)
        if x_root != y_root:
            if self.table[x_root] < self.table[y_root]:
                self.table[x_root] += self.table[y_root]
                self.table[y_root] = x_root
            else:
                self.table[y_root] += self.table[x_root]
                self.table[x_root] = y_root
    
    def isDisjoint(self, x, y):
        return self.find(x) != self.find(y)


def solve():
    import sys
    input_lines = sys.stdin.readlines()
    from bisect import bisect_left
    
    while True:
        N, M = map(int, input_lines[0].split())
        if N == 0 and M == 0:
            break
        
        h = map(int, input_lines[1:1+N])
        h = list(zip(h, range(1, 1 + N)))
        h.sort()
        rm_days, islands = zip(*h)
        
        bridges = [tuple(map(int, l.split())) for l in input_lines[1+N:1+N+M]]
        bridges.sort(key=lambda x: x[2])
        
        S = UnionFind(N + 1)
        cost = 0
        i = N
        mst_flag = True
        while i > 0:
            j = i
            i -= 1
            i = bisect_left(rm_days, rm_days[i])
            unsunk_islands = islands[i:]
            
            f = lambda x: x[0] in unsunk_islands and x[1] in unsunk_islands
            target_bridges = filter(f, bridges)
            
            # Number of required bridges
            if mst_flag:
                bridge_num = len(unsunk_islands) - 1
            else:
                bridge_num = j - i
            cnt = 0
            # Kruskal's algorithm
            for bridge in target_bridges:
                a, b, c = bridge
                if S.isDisjoint(a, b):
                    S.union(a, b)
                    cost += c
                    cnt += 1
                    if cnt == bridge_num:
                        mst_flag = False
                        break
            else:
                mst_flag = True
                S = UnionFind(N + 1)
                cost = 0
        
        if -N in S.table:
            print(cost)
        else:
            print(0)
            
        del input_lines[:N+1+M]

solve()


Measured memory_bytes: 19716
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n){cin>>a[i];}
    if(n%2){
        int res = 0;
        rep(i,n){
            res ^= a[i];
        }
        cout << (res==0 ? "Yes" : "No") << endl;
    }else{
        int res[2] = {};
        rep(i,n){
            res[i%2] ^= a[i];
        }
        cout << (res[0]==0&&res[1]==0 ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=200005,inf=1047483647;
struct node { int y,next; } a[N<<1];
LL an;
int s[N],fa[N],d1[N],d2[N],C[N],d3[N],head[N],i,j,k,n,m,z,Z,S;
bool p[N];
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

int read(){ int z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

void jb(int x,int y)
{
	a[++k]=(node){y,head[x]},head[x]=k,
	a[++k]=(node){x,head[y]},head[y]=k;
}

int dfs1(int w)
{
	s[w]=p[w];
	for (register int j=head[w];j;j=a[j].next)
	{
		int c=a[j].y;
		if (c!=fa[w])
		{
			fa[c]=w,z=dfs1(c)+1,s[w]+=s[c];
			if (z>d1[w])
				d2[w]=d1[w],d1[w]=z,C[w]=c;
			else
				d2[w]=max(d2[w],z);
		}
	}
	return d1[w];
}

void dfs2(int w)
{
	for (register int j=head[w];j;j=a[j].next)
	{
		int c=a[j].y;
		if (c!=fa[w])
			d3[c]=max(d3[w],C[w]==c?d2[w]:d1[w])+1,
			dfs2(c);
	}
}

int main()
{
	n=read(),k=1;
	for (i=1;i<n;++i) jb(read(),read());
	do c=getc(); while (c<'0'||c>'1');
	i=0;
	while (c>='0'&&c<='1') p[++i]=c-'0',c=getc(),S+=p[i];
	if (!S)
	{
		puts("0");
		return 0;
	}
	dfs1(1),dfs2(1);
	for (i=1;i<=n;++i)
	{
		z=max(d1[i],d3[i])-1,Z=p[i]?0:inf;
		for (j=head[i];j;j=a[j].next)
		{
			int c=a[j].y;
			z=min(z,(fa[c]==i?max(d3[i],C[i]==c?d2[i]:d1[i]):d1[i])+1);
			if (s[c])
				Z=min(Z,d1[c]+1);
		}
		if (S-s[i])
			Z=min(Z,d3[i]);
		if (z>=Z)
			an+=z-Z+1;
	}
	printf("%lld\n",an+1);
	return 0;
}

Measured memory_bytes: 19584
#include <cstring>
#include <cstdlib>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)<0?(-(a)):(a))
#define CS while(cases())
#define I(n) int n = gi()
#define II(n) n = gi()
#define L(n) ll n = gli()
#define LL(n) n = gli()
#define F0(i, n) for (int i = 0; i < n; i++)
#define F1(i, n) for (int i = 1; i < n; i++)
#define Fi(n, a) for (int i = 0; i < n; i++) a[i] = gi()
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

template<class T>
T gcd(T a, T b) {
    return (b == 0 ? a : gcd(b, a%b));
}

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int cases() {
    static int t = gi();
    return t--;
}

#define MD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x = gi();
    int g = gcd(x, 360);
    printf("%d\n", 360/g);

    return 0;
}


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

int main(void){
  int k,s;
  int z,cnt=0;
  cin>>k>>s;
  r(x,k+1){
    r(y,k+1){
      z=s-x-y;
      //cout<<x<<" "<<y<<" "<<z<<endl;
      if(z<=k && z>=0)cnt++;
    }
  }
  cout<<cnt<<endl;


  return 0;
}


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

const int MAXC = 16;
const int MAXR = 200;
int R, C;
string S[MAXR];

int dp[2][1<<MAXC];

int main() {
  cin >> R >> C;
  for(int i = 0; i < R; ++i) {
    cin >> S[i];
  }
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  int now = 0, next = 1;
  for(int i = 0; i < R; ++i) {
    for(int j = 0; j < C; ++j) {
      fill(dp[next], dp[next] + (1<<C), -1);
      for(int bit = 0; bit < (1<<C); ++bit) {
        if(dp[now][bit] == -1) continue;
        int value = dp[now][bit];

        char top = '_';
        if(i) {
          for(int k = C - j - 1, l = S[i-1].size(); k >= 0; --k) {
            if(bit >> k & 1) top = S[i-1][--l];
            else top = '_';
          }
        }

        char left = '_';
        int num = 0;
        for(int k = C - j, l = 0; k < C; ++k) {
          if(bit >> k & 1) left = S[i][l++], ++num;
          else left = '_';
        }

        do {
          int nbit = bit >> 1;
          if(num == S[i].size()) break;
          char c = S[i][num];
          nbit |= 1 << (C - 1);
          if(j+1 == C) {
            if(num+1 != S[i].size()) break;
          }
          dp[next][nbit] = max(dp[next][nbit],
                               value
                               + (isalpha(c) && c == top)
                               + (isalpha(c) && c == left));
        } while(0);

        do {
          int nbit = bit >> 1;
          if(j+1 == C) {
            if(num != S[i].size()) break;
          }
          dp[next][nbit] = max(dp[next][nbit], value);
        } while(0);
      }
      swap(now, next);
    }
  }
  int res = 0;
  for(int bit = 0; bit < (1<<C); ++bit) {
    res = max(res, dp[now][bit]);
  }
  cout << res*2 << endl;
  return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,n;
    cin>>h>>n;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    if(sum<h)
    cout<<"No";
    else
    cout<<"Yes";
}

Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  int A, B, C, D;
  cin >> A >> B >> C >> D;

  while(1){

    C -= B;
    if(C <= 0){
      cout << "Yes" << endl;
      return 0;
    }

    A -= D;
    if(A <= 0){
      cout << "No" << endl;
      return 0;
    }

  }

  return 0;
}

Measured memory_bytes: 3568
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      Long H = sc.nextLong();
      Long W = sc.nextLong();
      
      // 移動可能数マス算出
      Long move;
      if(H == 1 || W == 1){
        move = 1L;
      }else{
        move = (H * W + 1) / 2;
      }
      
      // 出力
      System.out.println(move);
    }


}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

ll n;
cin>>n;

  ll res=1ll<<60;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      res = min(res, i - 1 + n / i - 1);
    }
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
s = gets.chomp.split(" ")

x = s[0].to_i
a = s[1].to_i
b = s[2].to_i

c = a - b

if c >= 0 && c <= x
  puts "delicious"
elsif c < 0 && c.abs <= x
  puts "safe"
elsif c < 0 && c.abs > x
  puts "dangerous"
end


Measured memory_bytes: 1916
#
N, K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))

def gcd(a, b):
    if a < b:
        a, b = b, a

    if b == 0:
        return a
    else:
        return gcd(b, a % b)

g = A[0]
for a in A[1:]:
    g = gcd(g, a)

if max(A) >= K and K % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 58964
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {
	final static long MOD = 1000000007L;

	public static void main(String[] args) {
		Reader in = new Reader();
		int n = in.nextInt();
		int[] a = in.na(3);
		for(int t = 1; t<n; t++) {
			int[] b = in.na(3);
			int[] v = new int[3];
			for(int i = 0; i<3; i++)
				for(int j = 0; j<3; j++)
					if(i!=j)
						v[j] = Math.max(v[j], a[i]+b[j]);
			for(int i = 0; i<3; i++) a[i] = v[i];
		}
		int ans = 0;
		for(int i = 0; i<3; i++) ans = Math.max(ans, a[i]);
		System.out.println(ans);
	}

	static class Reader {
		static BufferedReader br;
		static StringTokenizer st;

		public Reader() {
			this.br = new BufferedReader(new InputStreamReader(System.in));
		}

		public int[] na(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nl(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public String[] nS(int n) {
			String[] a = new String[n];
			for (int i = 0; i < n; i++)
				a[i] = next();
			return a;
		}

		public int nextInt() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Integer.parseInt(st.nextToken());
		}

		public double nextDouble() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Double.parseDouble(st.nextToken());
		}

		public Long nextLong() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Long.parseLong(st.nextToken());
		}

		public String next() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return st.nextToken();
		}

		public static void readLine() {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
			}
		}
	}
}

Measured memory_bytes: 45188
#include <bits/stdc++.h>
using namespace std;
template<typename T1, typename T2>
inline bool cmx (T1& a, T2 b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
int main() {
	cin.tie(0); cin.sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	if (k >= 2 * n) {
		int ret = 0;
		for (int i = 0; i < n; i++) {
			if (v[i] > 0) ret += v[i];
		}
		cout << ret << endl;
		return 0;
	}
	auto check = [&] (int l, int r) -> int {
		int ret = 0;
		int cnt = l + n - r;
		if (k < cnt) return 0;
		vector<int> w;
		for (int i = 0; i < l; i++) {
			ret += v[i];
			w.push_back(v[i]);
		}
		for (int i = r; i < n; i++) {
			ret += v[i];
			w.push_back(v[i]);
		}
		sort(w.begin(), w.end());
		for (int i = 0; i < min(k - cnt, (int)w.size()); i++) {
			if (w[i] < 0) ret -= w[i];
		}
		return ret;
	};
	int ret = 0;
	for (int l = 0; l < n; l++) {
		for (int r = l; r <= n; r++) {
			cmx(ret, check(l, r));
		}
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>

typedef long long int64;

int n, m, c;
int a[25];

int main() {
// #ifndef ONLINE_JUDGE
//     freopen("b.in", "r", stdin);
//     freopen("b.out", "w", stdout);
// #endif

    int i, j, x;
    int ans = 0, sum = 0;

    scanf("%d %d %d", &n, &m, &c);
    for (i = 1; i <= m; i++)
        scanf("%d", &a[i]);
    for (i = 1; i <= n; i++) {
        sum = 0;
        for (j = 1; j <= m; j++) {
            scanf("%d", &x);
            sum += a[j] * x;
        }
        sum += c;
        if (sum > 0)
            ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

long long sum_xor(long long x)
{
	auto count = (long long)ceil(x / 2.0);
	long long sum = 0;
	if (count % 2 != 0)
	{
		sum++;
	}

	if (x % 2 == 0)
	{
		sum ^= x;
	}
	
	return sum;
}

int main()
{
	long long A, B;
	cin >> A >> B;

	cout << (sum_xor(A - 1) ^ sum_xor(B)) << endl;

	return 0;
}


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

using namespace std;

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

    int sum = 0;

    if (k >= a) {
        sum += a;
        k -= a;
    } else {
        sum += k;
        k = 0;
    }

    if (k >= b) {
        k -= b;
    } else {
        k = 0;
    }

    if (k >= c) {
        sum -= c;
        k -= c;
    } else {
        sum -= k;
        k = 0;
    }

    cout << sum << endl;

    return 0;
}


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

using namespace std;

int i,n;
map<string,bool> mem;
char s[10000];

int main() {
	scanf("%s",&s);
	n = strlen(s);
	
	for (i=0 ; i<n-8 ; i++) printf("%c",s[i]);
	printf("\n");
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;


void ABC141D()
{
	int N, M;
	cin >> N >> M;
	priority_queue<int> A;
	for (int i = 0; i < N; ++i)
	{
		int x;
		cin >> x;
		A.push(x);
	}
	for (int i = 0; i < M; ++i)
	{
		int x = A.top();
		if (x > 0)
			x /= 2;
		A.pop();
		A.push(x);
	}
	ll sum = 0;
	while (!A.empty())
	{
		sum += A.top();
		A.pop();
	}
	cout << sum << endl;
}
int main()
{
	ABC141D();
	return 0;
}

Measured memory_bytes: 892
s=int(input())
a=[s]
x=1
for i in range(10**6):
    if a[i]%2==0:
        if a[i]/2 in a:
            print(i+2)
            exit()
        else:
            a.append(a[i]/2)
    else:
        if 3*a[i]+1 in a:
            print(i+2)
            exit()
        else:
            a.append(3*a[i]+1)
    

Measured memory_bytes: 9052
r=1,s[];C(char*a){return*a*r-*1[&a]*r;}main(m){for(;r-1||~scanf("%*d%s"+!m*3,s);r=-r)qsort(s,8,1,C),m=r-1?!printf("%d\n",atoi(s)-m):atoi(s);}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long INF = 1LL<<60;
int main() {
  int N; cin>>N;
  vector<int> A(N);
  rep(i,N) cin>>A.at(i);
  int64_t M=1000,S=0;
  for(int i=0;i<N-1;i++){
    if(A.at(i)<=A.at(i+1)){
      S=M/A.at(i);
      M+=S*(A.at(i+1)-A.at(i));
    }
  }
  cout<<M;
}
      
  


Measured memory_bytes: 3612
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
    
int main() {
    int n; cin >> n;
    vector<long long> a(n);
    map<long long, long long> ma;
    for(int i = 0; i < n; ++i) cin >> a[i];
    
    for(int i = 0; i < n; ++i) ++ma[a[i]];
    
    int res = 0;
    EACH(it, ma) {
        if(it->second % 2 == 1) ++res;
    }
    
    cout << res << endl;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
	if(b&1)
		r=(r*a)%m;
	b=b/2;
	a=(a*a)%m;
	}
	return r%m;
}



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

    ll ans = 1;
    char c = s[0];
    for(ll i=1;i<n;i++)
    {
        if(s[i]==c)continue;
        else
        {
            ans++;
            c = s[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512