akhauriyash/Code-Regression huggingface dataset:
//WAPER
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define N 300010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int n,mul[N];
ll a[N];
const int mod=1e9+7;
inline int Z(int x){return x>=mod?x-mod:x;}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	mul[0]=1;
	for(register int i=1;i<=62;i++)mul[i]=1LL*mul[i-1]*2%mod;
	n=read();
	for(register int i=1;i<=n;i++)a[i]=read();int ans=0;
	for(register int i=0;i<=62;i++)
	{
		int num0=0,num1=0;
		for(register int j=1;j<=n;j++)
		{
			if(a[j]&(1LL<<i))num1++;
			else num0++;
		}
		ans=Z(ans+1LL*num0*num1%mod*mul[i]%mod);
	}
	printf("%d\n",ans);
	return 0;
}


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

int main() {
    char ch;
    while(1){
        scanf("%c", &ch);

        if (islower(ch)) {
            printf("%c", toupper(ch));
        } else {
            printf("%c", tolower(ch));
        }

        if ( ch == '\n' ) break;
    }
}

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

int main() {
  int N, A;
  cin >> N >> A;
  string d = "No";

  for(int i=0; i<(N/500+1); i++){
    for(int j=0; j<=A; j++){
      if(500*i+j==N){
        d = "Yes";
        break;
      }

    }
    
  }


  cout << d << endl;


}

Measured memory_bytes: 3584
#include<iostream>
#include<cmath>

using namespace std;

int main() {
  int n;
  cin >> n;
  long long ans = 1;
  int i;
  for (i=0; i<n; ++i) {
    long long a;
    cin >> a;
    if (log10(a) + log10(ans) > 18) {
      ans = -1;
      break;
    }
    ans *= a;
    if (ans > 1000000000000000000) {
      ans = -1;
      break;
    };
  }
  for (; i<n; ++i) {
    long long a;
    cin >> a;
    if (a == 0) ans = 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3464
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll n; cin >> n;
  vl num(n);
  
  rep(i,n) cin >> num[i];
  
  sort(all(num));
  
  ll a = num[n-1];
  
  cout << a << ' ';
  
  ll mark = (a+1)/2;
  
  ll mini = 1e9;
  
  rep(i,n){
    mini = min(mini,abs(num[i]-mark));
  }
  
  rep(i,n){
    if(abs(num[i]-mark) == mini){
      cout << num[i] << endl;
      break;
    }
  }
  
}

Measured memory_bytes: 4052
fun main() {
    val s = readLine() ?: return
    val k = readLine()?.toLong() ?: return
    var r = k
    buildString {
        s.forEach {
            val m = 26 - (it - 'a')
            if (m == 26) {
                append(it)
            } else if (r < m) {
                append(it)
            } else {
                r -= m
                append('a')
            }
        }
    }.let {
        if (r > 0) {
            val l = it.last()
            println(it.dropLast(1) + (l + r.toInt() % 26))
        } else {
            println(it)
        }
    }
}


Measured memory_bytes: 39568
import java.util.Scanner;

/**
 * @author yamino
 *
 */
public class Main {
	public static void main(String[] args) {
		//入力
		Scanner sc = new Scanner(System.in);
		String tmp = sc.next();
		sc.close();
		//整形
		StringBuffer sb = new StringBuffer(tmp);
		int num1 = Integer.parseInt(sb.substring(0, 2));
		int num2 = Integer.parseInt(sb.substring(2, 4));

		//分岐
		if(num1 <= 12 && num2 <= 12 && num1 >=1 && num2 >=1) {
			System.out.println("AMBIGUOUS");
			return;
		}else if(num1 <= 12 && num1 >= 1) {
			System.out.println("MMYY");
			return;
		}else if(num2 <= 12 && num2 >= 1) {
			System.out.println("YYMM");
			return;
		}else {
			System.out.println("NA");
			return;
		}
	}
}

Measured memory_bytes: 23252
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int a;
		cin >> a;
		cout << a + a*a + a*a*a << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 3616
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int bit[7];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int temp=n;
    int m=0;
    while(temp){
        ++m;
        temp/=10;
    }
    int ans=0;
    bit[1]=1;
    for(int i=2;i<=6;++i)
        bit[i]=10*bit[i-1];
    for(int i=1;i<=n;++i){
        int tt=i;
        int x=0,y=0;
        y=tt%10;
        if(!y)
            continue;
        while(tt){
            x=tt%10;
            tt/=10;
        }
        for(int j=1;j<=m;++j){
            if(j==1){
                if(x==y)
                    ++ans;
            }
            else if(j<m)
                ans+=bit[j-1];
            else{
                int mn=y*bit[m]+x;
                int mx=mn;
                for(int k=2;k<m;++k)
                    mx+=9*bit[k];
                if(n>=mn)
                    ans+=(min(n,mx)-mn)/10+1;
            }
        }
    }
    cout<<ans;
    return 0;
}//fff


Measured memory_bytes: 256
def main():
    s = input()
    K = int(input())
    ind = []
    for i in range(len(s)):
        for j in range(i+1, min(len(s)+1, i+6)):
            ind.append(s[i:j])
    ind = sorted(list(set(list(ind))))
    # print(ind)
    print(ind[K-1])

if __name__ == "__main__":
    main()

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

using namespace std;

#define MAX 400010
typedef long long ll;

int bit[MAX], n;

void init()
{
    n = MAX-1;
    memset(bit, 0, sizeof(bit));   
}

int sum(int i)
{
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(int i, int x)
{   
    while (i <= n) {
        bit[i] += x;
        i += i & -i;
    }
}

int get_val(int N, int key)
{
    int l = 0, idx = N;
    while (idx - l > 0) {
        int mid = (l + idx) / 2;
        if (sum(mid) < key) {
            l = mid + 1;
        } else {
            idx = mid;
        }
    }
    return l;
}

int main()
{
    ll Q, lim, x;
    int q;
    while (1) {
        scanf("%lld %lld", &Q, &lim);
        if (Q == 0 && lim == 0) break;
        ll idx = 1;
        init();
        map<ll, ll> i2v, v2i;
        while (Q--) {
            scanf("%d %lld", &q, &x);
            switch (q) {
                case 0: {
                    i2v[idx] = x; v2i[x] = idx;
                    add(idx, 1); idx++;
                    int r = sum(idx);
                    if (r > lim) {
                        add(get_val(idx, r - lim), -1);
                    }
                    break;
                }
                case 1: {
                    add(get_val(idx, x), -1);
                    break;
                }
                case 2: {                   
                    printf("%lld\n", i2v[get_val(idx, x)]);
                    break;
                }
                case 3: {
                    add(v2i[x], -1);
                    break;
                }
            }
        }
        puts("end");
    }
    return 0;
}

Measured memory_bytes: 52768
//To include everything you need
#include <bits/stdc++.h>
using namespace std;
typedef std::vector<int> vi;
typedef std::vector<std::pair<int, int> > vpi;
typedef std::vector<string> vs;
typedef std::vector<char> vc;

int main()
{

    int N;
    cin >> N;
    vi points(N);
    int min = 100, max = 1;
    int stamina = INT_MAX;
    // int mid = 0;
    for(int i =0;i<N;i++){
        int p;
        cin>>p;
        if(p<min)
            min = p;
        if(p>max)
            max = p;

        points[i] = p;
    }
    // mid = (min+max)/2.0;
    for (int i = 1; i < 101; i++)
    {
        int currentStamina = 0;
        for (int j = 0; j < N; j++)
        {
            currentStamina += pow(points[j] - i, 2);
        }
        if(currentStamina<stamina)
            stamina = currentStamina;
    }
    cout << stamina;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


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

    Y = sorted(X)
    A, B = Y[N // 2 - 1: N // 2 + 1]
    for x in X:
        if x <= A:
            print(B)
        else:
            print(A)


if __name__ == "__main__":
    main()


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

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

    int a[n], odd = 0;
    for (int& x: a) {
        cin >> x;
        if (x % 2) odd++;
    }

    cout << (odd ? (long long)pow(2, n - 1) : p ? 0 : (long long)pow(2, n)) << endl;

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

typedef struct {
	char name[ 21 ];
	int score;
} Rec;

Rec record[ 10 ];

void insertionSort( Rec *, int );

int main( void ) {
	int i, n, win, draw, flag = 0;

	while ( scanf( "%d", &n ), n ) {
		if ( flag )
			putchar( '\n' );

		for ( i = n; i--;  ) {
			scanf( "%s %d %*d %d", record[ i ].name, &win, &draw );

			record[ i ].score = win * 3 + draw;
		}

		insertionSort( record, n );

		while ( n-- )
			printf( "%s,%d\n", record[ n ].name, record[ n ].score );

		flag = 1;
	}

	return 0;
}

void insertionSort( Rec *data, int n ) {
	int i, j;
	Rec tmp;

	for ( i = 1; i < n; i++ ) {
		tmp = data[ i ];

		for ( j = i; j && data[ j - 1 ].score > tmp.score; j-- )
			data[ j ] = data[ j - 1 ];

		data[ j ] = tmp;
	}
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int n, m, mod, dp[307][307][307];
int main()
{
	cin >> n >> m >> mod;
	dp[0][1][0] = 1;
	for (int i = 0; i <= n; i++)
		for (int j = 1; j <= m; j++)
			for (int k = i; k >= 0; k--)
			{
				if (k)dp[i][j][k - 1] = (dp[i][j][k - 1] + dp[i][j][k]) % mod;
				else dp[i][j + 1][i] = (dp[i][j + 1][i] + dp[i][j][k]) % mod;
				dp[i + 1][j][k] = (dp[i + 1][j][k] + 1LL * (k + 1) * dp[i][j][k] % mod) % mod;
			}
	cout << dp[n][m][0] << endl;
	return 0;
}

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

int main(void){
	int n,m,count=0;
	scanf("%d %d",&n,&m);
	long long int *h;
	h=malloc(n*sizeof(long long int));
	for(int i=0;i<n;i++){
		scanf("%lld",&h[i]);
		//printf("%lld ",h[i]);
	}
	//printf("\n");
	
	int *check;
	check=malloc(n*sizeof(int));
	for(int i=0;i<n;i++){
		check[i]=0;
	}
	int a,b;
	for(int i=0;i<m;i++){
		scanf("%d %d",&a,&b);
			if(h[a-1]>h[b-1]){
				check[b-1]=1;
			}else if(h[a-1]<h[b-1]){
				check[a-1]=1;
			}else{
				check[a-1]=1;
				check[b-1]=1;
			}
			//printf("check[%d]=%d,check[%d]=%d\n",a,check[a-1],b,check[b-1]);
	}
	for(int i=0;i<n;i++){
		if(check[i]==0){
			count++;
		}
		//printf("%d",check[i]);
	}
	printf("%d",count);
	free(h);
	free(check);
}

Measured memory_bytes: 2484
#include <iostream>

using namespace std;

int main()
{

int a,b,x,y,z;
a>=-100;
b<=100;

cin>>a>>b;

x=a+b;
y=a-b;
z=a*b;

if(x>=y&&x>=z){cout<<x;}

else if(y>=z&&y>=x){cout<<y;}
else if(z>=x&&z>=y){cout<<z;}


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L


int Z_algo(string s) {
    int n = s.length();
    vector<int> z(n);
    int L = 0, R = 0;
    for (int i = 1; i < n; i++) {
        if (i > R) {
            L = R = i;
            while (R < n && s[R - L] == s[R]) R++;
            z[i] = R - L; R--;
        }
        else {
            int k = i - L;
            if (z[k] < R - i + 1) z[i] = z[k];
            else {
                L = i;
                while (R < n && s[R - L] == s[R]) R++;
                z[i] = R - L; R--;
            }
        }
    }
    int mx = 0;
    for (int i = 0; i < n; i++) mx = max(mx, min(i, z[i]));
    return mx;
}

int main() {
    int a, b;
    cin >> a >> b;
    if (b == 1) {
        cout << 0;
        return 0;
    }
    int ans = 1;
    int soc = 0;
    int pow = 1;
    while (a * pow - soc < b) {
        pow++;
        soc++;
        ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3564
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
	string s;
	cin >> s;
	int cnt=0;
	for(int i=0;i<s.size()-1;i++){
		if(s[i]==s[i+1]){
			cnt++;
			if(cnt>=2){
				cout << "Yes" << endl;
				return 0;
			}
		}else{
			cnt=0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
def resolve():
    N, K = map(int, input().split())
    candy_counter = [0] * N

    for _ in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for i in A:
            candy_counter[i-1] += 1

    ans = 0
    for i in candy_counter:
        if i == 0:
            ans += 1
    print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9088
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const int MAXN = 18;
const int MAXM = 1 << MAXN;
const int MOD = 1e9 + 7;

int n,m,ans;
int a[MAXN],f[MAXN][MAXM],fac[MAXM],ifac[MAXM];

int power(int x,int y){
	int res = 1;
	while(y){
		if(y & 1)
			res = 1ll * res * x % MOD;
		x = 1ll * x * x % MOD;
		y >>= 1;
	}
	return res;
}

void Init(int n){
	fac[0] = ifac[0] = 1;
	for(int i = 1;i <= n;i++)
		fac[i] = 1ll * fac[i - 1] * i % MOD;
	ifac[n] = power(fac[n],MOD - 2);
	for(int i = n - 1;i >= 1;i--)
		ifac[i] = 1ll * ifac[i + 1] * (i + 1) % MOD;
}

int C(int n,int m){
	if(n < m || m < 0)
		return 0;
	return 1ll * fac[n] * ifac[n - m] % MOD * ifac[m] % MOD;
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;i++)
		scanf("%d",&a[i]);
	int maxState = (1 << n);
	Init(maxState);
	f[m + 1][0] = 1;
	for(int i = m;i >= 1;i--){
		for(int S = 0;S < maxState;S++){
			f[i][S] = (f[i][S] + f[i + 1][S]) % MOD;
			for(int j = 0;j < n;j++){
				if(S & (1 << j))
					continue;
				f[i][S | (1 << j)] = (f[i][S | (1 << j)] + 1ll * f[i + 1][S] * C(maxState - S - a[i],(1 << j) - 1) % MOD * fac[1 << j] % MOD) % MOD;
			}
		}
	}
	for(int S = 0;S < maxState;S++){
		int cnt = 0;
		for(int i = S;i;i -= (i & -i))
			cnt++;
		if(cnt & 1)
			ans = (ans - 1ll * f[1][S] * fac[maxState - S - 1] % MOD + MOD) % MOD;
		else
			ans = (ans + 1ll * f[1][S] * fac[maxState - S - 1] % MOD) % MOD;
	}
	ans = 1ll * ans * maxState % MOD;
	printf("%d\n",ans);
	return 0;
}



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

typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9+10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert
#define era erase
typedef vector<int> vi;
typedef queue<int> qi;
typedef greater<int> gi;
typedef priority_queue<int> pqi;
typedef priority_queue<int,vi,gi> pqgi;

int read() {
	int xx=0,ww=1;
	char ch=getchar();
	while(ch>'9'||ch<'0') {
		if(ch=='-') ww=-ww;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		xx=10*xx+ch-48;
		ch=getchar();
	}
	return xx*ww;
}

int n,h,w;
int maxh,maxw;

int main() {
	n=read();
	h=read();
	w=read();
	maxh=max(n-h+1,0);
	maxw=max(n-w+1,0);
	printf("%d\n",maxh*maxw);
	return 0;
}


Measured memory_bytes: 256
require 'bigdecimal'

orders = Array.new(5) do
  gets.chomp.to_i
end

orders  = orders.sort_by do |i|
  if i % 10 == 0
    10
  else
    i % 10
  end
end

first = orders.shift
puts first + orders.map{|i| BigDecimal(i).ceil(-1).to_i}.inject(:+)


Measured memory_bytes: 1912
#複数の整数入力を受け付ける関数
def datain(num):

    data = []
    iscnt = True

    while iscnt:
        for val in map(int,input().split()):
            data.append(val)
            if len(data) == num:
                iscnt = False
                break
        
    return data

data = datain(int(input())+2)

minval = 1000000
ans = 0
temp = [abs(data[1]-(data[0]-0.006*temp)) for temp in data[2:]]
#print(temp)

for i,val in enumerate(temp):
    if minval > val:
        minval = val
        ans = i

print(ans+1)


Measured memory_bytes: 3064
def firstwin(a):
    odd = 0
    for x in a:
        if (x & 1) == 1:
            return True
    return False

def main():
    n = int(raw_input().strip())
    a = [int(raw_input().strip()) for i in xrange(n)]
    if firstwin(a):
        print 'first'
    else:
        print 'second'

if __name__ == '__main__':
    main()

Measured memory_bytes: 34280
#include <cstring>
#include <iostream>
using namespace std;
int main() {
    const int MAX_N = 100, MAX_W = 10000;
    int N, W, v[MAX_N], w[MAX_N];
    cin >> N >> W;
    for (int i = 0; i < N; ++i) {
        cin >> v[i] >> w[i];
    }
    int dp[MAX_N + 1][MAX_W + 1];
    memset(dp[0], 0, sizeof(dp[0]));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j) {
            if (j >= w[i]) {
                dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
            } else {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}



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

def factorization(n):
	arr=[]
	temp=n
	for i in range(2,int(-(-n**0.5//1))+1):
		if temp%i==0:
			cnt=0
			while temp%i==0:
				cnt+=1
				temp//=i
			arr.append([i,cnt])

	if temp!=1:
		arr.append([temp,1])

	if arr==[]:
		arr.append([n,1])

	return arr
	

def main():
	n = original_n =int(input().strip())
	factored =factorization(n)
	result=0

	if n==1:
		print("0")
		sys.exit()

	for i ,count in factored:
		diff=1
		while count > 0:
			count -=diff
			if count >=0:
				result+=1
				diff +=1

	print(result)


main()

Measured memory_bytes: 9492
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int X = sc.nextInt();
      if(X==1){
        System.out.println("Hello World");
      }else{
        int Y = sc.nextInt();
        int Z = sc.nextInt();
        System.out.println(Y+Z);
      }
    }
}

Measured memory_bytes: 35728
#include <iostream>
#include <bits/stdc++.h>
#include <string>

using namespace std;


typedef long long int ll;
typedef unsigned long long  ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef deque <int> di;
typedef deque <char> dc;
typedef vector<long long int> vll;

#define f(i, a, b) for (int i = a; i < b; i++)
#define f2(i, a, b) for (int i = a; i <=b; i++)
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front;
int main() {

int a;
int b;
int c;
cin >> a >> b >> c;
int d = a + b + c;

if (d != 17) {
    cout << "NO";
}
else {
    if (a != 5 && a != 7) {
        cout << "NO";
    }
    else if (b!=5 && b!= 7) {
        cout << "NO";
    }
    else if (c!=5 && c!=7) {

        cout << "NO";
    }
    else {
        cout << "YES";
    }
}
return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a.at(i).at(j);
    }
  }
  
  vector<bool> f_line(H, false), f_column(W, false); 
  
  for (int i = 0; i < H; i++) {
    if (W == 1 && a.at(i).at(0) == '.') {
      f_line.at(i) = true;
      continue;
    }
    for (int j = 0; j < W-1; j++) {
      if (a.at(i).at(j) != a.at(i).at(j+1)) {
        break;
      }
      else if (a.at(i).at(j) == '.' && j == W-2) f_line.at(i) = true;
    }
  }
  
  for (int j = 0; j < W; j++) {
    if (H == 1 && a.at(0).at(j) == '.') {
      f_column.at(j) = true;
      continue;
    }
    for (int i = 0; i < H-1; i++) {
      if (a.at(i).at(j) != a.at(i+1).at(j)) {
        break;
      }
      else if (a.at(i).at(j) == '.' && i == H-2) f_column.at(j) = true;
    }
  }
  
  for (int i = 0; i < H; i++) {
    if (f_line.at(i) == true) continue;
      for (int j = 0; j < W; j++) {
        if (f_column.at(j) == true) continue;
        cout << a.at(i).at(j);
      }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)

void fast() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main(){
 //fast();
  string s,t;
  cin>>s>>t;
  int n = s.length();
  int m = t.length();
  int ans = m;
  fr(i,0,n-m+1){
    int k = m;
    fr(j,i,i+m){
    	if(t[j-i] == s[j]){
        k--;
      }
    }
    ans = min(ans,k);
  }
  cout<<ans;
}

Measured memory_bytes: 3608
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Node {
    int id;
    Node left;
    Node right;
}

class Main {
    static Node root;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            String command = sc.next();
            if (command.charAt(0) == 'i') {
                int id = sc.nextInt();
                insert(id);
            } else if (command.charAt(0) == 'p') {
                System.out.println(inParse(root));
                System.out.println(preParse(root));
            } else if (command.charAt(0) == 'f') {
                int id = sc.nextInt();
                System.out.println(find(id));
            }
        }
    }

    public static void insert(int id) {
        Node insertedNode = new Node();
        insertedNode.id = id;

        if (root == null) {
            root = insertedNode;
            return;
        }

        Node node = root;
        while(true) {
            if (id < node.id) {
                if (node.left == null) {
                    node.left = insertedNode;
                    return;
                }
                node = node.left;
            } else {
                if (node.right == null) {
                    node.right = insertedNode;
                    return;
                }
                node = node.right;
            }
        }
    }

    public static String find(int id) {
        Node node = root;
        while(true) {
            if (node == null) {
                return "no";
            } else if (id == node.id) {
                return "yes";
            }

            if (id < node.id) {
                node = node.left;
            } else {
                node = node.right;
            }
        }
    }

    public static String preParse(Node node) {
        if (node == null) {
            return "";
        }
        return " " + node.id + preParse(node.left) + preParse(node.right);
    }

    public static String inParse(Node node) {
        if (node == null) {
            return "";
        }
        return inParse(node.left) + " " + node.id + inParse(node.right);
    }
}



Measured memory_bytes: 474436
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cassert>
#include <numeric>
#include <functional>

using namespace std;

int convert_geom(char g){
  switch(g){
  case '/':
    return +1;
  case '\\':
    return -1;
  case '_':
    return 0;
  default:
    assert(false);
  }
}

int main(){
  string geom;
  cin >> geom;
  const int N = geom.size();
  
  vector<int> height(N+1);
  vector<int> max_lefthand_height(N+1);
  vector<int> max_righthand_height(N+1);
  vector<int> water_level(N);

  //set height
  height[0] = 0;
  for(int i = 0; i<N; ++i){
    height[i+1] = height[i] + convert_geom(geom[i]);
  }

  //set max_lefthand_height
  max_lefthand_height[0] = height[0];
  for(int i = 0; i<N; ++i){
    max_lefthand_height[i+1] = max(max_lefthand_height[i], height[i+1]);
  }

  //set max_righthand_height
  max_righthand_height[N] = height[N];
  for(int i = N-1; i>-1; --i){
    max_righthand_height[i] = max(max_righthand_height[i+1], height[i]);
  }

  //set water_level
  for(int i = 0; i<N; ++i){
    water_level[i] = min(max_lefthand_height[i], 
			 max_righthand_height[i+1]);
  }
  
  
  int water_volume_x2 = 0;
  vector<int> ponds_x2;
  //cout << "w g" << endl;
  for(int i = 0; i<N; ++i){
    const int water_level_x2 = 2*water_level[i];
    const int ave_ground_level_x2 = height[i]+height[i+1];
    //const int max_ground_level_x2 = 2*max(height[i], height[i+1]);
    //cout << water_level_x2 << ' ' << ave_ground_level_x2 << endl;
    
    water_volume_x2 += max(0, water_level_x2 - ave_ground_level_x2);

    if(water_level_x2 == 2*height[i+1] && 
       water_volume_x2 > 0){
      ponds_x2.push_back(water_volume_x2);
      water_volume_x2 = 0;
    }
    //cout << "?:" << water_volume_x2 << endl;
  }
  
  if(water_volume_x2 > 0) {
    ponds_x2.push_back(water_volume_x2);
  }

  // //output 
  // cout << "---" << endl
  //      << "answer" << endl;
  cout << accumulate(ponds_x2.begin(), ponds_x2.end(), 0)/2 << endl;
  cout << ponds_x2.size();
  for(auto vol_x2 : ponds_x2){
    cout << ' ' << vol_x2/2;
  }
  cout << endl;
  //water_volume_x2/2 <<endl; 
  
  return 0;
}

Measured memory_bytes: 1540
a,b,k=map(int,input().split())
ab_min=[]
ab_max=[]
for i in range(a,min(b+1,a+k)):
    ab_min.append(i)
for j in range(max(a,b+1-k),b+1):
    ab_max.append(j)

ans=list(set(ab_min)|set(ab_max))
ans.sort()

for k in range(len(ans)):
    print(ans[k])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 int main() {
   int N;
   cin >> N;
   vector<int> vec(N);
   for(int i=0;i<N;i++){
     cin >> vec.at(i);
   }
   sort(vec.begin(),vec.end());
   int sum=0,count=1;
   for(int i=1;i<N;i++){
     if(vec.at(i)==vec.at(i-1)&&i!=N-1){
       count++;
     }
     else if(vec.at(i)!=vec.at(i-1)&&i!=N-1){
       sum += count%2;
       count = 1;
     }
     else if(vec.at(i)==vec.at(i-1)&&i==N-1){
       sum += (count+1)%2;
     }
     else{
       sum += count%2+1;
     }
   }
   cout << sum << endl;
}
  

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] receive = br.readLine().split(" ");
		Integer n = Integer.valueOf(receive[0]);
		Integer y = Integer.valueOf(receive[1]);
		int res10000 = -1, res5000 = -1, res1000 = -1, total, c;
		for (int a = 0; a <= n; a++) {
			for (int b = 0; b + a <= n; b++) {
				c = n - a - b;
				total = 10000 * a + 5000 * b + 1000 * c;
				if (total == y) {
					res10000 = a;
					res5000 = b;
					res1000 = c;
				}
			}
		}
		System.out.println(res10000 + " " + res5000 + " " + res1000);
	}
}

Measured memory_bytes: 24532
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000010
#define mod 1000000007
const int N = 10010;
char tmpread[12];
string s;
int a , b, c , d = 0 , dp[N][3];



int main(){
	int n;
	scanf("%d",&n);
	for(int it = 0 ;it < n;it++){
		scanf("%s",tmpread);
		s = (string)tmpread;
		for(int i = 0 ;i < (int)s.size() - 1;i++){
			if(s[i] == 'A' && s[i + 1] == 'B')
				a++;
		}
		if(s[0] == 'B' && s.back() == 'A')
			b++;
		else if(s[0] == 'B')
			c++;
		else if(s.back() == 'A')
			d++;
		
	}
	a += min(c , d) + b;
	if(c == 0 && d == 0 && b != 0)
		a--;
	cout << a << endl;
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int N,T,ans=0;cin>>N>>T;
    vector<int> time(N+1,0);
    REP(i,N)cin>>time[i];
    REP(i,N){
        if(i==N-1)ans+=T;
        else ans+=min(T,time[i+1]-time[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
n,t = map(int,input().split())
ab = sorted([list(map(int, input().split())) for i in range(n)])
dp = [[0 for i in range(t+1)]for j in range(n+1)]

for i in range(n):
    ti,vi = ab[i]
    for j in range(t+1):
        if j + ti <= t:
            dp[i+1][j+ti] = max(dp[i+1][j+ti],dp[i][j]+vi)
        dp[i+1][j] = max(dp[i][j],dp[i+1][j])

ans = 0
for i, (ti, vi) in enumerate(ab):
    ans = max(ans, dp[i][t - 1] + vi)
print(ans)


Measured memory_bytes: 124120
#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
using namespace std;

typedef long long ll;


int main() {
  int n, k; cin >> n >> k;
  double ans = 0;
  double e = 0;
  vector<double> le(n);
  for (int i = 0; i < n; ++i) {
    double p; cin >> p;
    if (i >= k) { 
      ans = max(ans, e);
      e -= le[i-k];
    }
    le[i] = (p+1);
    e += le[i];
  }
  ans = max(ans, e);
  cout << setprecision(10) << ans/2 << endl;
}



Measured memory_bytes: 1792
(set! *unchecked-math* true)
(defn input []
  (let [[N M] (->> (clojure.string/split (read-line) #"\s")
                (map #(Integer/parseInt %)))]
    (letfn [(inner-input [x]
              (->> (repeatedly x read-line)
                (into []
                  (comp (map #(clojure.string/split % #"\s"))
                    (map (partial mapv #(Integer/parseInt %)))))))]
      (vector (inner-input N) (inner-input M)))))

(defn distance [A B]
  (unchecked-add-int
    (Math/abs (unchecked-subtract-int (A 0) (B 0)))
    (Math/abs (unchecked-subtract-int (A 1) (B 1)))))

(defn inner-map [C S]
  (->> C
    (map-indexed #(vector-of :int %1 (distance S %2)))
    reverse
    (apply min-key second)
    first
    inc))

(defn Checkpoints [[S C]]
  (transduce
    (comp (map (partial inner-map C))
      (map #(str % "\n")))
    str
    S))


(->> (input)
  Checkpoints
  println)

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

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    REP(i, n) cin >> A[i];

    long long c1 = 0, c2 = 0, sum = 0;
    
    // + - + - + - +...
    REP(i, n){
        sum += A[i];
        if(i % 2){
            if(sum >= 0){
                c1 += sum + 1;
                sum = -1;
            }
        }else{
            if(sum > 0);
            else{
                c1 += 1 - sum;
                sum = 1;
            }
        }
    }

    // - + - + -+ ...
    sum = 0;
    REP(i, n){
        sum += A[i];
        if(i % 2){
            if(sum > 0);
            else{
                c2 += 1 - sum;
                sum = 1;
            }
        }else{
            if(sum >= 0){
                c2 += sum + 1;
                sum = -1;
            }
        }
    }
    cout << min(c1, c2) << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    char X, Y;
    cin >> X >> Y;
    if(X < Y) { printf("<\n"); }
    else if(X > Y) { printf(">\n"); }
    else { printf("=\n"); }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f first
#define  s second
#define pii pair<int,int>
#define pll pair<ll,l>
#define ull unsigned ll
#define mp make_pair
#define pb push_back

using namespace std;


int main(){
	int t;cin>>t;
	if(t>=30)cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 3552
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc060/tasks/abc060_b

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

    for (int i = 1; i <= A*B; i++) if (i*A%B==C){
            cout << "YES" << "\n";
            return 0;
    }


    cout << "NO" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int Max = 1000000;
bool prime[1000000];

void sieve(){
  for(int i=0;i<Max;i++) prime[i]= true;

  prime[0] = false;
  prime[1] = false;
  for(int i=2;i<Max;i++){
    if(prime[i]){
      for(int j=2*i;j<Max;j+=i){
        prime[j] = false;
      }
    }
  }
}

int main(){
    sieve();

  	int X;
    cin >> X;

    int i = 0;
    while(1){
      if(prime[X+i]){
        cout << X+i <<endl;
        return 0;
      }
      i++;
    }
  	
  	return 0;
}



Measured memory_bytes: 1280
n = int(input())

d = 2 
ans = 0
while d * d <= n:
  if n % d != 0:
    d += 1
    continue
  
  z = d
  
  while n % z == 0:
    n //= z 
    z *= d
    ans += 1
    
  while n % d == 0:
    n /= d

if n != 1:
  ans += 1
  
print(ans)
  

Measured memory_bytes: 9220
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll A, B;
    cin >> A >> B;
    if (A <= 5)
    {
        B = 0;
    }
    else if (A <= 12)
    {
        B /= 2;
    }

    cout << B << endl;

    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n, v;
    scanf("%d", &n);

    int a[n];
    for(int i=0 ; i<n ; i++) scanf("%d", &a[i]);
    
    for(int i=0 ; i<n ; i++)
        if(i==n-1)  printf("%d\n", a[i]);
        else        printf("%d ", a[i]);

    for(int i=1 ; i<n ; i++){
        int j=i;
        while(j>0 && a[j-1] > a[j]){
            v=a[j-1], a[j-1]=a[j], 
            a[j]=v, j--;
        }
        for(int i=0 ; i<n ; i++)
            if(i==n-1)    printf("%d\n", a[i]);
            else            printf("%d ", a[i]);
    }
    return 0;
}


Measured memory_bytes: 2028
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
using pii = pair<int, int>;

int main(){
	ios_base::sync_with_stdio(false);
	int h, w, n;
	cin >> w >> h >> n;
	vector<pii> objs;
	for(int i = 0; i < n; ++i){
		int x, y;
		cin >> x >> y;
		--x; --y;
		objs.emplace_back(y, x);
	}
	sort(objs.begin(), objs.end());
	const int init = lower_bound(objs.begin(), objs.end(), pii(1, 0)) - objs.begin();
	vector<int> leftmost(h, w);
	leftmost[0] = 0;
	for(int y = 1, i = init; y < h; ++y){
		leftmost[y] = leftmost[y - 1] + 1;
		while(i < n && objs[i].first == y){
			if(objs[i].second == leftmost[y]){ ++leftmost[y]; }
			++i;
		}
		leftmost[y] = min(w - 1, leftmost[y]);
	}
	int answer = w;
	for(const auto& p : objs){
		const int y = p.first, x = p.second;
		if(x - 1 < leftmost[y]){ continue; }
		answer = min(answer, x);
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 2672
#include <iostream>
using namespace std;
void one(int x,int h,int xy[101][101])
{
	for(int i=0;i<x;i++)
	{
		for(int j=0;j<h;j++)
		{
			xy[i][j] = 0;
		}
	}
}
void two(int x,int h,int w,int xy[101][101])
{
	for(int i=x;i<w;i++)
	{
		for(int j=0;j<h;j++)
		{
			xy[i][j] = 0;
		}
	}
}
void three(int w,int y,int xy[101][101])
{
	for(int i=0;i<w;i++)
	{
		for(int j=0;j<y;j++)
		{
			xy[i][j] = 0;
		}
	}
}
void four(int w,int y,int h,int xy[101][101])
{
	for(int i=0;i<w;i++)
	{
		for(int j=y;j<h;j++)
		{
			xy[i][j] = 0;
		}
	}
}
int main()
{
	int xy[101][101];
	int w,h,n;
	int s = 0;
	int x,y,a;
	cin >> w >> h >> n;
	for(int i=0;i<w;i++)
	{
		for(int j=0;j<h;j++)
		{
			xy[i][j] = 1;
		}
	}
	for(int i=0;i<n;i++)
	{
		cin >> x >> y >> a;
		switch(a)
		{
			case 1:
			one(x,h,xy);
			break;
			case 2:
			two(x,h,w,xy);
			break;
			case 3:
			three(w,y,xy);
			break;
			case 4:
			four(w,y,h,xy);
			break;
		}
	}
	for(int i=0;i<w;i++)
	{
		for(int j=0;j<h;j++)
		{
			if(xy[i][j])
			{
				s++;
			}
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;
const int N = 3e5 + 500;
const int LN = 21;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;

long long n, m, u, v, k, t, q, a, h, x, u1, v1, u2, v2;

int arr[N];

vector <pair <long long, long long> > prices;
int main() {
   ios::sync_with_stdio(false);cin.tie(0);
   cin >> n;

   cin >> u >> u1 >> u2 >> v >> v1 >> v2;
   prices.push_back(make_pair(u, v));
    prices.push_back(make_pair(u1, v1));
    prices.push_back(make_pair(u2, v2));
   long long best = n;
   
   for (long long i = 0; i * prices[0].first <= n; ++i) {
      for (long long j = 0; j * prices[1].first + i * prices[0].first <= n; ++j) {
         long long k = (n - j * prices[1].first - i * prices[0].first) / prices[2].first;
         if (prices[2].first > prices[2].second) k = 0;
         long long rem = n - (j * prices[1].first + i * prices[0].first + k * prices[2].first);
         best = max(best, rem + i * prices[0].second + j * prices[1].second + k * prices[2].second);
      }
   }
   
   n = best;
   
   if (n <= 5000) {
      for (long long i = 0; i * prices[0].second <= n; ++i) {
         for (long long j = 0; j * prices[1].second + i * prices[0].second <= n; ++j) {
            long long k = (n - j * prices[1].second - i * prices[0].second) / prices[2].second;
            if (prices[2].second > prices[2].first) k = 0;
            
            long long rem = n - (j * prices[1].second + i * prices[0].second + k * prices[2].second);
            best = max(best, rem + i * prices[0].first + j * prices[1].first + k * prices[2].first);
         }
      }
   } else {
      sort(prices.begin(), prices.end(), [](const pair <long long, long long> &a, const pair <long long, long long> &b) {
         return (a.first / a.second > b.first / b.second);
      });
      for (long long i = 0; i * prices[0].second <= n; ++i) {
         long long j = (n - i * prices[0].second) / prices[1].second;
         if (prices[1].second > prices[1].first) j = 0;
         long long rem = n - (j * prices[1].second + i * prices[0].second);
         best = max(best, rem + i * prices[0].first + j * prices[1].first);
      }
   }
   
   cout << best << endl;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);


ll ans = INF;
int N,A,B,C;
vector<ll> L;
void dfs(ll as,ll an,ll bs,ll bn,ll cs,ll cn,ll d){
    if(d==N){
        if(an>0&&bn>0&&cn>0){
        }else return;
        ll cost = abs(as-A) + (an-1)*10;
        cost += abs(bs-B) + (bn-1)*10;
        cost += abs(cs-C) + (cn-1)*10;
        ans = min(ans,cost);
        return;
    }
    int i = d;
    dfs(as+L[i],an+1,bs,bn,cs,cn,d+1);
    dfs(as,an,bs+L[i],bn+1,cs,cn,d+1);
    dfs(as,an,bs,bn,cs+L[i],cn+1,d+1);
    dfs(as,an,bs,bn,cs,cn,d+1);
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cin >> N >> A >> B >> C;
    L.resize(N);
    rep(i,N)cin >> L[i];
    dfs(0,0,0,0,0,0,0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>                                                                                                                                                                                         
using namespace std;                                                                                                                                                                                        
                                                                                                                                                                                                            
int main(){                                                                                                                                                                                                 
  int i=0, a;                                                                                                                                                                                               
  while(1){                                                                                                                                                                                                 
    cin >> a;                                                                                                                                                                                               
    if (a==0) break;                                                                                                                                                                                        
    i += 1;                                                                                                                                                                                                 
    cout << "Case " << i << ": " << a << endl;                                                                                                                                                              
  }                                                                                                                                                                                                         
  return 0;                                                                                                                                                                                                 
}  

Measured memory_bytes: 3076
n = int(input())
csf = []
for _ in range(n-1):
  csf.append(list(map(int,input().split())))
for i in range(n-1):
  time = 0
  for j in range(i,n-1):
    c,s,f = csf[j]
    start = max(time,s)
    START = ((start-1)//f+1)*f
    time = START + c
  print(time)
print(0)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, a, b;
	cin >> n >> a >> b;
	ll d = abs(a - b);
	if(d % 2 == 0){
		return cout << d / 2, 0;
	}
	ll ans = n;
	if(a > b) swap(a, b);
	ans = min(ans, a + abs((1) - (b-a)) / 2);
	b = n + 1 - b;
	a = n + 1 - a;
	swap(a, b);
	ans = min(ans, a + abs(1 - (b - a)) /2);
	cout << ans;
	return 0;
}




Measured memory_bytes: 256
N = int(input())
import math
#ユークリッド互除法の関数の定義
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)
x = list(map(int,input().split()))

if N==1:
    print(x[0])
else:
    element = gcd(x[0], x[1])
    if N==2:print(element)
    else:
        for i in range(2,N):
            element=gcd(element,x[i])
        print(element)

# print(gcd_list(numbers))

Measured memory_bytes: 15020
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
const int MAXN = (int)1e5 + 10;

int m,n;
int p[MAXN];

int Find(int x){
    return x==p[x] ? x : p[x]=Find(p[x]);
}

void Merge(int u,int v){
    int x=Find(u);
    int y=Find(v);
    if(x!=y){
        p[x]=y;
    }
}

void work(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) p[i]=i;
    for(int i=1;i<=m;i++){
        int u,v; scanf("%d%d",&u,&v);
        Merge(u,v);
    }
    int q; scanf("%d",&q);
    for(int i=1;i<=q;i++){
        int s,t; scanf("%d%d",&s,&t);
        if(Find(s)==Find(t)) printf("yes\n");
        else printf("no\n");
    }
}

int main(){
    work();
    return 0;
}




Measured memory_bytes: 3704
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------


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

	int c = 0;
	while (c < s.size() && s[c] != 'C') c++;

	int f = s.size() - 1;
	while (f >= 0 && s[f] != 'F') f--;

	if (c == s.size() || f < 0 || c >= f) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;

	return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  int N;
  int A[51],B[51],C[50];

  cin >> N;
  REP(i,N)cin >> A[i];

  int ans=0;

  REP(i,N){
    int b;
    cin >> b;
    ans+=b;
  }
  REP(i,N-1)cin >> C[i];

  REP(i,N-1){
    if(A[i]+1==A[i+1]){
      ans+=C[A[i]-1];
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  
  if(n/10%111==0){
    cout<<"Yes"<<endl;
  }
  else if(n%1000%111==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


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

using namespace std;

using ll=long long;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr int mo = 1e9+7;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<int> p(n),q(n);
    for(auto &a : p) cin>>a;
    for(auto &a : q) cin>>a;
    vector<int> pq(n);
    iota(pq.begin(),pq.end(),1);
    int pnum,qnum;
    pnum = qnum = 0;
    int count = 0;
    do{
        if(pq == p)pnum = count;
        if(pq == q)qnum = count;
        count++;
    }while(next_permutation(pq.begin(),pq.end()));
    cout << abs(pnum - qnum) << endl;
    return 0;
}


Measured memory_bytes: 256