akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>   
using namespace std;
#define N 50   
#define REP(i, n) for(int i=0; i<n; i++)
int h,w;
string str[N];
string str2[N];

int main(void){

    cin >> h;
    cin >> w;

    REP(i,h){
        cin >> str[i];
    }
    REP(i,h){
        REP(j,w){
           int num=0;
            if(str[i][j]=='.'){
                if(i>=1&&j>=1){
                    if(str[i-1][j-1]=='#') num++;         
                }
                if(i>=1){
                   if(str[i-1][j]=='#')num++;
                }
                if(i>=1&&j<=w-2){
                   if(str[i-1][j+1]=='#')num++;
                }
                if(j>=1){
                   if(str[i][j-1]=='#')num++;
                }
                if(j<=w-2){
                    if(str[i][j+1]=='#')num++;
                }
                if(i<=h-2&&j>=1){
                    if(str[i+1][j-1]=='#')num++;
                }
                if(i<=h-2){
                    if(str[i+1][j]=='#') num++;
                }
                if(i<=h-2&&j<=w-2){
                   if(str[i+1][j+1]=='#')num++;
                }
                 str[i][j]=char(num+'0');
            }else{
             str[i][j]='#';   
            }
        }
    }
    
    REP(i,h){
        REP(j,w)printf("%c",str[i][j]);
        printf("\n");
    }
  //  for (int i = 0; i < h; ++i) cout << str[i] << endl;

    return 0;
}


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

int main(){
    int V,E;
    cin>>V>>E;
    int G[V][V];
    fill(G[0],G[V],-1);
    for(int i=0;i<E;i++){
        int s,t,d;
        cin>>s>>t>>d;
        G[s][t]=d;
    }
    int dp[1<<V][V];
    fill(dp[0],dp[1<<V],1e8);
    dp[(1<<V)-1][0]=0;
    for(int S=(1<<V)-2;S>=0;S--){
        for(int v=0;v<V;v++){
            for(int u=0;u<V;u++){
                if(G[v][u]==-1){
                    continue;
                }
                if(!(S&(1<<u))){
                    dp[S][v]=min(dp[S][v],dp[S|(1<<u)][u]+G[v][u]);
                }
            }
        }
    }
    cout<<(dp[0][0]==1e8?-1:dp[0][0])<<endl;
}

Measured memory_bytes: 5024
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using LL = long long int;
using info = pair<int, int>;

int main (void) {
  int n, h;
  cin >> n >> h;
  vector<info> katanas(n * 2);
  REP(i, n) {
    int a, b;
    cin >> a >> b;
    katanas[2 * i] = make_pair(a, true);
    katanas[2 * i + 1] = make_pair(b, false);
  }
  sort(ALL(katanas), greater<info>());
  // REP(i, n * 2) {
  //   cerr << katanas[i].first << ", " << katanas[i].second << endl;
  // }
  int rest = h;
  REP(i, n * 2) {
    int attack;
    bool is_kiru;
    tie(attack, is_kiru) = katanas[i];
    if (!is_kiru) {
      rest -= attack;
      if (rest <= 0) {
        cout << i + 1 << endl;
        return 0;
      }
    } else {
      if (rest % attack == 0)
        cout << i + rest / attack << endl;
      else
        cout << i + 1 + rest / attack << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<math.h>
#include<stdio.h>
#include<string.h>
using namespace std;
const int mod=1000000007;
long long n,m,p;
long long bin[23];
int f[2][23][1048580];
long long c[23][23];
inline int modify(int s,int i){
	if(s&bin[i]){
		return s;
	}
	int w=s&(bin[n]-bin[i]);
	if(w){
		s-=w&(-w);
	}
	return s+bin[i];
}
int main(){
	cin>>n>>m>>p;
	n--;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			c[i][j]=-1;
		}
	}
	for(int i=1;i<=p;i++){
		int x,y,z;
		cin>>x>>y>>z;
		c[x][y]=z;
	}
	bin[0]=1;
	for(int i=1;i<=n;i++){
		bin[i]=bin[i-1]*2;
	}
	int now=0;
	f[0][0][0]=1;
	for(int i=1;i<=m;i++){
		for(int j=0;j<=n-1;j++){
			for(int s=0;s<=bin[n]-1;s++){
				if(f[now][j][s]){
					if(c[i][j+1]<=0&&!(s&bin[j])){
						f[now][j+1][s]=(f[now][j+1][s]+f[now][j][s])%mod;
					}
					if(c[i][j+1]!=0){
						int x=modify(s,j);
						f[now][j+1][x]=(f[now][j+1][x]+f[now][j][s])%mod;
					}
				}
			}
		}
		memset(f[now^1],0,sizeof(f[now^1]));
		for(int s=0;s<=bin[n]-1;s++){
			f[now^1][0][s]=f[now][n][s];
		}
		now^=1;
	}
	long long ans=0;
	for(int s=0;s<=bin[n]-1;s++){
		ans=(ans+f[now][0][s])%mod;
	}
	cout<<ans<<endl;
	return 0;
}
/*

in:
3 2 1
1 2 0

out:
6

*/

Measured memory_bytes: 188672
K = int(input())

powlis = [7*pow(10, i, K) for i in range(K)]
for i in range(K-1):
    powlis[i+1] = (powlis[i] + powlis[i+1]) % K
powlis[0] %= K


try:
    print(powlis.index(0) + 1)
except:
    print(-1)

Measured memory_bytes: 48504
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  ll M;
  cin >> N >> M;
  ll A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  map<ll,int> mp;
  ll R[N+1];
  R[0] = 0;
  mp[0]++;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    R[i+1] = R[i] + A[i];
    R[i+1] %= M;
    ans += mp[R[i+1]];
    mp[R[i+1]]++;
  }
  cout << ans << endl;
  return 0;
}

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

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009


using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}



int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> k)
    {
        queue < ll > qq;

        for(i = 1; i <= 9; i++) qq.push(i);

//        k = j;
        while(k--)
        {
            ans = qq.front();
            qq.pop();

            ll x = ans % 10;

//            cout << ans << endl;
            if(qq.size() > k) continue;

            if(ans % 10 != 0)
            {
                qq.push((ans * 10) + x - 1);
//                cout << (ans * 10) + x - 1 << " ";
            }

            qq.push((ans * 10) + x);

//            cout << (ans * 10) + x << " ";

            if(ans % 10 != 9)
            {
                qq.push((ans * 10) + x + 1);
//                cout << (ans * 10) + x + 1;
            }

//            cout << endl;
        }

        cout << ans << endl;
    }


}




Measured memory_bytes: 768
N,K= map(int,input().split())
P=list(map(int,input().split()))
mx=0
for i in range(K):
 mx+=(P[i]+1)/2
 now=mx
if N>K:
 for j in range(N-K):
  now=now+((P[K+j]+1)/2)-((P[j]+1)/2)
  mx=max(mx,now)
print(mx)

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

        //入力を受け取る
        int N = sc.nextInt();
        
        boolean judge = false;
        for(int i=1;i<=50000;i++) {
        	double pre = i*1.08;
        	if((int)pre == N) {
        		System.out.println(i);
        		judge = true;
        		break;
        	}
        }
        if (!judge) {
        	System.out.println(":(");
        }
    }
}

Measured memory_bytes: 21972
a = input()
for i in range(len(a) // 2):
    if a[i] != a[-(i+1)]:
        print("No")
        exit()
b = a[0:(len(a) - 1) // 2]
c = a[(len(a) + 3) // 2 - 1:len(a)]
for i in range(len(b) // 2):
    if b[i] != b[-(i+1)]:
        print("No")
        exit()
for i in range(len(c) // 2):
    if c[i] != c[-(i+1)]:
        print("No")
        exit()
print("Yes")

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

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


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

int main(){
  string s;
  int cc[26] = {};
  
  cin >> s;

  for(int i=0;i<s.size();i++) cc[s[i]-'a']++;

  bool flag = true;
  for(int i=0;i<26;i++) flag &= cc[i]%2 == 0;

  puts(flag?"Yes":"No");
  
  return 0;
}


Measured memory_bytes: 256
N, X, M = map(int, input().split())
record_sum = [0, ]
flag = [False for _ in range(M)]
An = X

# n=1
record_sum.append(An)
flag[An] = 1

for i in range(2, M + 2):
    An = pow(An, 2, M)  # 　(An ** 2) % Mと等価
    record_sum.append(record_sum[-1] + An)

    if flag[An]:
        start_index = flag[An]
        initial_cost = record_sum[start_index - 1]
        cycle_cost = record_sum[-1] - record_sum[start_index]
        cycle_length = i - start_index
    else:
        flag[An] = i

if start_index >= N:
    print(record_sum[N])

else:
    ans = 0
    ans += ((N - start_index) // cycle_length) * cycle_cost
    ans += record_sum[(N - start_index) % cycle_length + start_index]

    print(ans)


Measured memory_bytes: 16464
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;

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


Measured memory_bytes: 3084
#include "bits/stdc++.h"

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type,Name, n,m,d)vector<vector<Type>> Name(n, vector<Type>(m, d))
#define P pair
using namespace std;
using ll = long long;


int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	int a, b;
	cin >> a >> b;
	cout << 6 - a - b << endl;


	return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =999999999;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




//10億7。　　　100000007
//2*2行列 H*W
//vector<vector<int>> vec(H,vector<int>(W));
//for(int i=0;i<H;i++){
//for(int j=0;j<W;j++){
//cin>>vec[i][j];
//  }
//}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit(a)
//pair宣言　pair<int,int> p(5,7);
//ソート　sort(vec.begin(),vec.end());



int main(){
cout<<fixed<<setprecision(10);

  
  int X,Y;cin>>X>>Y;
  cout<<X+Y/2<<endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <iomanip>
#include <cstring>
#include <climits>
#include <cstdio>

#define nl '\n'

using namespace std;

string s, a, b;

bool pal(string x){
    for(long long i = 0; i < x.length(); i++){
        if(x[i] != x[x.length()-1-i]){
            return false;
        }
    }
    return true;
}

int main(){

    cin >> s;

    for(long long i = 0; i < ((s.length()-1)/2); i++){
        a.push_back(s[i]);
    }

    for(long long i = ((s.length()+3)/2)-1; i < s.length(); i++){
        b.push_back(s[i]);
    }

    if(pal(s) && pal(a) && pal(b)){
        cout << "Yes";
        return 0;
    }

    cout << "No";
}
 
//g++ -std=c++14 comp.cpp -o c && c.exe
//g++ -std=c++14 comp.cpp -o c; ./c.exe
//g++ -std=c++14 comp.cpp && ./a.out


//Surely this is going to AC

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long double PI = 3.14159265358979323846;

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

    string s;
    getline(cin, s);
    if (s == "ABC") {
        cout << "ARC\n";
    } else {
        cout << "ABC\n";
    }

    return 0;
}


Measured memory_bytes: 3636
using System;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int a = int.Parse(input[0]), b = int.Parse(input[1]), c = int.Parse(input[2]);
            if ((b - a) == (c - b))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
using namespace std;
typedef long long ll;
ll n, a, b, h[210000], lar, res;

void func(ll x, ll y){
    if (y - x <= 1) {
        res = y;
    } else {
        ll mid = (x + y) / 2, s = 0;
        for (ll i = 0; i < n; i++) {
            s += (h[i] > mid * b ? (h[i] - mid * b - 1) / (a - b) + 1 : 0);
        }
        if (mid < s) {
            func(mid, y);
        } else {
            func(x, mid);
        }
    }
}

int main(void){
    // Your code here!
    cin >> n >> a >> b;
    for (ll i = 0; i < n; i++) {
        cin >> h[i];
        lar = max(lar, h[i]);
    }
    func(0, (lar - 1) / b + 1);
    cout << res << endl;
}


Measured memory_bytes: 1024
n = int(input())
a = ord('a')

def f(x: str) -> str:
  return chr(int(x) + a)

i = 0
while i < 10 ** (n-1):
  x = str(i).zfill(n)
  maximum = 0
  flag = True
  for j, digit in enumerate(map(int, x)):
    if digit > maximum + 1:
      flag = False
      break
    elif digit == maximum + 1:
      maximum = digit
  if flag:
    print(''.join(map(f, x)))
    i += 1
  else:
    d = 10 ** (n - j)
    i = (i // d + 1) * d

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int N = 1e5 + 10;

int n, m;

VI edge[N];

VI l, r;

bool vis[N];

int main()
{
	gii(n, m);
	for (int i = 1; i <= m; ++i)
	{
		int u, v;
		gii(u, v);
		edge[u].pb(v);
		edge[v].pb(u);
		if (i == 1) vis[u] = vis[v] = 1, l.pb(u), r.pb(v);
	}
	while (1)
	{
		int x = -1;
		for (auto v : edge[l.back()])
			if (!vis[v]) x = v;
		if (x == -1) break;
		l.pb(x); vis[x] = 1;
	}
	while (1)
	{
		int x = -1;
		for (auto v : edge[r.back()])
			if (!vis[v]) x = v;
		if (x == -1) break;
		r.pb(x); vis[x] = 1;
	}
	printf("%d\n", SZ(l) + SZ(r));
	reverse(ALL(l));
	for (auto x : l)
		printf("%d ", x);
	for (auto x : r)
		printf("%d ", x);
	return 0;
}

Measured memory_bytes: 6776
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#define M 400010
#define Inf 2100000000
using namespace std;

typedef long long ll;

int n, m, Head[M], Next[M], Go[M], Val[M], Dis[M], Cnt = 0;

void addedge(int x, int y, int z) {
    Go[++Cnt] = y;
    Next[Cnt] = Head[x];
    Val[Cnt] = z;
    Head[x] = Cnt;
}

void DFS(int x) {
    for(int T = Head[x]; T; T = Next[T])
        if(Dis[Go[T]] == -Inf) {
            Dis[Go[T]] = Dis[x] + Val[T];
            DFS(Go[T]);
        }else if(Dis[Go[T]] != Dis[x] + Val[T]) {
                puts("No");
                exit(0);
            }
}

int main() {
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; i++) {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        addedge(x, y, z);
        addedge(y, x, -z);
    }
    for(int i = 1; i <= n; i++) Dis[i] = -Inf;
    for(int i = 1; i <= n; i++) if(Dis[i] == -Inf) {
        Dis[i] = 0;
        DFS(i);
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 8576
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			int times = sc.nextInt();
			Set<Long> set = new HashSet<Long>();
			for (int i = 0; i<times; i++){
				int query = sc.nextInt();
				long x = sc.nextLong();
				switch (query) {
				case 0:
					set.add(x);
					System.out.println(set.size());
					break;
				case 1:
					if (set.contains(x)) {
						System.out.println(1);
					} else System.out.println(0);
					break;
				case 2:
					set.remove(x);
					break;
				}
			}
		}
	}
}


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

int main() {
	int n;
	int a[200], ans = 0, ans2 = 100;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		ans = 0;
		while (a[i] % 2 == 0) {
			a[i] = a[i] / 2;
			ans++;
		}
		ans2 = min(ans2, ans);
	}
	cout << ans2 << endl;

	return 0;
}

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

using namespace std;

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, x, t;
  cin >> n >> x >> t;
  int cat = n / x + (n % x != 0);
  cout << cat * t;
}


Measured memory_bytes: 3648
#include<iostream>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n, m, flag, k;
int main() {
	scanf("%d%d%d", &n, &m, &k);
	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= m; j++) {
			int tmp = i * m + (n - i) * j - i * j;
			if(tmp == k)flag = 1;
		}
	}
	if(flag)printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

using namespace std;

#define int long long 

long long power(long long x, long long n, long long MOD){
	long long ans = 1;
	for(;n;n>>=1,x*=x,ans%=MOD,x%=MOD)
		if(n&1)ans*=x;
	return ans%MOD;
}


int solve4(int N, int K, int MOD){
	
	if(N > K*2) return power(K, N, MOD);
	
	N--;
	
	int res = 0;
	vector<vector<int>> dp(K, vector<int>((1<<(K*2-1)), 0));
	
	for(int i = 0; i < K; i++){
		dp[i][0] = 1;
	}
	
	for(int i = 0; i < 1<<(K*2-1); i++){
		for(int j = 0; j < K; j++){
			for(int k = 0; k < K; k++){
				int z = k - j + K - 1;
				if((i>>z)&1) continue;
				dp[k][i|(1<<z)] += dp[j][i];
				dp[k][i|(1<<z)] %= MOD;
			}
		}
	}
	
	for(int j = 0; j < 1<<(K*2-1); j++){
		int con = 0;
		for(int i = 0; i < (K*2-1); i++){
			if((j>>i)&1) con++;
		}
		
		if(con == N){
			for(int i = 0; i < K; i++){
					res += dp[i][j];
					res %= MOD;
			}
		}
	}
	
	res = power(K, N+1, MOD) - res + MOD;
	
	res %= MOD;
	
	return res;
}


signed main(){
	int N, K, M;
	
	cin>>N>>K>>M;
	
	cout<<solve4(N, K, M)<<endl;
}


Measured memory_bytes: 48028
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define sbits(a) __builtin_popcount(a)
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 1e5 + 1;
int A[N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll n;
    cin >> n;
    --n;
    cout << ((n * (n + 1)) >> 1);
    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    if (i >= K) {
      if (A.at(i) > A.at(i - K)) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
  }
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
#define keta(n) fixed<<setprecision(n)
using ll=int64_t;
using namespace std;
 
//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}
 
ll lcm(ll a,ll b){
    return a * b / gcd(a, b);
}
 
 
int main(){
    int n;
    double ans=0;
    cin>>n;
    vector<int> p(n);
    rep(i,n){
        cin>>p[i];
    }
    sort(p.begin(),p.end());
    rep(i,n){
        ans+=(p[i]/(pow(2,(n-i))));
    }
    ans+=(p[0]/(pow(2,n)));
    cout<<keta(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int a[200010]={0};
  int count = 0;
  for(int i = 0; i<S.size(); i++){
    if(S.at(i) == 'W'){
      a[count]+= i ;
      count++;
    }
  }
  int64_t sum ;
  for(int i = 0; i<count; i++){
    sum+= a[i]-i;
  }
  cout << sum << endl;
}

Measured memory_bytes: 1412
h, w = map(int, input().split())
a_matrix = [list(map(int, input().split())) for _ in range(h)]
ans_list = []
for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            if a_matrix[i][j] % 2 == 1:
                if j != w-1:
                    a_matrix[i][j+1] += 1
                    ans_list.append([i+1, j+1, i+1, j+2])
                elif j == w-1 and i != h-1:
                    a_matrix[i+1][j] += 1
                    ans_list.append([i+1, j+1, i+2, j+1])
    if i % 2 == 1:
        for j in range(w-1, -1, -1):
            if a_matrix[i][j] % 2 == 1:
                if j != 0:
                    a_matrix[i][j-1] += 1
                    ans_list.append([i+1, j+1, i+1, j])
                elif j == 0 and i != h-1:
                    a_matrix[i+1][j] += 1
                    ans_list.append([i+1, j+1, i+2, j+1])
print(len(ans_list))
for i in range(len(ans_list)):
    print(*ans_list[i])

Measured memory_bytes: 71132
#include <stdio.h>
#include <math.h>

int main(void)
{
	float d, t, s;

	scanf("%f %f %f", &d, &t, &s);

	float store = d / s;

	if (store <= t)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
}

Measured memory_bytes: 1712
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    long long N;
    cin >> N;
    vector<tuple<long long, long long, long long>> v(N);
    for(int i=0; i<N; i++){
        long long A, B;
        cin >> A >> B;
        v[i] = make_tuple(A+B, A, B);
    }
    sort(v.rbegin(), v.rend());

    long long ans = 0;
    for(int i=0; i<N; i++)
        if(i % 2 == 0)
            ans += get<1>(v[i]);
        else
            ans -= get<2>(v[i]);
    cout << ans << endl;
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int X,t;
    cin>>t>>X;
    printf("%.20f\n",1.0*t/X);
    return 0;
}


Measured memory_bytes: 256
n,q = map(int, input().split())
s = input()

nums = [0]*n
for i in range(n):
  if s[i] == "C":
    if s[i-1] == "A": nums[i] += 1
  if i != n-1: nums[i+1] = nums[i]

for _ in range(q):
  l,r = map(lambda x: int(x)-1, input().split())
  print(nums[r]-nums[l])

Measured memory_bytes: 11620
formula = gets
arr = formula.split(" ")
while arr.size != 1
	(arr.size).times do |i|
		if arr[i] == "+" and ((arr[i - 1] != "-" or arr[i - 1] != "*") and (arr[i - 2] != "-" or arr[i - 2] != "*"))
			arr[i] = arr[i - 2].to_i + arr[i - 1].to_i
			arr.delete_at(i - 1)
			arr.delete_at(i - 2)
			break
		elsif arr[i] == "-" and ((arr[i - 1] != "+" or arr[i - 1] != "*") and (arr[i - 2] != "+" or arr[i - 2] != "*"))
			arr[i] = arr[i - 2].to_i - arr[i - 1].to_i
			arr.delete_at(i - 1)
			arr.delete_at(i - 2)
			break
		elsif arr[i] == "*" and ((arr[i - 1] != "-" or arr[i - 1] != "+") and (arr[i - 2] != "-" or arr[i - 2] != "+"))
			arr[i] = arr[i - 2].to_i * arr[i - 1].to_i
			arr.delete_at(i - 1)
			arr.delete_at(i - 2)
			break
		end
	end
end
puts arr[0]

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

int main() {
  string S;
  cin >> S;
  int n = S.size();
  int a=0;
  if(n%2==1){a++;}
  else{
    n = n/2;
    for (int i = 0; i < n; i++){
      if(S.at(2*i)!='h'){a++;}
      if(S.at(2*i+1)!='i'){a++;}
    }
  }
  if(a==0){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
}


Measured memory_bytes: 256
/**
	������������ Author : Avi J Patel ������������
	������������ University : DA-IICT ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define N 100000
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define large 10000000000000001

#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
/*void calc()
{
	for(int i=0;i<2005;i++)
	{
		a[i][0]=1;
		a[i][i]=1;
		for(int j=1;j<i;j++)
		{
			a[i][j]=(a[i-1][j-1]+a[i-1][j])%MOD;	
		}
	}
}*/
int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	int temp=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i])
		temp=1;
	}
	if(temp==0)
	{
		cout<<0;
		return 0;
	}
	int cnt=0;
	vector<int> ans(n);
	for(int i=n-1;i>=0;i--)
	{
		if(i==n-1)
		{
			ans[i]=a[i];
			if(a[i])
			cnt++;
		}
		else
		{
			temp=0;
			for(int j=2*i+1;j<n;j+=i+1)
			{
				if(ans[j]==1)
				temp++;
			}
			if(a[i]%2==0 && temp%2==0)
			{
				ans[i]==0;
			}
			else if(a[i]%2==1 && temp%2==1)
			{
				ans[i]=0;
			}
			else if(a[i]%2==0 && temp%2==1)
			{
				ans[i]=1;
				cnt++;
			}
			else if(a[i]%2==1 && temp%2==0)
			{
				ans[i]=1;
				cnt++;
			}
		}
		//cout<<ans[i]<<" ";
	}
	cout<<cnt<<endl;
	for(int i=0;i<ans.size();i++)
	{
		if(ans[i])
		cout<<i+1<<" ";
	}
	return 0;
}









Measured memory_bytes: 2432
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
        sc.Scan()
        return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

func bitCount(n uint) int {

        x := uint64(n)

        const m = 1<<64 - 1
        const m0 = 0x5555555555555555
        const m1 = 0x3333333333333333
        const m2 = 0x0f0f0f0f0f0f0f0f

        x = x>>1&(m0&m) + x&(m0&m)
        x = x>>2&(m1&m) + x&(m1&m)
        x = (x>>4 + x) & (m2 & m)
        x += x >> 8
        x += x >> 16
        x += x >> 32

        return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
        return ((n >> uint(i)) & 1) == 1
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////
func dadd(a, b int) int {
        r := a + b

        return r % 1000000007
}
func strSpritp(str string) []string {
        cols := strings.Split(str, "")
        return cols
}

func main() {
        line := nextLine()

        spl := intSprit(line)

        H := spl[0]
        W := spl[1]

        dp := make([][]int, 1010)
        for i := 0; i < 1010; i++ {
                dp[i] = make([]int, 1010)
        }

        m := make([][]string, H)
        for i := 0; i < H; i++ {
                m[i] = strSpritp(nextLine())
        }
        dp[0][0] = 1

        for i := 0; i < H; i++ {
                for j := 0; j < W; j++ {
                        if i+1 < H && m[i+1][j] == "." {
                                dp[i+1][j] = dadd(dp[i+1][j], dp[i][j])
                        }
                        if j+1 < W && m[i][j+1] == "." {
                                dp[i][j+1] = dadd(dp[i][j+1], dp[i][j])
                        }
                }
        }
        fmt.Println(dp[H-1][W-1])
}

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

using namespace std;

int distribute(vector<int> a, int x)
{
    int ans = 0, i = 0;
    int size = a.size();
    while (x >= 0 && i < size)
    {
        x -= a[i];
        ans++;
        i++;
    }

    if (x != 0)
    {
        ans -= 1;
    }
    return ans;
}

int main()
{
    int N, x;
    cin >> N >> x;
    vector<int> a(N);

    for (int i = 0; i < N; i++)
    {
        int s;
        cin >> s;
        a[i] = s;
    }
    sort(a.begin(), a.end());
    cout << distribute(a, x) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N, A, B;
      // 最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよいです

int main() {
    cin >> N >> A >> B;
    if(N == 1) cout << "Hello World" << endl;
    else cout << A + B << endl;
}

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

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

  int n,a,b,c,d;cin>>n>>a>>b>>c>>d;
  string s;cin>>s;

  a--,b--,c--,d--;

  int ok=1;
  for(int i=a;i<c;i++){
    if(s[i]=='#'&&s[i+1]=='#'){
      ok=0;
    }
  }
  for(int i=b;i<d;i++){
    if(s[i]=='#'&&s[i+1]=='#'){
      ok=0;
    }
  }
  if(d<c){
    int b_jump=0;
    for(int i=b-1;i<d;i++){
      if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
        b_jump=1;
      }
    }
    ok=ok&&b_jump;
  }

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

  return 0;
}


Measured memory_bytes: 592
from itertools import accumulate

N = int(input())
S1 = list(map(int, input().split()))
S2 = list(map(int, input().split()))

S2 = list(reversed(S2))

s1 = list(accumulate(S1))
s2 = list(accumulate(S2))

s2 = list(reversed(s2))
s3 = [x + y for (x, y) in zip(s1, s2)]

print(max(s3))


Measured memory_bytes: 3064
// C - Poll
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	map<string, int> m;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		m[s]++;
	}
	vector<pair<int, string> > a;
	for (map<string, int>::iterator it = m.begin(); it != m.end(); ++it)
		a.push_back(make_pair(-it->second, it->first));
	sort(a.begin(), a.end());
	for (int i = 0; i < a.size(); i++) {
		if (i > 0 && a[i].first != a[i - 1].first) break;
		cout << a[i].second << endl;
	}

	return 0;
}


Measured memory_bytes: 29428
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {

        
        var NK = ReadLine().Split().Select(long.Parse).ToArray();
        var N = NK[0];
        var K = NK[1];
        var A = ReadLine().Split().Select(int.Parse).ToArray();
#if tru
        var B = new int[K*N];
        for (int i = 0; i < B.Length; i++)
        {
            B[i] = A[i % N];
        }
        var ans = 0;
        for (int i = 0; i < B.Length; i++)
        {
            for (int j = 0; j < B.Length; j++)
            {
                if (B[i] > B[j]) ans++;
            }
        }
        WriteLine(ans);
#else
        var mod = 1000000007L;
        var ans = 0L;
        var k = K * (K + 1) / 2 % mod;
        var t = K * (K - 1) / 2 % mod;
        //Console.WriteLine(k);
        for (int i = 0; i < N; i++)
        {
            for (int j = i + 1; j < N; j++)
            {
                if (A[i] > A[j])
                {
                    ans = (ans + k) % mod;
                }
                if(A[i]<A[j])
                {
                    ans = (ans + t) % mod;
                }
            }
        }
        WriteLine(ans);
#endif
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>> vec(n,vector<int>(m));
  rep(i,n)rep(j,m) cin>>vec[i][j], vec[i][j]--;

  if(n==1){
    cout << 1 << endl;
    return 0;
  }
  if(m==1){
    cout << n << endl;
    return 0;
  }

  int l=0, r=n;
  while(r-l>1){
    int mid = (l+r)/2;
    auto f = [&](){
      vector<bool> used(m,false);
      vector<vector<int>> keep(m);
      vector<int> p(n,0);
      rep(i,n) keep[vec[i][0]].pb(i);
      set<pair<int,int>> nums;
      rep(i,m) if(keep[i].size()>0) nums.insert(mp(keep[i].size(), i));

      while( (--end(nums))->fi > mid ){
        pair<int,int> pr = *(--end(nums));
        nums.erase(pr);
        used[pr.se] = true;
        for(auto i : keep[pr.se]){
          while(p[i] < m && used[vec[i][p[i]]]) p[i]++;
          if(p[i]==m) return false;
          int x = vec[i][p[i]];
          nums.insert(mp(keep[x].size()+1, x));
          if(keep[x].size()>0){
            nums.erase(mp(keep[x].size(), x));
          }
          keep[x].pb(i);
        }
      }
      return true;
    };

    if(f()) r = mid;
    else l = mid;
  }

  cout << r << endl;

  return 0;
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define PI pair<int , int>
#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

//#define max(a,b) a>b?a:b
//#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

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

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

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	int n,x,t;
	cin>>n>>x>>t;
	cout<<(ll)t*(int)ceil((double)n/x);
    return 0;
}


Measured memory_bytes: 3632
import math
r = 10000
sqrt = int(math.sqrt(r))
p = [1 for i in range(r)]
p[0] = 0
for i in range(sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0 for j in range(2*i+1,r,i+1)]
prime = []
for i in range(r):
    if p[i]:
        prime.append(i)

while True:
    try:
        n = int(raw_input())
        count = 0
        for i in prime:
            if i > n-1:
                break
            if p[i]*p[n-i-1] == 1:
                count += 1
        print count
    except:
        break

Measured memory_bytes: 4764
N, P = map(int, input().split())

def prime_factor(n):
    res = {}
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            res[i] = res.get(i, 0) + 1
            n //= i
    if n != 1:
        res[n] = 1
    return res
            
ans = 1
for k, v in prime_factor(P).items():
    if v >= N:
        ans *= (k ** (v // N))

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define v vector<ll>
#define vv vector<v>
#define p pair<ll,ll>
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    v a(n+1,-1),b(n+1,-1),c(n+1,-1);
    for (int i=1; i<=n; i++)
    	cin>>a[i]>>b[i]>>c[i];
    vv dp(n+1,v(4,0));
    for (int i=1; i<=n; i++)
    {
    	dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i];
    	dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b[i];
    	dp[i][3]=max(dp[i-1][2],dp[i-1][1])+c[i];
    }
    cout<<max(dp[n][1],max(dp[n][2],dp[n][3]))<<endl;
	return 0;
}

Measured memory_bytes: 9600
def main():
    S = input()

    cnt_A = 0
    cnt_B = 0

    for i in range(len(S)):
        if S[i] == "A":
            cnt_A += 1
        else:
            cnt_B += 1

    if cnt_A == 3 or cnt_B == 3:
        print('{}'.format('No'))
    else:
        print('{}'.format('Yes'))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
/***************************************************************************************
 * There is a data which provides heights (in meter) of mountains.
 * The data is only for ten mountains.
 *
 * Write a program which prints heights of the top three mountains in descending order.
 ***************************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define DATA_SIZE   (10)
#define SEARCH_CNT  (3)
#define TOP3        (3)

static int* allocateInputData(size_t size);
static int* findTop3OfHeight(size_t size, const int *data);
static void putsData(const int *data);
static int cmp( const void *p, const void *q );

int main(void)
{
    int *vec = NULL;
    int *top3 = NULL;

    vec = allocateInputData(DATA_SIZE);
    top3 = findTop3OfHeight(TOP3, vec);
    putsData(top3);

    free(vec);
    free(top3);

    return 0;
}

static int* allocateInputData(size_t size)
{
    int i = 0;
    int *arr = (int *) malloc(size * sizeof(int));

    if ( NULL != arr ) {
        for (i = 0; i < DATA_SIZE; i++) {
            scanf("%d", &arr[i]);
        }
    }

    return arr;
}

static int* findTop3OfHeight(size_t size, const int *data)
{
    int i = 0;
    int *t = NULL;
    int *arr = NULL;

    if ( NULL != data) {
        t = (int *) malloc( DATA_SIZE * sizeof(int));
        for ( i = 0; i < DATA_SIZE; i++ ) {
            t[i] = data[i];
        }
        qsort(t, DATA_SIZE, sizeof(int), cmp);
        arr = (int *) malloc( size * sizeof(int));
        if ( NULL != arr ) {
            for ( i = 0; i < SEARCH_CNT; i++ ) {
                memcpy(&arr[i], &t[i], sizeof(int));
            }
        }

        free(t);
    }

    return arr;
}

static void putsData(const int *data)
{
    int i = 0;

    for ( i = 0; i < TOP3; i++ ) {
        printf( "%d\n", data[i]);
    }
}

static int cmp( const void *p, const void *q )
{
    return *(int*)q - *(int*)p;
}

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

int main() {

	int N;
	cin >> N;

	if (N == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int A, B;
		cin >> A >> B;
		cout << A + B << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int i,n,p;
	
	scanf("%d",&n);
	p=100000;
	for(i=1;i<=n;i++)
	{
		p=p*105/100;
		if(p%1000==0)
		{
		   p/=1000;
		   p*=1000;
		}
		else
		{
			p/=1000;
			p+=1;
			p*=1000;
		}
	}
	printf("%d\n",p);
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
//ll const INF=1001001001;
//ll const INF=1001001001001001001;
ll const MOD=1000000007;

ll K,A,B;

int main(){
    cin>>K>>A>>B;

    ll ans=0;
    ans=max(ans,1+K);
    if(A+1<B){
        ll res=A+(K-(A-1))/2*(B-A);
        if((K-(A-1))%2==1) res++;
        ans=max(ans,res);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
int main(){
    long long N;
    cin >> N;
    map<P, long long> m;
    for(int i = 1; i <= N; i++){
        int t = i % 10;
        int s = i;
        while(s >= 10){
            s /= 10;
        }
        if(t == 0) continue;
        m[P(s, t)]++;
    }
    long long ans = 0;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            ans += m[P(i, j)]*m[P(j, i)];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# 入力を格納
C = [list(map(int, input().split())) for _ in range(3)]

# a, bをリストとして準備
a = [0] * 3
b = [0] * 3

# a1=0ならば、b1, b2, b3はC[0]に該当
b[0], b[1], b[2] = C[0][0], C[0][1], C[0][2]

# Cとbの値からa1, a2, a3の値を求める
a[0], a[1], a[2] = 0, C[1][0] - b[0], C[2][0] - b[0]

# Cとai+biを比較し、いずれかのケースで一致いない場合は出力を”No"とする
ans = "Yes"
for i in range(3):
    for j in range(3):
        if C[i][j] == (a[i] + b[j]):
            pass
        else:
            ans = "No"
            break

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <cstdlib>
using namespace std;

typedef pair<int,int> pii;
#define fi first
#define se second

int main() {
	int n, m;
	while(cin >> m >> n, m || n) {
		vector<pii> query;
		vector<int> ans;
		for(int i = 0; i < n; i++) {
			int t;
			cin >> t;
			query.push_back(pii(t,i+1));
		}

		queue<pii> cq;
		vector<stack<pii> > park;
		for(int i = 0; i < m; i++)
			park.push_back(stack<pii>());
		for(int i = 0; i < 20000; i++) {
			if(i % 10 == 0 && i / 10 < query.size()) {
				cq.push(query[i/10]);
			}
			// out
			for(int j = 0; j < m; j++) {
				while(!park[j].empty() && park[j].top().fi <= i) {
					ans.push_back(park[j].top().se);
					park[j].pop();
				}
			}
			// in
			while(!cq.empty()) {
				bool flg = true;
				bool bkflg = true;
				for(int j = 0; j < m && flg; j++) {
					if(park[j].empty()) {
						park[j].push(cq.front());
						park[j].top().fi += i;
						cq.pop();
						flg = false;
					}
					bkflg &= park[j].size() == 2;
				}
				
				int mn = 20000, indx = -1;
				for(int j = 0; j < m && flg && !bkflg; j++) {
					if(park[j].size() == 1 && park[j].top().fi > i + cq.front().fi) {
						if(mn > abs(park[j].top().fi - (i + cq.front().fi))) {
							mn = abs(park[j].top().fi - (i + cq.front().fi));
							indx = j;
						}
					}
				}

				if(indx != -1) {
					park[indx].push(cq.front());
					park[indx].top().fi += i;
					cq.pop();
					flg = false;
				}

				for(int j = 0; j < m && flg && !bkflg; j++) {
					if(park[j].size() == 1) {
						if(mn > abs(park[j].top().fi - (i + cq.front().fi))) {
							mn = abs(park[j].top().fi - (i + cq.front().fi));
							indx = j;
						}
					}
				}

				if(flg && !bkflg) {
					park[indx].push(cq.front());
					park[indx].top().fi += i;
					cq.pop();
				}

				if(bkflg)
					break;
			}
		}

		for(int i = 0; i < ans.size() - 1; i++) {
			cout << ans[i] << " ";
		}
		cout << ans.back() << endl;
	}
}

Measured memory_bytes: 1236
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <iostream>
#include <string>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <queue>
#include <deque>
#include <math.h>
#include <cmath>
#include <stack>
#include <algorithm>
#include <list>
#include <array>
#include <valarray>
#include <unordered_map>
#include <cassert>
#include <random>
#include <cstring>

using namespace std;

typedef long long li;
typedef pair<int, int> pii;

#define X first
#define Y second
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

double eps = 1e-5;
const int INF = 1e9 + 7;
const li LINF = 9e18 + 7;


int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	int n, a, b;
	cin >> n >> a >> b;

	int t = abs(a - b);

	if (t % 2 == 0) {
		cout << "Alice";
	}
	else {
		cout << "Borys";
	}
	cout << endl;
}

Measured memory_bytes: 256