akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void) {
    int X;

    scanf("%d", &X);
    
    if( X >= 30 ) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 1648
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;
	std::vector<std::string>s(N);
	rep(i, N) in >> s[i];

	LL ans = 0, cntA = 0, cntB = 0;
	bool flag = false;
	std::vector<LL>selfAns(N);
	rep(i, N)
	{
		rep(j, (LL)s[i].length() - 1)
		{
			if (s[i][j] == 'A' && s[i][j + 1] == 'B') ++selfAns[i];
		}
		ans += selfAns[i];
		if (s[i][0] == 'B') ++cntB;
		if (s[i][(LL)s[i].length() - 1] == 'A') ++cntA;
		if ((s[i][0] == 'B' || s[i][(LL)s[i].length() - 1] == 'A') && !(s[i][0] == 'B' && s[i][(LL)s[i].length() - 1] == 'A')) flag = true;
	}
	ans += std::min(cntA, cntB);
	if (!flag && std::min(cntA, cntB) > 0) ans--;
	out << ans << std::endl;
}


Measured memory_bytes: 896
def calc_ans(max_list):
    ans = 0
    for i in range(n - 1):
        ans += abs(max_list[i+1] - max_list[i])
    return ans

n = int(input())
a = [int(input()) for i in range(n)]

a.sort()
if n % 2 == 0:
    max_list = []
    mean = n // 2
    list1 = a[mean:]
    list2 = a[:mean]
    for i in range(mean):
        max_list.append(list1[i])
        max_list.append(list2[i])
    ans = calc_ans(max_list)
else:
    max_list = []
    mean = n // 2
    list1 = a[mean:]
    list2 = a[:mean]
    list1[1], list1[-1] = list1[-1], list1[1]
    for i in range(mean):
        max_list.append(list1[i])
        max_list.append(list2[i])
    max_list.append(list1[-1])
    ans = calc_ans(max_list)

    max_list = []
    mean = n // 2 + 1
    list1 = a[:mean]
    list2 = a[mean:]
    list1[0], list1[-2] = list1[-2], list1[0]
    for i in range(mean - 1):
        max_list.append(list1[i])
        max_list.append(list2[i])
    max_list.append(list1[-1])
    ans = max(ans, calc_ans(max_list))

print(ans)

Measured memory_bytes: 8940
// g++ -std=c++14

//Difficulty according to solve count during contest:
//A B C D H F E I G K L M N P S O Q R J U Z Y X T V W

#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(c) (c.begin(),c.end())
#define LET(x, a)  __typeof(a) x(a)
#define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define inf 1000000000000000001

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

#define int ll
vector<int> curr, prev1;
int32_t main(){ _
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  vector<vector<int> > dp(n + 1, vector<int>(m + 1, 0));
  vector<vector<pair<int, int> > > par(n + 1, vector<pair<int, int> >(m + 1, make_pair(-1, -1)));

  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= m; j++){
      if(i == 0 or j == 0)
        continue;
      if(s[i - 1] == t[j - 1]){
        dp[i][j] = dp[i - 1][j - 1] + 1;
        par[i][j] = make_pair(i - 1, j - 1);
      }
      if(dp[i - 1][j] > dp[i][j]){
          dp[i][j] = dp[i - 1][j];
          par[i][j] = make_pair(i - 1, j);
      }
      if(dp[i][j - 1] > dp[i][j]){
        dp[i][j] = dp[i][j - 1];
        par[i][j] = make_pair(i, j - 1);
      }
    }
  }
  pair<int, int> currPar = make_pair(n, m);
  string ans = "";
  while(currPar != make_pair((long long)-1, (long long)-1) and currPar != make_pair((long long)0, (long long)0)){
      auto nextPar = par[currPar.first][currPar.second];
      if(nextPar.first == currPar.first - 1 and nextPar.second == currPar.second - 1)
        ans += s[currPar.first - 1];
      currPar = nextPar;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}


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


class Main {
    static long sq(long x){return x*x;}
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int m=sc.nextInt();
        UnionFind u=new UnionFind(n);
        for(int i=0;i<m;++i){
            int a=sc.nextInt()-1;
            int b=sc.nextInt()-1;
            u.unify(a,b);
        }
        int d0=0;
        int d1=0;
        for(int i=0;i<n;++i){
            if(u.root(i)==u.root(0))d0++;
            if(u.root(i)==u.root(1))d1++;
        }
        long ans=Math.max(sq(n-d0)+sq(d0),sq(n-d1)+sq(d1));
        ans=(ans-n)/2;
        ans-=m;
        out.println(ans);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        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;
        }
        int[] nextIntArray(int n){
            int[]r=new int[n];
            for(int i=0;i<n;++i)r[i]=nextInt();
            return r;
        }
    }
}
class UnionFind {
    int[] parent;
    int[] rank;
    UnionFind(int n) {
	this.parent = new int[n];
	this.rank = new int[n];
	this.clear();
    }
    void clear() {
	int n = this.parent.length;
	for (int i = 0; i < n; ++i) {
	    this.parent[i] = i;
	    this.rank[i] = 0;
	}
    }
    void unify(int x, int y) {
	int rootX = this.root(x);
	int rootY = this.root(y);
	if (rootX == rootY) {
	    return;
	}
	if (this.rank[rootX] < this.rank[rootY]) {
	    this.parent[rootX] = rootY;
	} else {
	    this.parent[rootY] = rootX;
	    if (this.rank[rootX] == this.rank[rootY]) {
		this.rank[rootX]++;
	    }
	}
    }
    int root(int x) {
	if (this.parent[x] == x) {
	    return x;
	}
	return this.parent[x] = this.root(this.parent[x]);
    }
}


Measured memory_bytes: 43612
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <queue>
#include <set>

using namespace std;

const int maxN = 110;

#define FORU(i, l, r) for (int i = l; i <= r; ++i)
#define FORD(i, r, l) for (int i = r; i >= l; --i)
#define REPU(i, r) for (int i = 0; i < r; ++i)
#define F first
#define S second
#define PB push_back
#define LL long long
#define BIT(x, i) ((x >> i) & 1)

int res, m, x[maxN], y[maxN];
vector < int > idx1, idx2, idx;
set < int > mset;

double get_slope(int i, int j) {
    return (x[i] == x[j] ? -1 : (1.0 * (y[i] - y[j])) / (x[i] - x[j]));
}

int cmp_slope(int i, int j) {
    if (x[idx1[i]] == x[idx2[i]] &&
        x[idx1[j]] == x[idx2[j]]) return 0;
    if (x[idx1[i]] == x[idx2[i]]) return -1;
    if (x[idx1[j]] == x[idx2[j]]) return 1;

    int dxi = x[idx1[i]] - x[idx2[i]], dyi = y[idx1[i]] - y[idx2[i]];
    int dxj = x[idx1[j]] - x[idx2[j]], dyj = y[idx1[j]] - y[idx2[j]];
    if (dxi < 0) dxi *= (-1), dyi *= (-1);
    if (dxj < 0) dxj *= (-1), dyj *= (-1);

    if (dyi * dxj == dyj * dxi) return 0;
    if (dyi * dxj < dyj * dxi) return -1;
    return 1;
}

bool cmp(int i, int j) {
    return (cmp_slope(i, j) == -1);
}

void solve(int t) {
    if (t > (m / 2)) {
        idx.clear();
        REPU(i, idx1.size()) idx.PB(i);
        sort(idx.begin(), idx.end(), cmp);
        int num = 0, tmp = 0;
        REPU(t, idx.size()) {
            if (t && cmp_slope(idx[t], idx[t - 1]) != 0) {
                tmp += (num * (num - 1)) / 2;
                num = 0;
            }
            ++num;
        }
        tmp += (num * (num - 1)) / 2;
        res = max(res, tmp);
        return;
    }
    vector < int > arr; arr.clear();
    for (auto i : mset) arr.PB(i);
    idx1.PB(arr[0]);
    mset.erase(arr[0]);
    FORU(i, 1, arr.size() - 1) {
        idx2.PB(arr[i]);
        mset.erase(arr[i]);
        solve(t + 1);
        mset.insert(arr[i]);
        idx2.pop_back();
    }
    mset.insert(arr[0]);
    idx1.pop_back();
}

int main() {
    cin >> m;
    FORU(i, 1, m) {
        cin >> x[i] >> y[i];
        mset.insert(i);
    }
    solve(1);
    cout << res << endl;
}



Measured memory_bytes: 3188
require 'prime'
a= gets.to_i
ans = 0

def number_divisors(n)
  Prime.prime_division(n).map {|p, e| e + 1 }.inject(:*)
end

for num in 3..a do
  if num.odd?
     if number_divisors(num) == 8
       ans += 1
     end
  end
end
p ans

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define c2(n,m) cin>>n>>m
#define c3(n,m,k) cin>>n>>m>>k
#define c4(n,m,k,l) cin>>n>>m>>k>>l
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  int a,b,c,d,e=0;
  c3(a,b,c);
  int x[a];
  rep(i,0,a) c(x[i]);
  rep(i,0,a){
    e+=(b+x[i]-1)/x[i];
  }
  co(e+c);
  
  
  return 0;
}


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

int main() {
  long double N;
  int K;
  cin >> N >> K;
  long double result = 0;
  for (int i = 1; i <= N; ++i) {
    int num = i;
    long double prob = 1. / N;
    while (num <= K - 1) {
      prob *= 0.5;
      num *= 2;
    }
    result += prob;
  }
  cout.precision(12);
  cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int H,W,i,j;

int main() {
  int H,W,i,j;
  cin >> H >> W;
  char field[W+1][H+1];
  char ans[W+1][H+1];
  
  for(j=0;j<H;j++){
    for(i=0;i<W;i++){
      cin >> field[i][j];
      ans[i][j] = 48;
    }
  }
  
  for(j=0;j<H;j++){
    for(i=0;i<W;i++){
      if(field[i][j] == '#'){
        ans[i][j] = '#';
        //左上
        if(i-1 >= 0 && j-1 >= 0 && field[i-1][j-1] == '.'){
          ans[i-1][j-1]++;
        }
        //上
        if(j-1 >= 0 && field[i][j-1] == '.'){
          ans[i][j-1]++;
        }
        //右上
        if(i+1 <= W && j-1 >= 0 && field[i+1][j-1] == '.'){
          ans[i+1][j-1]++;
        }
        //左
        if(i-1 >= 0 && field[i-1][j] == '.'){
          ans[i-1][j]++;
        }
        //右
        if(i+1 <= W && field[i+1][j] == '.'){
          ans[i+1][j]++;
        }
        //左下
        if(i-1 >= 0 && j+1 <= H && field[i-1][j+1] == '.'){
          ans[i-1][j+1]++;
        }
        //下
        if(j+1 <= H && field[i][j+1] == '.'){
          ans[i][j+1]++;
        }
        //右下
        if(i+1 <= W && j+1 <= H && field[i+1][j+1] == '.'){
          ans[i+1][j+1]++;
        }
      }
    }
  }
  
  for(j=0;j<H;j++){
    for(i=0;i<W;i++){
      cout << ans[i][j];
    }
    cout << endl;
  }
}



Measured memory_bytes: 256
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, d; cin >> n >> d;
	int r = 2*d+1;
	int ans = n/r;
	if(n%r) ans++;
	println(ans);
}


Measured memory_bytes: 384
import java.util.Scanner;
 
 
public class Main{
     
    public static void main(String[] args){
    	
    	final Scanner sc = new Scanner(System.in);
    	
    	final int n = sc.nextInt();
    	
    	long sum = 0;
    	int[][] adj = new int[n][n];
    	
    	for(int i = 0; i < n; i++){
    		for(int j = 0; j < n; j++){
    			adj[i][j] = sc.nextInt();
    		}
    	}
    	
    	for(int i = 0; i < n; i++){
    		for(int j = i + 1; j < n; j++){
    			sum += Math.min(adj[i][j], adj[j][i]);
    		}
    	}
    	
    	System.out.println(sum);
    	
    }
     
}

Measured memory_bytes: 31200
#include <bits/stdc++.h>
#include <cstring>
#include <ctype.h>
#include<stdlib.h>

#define flin            freopen("input.txt", "r", stdin); 
#define flout           freopen("output.txt", "w", stdout);
#define ll              long long
#define ull             unsigned long long
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl              '\n'
#define nll             '\0'
#define pb              push_back
#define bdyptb          return 0;
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define mset(a, b)      memset(a, b, sizeof(a));
#define testcase        ll t,tt; cin>>tt; for(t=1;t<=tt;t++)

#define pi acos(-1.00)   
#define mx 1000007

using namespace std;
int gcd(int x,int y)
{        
    return x ? gcd(y%x,x) : y;   
}  

int findGCD(int arr[], int n) 
{ 
    int result = arr[0]; 
    for (int i = 1; i < n; i++) 
    { 
        result = gcd(arr[i], result); 
  
        if(result == 1) 
        { 
           return 1; 
        } 
    } 
    return result; 
}
int main()
{
    fastio;
    int n,k;
    cin>>n>>k;
    int a[n];
    
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    int g=findGCD(a,n);
    if(n==1 and k==a[0])cout<<"POSSIBLE\n";
    else if(k%g==0 and k<=*max_element(a,a+n))cout<<"POSSIBLE\n";
    else cout<<"IMPOSSIBLE\n";
    // cout<<g<<nl<<k<<nl<<*max_element(a,a+n)<<nl;
    bdyptb;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main()
{
    static const double pi = 3.141592653589793;
    lint a,b,h,m;
    cin >> a >> b >> h >> m;
    long double ax, ay, bx, by;
    long double at, bt;
    bt = (m / 60.0)*2*pi;
    at = ((h / 12.0) + (m / (12. * 60.))) * 2 * pi;
    ax = a*cos(at);
    ay = a*sin(at);
    bx = b*cos(bt);
    by = b*sin(bt);

    long double ans;
    ans = pow((ax - bx), 2.) + pow((ay - by), 2.);
    ans = sqrt(ans);

    cout <<  std::setprecision(20) << ans << "\n";

    return 0;
}

Measured memory_bytes: 4164
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> cnt(5, 0);
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if(s[0] == 'M') {
            cnt[0]++;
        } else if(s[0] == 'A') {
            cnt[1]++;
        } else if(s[0] == 'R') {
            cnt[2]++;
        } else if(s[0] == 'C') {
            cnt[3]++;
        } else if(s[0] == 'H') {
            cnt[4]++;
        }
    }
    ll ans = 0;
    for(int bit = 0; bit < (1 << 5); bit++) {
        vector<int> id;
        for(int i = 0; i < 5; i++) {
            if(bit & (1 << i)) {
                id.push_back(i);
            }
        }
        if(id.size() == 3) {
            ll tmp = 1;
            for(auto i : id) {
                tmp *= cnt[i];
            }
            ans += tmp;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int a, b, c, d, n;
	int x = 0;
	
	while(cin >> n){
		for(int i = 0;i <10;i++){
			for(int j = 0; j < 10; j++){
				for(int k = 0; k < 10; k++){
					for(int l = 0; l < 10; l++){
						if(i + j + k + l == n){
							x++;
						}
					}
				}
			}
		}
		cout << x << endl;
		x = 0;
	}
	
	return 0;
}

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

using namespace std;

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

    vector<int> erasedNumbers;
    for (;;)
    {
        if (Bs.empty()) break;

        int n = static_cast<int>(Bs.size());
        bool notErase = true;
        for (int i = n - 1; i >= 0; --i)
        {
            if (Bs[i] == i + 1)
            {
                Bs.erase(Bs.begin() + i);
                erasedNumbers.push_back(i + 1);
                notErase = false;
                break;
            }
        }
        if (notErase)
        {
            cout << -1;
            return 0;
        }
    }
    
    reverse(erasedNumbers.begin(), erasedNumbers.end());
    for (const int i : erasedNumbers)
        cout << i << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int p,n,ta[101],ha[101],k,i,j,x,y,ba;
	while(1){
		k=0;
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++)scanf("%d",&ta[i]);
		for(j=1;j<=n*2;j++){
			for(i=0;i<n;i++){
				if(ta[i]==j)break;
				else if(n==i+1){
					ha[k]=j;
					++k;
				}
			}
		}
		for(i=0;i<n;i++){
			for(j=i;j<n;j++){
				if(ta[i]>ta[j]){
					x=ta[i];
					ta[i]=ta[j];
					ta[j]=x;
				}
				if(ha[i]>ha[j]){
					x=ha[i];
					ha[i]=ha[j];
					ha[j]=x;
				}
			}
		}
		k=0,ba=0,x=n,y=n;
		while(1){
			if(k==0){
				p=1;
				for(i=0;i<n;i++){
					if(ba<ta[i]){
						--x;
						ba=ta[i];
						ta[i]=0;
						p=0;
						break;
					}
				}
				k=1;
			}
			else{
				p=2;
				for(i=0;i<n;i++){
					if(ba<ha[i]){
						--y;
						ba=ha[i];
						ha[i]=0;
						p=0;
						break;
					}
				}
				k=0;
			}
			if(x==0 || y==0)break;
			if(p!=0)ba=0;
		}
		printf("%d\n%d\n",y,x);
	}
	return 0;
}


Measured memory_bytes: 2056
import java.util.*;
public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int data[] = new int[n];
    int total[] = new int[n+1];
    int count = 0 ;
    total[0] = 0;

    for (int i = 0 ; i < n ; i++ ) {
      data[i] = sc.nextInt();
    }

    for (int i = 0 ; i < n; i++ ) {
      total[i+1] = data[i] + total[i];
    }

    for (int i = 0 ; i < n+1 ; i++ ) {
      if (total[i] <= x) {
        count++;
      }
    }
    System.out.println(count);
  }
}


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

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

using namespace std;

int main()
{
	int ans = 0;
	string s,t="CODEFESTIVAL2016";
	cin >> s;

	rep(i, s.size())
		if (s[i] != t[i])
			ans++;
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
// Graph i
#include <stdio.h>
#include <stdlib.h>
#define N 100

int main() {
  int i, j;
  int u, k, v, n;
  int m[N][N] = {0};

  // input
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", &u);
    scanf("%d", &k);
    for(j = 0; j < k; j++) {
      scanf("%d", &v);
      m[u-1][v-1] = 1;
    }
  }

  // output
  for(i = 0; i < n; i++) {
    for(j = 0; j < n; j++) {
      printf("%d", m[i][j]);
      if(j != n - 1) printf(" ");
    }
    printf("\n");
  }
  
  
  return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,srt,end) for (long long i=(srt);i<(long long)(end);i++)
#define VL vector<ll> 
ll N,K;
int main(){
    cin>>N>>K;
    VL H(N);
    rep(i,0,N)cin>>H[i];
    sort(H.begin(),H.end());
    ll sum=0;
    //HPの低い方からN-K体を通常攻撃で倒す
    rep(i,0,N-K){
        sum+=H[i];
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int N; std::cin >> N;
  std::string S, T; std::cin >> S >> T;
  for (int i = 0; i < N; ++i) std::cout << S[i] << T[i];
  std::cout << std::endl;
}


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

struct LowestCommonAncestor{
  const int MAX_LOG_V = 50;
  
  vector<vector<int> > G,parent;
  int root=0,V;
  vector<int> depth;
  LowestCommonAncestor(){}
  LowestCommonAncestor(int V):V(V){init();}

  void init(){
    for(int i=0;i<(int)G.size();i++) G[i].clear();
    G.clear();
    for(int i=0;i<(int)parent.size();i++) parent[i].clear();
    parent.clear();
    depth.clear();
    G.resize(V);
    parent.resize(MAX_LOG_V,vector<int>(V));
    depth.resize(V);
  }

  void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }
  
  void dfs(int v,int p,int d){
    parent[0][v]=p;
    depth[v]=d;
    for(int i=0;i<(int)G[v].size();i++){
      if(G[v][i]!=p) dfs(G[v][i],v,d+1);
    }
  }
  
  void build(){
    dfs(root,-1,0);
    for(int k=0;k+1<MAX_LOG_V;k++){
      for(int v=0;v<V;v++){
	if(parent[k][v]<0) parent[k+1][v]=-1;
	else parent[k+1][v]=parent[k][parent[k][v]];
      }
    }
  }
  
  int lca(int u,int v){
    if(depth[u]>depth[v]) swap(u,v);
    for(int k=0;k<MAX_LOG_V;k++){
      if((depth[v]-depth[u])>>k&1){
	v=parent[k][v];
      }
    }
    if(u==v) return u;
    for(int k=MAX_LOG_V-1;k>=0;k--){
      if(parent[k][u]!=parent[k][v]){
	u=parent[k][u];
	v=parent[k][v];
      }
    }
    return parent[0][u];
  }
};


typedef pair<int,int> P;
vector<P> G[114514];
int di[114514];
void dfs(int v,int p,int d){
  di[v]=d;
  for(P e:G[v]){
    int u=e.first,c=e.second;
    if(u==p) continue;
    dfs(u,v,d+c);
  }
}

signed main(){
  int n;
  cin>>n;
  LowestCommonAncestor lca(n);
  for(int i=0;i<n-1;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    lca.add_edge(a,b);
    G[a].push_back(P(b,c));
    G[b].push_back(P(a,c));
  }
  
  int q,k;
  cin>>q>>k;
  k--;
  lca.root=k;
  lca.build();
  dfs(k,-1,0);
  for(int i=0;i<q;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    cout<<di[x]+di[y]<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 60144
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void fail() {
    cout << -1 << endl;
    exit(0);
}

void out(vector<int> x) {
    rep(i, (int)x.size()) {
        if(i) cout << " ";
        cout << x[i] + 1;
    }
    cout << endl;
    exit(0);
}

void solve() {
    int n;
	cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        -- a[i];
    }
    set<int> se;
    for(int i = 1; i < n; ++ i) se.insert(i);
    vector<int> ans(1, 0);
    for(int i = 1; i < n - 1; ++ i) {
        auto ite = se.begin();
        if(*ite == a[ans.back()]) ++ ite;
        ans.push_back(*ite);
        se.erase(ite);
    }
    int b = *se.begin();
    if(b != a[ans.back()]) {
        ans.push_back(b);
        out(ans);
    }
    set<int> pool;
    while(ans.size() and a[ans.back()] == b) {
        pool.insert(ans.back());
        ans.pop_back();
    } 
    if(pool.size() == 1) {
        if(n == 2) fail();
        vector<int> p;
        p.push_back(b);
        p.push_back(*pool.begin());
        p.push_back(ans.back());
        ans.pop_back();
        sort(all(p));
        auto tmp = ans;
        vector<int> res = {n + 1};
        do {
            for(int x: p) tmp.push_back(x);
            bool ok = 1;
            rep(i, n - 1) {
                if(tmp[i + 1] == a[tmp[i]]) ok = 0;
            }
            if(ok) chmin(res, tmp);
            rep(i, 3) tmp.pop_back();
        } while(next_permutation(all(p)));
        ans = res;
    } else {
        ans.push_back(b);
        while(pool.size()) {
            auto ite = pool.begin();
            if(*ite == a[ans.back()]) ++ ite;
            ans.push_back(*ite);
            pool.erase(ite);
        }
    }
    out(ans);
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 9268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

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



signed main(){
    int g,r;cin>>g>>r;
    ll ans=1;
    vector<vector<int>> v(g,vector<int>(r,g*r));
    vector<int> can(g*r+1,0);
    vector<P> pac(g*r+1,{-1,-1});
    rep(i,0,g){
        int x;cin>>x;
        rep(j,0,r){
            v[i][j]=min(v[i][j],x);
        }

        if(pac[x].fs>=0){
            cout<<0<<endl;
            return 0;
        }
        pac[x].fs=i;
    }

    rep(i,0,r){
        int x;cin>>x;
        rep(j,0,g){
            v[j][i]=min(v[j][i],x);
        }

        if(pac[x].sc>=0){
            cout<<0<<endl;
            return 0;
        }
        pac[x].sc=i;
    }

    rep(i,0,g)rep(j,0,r){
        can[v[i][j]]++;
    }

    ll now=0;
    for(int i=g*r;1<=i;i--){
        
        if(pac[i].fs>=0 && pac[i].sc>=0){
            now+=can[i]-1;
        }else if(pac[i].fs*pac[i].sc<=0){
            ans*=can[i];
            now+=can[i]-1;
        }else{
            ans*=now;
            now--;
        }
        ans%=mod;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=505;
int n,mod,cnt;
pair<int,int> s[N];
int dp[N][N];
int main(){
	scanf("%d%d",&n,&mod);
	int lim1=n*n,lim2=n*n*4;
	for(int i=0;i<n*2;++i){
		int f=-1,g=-1;
		for(int j=n*2-1;~j;--j) if(i*i+j*j<=lim2){ f=j; break; }
		for(int j=n*2-1;~j;--j) if(i*i+j*j< lim1){ g=j; break; }
		if(g==-1) s[++cnt]=make_pair(f,0);
		else s[++cnt]=make_pair(g,f);
	}
	sort(s+1,s+cnt+1); int ans=0;
	for(int k=0;k<=n;++k){
		memset(dp,0,sizeof(dp)); dp[0][0]=1; int c1=0,c2=0;
		for(int i=1;i<=cnt;++i){
			if(!s[i].second){
				int f=s[i].first;
				for(int j=0;j<=n;++j) if(dp[i-1][j]) (dp[i][j]+=1ll*dp[i-1][j]*max(f+1-c1-j,0)%mod)%=mod;
				++c1;
			}
			else{
				int g=s[i].first,f=s[i].second;
				for(int j=0;j<=n;++j) if(dp[i-1][j]){
					(dp[i][j+1]+=1ll*dp[i-1][j]*max(g+1-c1-j,0)%mod)%=mod;
					(dp[i][j]+=1ll*dp[i-1][j]*max(f+1-k-n-c2+j,0)%mod)%=mod;
				} ++c2;
			}
		}
		if(k&1) (ans+=mod-dp[cnt][k])%=mod;
		else (ans+=dp[cnt][k])%=mod;
	}
	return printf("%d\n",ans),0;
}
 

Measured memory_bytes: 4788
#include <stdio.h>
#include <string.h>
char t1[1510];
char t2[1510];
int main(){
    int n;
    int a=0,b=0;
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",&t1,&t2);
        if(strcmp(t1,t2)==0) a++,b++;
        if(strcmp(t1,t2)>0) a+=3;
        if(strcmp(t1,t2)<0) b+=3;
    }
    printf("%d %d\n",a,b);
    return 0;
}


Measured memory_bytes: 2736
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

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

int main () {
  int n; cin >> n;
  vi h(n); REP(i,n) cin >> h[i];

  reverse(ALL(h));

  int ans = 0;
  int val = 0;
  FOR(i,1,n) {
    if (h[i-1] <= h[i]) val++;
    else val = 0;
    ans = max(ans,val);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,x,n) for(int i=x;i<n;i++)
#define breps(i,x,n) for(int i=x;i>=n;i--)
#define exrep(x,vec) for(auto&& x : vec);
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

/**
* ------------- ここからコード -------------
*/

int main(void) {

	ll a, b, c, d, x, y, z;
	ll ans = 0;
	string s, t, u;
	cin >> x;

	cout << (x==1?0:1) << endl;

	return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <limits.h>

using namespace std;

int main()
{
	int D;
	long G;
	cin >> D >> G;
	
	vector<long> p(D);
	vector<long> c(D);
	for (int i = 0; i < D; i++)
	{
		cin >> p[i] >> c[i];
	}
	
	long answer = LONG_MAX;
	// ビット全検索
	for (int bit = 0; bit < (1<<D); bit++)
	{
		long sumValue = 0;
		long count = 0;
		
		for (int i = 0; i < D; i++)
		{
			if (bit & (1<<i))
			{
				// コンプリートボーナス + p[i]問題の点数
				sumValue += c[i] + p[i] * 100 * (i + 1);
				count += p[i];
			}
		}
		
		if (sumValue >= G)
		{
			answer = min(answer, count);
		}
		// コンプリートボーナスを除いた場合の計算
		else
		{
			// p[i]の点数の高い問題から計算する
			for (int i = D - 1; i >= 0; i--)
			{
				if (bit & (1<<i))
				{
					continue;
				}
				
				for (int j = 0; j < p[i]; j++)
				{
					if (sumValue >= G)
					{
						break;
					}
					
					sumValue += 100 * (i + 1);
					count++;
				}
			}
			
			answer = min(answer, count);
		}
	}
	
	// 出力
	cout << answer << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int i, N;
	double	A[1001],sum=0,t[101],x ;
	scanf("%d", &N);
	for (i = 1; i <= N; i++)
		scanf("%lf", &A[i]);
	for (i = 1; i <= N; i++) {
		t[i] = 1 / A[i];
		sum += t[i];
	}
	x = 1 / sum;
	printf("%.5lf", x);
	return 0;
}

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

int main(){
int N,M,X;
  cin>>N>>M>>X;
  
  vector<int>A(M);
  
  
  int left=0, right=0;
  for(int i=0; i<M; i++){
    cin>>A[i];
   if(A[i]<X){left++;}
   if(A[i]>X){right++;} 
  }
  
  cout<<min(left, right);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)
#define mp(a, b) make_pair(a, b)
#define eps 1e-9
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
const int N = 1e5 + 10;
const ll INF = 1LL << 60;
ll iv[N];
ll powM(ll a, ll b){ll res = 1;for(;b;a=a*a%M,b/=2) if(b&1) res=res*a%M;return res;}
ll nckbig(int n, int k){ll ans = 1;for(int i=1; i<=k; ++i){ans = ans*(n-i+1)%M*iv[i]%M;}return ans;}
ll caliv(){iv[1] = 1;for(int i=2; i<N; i++){iv[i] = M-M/i*iv[M%i]%M;}}
ll f1[N], f2[N];
ll calf(){f1[0] = f2[0] = 1;for(int i=2; i <N; ++i){f1[i] = f1[i-1]*i%M;f2[i] = f2[i-i]*iv[i]%M;}}
ll nck(int n, int k){return f1[n]*f2[n-k]%M*f2[k]%M;}
ll npk(int n, int k){return f1[n]*f2[n-k]%M;}
ll Rnck(int big){if(big){caliv();}else{calf();}}

void solve()
{
  int k, q;
  cin>>k>>q;
  vector<ll> v(k);
  rep(i, 0, k) cin>>v[i];
  while(q--){
    ll n, x, m;
    cin>>n>>x>>m;
    ll s1 = 0, s2=0;
    rep(i, 0, k){
      ll tmp = v[i]%m;
      if(!tmp) tmp = m;
      if((n-1)%k > i) s2 += tmp;
      s1 += tmp;
    }
    ll x2 = x + (n-1)/k*s1 + s2;
    cout<<(n-1-(x2/m-x/m))<<endl;
  }
}


int main()
{
    FAST
    ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
    int k, s;
    scanf("%d %d", &k, &s);

    int cnt = 0;
    for (int i=0; i <= k;i++){
        for (int j=0; j <= k; j++){
            if (0 <= s-i-j && s-i-j <= k) cnt++;
        }
    }

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


    return 0;
} 



Measured memory_bytes: 128
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        long n = in.nextLong();
        ArrayList<Long> al = new ArrayList<Long>();
        al.add(2L);
            al.add(1L);
            int count = 2;
            while(count<=n){
                al.add(al.get(count-1)+al.get(count-2));
                ++count;
            }
            out.println(al.get(al.size()-1));
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 32968
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<int> h(n);
    rep(i,n) cin>>h[i];
    int ans=0,height=0;
    rep(i,n){
        if(height<h[i]) ans+=h[i]-height;
        height=h[i];
    }
    cout<<ans;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		char ch[] = S.toCharArray();
		int fl = N;
		int lr = -1;
		int addl = 0;
		int addr = 0;
		for (int i = 0; i < N; i++) {
			if (ch[i] == '(') {
				fl = i;
				break;
			}
		}
		for (int i = N - 1; i >= 0; i--) {
			if (ch[i] == ')') {
				lr = i;
				break;
			}
		}
		int c = 0;
		addl = fl;
		addr = N-1-lr;
		if (fl < lr) {
			for (int i = fl; i <= lr; i++) {
				if (ch[i] == '(') {
					c++;
				} else if (c == 0) {
					addl++;
				} else {
					c--;
				}
			}
			addr += c;
		}
		for (int i = 0; i < addl; i++) {
			System.out.print("(");
		}
		System.out.print(S);
		for (int i = 0; i < addr; i++) {
			System.out.print(")");
		}
		System.out.println();
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll ceil(ll x){
    return (2*x+10)/11;
}
int main(){
    ll x;
    cin>>x;
    if((2*x-1)%11==0) cout<<(2*x-1)/11;
    else if((2*x)%11==0) cout<<2*x/11<<endl;
    else cout<<ceil(x)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, k;
string s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> s >> k;
  k--;
  FOR(i, 0, n) cout << (s[i]==s[k] ? s[k] : '*');
  cout << endl;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"math"
)

func main() {

	var (
		n int
		a int
		b int
		c int
		d int
		e int
	)

	fmt.Scan(&n, &a, &b, &c, &d, &e)

	min := math.Min(float64(a), math.Min(float64(b), math.Min(float64(c), math.Min(float64(d), float64(e)))))

	time := n / int(min)

	if n%int(min) == 0 {
		time = time + 4
	} else {
		time = time + 1 + 4
	}

	fmt.Print(time)

}


Measured memory_bytes: 512
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        aa: [usize; n]
    };
    let mut odds = 0;
    let mut amari2 = 0;
    let mut space4 = 0;
    for a in aa {
        match a % 4 {
            0 => space4 += 1,
            2 => amari2 += 1,
            _ => odds += 1,
        }
    }
    if amari2 == 0 {
        println!("{}", ["No", "Yes"][(odds <= (space4 + 1)) as usize])
    } else {
        // 2あまりは2個以上あれば打ち消しあえて一端は4の隣
        amari2 = 1;
        println!(
            "{}",
            ["No", "Yes"][((odds + amari2) <= (space4 + 1)) as usize]
        )
    }
}


Measured memory_bytes: 3636
#include <cstdio>
#include <functional>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <cstdlib>

bool remove(std::vector<std::vector<int>> &D, std::vector<int> &p, int &P, size_t k, int d) {
  int min=1e9, max=0;
  for (size_t i=0; i<D.size(); ++i) {
    if (i == k) continue;
    min = std::min(min, p[i]);
    max = std::max(max, p[i]);
  }

  bool res=false;
  while (!D[k].empty()) {
    int next=p[k]-D[k].back();
    if (abs(next-min) > d) break;
    if (abs(next-max) > d) break;

    p[k] -= D[k].back();
    P -= D[k].back();
    D[k].pop_back();
    res = true;
  }

  return res;
}

int testcase_ends() {
  int n, d;
  scanf("%d %d", &n, &d);

  if (n == 0) 
    return 1;

  std::vector<std::vector<int>> D(n);
  std::vector<int> p(n);
  int P=0;
  for (int i=0; i<n; ++i) {
    int m;
    scanf("%d", &m);
    D[i].resize(m);
    for (int j=0; j<m; ++j) {
      int c;
      scanf("%d", &c);
      D[i][j] = c;
      p[i] += c;
      P += c;
    }
  }

  while (P) {
    for (int i=0; i<n; ++i) {
      if (remove(D, p, P, i, d)) {
	break;
      }
      if (i == n-1) {
	printf("No\n");
	return 0;
      }
    }
  }

  printf("Yes\n");
  return 0;
}

int main() {
  while (!testcase_ends()) {}

  return 0;
}

Measured memory_bytes: 2592
N,K = (int(T) for T in input().split())
Ins = [[] for T in range(0,N)]
for TN in range(0,N):
    Ins[TN] = [int(T) for T in input().split()]
InsSort = sorted(Ins)
Total = 0
for TN in range(0,N):
    if Total<K<=Total+InsSort[TN][1]:
        print(InsSort[TN][0])
        break
    else:
        Total += InsSort[TN][1]

Measured memory_bytes: 26748
n=int(input())
a=input()
b=a.split()
O=int(b[0])
Count=0
while O%2==0:
    O/=2
    Count+=1
for i in range(n):
    count=0
    o=int(b[i])
    while o%2==0:
        count+=1
        o/=2
    if count<Count:
        Count=count
print(Count)


Measured memory_bytes: 3060
#include <stdio.h>

int Euclidean_algorithm(int A,int B)
{
  if (A >= B)
  {
    A = A % B;
    if (A == 0)
    {
      return (B);
    }
  }
  else
  {
    B = B % A;
    if (B == 0)
    {
      return (A);
    }
  }
  Euclidean_algorithm(A,B);
}

int main()
{
  int A,B;
  scanf("%d %d",&A,&B);
  printf("%ld",(long)A*B/Euclidean_algorithm(A,B));
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B_ISU
{
    class B_ISU
    {
        static void Main(string[] args)
        {
            string[] strIn = Console.ReadLine().Split(' ');

            int intX = int.Parse(strIn[0]);
            int intY = int.Parse(strIn[1]);
            int intZ = int.Parse(strIn[2]);


            int intAns = 0;
            while (true)
            {
                intAns++;

                if ((intAns + 1) * intZ + intAns * intY > intX) break;

            }

            intAns--;

            Console.WriteLine(intAns);



        }
    }
}


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


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

  int N; cin >> N;
  vector<int> a(N), b(N), rev(N);
  for (int i = 0; i < N; i++) {
    int p; cin >> p; p--;
    rev.at(p) = i;
  }
  a.at(0) = 1;
  b.at(0) = rev.at(0) - a.at(0);
  for (int i = 1; i < N; i++) {
    int diff = rev.at(i) - rev.at(i-1);
    if (diff > 0) {
      a.at(i) = a.at(i-1) + diff + 1;
      b.at(i) = b.at(i-1) - 1;
    }else {
      a.at(i) = a.at(i-1) + 1;
      b.at(i) = b.at(i-1) + diff - 1;
    }
  }
  int shift = 1 - b.at(N-1);
  for (int i = 0; i < N; i++) b.at(i) += shift;
  
  for (int i = 0; i < N; i++) {
    if (i > 0) cout << " ";
    cout << a.at(i);
  }
  cout << endl;
  for (int i = 0; i < N; i++) {
    if (i > 0) cout << " ";
    cout << b.at(i);
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 3764