akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define sz(s) (ll)s.size()
#define print(d) cout << fixed << setprecision(15) << d
#define pii pair<ll,ll>
#define ppii pair<ll,pii>
#define ff first
#define ss second
const ll MOD = 1000000007;
const ll MAXN = 1e6 + 5;
const ll inf = 2e18;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
tree_order_statistics_node_update> ord_set;
#define debug(x) cerr << #x << " = " << x << endl


ll power(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x%m * p%m) % m; 
} 


int main()
{
   fast
   ll m,n;
   cin >> m >> n;
   ll p;
   cin >> p;
   if( (2+0.0)*(ld)sqrt((ld)(n+0.0)*(ld)(m+0.0)) < (ld)(p-m-n+0.0))
   {
   	cout << "Yes\n";
   }
   else
   	cout << "No\n";
   
   return 0;
}










Measured memory_bytes: 256
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PB push_back
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main()
{
    FIO
    string str;
    cin>>str;
    int l = str.size();
    int count = 0;
    for(int i = 0; i <= (l-1)/2; ++i) {
        if (str[i] != str[l-i-1])
        {
            count++;
        }
    }
    cout<<count;
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  string S;
  cin >> S;
  string ans = "Yes";
  REP(i, S.size()) {
    if (i % 2 == 0 && S[i] == 'L') ans = "No";
    if (i % 2 == 1 && S[i] == 'R') ans = "No";
  }
  cout << ans << '\n';
}


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

int N, D;

int dp[20][20];
int distance(string& s1, string& s2){
	for(int i = 0; i <= s1.length(); i++){
		dp[i][0] = i;
	}
	for(int j = 0; j <= s2.length(); j++){
		dp[0][j] = j;
	}
	for(int i = 0; i < s1.length(); i++){
		for(int j = 0; j < s2.length(); j++){
			int ans = 100000;
			ans = min(ans, dp[i][j + 1] + 1);
			ans = min(ans, dp[i + 1][j] + 1);
			if(s1[i] == s2[j]){
				ans = min(ans, dp[i][j]);
			}else{
				ans = min(ans, dp[i][j] + 1);
			}
			if(i >= 1 && j >= 1 && s1[i] == s2[j - 1] && s1[i - 1] == s2[j]){
				ans = min(ans, dp[i - 1][j - 1] + 1);
			}

			if(i >= 2 && j >= 1 && s1[i] == s2[j - 1] && s1[i - 2] == s2[j]){
				ans = min(ans, dp[i - 2][j - 1] + 2);
			}	
			if(i >= 1 && j >= 2 && s1[i] == s2[j - 2] && s1[i - 1] == s2[j]){
				ans = min(ans, dp[i - 1][j - 2] + 2);
			}
			dp[i + 1][j + 1] = ans;
		}
	}
	/*
	for(int i = 0; i <= s1.length(); i++){
		for(int j = 0; j <= s2.length(); j++){
			cout << " " << dp[i][j];
		}
		cout << endl;
	}
	cout << s1 << ":" << s2 << dp[s1.length()][s2.length()] << endl;
	*/
	return dp[s1.length()][s2.length()];
}

int main(){
	while(cin >> N, N){
		cin >> D;
		vector<string> names(N);
		for(int i = 0; i < N; i++){
			cin >> names[i];
		}
		sort(names.begin(), names.end());
		int cnt = 0;
		for(int i = 0; i < N; i++){
			for(int j = i + 1; j < N; j++){
				if(distance(names[i], names[j]) <= D){
					cout << names[i] << "," << names[j] << endl;
					cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 3216
#include <stdio.h>

int main(void){
    int a,op,b;
    while(1){
        scanf("%d %lc %d",&a,&op,&b);
       if ( op == '+' ){
           printf("%d\n",a+b);} 
        else if ( op == '-' ){
           printf("%d\n",a-b);} 
        else if ( op == '*' ){
           printf("%d\n",a*b);}
        else if ( op == '/' ){
           printf("%d\n",a/b);}
        else if ( op == '?' ){
           break;} 
    }
    return 0;
}

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

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

using namespace std;

typedef long long ll;

int main()
{
    string S;
    cin >> S;
    string ans;
    if (S == "Sunny")
    {
        ans = "Cloudy";
    }
    else if (S == "Cloudy")
    {
        ans = "Rainy";
    }
    else 
    {
        ans = "Sunny";
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,x,cnt;
    while(1){
        cin>>n>>x;
        cnt=0;
        if(n==0&&x==0)break;
        for(int i=1;i<=n;i++)
            for(int j=i+1;j<=n;j++)
                for(int k=j+1;k<=n;k++)
                    if(i+j+k==x) cnt++;
        cout<<cnt<<endl;
    }
}

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

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;

int main()
{
	FAST;
	string str;
	cin >> str;
	int n = str.size();

	if (n % 2 == 0)
	{
		cout << "No";
		return 0;
	}

	for (int i = 0 ; i < str.size() ; i++)
		if (str[i] != str[n - i - 1])
		{
			cout << "No";
			return 0;
		}


	for (int i = 0 ; i < (n - 1) / 2 ; i++)
	{
		if (str[i] != str[(n - 1) / 2 - i - 1])
		{
			cout << "No";
			return 0;
		}
	}

	for (int i = (n + 3) / 2 ; i < n ; i++)
	{
		if (str[i] != str[n - i - 1])
		{
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";

	return 0;
}



Measured memory_bytes: 256
// luogu-judger-enable-o2
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main (){
	cin>>a>>b;
    c=b*pow(b-1,(double)a-1);
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

long long int result[(1 << 15)][15][15];

int main()
{
	int v, e;
	cin >> v >> e;
	long long int graph[16][16];
	for(int i = 0; i < v; i++){
		for(int j = 0; j < v; j++){
			graph[i][j] = mod;
			for(int k = 0; k < (1 << v); k++){
				result[k][i][j] = mod;
			}
		}
	}
	for(int i = 0; i < e; i++){
		int s, t;
		long long int d;
		cin >> s >> t >> d;
		graph[s][t] = d;
	}
	for(int i = 0; i < v; i++){
		result[(1 << i)][i][i] = 0;
	}
	for(int i = 1; i < (1 << v); i++){
		for(int s = 0; s < v; s++){
			for(int j = 0; j < v; j++){
				if(result[i][j][s] == mod) continue;
				for(int k = 0; k < v; k++){
					if((i & (1 << k)) > 0) continue;
					result[i | (1 << k)][k][s] = min(result[i | (1 << k)][k][s], result[i][j][s] + graph[j][k]);
				}
			}
		}
	}
	long long int ans = mod;
	for(int i = 0; i < v; i++){
		for(int j = 0; j < v; j++){
			ans = min(ans, result[(1 << v) - 1][i][j] + graph[i][j]);
		}
	}
	if(ans == mod) ans = -1;
	cout << ans << endl;
}


Measured memory_bytes: 60684
N,M,*f = open(0).read().split()
N = int(N)
M = int(M)
pS = [f[i*2:i*2+2] for i in range(M)]
accepted = [0] * (N+1)
wrong = [0] * (N+1)
penalty = [0] * (N+1)
for p,S in pS:
    i = int(p)
    if accepted[i] == 0:
        if S == 'AC':
            penalty[i] = wrong[i]
            accepted[i] = 1
        else:
            wrong[i] += 1
print(sum(accepted),sum(penalty))

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

using namespace std;

typedef long long int ll;
#define pb push_back
#define ALL(a) (a).begin() , a.end()

int mod = 1e9 + 7;
int add(int a, int b){
	if(a + b >= mod)return a+ b - mod;
	return a + b;
}
int mul(int a, int b){
	return 1LL * a * b  % mod;
}
int const N = 100 * 1010;

/********************i**********************************/
void solve(){
	int n, k;
	cin >> n >> k;
	vector<bool > dp(k+ 1, 0);
	vector<int> vec(n);
	for(auto &a : vec)cin >> a;
	sort(ALL(vec));
	for(int x = *min_element(ALL(vec)); x<= k; x++){
		bool flag = false;
		for(int a : vec){
			if(a > x)break;
			flag |= !(dp[x- a]);
		}
		dp[x] = flag;
	}
	if(dp[k])cout << "First\n";
	else cout << "Second\n";
}


/******************************************************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int t;
	t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 256
k = int(input())
anss = [["a"]]

for i in range(k-1):
  anss.append([])
  for j in anss[i]:
    for l in range(len(set(list(j)))+1):
      anss[i+1].append(str(j)+chr(97+l))
anss[k-1].sort()
for i in anss[k-1]:
  print(i)

Measured memory_bytes: 14648
def factor(n, i):
    count = 0
    while n % i == 0:
        count += 1
        n = n // i
    return count


def main():
    n, *a = map(int, open(0).read().split())
    ans = sum([factor(x, 2) for x in a])
    print(ans)


if __name__ == '__main__':
    main()


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

int main (){
    int N;
    scanf("%d",&N);
    int h[N];
    for (int i = 0; i < N; i++){
        scanf("%d",&h[i]);
    }
    bool flag=true;
    int count=0;
    bool prevst=false;
    while (flag){
        flag=false;
        prevst=false;
        for (int i = 0; i < N; i++){
            if(h[i]>0 && prevst==false) count+=1;
            if(h[i]==0) prevst=false;
            if(h[i]>0) prevst=true;
            if(h[i]>0) h[i]--;
            if(h[i]>0) flag=true;
        }
    }
    printf("%d",count);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

LL N, C;
pair<LL, LL>sus[123456];

LL solve() {
	vector<LL>flip(1);
	LL cal = 0;
	for (int i = N - 1; i >= 0; --i) {
		cal += sus[i].second;
		flip.push_back(cal - 2 * (C - sus[i].first));
		flip.back() = max(flip.back(), flip[flip.size() - 2]);
	}
	vector<LL>go(1);
	LL cas = 0;
	for (int i = 0; i < N; ++i) {
		cas += sus[i].second;
		go.push_back(cas - (sus[i].first));
		go.back() = max(go.back(), go[go.size() - 2]);
	}
	LL ans = 0;
	for (int i = 0; i <= N; ++i) {
		ans = max(ans, flip[i] + go[N - i]);
	}
	//cout << ans << endl;
	return ans;
}

int main(void)
{
	cin >> N >> C;
	for (int i = 0; i < N; ++i) {
		cin >> sus[i].first >> sus[i].second;
	}
	LL ans = solve();
	for (int i = 0; i < N; ++i) {
		sus[i].first = C - sus[i].first;
	}
	sort(sus, sus + N);
	LL can = solve();
	cout << max(ans, can) << endl;
	return 0;
}


Measured memory_bytes: 4436
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;

int N, M, X, ans;
int C[20];
int A[20][20];
deque<int> d;

void solve(int Cou, int len) {
  if (Cou == N) {
    int Al[M] = {0};
    int total = 0;
    for (int i = 0; i < len; ++i) {
      // int di = d.front();
      // d.pop_front();
      int di = d[i];
      total += C[di];
      // printf("%d ", di);
      for (int j = 0; j < M; ++j) {
        Al[j] += A[di][j];
      }
    }
    // printf("\n");
    int bl = 0;
    for (int i = 0; i < M; ++i) {
      // printf("%d\n", Al[i]);
      if (Al[i] >= X) {
        ++bl;
      }
    }
    if (bl == M) {
      ans = min(ans, total);
    }
  } else {
    solve(Cou+1, len);
    d.push_back(Cou);
    solve(Cou+1, len+1);
    d.pop_back();
  }
  return ;
}

int main () {
  cin >> N >> M >> X;
  ans = -1;
  for (int i = 0; i < N; ++i) {
    cin >> C[i];
    for (int j = 0; j < M; ++j) {
      cin >> A[i][j];
    }
  }
  ans = 1000000000;
  solve(0, 0);
  if (ans == 1000000000) {
    ans = -1;
  }
  printf("%d\n", ans);
  return 0;
}

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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



void solve(){
	llint x;
	cin >> x;
	llint n=100;
	llint y;
	for(y=0;n<x;y++){
		n*=1.01;
	}
	cout << y << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


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

int main()
{
	int n;
    cin >> n;
    long long a, b;
    vector<pair<long long, long long>> vec(n);

    REP(i, n) {
        cin >> a >> b;
        vec[i] = make_pair(b, a);
    }

    sort(vec.begin(), vec.end());
    long long time = 0;
    bool flag = true;

    REP(i, n) {
        time += vec[i].second;
        if (time > vec[i].first) {
            flag = false;
            break;
        }
    }

    if (flag)   cout << "Yes" << endl;
    else cout << "No" << endl;
     
}


Measured memory_bytes: 3328
from math import factorial

N, P = map(int, input().split())
A = list(map(int, input().split()))
odd, even = 0, 0
for i in range(N):
    if A[i] % 2:
        odd += 1
    else:
        even += 1

ans = 0
for i in range(odd+1):
    if i%2 == P:
        ans += factorial(odd) / factorial(i) / factorial(odd-i)
ans *= 2**even

print(int(ans))


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	int a[33]={0},l;
	while(cin>>a[0]>>l){
		if(a[0]==0&&l==0) break;
		for(int i=1;i<=20;i++){
			for(int j=1;j<=l;j++){
				int x=a[i-1]/pow(10,j-1);
				a[20+j]=x%10;
				a[26+j]=0;
			}
			for(int j=1;j<=l;j++){
				for(int k=1;k<=l;k++){
					a[26+j]=max(a[26+j],a[20+k]);
				}
				for(int k=1;k<=l;k++){
					if(a[26+j]==a[20+k]){
						a[20+k]=0;
						break;
					}
				}
			}
			for(int j=l;j>=1;j--){
				a[i]=a[i]-a[26+j]*pow(10,j-1)+a[27+l-j]*pow(10,j-1);
			}
			for(int j=0;j<i;j++){
				if(a[j]==a[i]){
					cout<<j<<" "<<a[i]<<" "<<i-j<<endl;
					goto end;
				}
			}
		}
		end:;
		for(int i=0;i<33;i++){
			a[i]=0;
		}
	}
    return 0;
}

Measured memory_bytes: 1204
using System;

namespace abc059_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string b = Console.ReadLine();
            if (a.Length != b.Length)
            {
                Console.WriteLine(a.Length > b.Length ? "GREATER" : "LESS");
            }
            else
            {
                if (a != b)
                {
                    Console.WriteLine(a.CompareTo(b) > 0 ? "GREATER" : "LESS");
                }
                else
                {
                    Console.WriteLine("EQUAL");
                }
            }
        }
    }
}

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

int main(){
    while(1){
        
        int h,w;
        
        cin>>h>>w;
        
        if ( h == 0 && w == 0 ) break;
        
        for ( int i = 0; i < h; i++){
            for ( int j = 0; j < w; j++){
                
                if (( i + j ) % 2 == 0 ) cout<<"#";
                
                else cout<<".";
            }       
            
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


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

bool f[110][110];

int main(){
	ll n;
	cin>>n;
	cout<<n*(n-1)/2-n/2<<endl;
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++){
		f[i][i]=1;
		ll x=n;
		if(n%2==0)x++;
		if(i+j==x)f[i][j]=f[j][i]=1;
	}
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++){
		if(!f[i][j])cout<<i<<' '<<j<<endl;
		f[i][j]=f[j][i]=1;
	}
	return 0;
}


Measured memory_bytes: 3564
input = readlines
# input = ["3 2\n", "1 1\n"]
connected_input = ""

input.each do |row|
  connected_input += row
end

splitted_input = connected_input.split(" ")

H = splitted_input[0].to_i
W = splitted_input[1].to_i
h = splitted_input[2].to_i
w = splitted_input[3].to_i

number_of_all_square = H * W
number_of_black_square = H * w + W * h - w * h
number_of_white_square = number_of_all_square - number_of_black_square

puts number_of_white_square


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    cout << (1000-n%1000)%1000 << "\n";
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int priceA = sc.nextInt();
        int priceB = sc.nextInt();
        int priceAB = sc.nextInt();
        int needACount = sc.nextInt();
        int needBCount = sc.nextInt();
        
        int countOfTheMore = Math.max(needACount, needBCount);
        int countOfTheLess = Math.min(needACount, needBCount);
        int priceOfCountOfTheMore = 0;
        if (countOfTheLess == needACount) {
            priceOfCountOfTheMore = priceB;
        } else {
            priceOfCountOfTheMore = priceA;
        }
        
        int pricePlanA = priceA * needACount + priceB * needBCount;
        int pricePlanB = priceAB * 2 * countOfTheMore;
        int pricePlanC = priceAB * 2 * countOfTheLess + priceOfCountOfTheMore * (countOfTheMore - countOfTheLess);
        int answer = 0;
        if (pricePlanA < pricePlanB) {
            answer = pricePlanA;
        } else {
            answer = pricePlanB;
        }
        
        if (pricePlanC < answer) {
            answer = pricePlanC;
        }
        
        System.out.println(answer);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("outp.txt","w",stdout);
    #endif
    ll n;vector<char>v;
    cin>>n;
    while(n!=0)
    {
        ll x=n%26;
        if(x==0)
        {
            x=x+26;
        }
        char c=(char)(96+x);
        v.push_back(c);
        if(n%26==0)
            n=n/26 -1;
        else
            n=n/26;
    }
    for(ll i=v.size()-1;i>=0;i--)
        cout<<v[i];
}

    


Measured memory_bytes: 3620
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll X, Y, Z;
ll memo[100][2][2];
bool visited[100][2][2];

ll dfs(int d, int down, int up) {
  ll res = LLINF;

  int x = (X >> d) & 1;
  int y = (Y >> d) & 1;
  int z = (Z >> d) & 1;

  if ((X >> d) == 0 && down) return LLINF;
  if ((X >> d) == 0 && (Y >> d) == 0 && (Z >> d) == 0 && !down && !up) return 0;

  if (visited[d][down][up]) return memo[d][down][up];

  // 0
  bool ok0 = (x ^ down) ^ (y ^ up) ^ z == 0;
  int nextX0 = x - down < 0, nextY0 = y + up >= 2;
  if (ok0) {
    res = min(res, dfs(d + 1, nextX0, nextY0));
  }

  // 1
  bool ok1 = (x ^ down ^ 1) ^ (y ^ up ^ 1) ^ z == 0;
  int nextX1 = x - down - 1 < 0, nextY1 = y + up + 1 >= 2;
  if (ok1) {
    res = min(res, dfs(d + 1, nextX1, nextY1) + (1LL << d));
  }

  debug(d, down, up, res);

  visited[d][down][up] = true;
  return memo[d][down][up] = res;
}

int main() {
  int N;
  ll A[SIZE];

  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (i >= 2) Z ^= A[i];
  }

  X = A[0];
  Y = A[1];

  ll ans = dfs(0, false, false);

  if (ans == LLINF || ans == A[0]) {
    cout << "-1" << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
using namespace std;
static const int MAX_N = 100000;

int main(void){
    int n;
    int H[MAX_N];
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> H[i];
    }
    int counter = 0;
    for(int i=0; i<n-1; i++){
        if(H[i]<=H[i+1]-1){
            H[i+1] -= 1;
        }
        if(H[i]>H[i+1]) counter += 1;
    }

    if(counter==0) cout << "Yes";
    else cout << "No";
    
    return 0;
}

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

using namespace std;

int main() {
    int_fast64_t x, p = 100;

    cin >> x;

    int n = 0;

    while(p < x) {
        p *= 1.01;
        n++;
    }

    printf("%d\n", n);

    return 0;
}

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

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

 for(int i=0;i<Q;i++){
	int c,a,n;
	cin>>c>>a>>n;

	int can=min(min(c,a),n);
	c-=can;
	a-=can;

 	int cca=min(c/2,a);
	c-=cca*2;

	int ccc=c/3;

	cout<<can+cca+ccc<<endl;
 }
return 0;
}

Measured memory_bytes: 3076
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// -----------------------------------------------------------------------------
// main
// -----------------------------------------------------------------------------
fn main(){
    input!{
        a1: isize,
        a2: isize,
        a3: isize
    }
    let mut a = vec![];
    a.push(a1); a.push(a2); a.push(a3);
    a.sort();
    println!("{}", (a[0]-a[1]).abs() + (a[1]-a[2]).abs());
}



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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int A, B, C, D, E, K;
    cin >> A >> B >> C >> D >> E >> K;
    cout << (E - A > K ? ":(" : "Yay!");
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;




int main(){
    int N,D,X; cin >> N >> D >> X;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    int sum = 0;
    rep(i,N){
        rep(j,1000){
            if(j*A[i]+1 > D) break;
            sum++;
        }
    }
    int ans = sum+X;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
int main() {
    int N ,M;
    cin >> N >> M;
    vector<bool>S(N+1, false);
    vector<int>P(N+1);
    int qNum = 0;
    int penare = 0;
    rep(i, 0, M){
        string tmpS;
        int tmpP;
        cin >> tmpP >> tmpS;
        if(S[tmpP] != true && tmpS == "AC"){
            S[tmpP] = true;
            qNum++;
        }
        if(!S[tmpP]){
            P[tmpP]++;
        }
    }
    rep(i, 0, N+1){
        if(S[i]){
            penare += P[i];
        }
    }
    cout << qNum <<" "<< penare << endl;
    return 0;
}


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

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  int k;
  cin >> k;
  sort(a, a + 3);
  for (int i = 0; i < k; i++) {
    a[2] *= 2;
  }
  cout << a[0] + a[1] + a[2] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int x,i,j,d[10000];
	i=0;
	j=0;
	scanf("%d",&x);
	while(x!=0){
		d[j]=x;
		j=j+1; i=i+1;
		scanf("%d",&x);
	}
	for (j=0; j<i; j++){
		printf("Case %d: %d\n",j+1,d[j]);
	}
	return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};


int main(){
  int n, m; cin >> n >> m;
  string s; cin >> s;
  reverse(all(s));
  vi ans;
  int now = 0;
  while(1){
    bool ng = true;
    for(int i = m; i >= 1; i--) {
      if(now+i <= n && s[now+i] == '0'){
        now += i;
        ng = false;
        ans.pb(i);
        break;
      }
    }
    if(ng){
      cout << -1 << endl;
      return 0;
    }

    if(now == n) break;
  }

  reverse(all(ans));

  for(int i = 0; i < ans.size(); i++) {
    if(i != ans.size()) cout << ans[i] << " ";
    else cout << ans[i] << endl;
  }
  
}


Measured memory_bytes: 1144
#include <iostream>
#define rep(i, n) for(int i=0; i<N; i++)

using namespace std;

int main(void){
  int N, K;
  cin >> N >> K;
  int A[N];
  rep(i, N)
    cin >> A[i];
  //ここまで入力

  //選べる数がK=Nのときは1回の操作で完了する
  if(N == K){
    cout << 1 << endl;
    return 0;
  }
    
  cout << ((N-1)+(K-1)-1)/(K-1) << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (ll (i) = (s); (i) < (e); ++(i))
#define per(i, s, e) for (ll (i) = (s); (i) >= (e); --(i))
#define all(x) x.begin(),x.end()

// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(void) {
    ll x, y; cin >> x >> y;
    if ((x+y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll n, m;
    n = (2*y - x)/3;
    m = (2*x - y)/3;
    if (n < 0 || m < 0) {
        cout << 0 << endl;
        return 0;
    }
    combination com = combination(n+m);
    mint ans = com((n+m), n);
    cout << ans.x << endl;
}


Measured memory_bytes: 10624
n = int(input())
m = 0
a = 0
r = 0
c = 0
h = 0
count = 0
for i in range(n):
    l = input()
    if l[0] == "M":
        m += 1
    elif l[0] == 'R':
        r += 1
    elif l[0] == "A":
        a += 1
    elif l[0] == "C":
        c += 1
    elif l[0] == "H":
        h += 1
count += m*a*r
count += m*a*c
count += m*a*h
count += m*r*c
count += m*r*h
count += m*c*h
count += a*r*c
count += a*r*h
count += a*c*h
count += r*c*h
print(count)

Measured memory_bytes: 3064
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
co = collections.Counter()
n = ni()
A = lma()
s = 0
co[0]+=1
for a in A:
    s+=a
    co[s]+=1

ans = 0
for val in co.values():
    ans+= val*(val-1)//2
print(ans)


Measured memory_bytes: 42900
n = gets.chomp.to_i

l = gets.chomp.split(' ').map(&:to_i)

t = l.combination(3).map{|i| i.map(&:to_i)}
count = 0

t.each{|i|
  a = i[0]
  b = i[1]
  c = i[2]
if(a==b || b==c || a==c)
elsif((a-b).abs < c && c < a+b)
count += 1
end

}

puts count


Measured memory_bytes: 24328
using System;
using System.Collections.Generic;
using System.Text;

class TEST{
	static void Main(){
		while(true){
			String s=Console.ReadLine();
			if(s==null)break;
			var d=Array.ConvertAll(s.Split(' '),elem=>int.Parse(elem));
			Sol mySol=new Sol(d[0],d[1]);
			Console.WriteLine(mySol.Ans);
		}
	}
}

class Sol{
	int ans;
	public int Ans{
		get{return ans;}
	}
	
	int V;
	int d;
	const int N=1001;
	int[] F;
	bool[] alive;
	bool[,] ARR;
	int cnt;
	public Sol(int Vin,int din){
		V=Vin;d=din;
		F=new int[V+1];
		F[0]=1;F[1]=2;
		for(int i=2;i<=V;i++)F[i]=(F[i-1]+F[i-2])%N;
		ARR=new bool[V+1,V+1];
		
		for(int i=0;i<=V;i++){ARR[0,i]=ARR[i,0]=ARR[i,i]=false;}
		for(int i=1;i<=V;i++){
			for(int j=i+1;j<=V;j++){
				ARR[i,j]=ARR[j,i]=false;
				if(F[i]>F[j] && F[i]-F[j]<d)ARR[i,j]=ARR[j,i]=true;
				if(F[i]<=F[j] && F[j]-F[i]<d)ARR[i,j]=ARR[j,i]=true;
			}
		}
		alive =new bool[V+1];
		alive[0]=false;
		for(int i=1;i<=V;i++)alive[i]=true;

		ans=0;
		for(int i=1;i<=V;i++){
			if(alive[i]){
				cnt=0;
				DFS(i);
			}
		}
	}
	
	void DFS(int start){
		if(cnt==0)ans++;
		cnt++;
		for(int i=1;i<=V;i++){
			if(ARR[start,i] && alive[i]){
				alive[i]=false;
				DFS(i);
			}
		}
	}
}

Measured memory_bytes: 8220
#include<cstdio>
int main(){
    int n,sum=0,tmp;
    scanf("%d",&n);
    for(register int i=1;i<=n;i++){
        scanf("%d",&tmp);
        sum+=tmp;
    }
    if(sum%2==0){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
}

Measured memory_bytes: 128
import math
 
K = int(input())
 
lis = tuple([i for i in range(1,K+1)])
a = 0
 
for i in lis:
    for j in lis:
        i_j= math.gcd(i,j)
        for k in lis:
            i_k = math.gcd(i,k)
            i_j_k = math.gcd(i_j,i_k)
            a += i_j_k
print(a)

Measured memory_bytes: 67824
#include <iostream>
using namespace std;
int main(){
  char a,b;
    cin >> a>> b;
    if(a=='H'){
        cout << b << endl;
    }
    else if(a=='D' && b == 'H'){
        cout << "D" << endl;
    }
    else{
     cout << "H" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
float x1,y1,x2,y2,x3,y3,xp,yp;
float det,xe,ye;
main()
{
	while(~scanf("%f%f%f%f%f%f%f%f",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)){
		x1-=x3;
		y1-=y3;
		x2-=x3;
		y2-=y3;
		xp-=x3;
		yp-=y3;
		det=x1*y2-x2*y1;
		xe=(xp*y2-yp*x2)/det;
		ye=(yp*x1-xp*y1)/det;
		puts(xe>0&&ye>0&&xe+ye<1?"YES":"NO");
	}
}

Measured memory_bytes: 0
n = int(input())
H = list(map(int, input().split()))
flag = True
for i in range(n-1, 0, -1):
  if H[i]+1 < H[i-1]:
    print('No')
    flag = False
    break
  elif H[i]+1 == H[i-1]:
    H[i-1] -= 1
if flag:
  print('Yes')

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

int main()
{ 
   int a,b,c,x,y;
   cin>>a>>b>>c>>x>>y;
   int ans=2*c*max(x,y);
   for(int i=0;i<=max(x,y);i++){
       int cost=2*c*i+a*max(0,x-i)+b*max(0,y-i);
       ans=min(ans,cost);
   }
   
   cout<<ans<<endl;

   
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i];

	sort(all(v));
	cout << v[v.size() - 1] - v[0] << endl;
	return (0);
}


Measured memory_bytes: 3564
def main():
  s = ''.join(reversed(input()))
  multiplier = 1
  divisor = 10 ** 9 + 7
  list10 = list(range(10))
  list13 = list(range(13))
  p = [0] * 13
  np = [0] * 13
  rt = [i % 13 for i in range(121)]
  p[0] = 1
  for i in range(len(s)):
    if s[i] != '?':
      r = rt[int(s[i]) * multiplier]
      for j in list13:
        np[rt[j + r]] = p[j]
    else:
      r = 0
      for j in list10:
        for k in list13:
          np[rt[k + r]] += p[k]
        r = rt[r + multiplier]
    for j in list13:
      p[j] = np[j] % divisor
      np[j] = 0
    multiplier = rt[10 * multiplier]
  print(p[5])
main()

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

int main() {
  int N, K;
  int counter = 0;
  cin >> N >> K;
  
  for(int i=0; i<N; i++){
    int p;
    cin >> p;
    if(p < K-p){
      counter += p*2;
    }else{
      counter += (K-p)*2;
    }
  }
  
  cout << counter << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
    ll N;
  cin >>N;
  ll h[N];
  for(ll i=0;i<N;i++){
  cin >>h[i];
  }
ll dp[N];
  for(ll i=1;i<N;i++){dp[i]=INF;}
  dp[0]=0;

  for(ll i=0;i<N;i++){
	for(ll j=1;j<3;j++){
	    if(i-j>=0){dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));}
    }       

    // cout<<i<<";"<<dp[i]<<endl;
  }
  //  cout<<dp[i]<<endl;
    
  
  cout<<dp[N-1]<<endl;
  
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <stdio.h>
//#define int long long
using namespace std;
#define loop(n) for(int i=0;i<n;i++)
#define endl '\n'
#define OnlineJudgec
#define F first
#define S second
#define  precision(n)  cout << fixed << setprecision(n)
#define clr(v,d ) memset(v, d, sizeof(v))
typedef long long ll;
typedef vector<int> vi;
void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    cout.tie(0);
    #ifdef OnlineJudge
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}
ll S(ll x){ll s = 0;while(x){s += x % 10;x /= 10;}return s;} /// sum of digits.
ll powe(ll a , ll n){if(n == 1)return a;return a * powe(a ,n-1);}
ll com(int n,int m){ll z = 1;for(int i = 0; i < m;i++){z = z * ( n - i) / (i + 1) ;}return z;}
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int dr[] = {0,0,0,1,1,1,-1,-1,-1};
int dc[] ={-1,0,1,-1,0,1,-1,0,1};
/// <<------------------------------------------------------------------------------>>
const int N = 1009;
int n,m;
int MOD = int(1e9) + 7;
char arr[N][N];
ll dp[N][N];
bool valid(int i ,int j)
{
    return (i < n && j < m && arr[i][j] == '.');
}
ll solve(int i , int j)
{
    if(!valid(i,j))
        return 0;
    if(i == n -1 && j == m - 1)
        return 1;
    ll &rst = dp[i][j];
    if(~rst)
        return rst;
    rst = solve(i+1,j) % MOD;
    rst += solve(i,j+1)% MOD;
    return rst % MOD;
}
/// <<------------------------------------------------------------------------------>>
int main()
{
    init();
    cin >> n >> m;
    for(int i = 0 ;i < n;i++)
    {
        for(int j = 0 ;j < m ;j++)
            cin >> arr[i][j];
    }
    clr(dp,-1);
    cout<<solve(0,0);
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
    using namespace std;
    int main(){
    	int a,b,c;
      cin>>a>>b>>c;
      int s=(a+b+c)/2;
      int area=sqrt(s*(s-a)*(s-b)*(s-c));
      cout<<area<<endl;
      return 0;
    }

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

using namespace std;

int n_digit(long long x) {
	if (x == 0) {
		return 1;
	}
	int ret = 0;
	while (x > 0) {
		ret++;
		x /= 10;
	}
	return ret;
}

int f(long long a, long long b) {
	return max(n_digit(a), n_digit(b));
}

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

	int x = sqrt(n);
	while (x > 0) {
		if (n % x == 0) {
			break;
		}
		x--;
	}

	cout << f(n / x, x) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		List<Integer> array = new ArrayList<Integer>();

		while (true) {
			Integer n = sc.nextInt();
			if (0 == n.intValue()) {
				break;
			}
			array.add(n);
		}

		for (int i = 0; i < array.size(); i++) {
			System.out.println("Case " + (i + 1) +  ": " + array.get(i));
		}

		sc.close();
	}

}

Measured memory_bytes: 43472
N = int(input())
A = list(map(int, input().split()))

four = 0
two = 0
one = 0
for i in range(N):
  if A[i] % 4 == 0:
    four += 1
  elif A[i] % 2 == 0:
    two += 1
  else:
    one += 1
    
if four >= one:
  print("Yes")
elif (four + 1 == one) and (two == 0):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#include <math.h>
#define ll long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define rep(i, init, n) for (int i = init; i < n; i++)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define gcd __gcd
# define M_PI 3.14159265358979323846
using namespace std;
const ll mod = 1e9 + 7;
const int N = 1e5 + 4;
const ll MOD = 998244353;
bool visited[N];
vector<int> edge[N];
vector<int> conc[N];
int c = 0;

ll POW(ll base, ll exponent){
    ll result = 1;
    while (exponent > 0)
    {
        if (exponent % 2 == 1)
            result = (result * base) % mod;
        exponent = exponent >> 1;
        base = (base * base) % mod;
    }
    return result;
}

ll Inv(ll x){
    return POW(x, MOD - 2);
}

void DFS(int src){
    visited[src] = 1;
    conc[c].pb(src);
    for(auto i : edge[src]){
        if(!visited[i]) DFS(i);
    }
}

void BFS(int s, vector<int> &d){
    d[s] = 0;
    queue<int> q;
    q.push(s);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto to : edge[v]) {
            if (d[to] == N){
                d[to] = d[v] + 1;
                q.push(to);
            }
        }
    }
}

int main(){
    IOS
    int n;
    cin>>n;
    n = n % 10;
    if(n == 3) cout<<"bon";
    else if(n == 0 or n == 1 or n == 6 or n == 8) cout<<"pon";
    else cout<<"hon";
    return 0;
}

Measured memory_bytes: 8340
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    n%=10;
    if(n==2||n==4||n==5||n==7||n==9)
        printf("hon\n");
    else if(n==0||n==1||n==6||n==8)
        printf("pon\n");
    else
        printf("bon\n");
    return 0;
}


Measured memory_bytes: 1616
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i-1]-h[i]))
print(dp[-1])


Measured memory_bytes: 13980
#include <stdio.h>
int main(void){
    // Your code here!
    char s[100];
    int n, i, a=0;
    
    scanf("%d",&n);
    scanf("%s",s);
    
    for(i=0;i<n;i++){
        if((s[i]=='A')&&(s[i+1]=='B')&&(s[i+2]=='C')) a++;
    }
    printf("%d\n",a);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e9+7;

struct Matrix
{
    int a[51][51];
    Matrix()
    {
        memset(a,0,sizeof(a));
    }
};

Matrix operator *(Matrix a,Matrix b)
{
    Matrix c;

    for(int i=0;i<=50;i++)
        for(int j=0;j<=50;j++)
            for(int k=0;k<=50;k++)
                c.a[i][j]= (c.a[i][j]+(a.a[i][k]*b.a[k][j]))%mod;
    return c;

}

void ht(Matrix a)
{
    for(int i=0;i<=50;i++)
        {
            for(int j=0;j<=50;j++)
            cout<<a.a[i][j]<<" ";
                cout<<endl;
        }
}

Matrix a;

Matrix pw(int n)
{
    if(n==1) return a;
    Matrix c=pw(n/2);
    if(n%2) return c*c*a;
    else return c*c;
}

 main()
{
  //  freopen("CPATH.inp","r",stdin);
  //  freopen("CPATH.out","w",stdout);
    int x,y,n,m,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
          cin>>a.a[i][j];
    }
   // ht(a*a);

    Matrix def=pw(k);
    long long res=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
          {
            res=(res+def.a[i][j])%mod;
          }
    }
    cout<<res;
}


Measured memory_bytes: 7552
#include<stdio.h>
int main(void)
{
	int m,n,x;
	1<=m && m<=1000;
	scanf("%d",&n);
	while(n!=0) {
		x=0;
		m=1000-n;
		while(!(m<500)) {
			m=m-500;
			x+=1;
		}
		while(!(m<100)) {
			m=m-100;
			x+=1;
		}
		while(!(m<50)) {
			m=m-50;
			x+=1;
		}
		while(!(m<10)) {
			m=m-10;
			x+=1;
		}
		while(!(m<5)) {
			m=m-5;
			x+=1;
		}
		while(!(m<1)) {
			m=m-1;
			x+=1;
		}
		printf("%d\n",x);
	scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define de(c) cout << #c << " = " << c << endl
#define dd(c) cout << #c << " = " << c << " "
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int maxn = 1e5 + 1000;

string str;
int ans1[maxn];
int ans2[maxn];
int ans[maxn];
int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> str;
	int n = str.size();
	VI l;
	VI R;
	int tl=0;
	int tr=0;
	rep(i,0,n)
	{
		if(str[i] == 'L')
		{
			if(tr)
			{
				R.pb(i-1);
			}
			if(tl)
			{
				continue;
			}
			else
			{
				l.pb(i);
			}
			tl = 1;
			tr = 0;
		}
		else
		{
			tr = 1;
			tl = 0;
		}
	}
	// for(auto &v : l)
	// {
	// 	dd("*"),de(v);
	// }
	// for(auto &v : R)
	// {
	// 	de(v);
	// }
	int t1 = 0;
	int t2 = 0;
	int st = 0;
	int se = 0;
	int f = 1;
	rep(i,1,n)
	{
		if(str[i] == 'R')
		{
			if(f == 0)
			{
				ans2[t1] += (se-st+2)/2;
				ans1[t1++] += (se-st+1)/2;
				st = i;
				se = i;
				f = 1;
			}
			else
			{
				f = 1;
				se = i;
			}
		}
		else
		{
			if(f == 1)
			{
				ans1[t2] += (se-st+2)/2;
				ans2[t2++] += (se-st+1)/2;
				st = i;
				se = i;
				f = 0;
			}
			else
			{
				f = 0;
				se = i;
			}
		}
	}
	ans2[t1] += (se-st+2)/2;
	ans1[t1++] += (se-st+1)/2;
	// de(t1),de(t2);
	// rep(i,0,t1)
	// {
	// 	de(ans1[i]);
	// 	de(ans2[i]);	
	// }
	int cnt = 0;
	for(auto &v:R)
	{
		ans[v] = ans1[cnt++]; 
	}
	cnt = 0;
	for(auto &v:l)
	{
		ans[v] = ans2[cnt++]; 
	}
	rep(i,0,n)
	{
		if(i == n-1)
		cout << ans[i] <<endl;
		else
		{
			cout << ans[i] << " ";
		}
	}
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tuple<int,int,int> iii;
typedef vector<iii> viii;

#define umap unordered_map
#define uset unordered_set
#define pb push_back
#define LSOne(x) (x & (-x))
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

const int iinf = 1e9+7;
const ll inf = 1e18+7;

const int nax = 405;

ll dp[nax][nax];
// dp[i][j] - minimum cost of combining slimes i to j

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n; cin >> n;
    vi v(n);
    auto sum = [&](int i, int j) {
        ll ret = 0;
        for (int x = i; x <= j; ++x) ret += v[x];
        return ret;
    };
    for (auto& i : v) cin >> i;
    for (int i = n-1; i >= 0; --i)
        for (int j = i; j < n; ++j) {
            if (i == j) {
                dp[i][j] = 0;
            } else {
                dp[i][j] = inf;
                ll k = sum(i,j);
                for (int x = i; x < j; ++x) {
                    dp[i][j] = min(dp[i][j], dp[i][x] + dp[x+1][j] + k);
                }
            }
        }
    cout << dp[0][n-1] << endl;
}


Measured memory_bytes: 1536