akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 1 * 1e6 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int n, m, x;
int g[13], v[13][13];
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    cin >> n >> m >> x;
    fore(i, 0, n){
        cin >> g[i];
        fore(j, 0, m)
            cin >> v[i][j]; 
    }
    ll ans = 2e9;
    for(int i = 0; i < (1 << n); i++){
        vi arr(m, 0);
        ll cur = 0;
        for(int j = 0; j < n; j++){
            if(i & (1 << j)){
                fore(k, 0, m)
                    arr[k] += v[j][k];
                cur += g[j];
            }
        }
        bool flag = 1;
        fore(j, 0, m)
            flag &= (arr[j] >= x);
        if(flag)
            ans = min(ans, cur);
        
    }
    if(ans == 2e9)
        ans = -1;
    cout << ans << '\n';
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}   

Measured memory_bytes: 3812
# _*_ coding:utf-8 _*_

import sys

input = [int(i) for i in sys.stdin.readline().split(' ')]
input_matrix = []

for i in range(input[0]):
	input_matrix.append(sys.stdin.readline().replace('\n',''))

for i in range(input[1] + 2):
	print('#',end='')
print()

for i in range(input[0]):
	print('#',end='')
	print(input_matrix[i],end='')
	print('#',)
	
for i in range(input[1] + 2):
	print('#',end='')
	


Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
	int a,b,c,i,min,sum;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	sum = c-b;
	if(c<b)
		min=c;
	else
		min=b;
	for(i=2;i<a;i++){
		scanf("%d",&b);
		if(sum < b - min)
			sum = b - min;
		if(min > b)
			min = b;
	} 
	printf("%d\n",sum);
	return 0;
}
		
		

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

int main(){
  int N;
  cin>>N;
  vector<int>L(N);//配列を確保
  rep(i,N)cin>>L[i];//配列を格納
  sort(L.begin(),L.end());//まず、ソート
  
  int ans=0;//答を初期化
  rep(i,N-2){//一番短い辺
    for (int j=i+1;j<N-1;++j){//二番目に短い辺
      int IJ=L[i]+L[j];
      int Bound=lower_bound(L.begin(),L.end(),IJ)-L.begin();
      //二分探索、探索したい値以上が現れる最初の位置のイテレータを取得
      //インデックスを取得⇒取得したイテレータ - 探索したい領域の先頭
      ans+=Bound-(j+1);
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


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

int main(){
	char ch;
	while(1){
		cin.get(ch);
		if(ch == '\n')
			break;
		if(islower(ch))
			ch = toupper(ch);
		else if(isupper(ch))
			ch = tolower(ch);
		cout << ch;
	}
        cout << endl;
	return 0;
}

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

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int[] c = new int[n-1];
        int[] s = new int[n-1];
        int[] f = new int[n-1];
        for (int i = 0; i < n - 1; i++) {
            c[i] = in.nextInt();
            s[i] = in.nextInt();
            f[i] = in.nextInt();
        }

        for (int i = 0; i < n - 1; i++) {
            out.println(solve(i, c, s, f));
        }
        out.println(0);
    }

    private static int solve(int i, int[] c, int[] s, int[] f) {
        // out.println("Solving for " + i);
        int current = 0;
        for (int j = i; j < c.length; j++) {
            // out.println("Current time: " + current);
            if (current < s[j]) {
                current = s[j];
            }
            // out.println("Current time (waited before start): " + current);
            if (current % f[j] != 0) {
                int q = current / f[j];
                int toAdd = f[j] - (current - q * f[j]);
                current += toAdd;
            }
            // out.println("Current time (waited before next train): " + current);
            current += c[j];
        }
        // out.println("Returning time: " + current);
        return current;
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

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

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

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


Measured memory_bytes: 22996
#include "bits/stdc++.h"
using namespace std;

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	string S;
	cin >> S;
	for (int i = 0; i < 3; i++) {
		if (S[i] == '1') {
			S[i] = '9';
		}
		else if(S[i] == '9'){
			S[i] = '1';
		}
	}
	cout << S;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main(){
	int w,h;
	vector<string> f(30);
	vector< vector<int> > g(30,vector<int>(30,0));
	int count = 0;
	int count2 = 0;

	while(1){
		cin >> w >> h;
		if(w == 0 && h == 0){
			break;
		}

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



		for(int i = 0;i < h; i++){
			for(int j = 0;j < w;j++){
				g[i][j] = 0;
			}
		}
		count = 0;
		count2 = 0;
		while(1){
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w;j++){
					if(f[i][j] == '@' && count== 0){
						g[i][j] = 1;
						count2++;
					}else if(g[i][j] == 1){
						if(i != 0){
							if(f[i-1][j] == '.'){
								if(g[i-1][j] == 0){
									count2++;
								}
								g[i-1][j] = 1;

							}
						}
						if(i != h-1){
							if(f[i+1][j] == '.'){
								if(g[i+1][j] == 0){
									count2++;
								}
								g[i+1][j] = 1;
							}
						}
						if(j != 0){
							if(f[i][j-1] == '.'){
								if(g[i][j-1] == 0){
									count2++;
								}
								g[i][j-1] = 1;
							}
						}
						if(j != w-1){
							if(f[i][j+1] == '.'){
								if(g[i][j+1] == 0){
									count2++;
								}
								g[i][j+1] = 1;
							}
						}
					}else{}
				}
			}

			if(count == count2){
				cout << count << endl;
				break;
			}
			count = count2;
		}

	}
}

Measured memory_bytes: 3100
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <fstream>
#include <cstddef>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
const ll INF = (1<<30);
const ll NEGA=-INF*10000; 


ll ans = 0;
int n,m;
int cnt=0;

int a[4000000],b[4000000],c[4000000];
int main() 
{
 int a,b;
 cin>>a>>b;
 int d=b-a;
 int sum=0;
 rep(i,d){
   sum+=(i+1);
 }
 cout<<sum-b<<endl;
}



Measured memory_bytes: 256
li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(li[int(input())-1])

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

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) cin >> L[i];

    sort(L.begin(), L.end());

    int ans = 0;
    for (int i = 0; i + 1 < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int l = j + 1;
            int r = lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin();
            ans += r - l;
        }
    }

    cout << ans << endl;
}

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


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

using namespace std;

void B_145() 
{
  int N;
  string S;
  cin >> N >> S;

  if (N % 2 != 0)
  {
    cout << "No" << endl;
    return;
  }
  else
  {
    for (int i = 0; i < N / 2; ++i)
    {
      if (S[i] != S[N / 2 + i])
      {
        cout << "No" << endl;
        return;
      }
    }
    cout << "Yes" << endl;
  }
}

int main()
{
  //C_140();
  //C_141();
  //C_142();
  //C_143();
  //C_144();
  //C_145();
  //C_146();
  //C_147();
  //C_148();
  //C_149();
  //A_149();
  //B_149();
  //A_148();
  //B_148();
  //A_147();
  //B_147();
  //A_146();
  //B_146();
  B_145();
  return 0;
}


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

int main() {
  int N ;
  cin >> N;
  string S;
  bool check = false;
  for(int i = 0; i < N; i++){
  	cin >> S;
    if(S == "Y"){
    	check = true;
        break;
    }
  }
  if(check == false){
  	cout << "Three" << endl;
  }else{
  	cout << "Four" << endl;
  }
}


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

using namespace std;

int main () {

    int N;
    cin >> N;
    vector<int> v(N);

    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }
    int res = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            res += v[i] * v[j];
        }
    }

    cout << res;

    return 0;
}

Measured memory_bytes: 256
n, m, x = gets.to_s.split.map{|e|e.to_i}

cas = Array.new(n){ gets.to_s.split.map{|e|e.to_i} }

inf = 10 ** 7
ans = inf
(2**n).times do |bit|
  
  cnt = 0
  rikaido = Array.new(m+1){ 0 }
  rikaido[0] = x
  cas.each_with_index do |ca, i|
    
    if bit[i] == 1
      cnt += ca[0]
      (1..m).each{ |j| rikaido[j] += ca[j] }
    end
  end
  
  ans = [ans, cnt].min if rikaido.all?{ |r| r >= x } 
end

puts ans == inf ? -1 : ans

Measured memory_bytes: 14316
s = list(input())
output = []
for i in range(len(s)):
    if s[i] == "0":
        output.append("0")
    elif s[i] == "1":
        output.append("1")
    else:
        if len(output) > 0:
            output.pop()
        else:
            pass
print("".join(output))

Measured memory_bytes: 8940
#include"bits/stdc++.h"
using namespace std;
 
#define MAX 502
#define ull unsigned long long int 
int n;
int ty_r[MAX];
ull val_r[MAX];
int ty_c[MAX];
ull val_c[MAX];
bool tmp[MAX][MAX];
int emp[MAX];
ull ans[MAX][MAX];
void transpose(){
	for(int i=0;i<n;i++){
		for(int j=0;j<i;j++)swap(tmp[i][j],tmp[j][i]);
		swap(val_r[i],val_c[i]);
		swap(ty_r[i],ty_c[i]);
	}
}
void fi(long long int pos){
	memset(emp, 0, sizeof(emp));
	for (int j = 0; j < n; j++) {
		if (ty_c[j] == false) {
			emp[j] = n - 1;
			for (int k = 0; k < n; k++) emp[j]-=tmp[k][j];
		}
	}
	for (int i = 0; i < n; i++) {
		if (ty_r[i]) {
			if (((val_r[i]) >> pos) & 1ULL) {
				bool valid = false;
				for (int j = 0; j < n; j++) valid|=tmp[i][j];
				if (valid == false) {
					for (int j = 0; j < n; j++) {
						if (emp[j]>0) { 
							emp[j]--;
							tmp[i][j] = true;
							break;
						}
					}
				}
			}
		}
	}
}
void solve(ull pos) {
	memset(tmp, false, sizeof(tmp));
	for (int i = 0; i < n; i++) {
		if (ty_r[i]==false&&((val_r[i]) >> pos) & 1ULL) for (int j = 0; j < n; j++) tmp[i][j] = 1;
		if(ty_c[i]==false&&((val_c[i]) >> pos) & 1ULL) for (int j = 0; j < n; j++) tmp[j][i] = 1;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (ty_r[i] == ty_c[j]) {
				if (ty_r[i] == false) tmp[i][j] = ((val_r[i] >> pos) & 1ULL)| ((val_c[j] >> pos) & 1ULL);
				else tmp[i][j] = ((val_r[i] >> pos) & 1ULL)& ((val_c[j] >> pos) & 1ULL);
			}
		}
	}
	fi(pos);
	transpose();
	fi(pos);
	transpose();
	for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) ans[i][j] += ((ull)(tmp[i][j]) << pos);
}
void fo(){
	puts("-1");
	exit(0);
}
void check() {
	for (int i = 0; i < n; i++) {
		ull AN = -1; ull O = 0; ull AN2 = -1; ull O2 = 0;
		for (int j = 0; j < n; j++) {
			AN &= ans[i][j];
			O |= ans[i][j];
			AN2&=ans[j][i];
			O2|=ans[j][i];
		}
		if (ty_r[i] == false&&AN != val_r[i]) fo();
		else if(ty_r[i] == true&&O!=val_r[i]) fo();
		if (ty_c[i] == false&&AN2 != val_c[i]) fo();
		else if (ty_c[i] && O2 != val_c[i]) fo();
	}
}
int main() {
		cin>>n;
		for (int i = 0; i < n; i++) scanf("%d", &ty_r[i]);
		for (int j = 0; j < n; j++) scanf("%d", &ty_c[j]);
		for (int i = 0; i < n; i++) scanf("%llu", &val_r[i]);
		for (int j = 0; j < n; j++) scanf("%llu", &val_c[j]);
		for (int i = 0; i < 64; i++) solve(i);
		check();
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (j)printf(" ");
				printf("%llu", ans[i][j]);
			}
			puts("");
		}
	return 0;
}


Measured memory_bytes: 7696
#define MOD 1000000007

#include <iostream>
#include <vector>
using namespace std;

long pow(long a, long b) {
	if (!b) return 1;
	long c = pow(a, b / 2);
	if (b % 2) c = a * c % MOD * c % MOD;
	else c = c * c % MOD;
	return c;
}

int main() {
	int X, Y;
	cin >> X >> Y;
	if ((X * 2 - Y) % 3 || (Y * 2 - X) % 3) cout << 0;
	else {
		int a = (X * 2 - Y) / 3, b = (Y * 2 - X) / 3;
		if (a < 0 || b < 0) cout << 0;
		else {
			vector<long> c(a + b + 1, 1), d(a + b + 1, 1);
			for (int i = 1; i <= a + b; i++) {
				c[i] = c[i - 1] * i % MOD;
				d[i] = pow(c[i], MOD - 2);
			}
			cout << c[a + b] * d[a] % MOD * d[b] % MOD;
		}
	}
}

Measured memory_bytes: 10624
import math

a, b, h, m = map(int, input().split())

angle = abs(30*h + 0.5*m - 6*m)
dangle = angle if angle <= 180 else 360 - angle
d = math.sqrt(a**2 + b**2 - 2*a*b * math.cos(math.radians(dangle)))
print(d)

Measured memory_bytes: 9432
using System;
using System.Collections.Generic;
using System.Linq;

namespace _3_B
{
    class Program
    {
        static void Main(string[] args)
        {
            Queue<int> time = new Queue<int>();
            Queue<string> name = new Queue<string>();
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i < x[0]; i++)
            {
                string[] s = Console.ReadLine().Split();
                name.Enqueue(s[0]);
                time.Enqueue(int.Parse(s[1]));
            }
            int ret = 0;
            while (name.Count > 0)
            {
                int now = time.Dequeue();
                if (x[1] >= now)
                {
                    ret += now;
                    Console.WriteLine(name.Dequeue() + " " + ret);
                }
                else
                {
                    ret += x[1];
                    time.Enqueue(now - x[1]);
                    name.Enqueue(name.Dequeue());
                }
            }
        }
    }
}

Measured memory_bytes: 14748
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(void){
    int N;
    cin>>N;
    REP(i,N){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int n=a*c+b*d;
        int s=(a*max(c,5)+b*max(d,2))*0.8;
        cout<<min(n,s)<<endl;
    }
}





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

using namespace std;

typedef long long ll;

const int MAXN = 2E3 + 10;
const ll MOD = 924844033;

int n, K;
int m0;
ll a[MAXN];
int com[MAXN][MAXN];

void calc(int m){
	static ll c[MAXN];
	int m1 = m >> 1;
	copy_n(a, m0 + 1, c);
	fill_n(a, m0 + m1 + 1, 0);
	for (int i = 0; i <= m1; ++i){
		ll t = com[m - i][i];
		for (int j = 0; j <= m0; ++j)
			a[i + j] = (a[i + j] + t * c[j]) % MOD;
	}
	m0 += m1;
}

int main(){
	for (int i = 0; i < MAXN; ++i){
		com[i][0] = com[i][i] = 1;
		for (int j = 1; j < i; ++j)
			com[i][j] = (com[i - 1][j - 1] + com[i - 1] [j]) % MOD;
	}
	scanf("%d%d", &n, &K);
	a[0] = 1, m0 = 0;
	for (int i = 0; i < K; ++i){
		calc((n - i - 1) / K + 1);
		calc((n - i - 1) / K + 1);
	}
	ll ans = 0;
	ll e = n & 1 ? -1 : 1;
	for (int i = n; i >= 0; --i){
		ans = (ans + e * a[i]) % MOD;
		e = MOD - e * (n - i + 1) % MOD;
	}
	printf("%d\n", (int)ans);
	
	return 0;
}


Measured memory_bytes: 14080
#ifndef VS
#include<bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};
constexpr int MAX_LEN = 25;

LL dp_N[MAX_LEN][1000][2]; bool vis_N[MAX_LEN];
LL dp_all[MAX_LEN][1000][2]; bool vis_all[MAX_LEN];
void f(int d);
void g(int d);

vector<int> in;
int len;
bool usa[10000];
void f(int d) {
	if (vis_N[d])return;
	vis_N[d] = true;
	for (int i : range(1000)) {
		dp_N[d][i][0] = dp_N[d][i][1] = 0;
	}
	if (d == 0) {
		dp_N[d][0][0] = 1; return;
	}
	f(d - 1); g(d - 1);
	{
		int p = in[d - 1];
		for (int i : range(1000)) {
			int nxt = p * 1000 + i;
			dp_N[d][nxt / 10][1] += dp_N[d - 1][i][1];
			if (usa[nxt]) {
				dp_N[d][nxt / 10][1] += dp_N[d - 1][i][0];
			}
			else {
				dp_N[d][nxt / 10][0] += dp_N[d - 1][i][0];
			}
		}
	}
	for(int p:range(in[d-1])){
		for (int i : range(1000)) {
			int nxt = p * 1000 + i;
			dp_N[d][nxt / 10][1] += dp_all[d - 1][i][1];
			if (usa[nxt]) {
				dp_N[d][nxt / 10][1] += dp_all[d - 1][i][0];
			}
			else {
				dp_N[d][nxt / 10][0] += dp_all[d - 1][i][0];
			}
		}
	}
}
void g(int d) {
	if (vis_all[d])return;
	vis_all[d] = true;
	for (int i : range(1000)) {
		dp_all[d][i][0] = dp_all[d][i][1] = 0;
	}
	if (d == 0) {
		dp_all[d][0][0] = 1; return;
	}
	f(d - 1); g(d - 1);
	for (int p : range(10)) {
		for (int i : range(1000)) {
			int nxt = p * 1000 + i;
			dp_all[d][nxt / 10][1] += dp_all[d - 1][i][1];
			if (usa[nxt]) {
				dp_all[d][nxt / 10][1] += dp_all[d - 1][i][0];
			}
			else {
				dp_all[d][nxt / 10][0] += dp_all[d - 1][i][0];
			}
		}
	}
}

int main() {
	for (int i : range(10000))usa[i] = false;
	for (int i : range(10))usa[5103 + i * 10] = true;
	string s;
	cin >> s;
	reverse(ALL(s));
	for (auto &it : s)in.push_back(it - '0');
	for(int i:range(3))in.push_back(0);
	len = in.size();
	f(len);
	LL ret = 0;
	ret+=dp_N[len][0][1];
	cout << ret << endl;
	return 0;
}



Measured memory_bytes: 3896
n = int(input())
a = list(map(int,input().split()))

#aに含まれる要素とその個数を取得する
d = {}
for i in range(n):
	d[a[i]] = d.get(a[i], 0) + 1

# print(d)

cnt = 0
for v in d.values():
	# val = d.get(a[k])
	# print(v)
	cnt += v * (v - 1) // 2


for i in range(n):
	print(cnt - d.get(a[i]) + 1)

Measured memory_bytes: 87756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define per(i, a, b) for(int i = a; i >= b; i--)
typedef long long LL;
const int maxn = 105;
const LL mod = 1e9 + 7;

int n, h[maxn];
struct Node {
	LL x, y;
};
LL ans;

LL Ksm(LL a, LL b) {
	LL ans = 1;
	while(b) {
		if(b&1) ans = ans*a%mod;
		b /= 2;
		a = a*a%mod;
	}
	return ans;
}

Node Solve(int l, int r, int bot) {
	int cnt = 0, low = 1e9;
	Node ans;
	rep(i, l, r) 
	    low = min(low, h[i]);
	rep(i, l, r)
	    if(h[i] == low) cnt++;
	if(cnt == r - l + 1) {
		if(!low) return (Node) {1, 1};
		ans.y = Ksm(2, low - bot);
		ans.x = (Ksm(2, r - l + 1) + Ksm(2, low - bot) - 2)%mod;
		return ans; 
	}
	LL c1 = 1, c2 = 1;
	rep(i, l, r) {
		if(h[i] == low) continue;
		int cur = i;
		while(h[cur + 1] > low && cur < r) cur++;
		Node res = Solve(i, cur, low);
		i = cur;
		c2 = c2*res.y%mod;
		c1 = c1*(res.x + res.y)%mod;
	}
	c1 = (c1*Ksm(2, cnt)%mod + c2*(Ksm(2, low - bot) - 2 + mod)%mod)%mod;
	c2 = c2*Ksm(2, low - bot)%mod;
	return (Node) {c1, c2};
}

int main() {
	cin>>n;
	rep(i, 1, n) 
	    cin>>h[i];
	ans = 1;
	for(int i = 1; i <= n; i++)
    	if(h[i] > max(h[i - 1], h[i + 1])) {
    		ans = ans*Ksm(2, h[i] - max(h[i - 1], h[i + 1]))%mod;
            h[i] = max(h[i - 1], h[i + 1]);
    	}
	Node tmp = Solve(1, n, 0);
	cout<<(ans*tmp.x%mod + mod)%mod<<endl;
}

Measured memory_bytes: 3616
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define output(x) cout<<x<<endl;
int par[100001];

void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
	}
}
//木の根を求める
int root(int x) {
	if (par[x] == x)
		return x;
	else {
		return par[x] = root(par[x]);
	}
}
//find
bool same(int x, int y) {
	return root(x) == root(y);

}
//union
void unite(int x, int y) {
	x = root(x);
	y = root(y);
	if (x == y) return;
	par[x] = y;
}

int main()
{
	long long int N, i,j, k, l, m, ans, sum,flag;
	sum = 0;
	flag = 0;
	char A[200001];
	long long int num[26] = {};
	cin >> A;
	k = strlen(A);
	REP(i, 0, k) {
		num[A[i] - 'a']++;
	}
	sum = (k*(k - 1)) / 2+1;
	REP(i, 0, 26) {
		sum -= (num[i] * (num[i] - 1)) / 2;
	}
	output(sum);



	return 0;
}



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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
    int N; cin >> N;
    vector<int> T(N); REP(i, N) cin >> T[i];
    int M; cin >> M;
    vector<int> P(M), X(M); REP(i, M) cin >> P[i] >> X[i];

    int tmp = 0;
    REP(i, M) {
        tmp = T[P[i] - 1];

        T[P[i] - 1] = X[i];

        cout << accumulate(all(T), 0) << endl;

        T[P[i] - 1] = tmp;
    }
}

Measured memory_bytes: 256
import java.util.*;

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

		String s = sc.nextLine();

		int x = 0;

		for(int i=0;i < s.length()/2 ;i++){
			if(!(s.charAt(i) == s.charAt(s.length()-i-1)))
				x+=1;
		}
		System.out.println(x);

	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,c[2005],cnt=0; 
	cin>>a;
	for (int i=0;i<a;i++)
		cin>>c[i];
	sort(c,c+a);
	for(int m=1;m<a;m++)
	{
		int s=0;
		for(int b=m+1;b<a;b++)
		{
			while(s<m&&c[s]+c[m]<=c[b])
				s++;
			cnt+=m-s;
		}
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
 
#define FI(z,n) for(int j=z; j<=n; j++)
#define FL(z,n) for(l j=z; j<=n; j++)
 
#define inf 10000000000
#define mod 1000000007
 
void In_Out(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt", "w", stderr);
    #endif
}

struct Items{
    ll val, wt;
};
 
 
int main(){
 
    // In_Out();

    ll n, w;
    cin >> n >> w;

    Items arr[n];
    for(ll i=0; i<n; i++){
        cin >> arr[i].wt >> arr[i].val;
    }

    ll dp[n+1][w+1];

    for(ll i=0; i<=n; i++){
        for(ll j=0; j<=w; j++){

            if(i==0 || j==0){
                dp[i][j] = 0;
            }
            else if(arr[i-1].wt <= j){
                dp[i][j] = max(arr[i-1].val + dp[i-1][j-arr[i-1].wt], dp[i-1][j]);
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    cout << dp[n][w];
    
}

Measured memory_bytes: 82524
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int N;
char S[212345];

int migi[212345], hidari[212345], c = 0;

int main() {

	scanf("%d", &N);
	scanf("%s", S);

	for (int i = N - 1; i >= 0; --i) {
		migi[i] = c;
		if (S[i] == '.') {
			c++;
		}
	}

	c = 0;
	rep(i, N) {
		hidari[i] = c;
		if (S[i] == '#') {
			c++;
		}
	}

	int ans = 212345;

	rep(i, N) {
		int t = hidari[i] + migi[i];
		if (S[i] == '.') ++t;
		ans = min(ans, t);
	}

	int t = hidari[N - 1];
	if (S[N - 1] == '#') ++t;
	ans = min(ans, t);

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

	return 0;
}


Measured memory_bytes: 2048
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
	String s1 = sc.next();
	String s2 = sc.next();
	for(int i = 0; i<s1.length(); i++) {
            if(s1.charAt(i)!=s2.charAt(s1.length()-1-i)) {
		System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;


int main(){
  int n;
  cin >> n;
  vector<ll> a(87,0);
  a[0]=2;a[1]=1;
  REP(i,2,n+1){
    a[i] = a[i-1] + a[i-2];
  }
  ll ans = a[n];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <functional>
#include <ctime>
#include <limits>
#include <tuple>
#include <complex>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left
#define right _right

const ld pi = acos(-1.0l);

template<typename T>
T abs(T x) {
    return x > 0 ? x : -x;
}

template<typename T>
T sqr(T x) {
    return x * x;
}

template<typename T>
void chmin(T &x, T y) {
    x = min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
    x = max(x, y);
}

template<typename U, typename V>
ostream &operator<<(ostream &s, const pair<U, V> &x) {
    s << "(" << x.fst << ", " << x.snd << ")";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const vector<U> &x) {
    s << "[";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "]";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const set<U> &x) {
    s << "{";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "}";
    return s;
}

template<int sz>
ostream operator<<(ostream &s, const bitset<sz> &x) {
    for (int i = 0; i < sz; i++) {
        s << x[i];
    }
    return s;
}


//-----------------------------------------------------------------------------


int main() {
    srand(time(NULL));

    retry:
#ifdef LOCAL
    //gen();
    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen("lock.in", "r", stdin);
    //freopen("lock.out", "w", stdout);
#endif

    int n;
    cin >> n;
    vector<ll> a(2 * n);
    for (int i = 0; i < 2 * n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    for (int i = 0; i < 2 * n; i += 2) {
        ans += a[i];
    }
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 256
s = int(input())
l = []
f = s
l.append(f)
cnt = 1
while True:
  cnt += 1
  if f % 2 == 0:
    f = int(f/2)
  elif f % 2 == 1:
    f = int(3*f + 1)
  l.append(f)
  #print(l)
  #print(sorted(l), sorted(list(set(l))))
  if sorted(list(set(l))) == sorted(l): 
    #print(cnt)
    pass
  else:
    break

print(cnt)
  

Measured memory_bytes: 3060
package main

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

func main() {
	N := ReadInt()
	c := make([]int, 3)
	for i := 0; i < N; i++ {
		a := ReadInt()
		if a%4 == 0 {
			c[2]++
		} else if a%2 == 0 {
			c[1]++
		} else {
			c[0]++
		}
	}
	if c[1] > 0 {
		c[0]++
	}
	if c[2]+1 >= c[0] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


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

namespace AtTest.ABC_136
{
    class E
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            long[] nk = ReadLongs();
            long n = nk[0];
            long k = nk[1];
            long[] array = ReadLongs();
            long sum = 0;
            for (int i = 0; i < n; i++) sum += array[i];

            List<long> primes = new List<long>();
            for(long i = 1; i * i <= sum; i++)
            {
                if (sum % i == 0)
                {
                    primes.Add(i);
                    primes.Add(sum / i);
                }
            }
            primes.Sort();

            long res = 1;
            for (
                int i = 1; i < primes.Count; i++)
            {
                long[] deltas = new long[n];
                long elseSum = 0;
                for(int j = 0; j < n; j++)
                {
                    deltas[j] = array[j] % primes[i];
                    elseSum += primes[i] - deltas[j];
                }

                Array.Sort(deltas);
                long now = 0;
                bool valid = false;
                for(int j = 0; j < n; j++)
                {
                    now += deltas[j];
                    elseSum -= primes[i] - deltas[j];
                    if (now > k) break;
                    if (elseSum == now)
                    {
                        valid = true;
                        break;
                    }
                }
                if (valid) res = primes[i];
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  int cnt = 0;
  for (int i = 0; i < N; i++){
    cin >> h[i];
    if (h[i] >= K){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
import itertools

N = int(input())

Ps = tuple(map(int, input().split()))
Qs = tuple(map(int, input().split()))

Ns = [i for i in range(1, N + 1)]
perms = itertools.permutations(Ns, N)

p_found = False
q_found = False
for i, p in enumerate(perms):
    if Ps == p:
        a = i
        p_found = True
    if Qs == p:
        b = i
        q_found = True
    if p_found and q_found:
        break

print(abs(a - b))


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

using namespace std;
typedef long long ll;
int main(){
 ll n;
 map<string,ll> words;
 cin >> n;
 ll i=0;
 while(n--){
    i++;
    string k;cin >> k;
    words.insert(pair<string,ll>(k,i));

 }
 cout << words.size() << "\n";

}


Measured memory_bytes: 19240
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int main(){
   ll x,y;
   cin>>x>>y;
   ll x1,y1;
   ll count=0;
   double a;
   while (x--)
   {
       cin>>x1>>y1;
       a=sqrt(x1*x1+y1*y1);
       if(a<=y)
       {
           count++;
       }
   }
   cout<<count<<endl;
}


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

int x, y, c, t;

int abs(int p) {return p > 0 ? p : -p;}

int main()
{
	cin >> x >> y;
	c = abs(abs(x) - abs(y));
	if (x != 0 && y != 0) t = 1;
	if (x <= y) c += (x < 0 != y < 0) * t;
	else c += 1 + (x < 0 == y < 0) * t;
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <sstream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <set>
#include <vector>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <queue>
#define maxn 10005
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int m,n;
int a[maxn],b[maxn];

int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=0;i<n;i++)
            scanf("%d",&a[i]);
        for(int i=0;i<n;i++)
            scanf("%d",&b[i]);
        ll suma=0,sumb=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]>b[i])
                sumb+=a[i]-b[i];
            if(a[i]<b[i])
                suma+=(b[i]-a[i])/2;
        }
        if(suma<sumb)
            printf("No\n");
        else
            printf("Yes\n");
    }
    return 0;
}


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

int main(){
  
  int N;
  string msg = "Three";
  cin >> N;
  
  
  for ( int i = 0; i < N; i++){
    
    string S;
    cin >> S;
    
    if ( S == "Y" ) {
      msg = "Four";
      break;
    }
  }
  
  cout << msg << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int cnt=0;
    if(s[0]=='1')
    ++cnt;
    if(s[1]=='1')
    ++cnt;
    if(s[2]=='1')
    ++cnt;
    cout<<cnt<<endl;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define prod 1000000000000000000
int main()
{
    lli n;
    cin>>n;
    vector<lli> v(n);
    bool iszero=false;
    for(int i=0;i<n;i++) {cin>>v[i]; if(v[i]==0) iszero=true;}
    if(iszero) cout<<0<<endl;
    else
    {
        double sum=0;
        for(int i=0;i<n;i++) sum+=log10(v[i]);
        if(sum>18) cout<<-1<<endl;
        else
        {
            lli product=1;
            for(int i=0;i<n;i++) product*=v[i];
            if(product>prod) cout<<-1<<endl;
            else cout<<product<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4116
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let mut w:String = read();
    w = w.to_lowercase();
    let mut cnt = 0;
    loop {
        let mut t:String = read();
        if t == "END_OF_TEXT" {
            break;
        }
        t = t.to_lowercase();
        if w == t {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 5040
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) {
    ll t; 
    cin >> t;
    a[i] = abs(t-k);
  }
  ll ans = a[0];
  rep(i,n-1) {
    ans = gcd(ans,a[i+1]);
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3884
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

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

template <class T> void max_swap(T& a, const T b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n, m, s;
	while (scanf("%d%d%d", &n, &m, &s), n | m | s)
	{
		int nn = n * n;

		// dp[iÈºðgÁ½][j(a_jÜÅ)][s] = sum|k=[1..i-1](dp[k][j-1][s-k])
		static int dp[2][50][3001];
		const int mod = 100000;

		rep (i, nn + 1)
			rep (j, s + 1)
				dp[0][i][j] = dp[1][i][j] = 0;

		dp[0][0][0] = 1;
		for (int i = 1; i <= m; ++i)
		{
			int (*prev)[3001] = dp[(i + 1) & 1];
			int (*cur)[3001] = dp[i & 1];

			rep (j, nn + 1)
				rep (k, s + 1)
					cur[j][k] = prev[j][k];

			for (int j = nn; j > 0; --j)
				for (int k = s; k >= i; --k)
					if (prev[j - 1][k - i])
						(cur[j][k] += prev[j - 1][k - i]) %= mod;
		}

		printf("%d\n", dp[m & 1][nn][s]);
	}
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> inline bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,k,m{INT_MAX},d0=-1,d1=-1;
    in>>n>>k;
    vector<int> a(n+1);
    Fr(i,n){
        in>>a[i];
        if(chmin(m,a[i])) d0=i;
    }
    string ans;
    m=INT_MAX;
    Fr(j,n) if(j!=d0){
        ans+=to_string(j)+' ';
        if(--a[j]<0) return puts("-1"),0;
        if(chmin(m,a[j])) d1=j;
    }
    ans+=to_string(d0)+' ';
    if(--a[d0]<0) return puts("-1"),0;
    fr(i,k){
        m=INT_MAX;
        int d2=-1;
        Fr(j,n) if(j!=d0&&j!=d1){
            ans+=to_string(j)+' ';
            if(--a[j]<0) return puts("-1"),0;
            if(chmin(m,a[j])) d2=j;
        }
        if(a[d0]<m) d2=d0;
        ans+=to_string(d1)+' ';
        if(--a[d1]<0) return puts("-1"),0;
        d0=d1;d1=d2;
    }
    cout<<(n-1)*(k+1)+1<<'\n'<<ans<<'\n';
}

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bit(n) (1LL<<(n))
// functions
template <typename T> void unique(T& c){c.erase(std::unique(c.begin(), c.end()), c.end());}
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int n; cin >> n;
  cout << (n + 1) / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	float wei;
	while(cin >> wei)
	{
		if(wei <= 48) cout << "light fly" << endl;
		else if(wei <= 51) cout << "fly" << endl;
		else if(wei <= 54) cout << "bantam" << endl;
		else if(wei <= 57) cout << "feather" << endl;
		else if(wei <= 60) cout << "light" << endl;
		else if(wei <= 64) cout << "light welter" << endl;
		else if(wei <= 69) cout << "welter" << endl;
		else if(wei <= 75) cout << "light middle" << endl;
		else if(wei <= 81) cout << "middle" << endl;
		else if(wei <= 91) cout << "light heavy" << endl;
		else			   cout << "heavy" << endl;
	}
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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 main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  int A,B; cin >> A >> B;

  vector<vector<char>> grid(90,vector<char>(90,'.'));
  int wy,wx;
  wy = wx = 0;
  rep(i,A-1) {
    grid[wy+1][wx] = grid[wy][wx+1] = grid[wy+1][wx+1] = '#';
    wy += 2;
    if (wy >= 90) {
      wy = 0;
      wx += 2;
    }
  }
  int by,bx;
  if (A == 1) B++;
  by = bx = 89;
  rep(i,B-1) {
    grid[by][bx] = '#';
    by -= 2;
    if (by < 0) {
      by += 90;
      bx -= 2;
    }
  }

  cout << 90 << " " << 90 << endl;
  rep(i,90) {
    rep(j,90) cout << grid[i][j];
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int n, m;
int ans;
int sum[1005];

int main() {
	cin >> n >> m;
	for(int i = 1; i <= 999; i++) sum[i] = sum[i - 1] + i;
	for(int i = 1; i <= 999; i++) {
		for(int j = 999; j >= 1; j--) {
			if(sum[i] - n == sum[j] - m) {
				ans = sum[i] - n;
				break;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256