akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int max = 0;
		int sum = 0;
		for(int i = 0; i < n; i++){
			if(s.charAt(i)== 'I'){
				sum += 1;
			}else if(s.charAt(i)== 'D'){
				sum -= 1;
			}
		    max = Math.max(max, sum);
	    }
	    System.out.println(max);
	}
}

Measured memory_bytes: 21844
n = int(input())
# sum(i + 1 for i in range(4500)) = 10127250

num = 0
for i in range(4500):
  num += (i + 1)
  if num >= n:
    break
print(*(j + 1 for j in range(i + 1) if j + 1 != num - n), sep='\n')


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
const int MAX = 1e5;
using P = pair<int,int>;

vector<int> g[MAX];
vector<int> c(MAX,0);
vector<P> ans;

void dfs(int u, int p) {
  for(auto e : g[u]) {
    if(e != p) dfs(e,u);
  }
  if(u) {
    if(c[u] % 2) {
      ans.push_back(P(u,p));
      c[u]++;
    } else {
      ans.push_back(P(p,u));
      c[p]++;
    }
  }
}

class Union_Find{
  vector<int> par; vector<int> rank; vector<int> num;
public:
  Union_Find(int n) {
    par = vector<int>(n); rank = vector<int>(n,0); num = vector<int>(n,1);
    rep(i,n) par[i] = i;
  }
  int find(int x) {
    if(par[x] == x) return x;
    else  return par[x] = find(par[x]);
  }
  int number(int x) {
    return num[find(x)];
  }
  void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) rank[x]++;
    par[y] = x;
    num[x] += num[y];
  } 
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main(){
  int n, m;
  cin >> n >> m;
  Union_Find uf(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    if(uf.same(a,b)) {
      c[a]++;
      ans.push_back(P(a,b));
    } else {
      uf.unite(a,b);
      g[a].push_back(b);
      g[b].push_back(a);
    }
  }
  if(m % 2) {
    cout << -1 << endl;
    return 0;
  }
  dfs(0,-1);
  for(auto x : ans) cout << x.first+1 << " " << x.second+1 << endl;
  return 0;
}

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

class D
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(long.Parse).ToArray();
		long a = h[0], b = h[1];
		Console.WriteLine(b - a < 10 ? XorSum(a, b) : XorSum(a, a + 3 - a % 4) ^ XorSum(b - b % 4, b));
	}

	static long XorSum(long m, long M) => Range(m, M).Aggregate((x, y) => x ^ y);
	static IEnumerable<long> Range(long m, long M) { for (var i = m; i <= M; i++) yield return i; }
}


Measured memory_bytes: 13396
# -*- coding: utf-8 -*-


def main():
    s = list(input())
    n = len(s)
    t = list(input())
    m = len(t)
    # LCSの長さを状態として持つ
    dp = [[0 for _ in range(m + 1)] for _ in range(n + 1)]

    # See:
    # https://qiita.com/drken/items/03c7db44ccd27820ea0d
    # LCSの求め方は蟻本のpp.56-57も参照
    # △文字列s, tを二次元配列の形で扱う
    for i in range(n):
        for j in range(m):
            if s[i] == t[j]:
                dp[i + 1][j + 1] = dp[i][j] + 1
            else:
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])

    ans = ''
    i = n
    j = m

    # △復元
    # dp tableの値を見てどこから更新されたかを特定
    while i > 0 and j > 0:
        # (i - 1, j) -> (i, j)
        if dp[i][j] == dp[i - 1][j]:
            i -= 1
        # (i, j - 1) -> (i, j)
        elif dp[i][j] == dp[i][j - 1]:
            j -= 1
        # (i - 1, j - 1) -> (i, j)
        else:
            ans = s[i - 1] + ans
            i -= 1
            j -= 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 120156
#include <stdio.h>

int main(int argc, char** argv)
{
	int j, k, max_i, H, W, ar[10000];
	char a, b;

	int i = 0;
	while (1) {
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) {
			break;
		}
		ar[i * 2] = H;
		ar[i * 2 + 1] = W;
		i++;
	}
	max_i = i;

	for (i = 0; i < max_i; i++) {
		for (j = 0; j < ar[i * 2]; j++) {
			for (k = 0; k < ar[i * 2 + 1]; k++) {
				if (j == 0 || j % 2 == 0) {
					a = '#';
					b = '.';
				}
				else {
					a = '.';
					b = '#';
				}

				if (k == 0 || k % 2 == 0) {
					printf("%c", a);
				}
				else {
					printf("%c", b);
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;

int main(){
  int N;
  cin>>N;
  vector<int> V;
  int64_t y=0;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    V.push_back(a);
    y+=a;
  }
  int64_t ans=1LL<<60;
  int64_t x=0;
  for(int i=0;i<N-1;i++){
    x+=V[i];
    y-=V[i];
    ans=min(ans,abs(x-y));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1400
S = input()

S_len = len(S)
def insert_plus(exp, index=1):
    if index == S_len:
        return eval(exp)

    pn = exp.count("+")
    ans_in = insert_plus(exp[:index+pn]+"+"+exp[index+pn:], index+1)
    ans_ex = insert_plus(exp, index+1)
    return ans_in + ans_ex

print(insert_plus(S))

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){
  int t ;
  cin >> t;
  string a , b, c;
  a = "ABC";
  b= "ARC";
  c = "AGC";
  if(t < 1200) cout << "ABC" << endl;
  else if(t < 2800) cout  << "ARC" << endl;
  else cout << "AGC" << endl;
}

Measured memory_bytes: 256
class ModCombination
  attr_reader :fac, :inv, :finv, :mod

  MOD = 10 ** 9 + 7

  def initialize(n, mod: MOD)
    @mod = mod
    @fac = [1, 1]
    @inv = [1, 1]
    @finv = [1, 1]

    (2..n).each do |i|
      @fac[i] = fac[i - 1] * i % mod
      @inv[i] = mod - inv[mod % i] * (mod / i) % mod
      @finv[i] = finv[i - 1] * inv[i] % mod
    end
  end

  def combination(n, k)
    return 0 if n < k
    return 0 if n < 0 || k < 0

    fac[n] * (finv[k] * finv[n - k] % mod) % mod
  end

  def repeated_combination(n, k)
    combination(n + k - 1, k)
  end
end

K = gets.to_i
S = gets.chomp
N = S.size
MOD = 10 ** 9 + 7

mc = ModCombination.new(N + K + 1)
ans = 0

0.upto(K) do |k|
  v = K - k
  a = mc.repeated_combination(N, v)
  b = 25.pow(v, MOD)
  c = 26.pow(k, MOD)

  ans += a * b * c
  ans %= MOD
end

puts ans


Measured memory_bytes: 63324
n, m = map(int, input().split())

flag = False

used = []
d = [0]*n
for _ in range(m):
    s, c = map(int, input().split())
    if n > 1 and (s == 1 and c == 0):
        flag = True
    if (s in used) and d[s-1] != c:
        flag = True
    else:
        d[s-1] = c
        used.append(s)
    
if flag:
    print(-1)
else:
    if n != 1 and d[0] == 0: 
        d[0] = 1
    print(''.join(map(str, d)))

Measured memory_bytes: 3064
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

ans=0
tmp=1
for i in range(1,N+1):
    ans=ans+b[a[i-1]-1]
    if i>1 and a[i-1]-tmp==1:
        ans=ans+c[tmp-1]
    tmp=a[i-1]

print(ans)

Measured memory_bytes: 3064
#include <iostream>

#define rep(i, first, to) for(ll i = first; i < to; ++i)

using namespace std;
typedef long long ll;

int data[200000];
void solve() {
	int n;
	cin >> n;

	rep(i, 0, n) {
		cin >> data[i];
	}
	int max1 = max(data[n - 1], data[n - 2]);
	int max2 = data[n - 1] - data[n - 2];

	for (int i = n - 3; i >= 0; --i) {
		if (max2 < (max1 - data[i])) {
			max2 = max1 - data[i];
		}
		if (max1 < data[i]) {
			max1 = data[i];
		}
	}
	cout << max2 << endl;
}

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

Measured memory_bytes: 3852
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
	string s;
	cin >> s;
	ll a = 0;
	ll ans = 0;
	for (int z=0;z<s.size()-1;z++){
		if (s[z] == 'A') a++;
		else if (s[z] == 'B' && s[z+1] == 'C'){
			a--;
			ans += 1;
			z += 2;
			ll bc = 0;
			for (;z<s.size()-1;z++){
				if (s[z] == 'B' && s[z] == 'C'){
					bc++;
				} else break;
			}
			z--;
			ans += (a+bc+a*bc);
			a += 1;
		}
		else a = 0;
	}
	cout << ans << endl;
	cin >> s;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)

{

int a,b,c,i,s;

s=0;

scanf("%d %d %d",&a,&b,&c);

for(i=a;i<=b;i++)

{

if(c%i==0)

{

s=s+1;

}

}

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

return 0;

}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x)(x)*(x)
#define fz1(i,n) for (i=1;i<=n;i++)
#define fd1(i,n) for (i=n;i>=1;i--)
#define fz0g(i,n) for (i=0;i<=n;i++)
#define fd0g(i,n) for (i=n;i>=0;i--)
#define fz0k(i,n) for (i=0;i<n;i++)
#define fd0k(i,n) for (i=(long long)(n-1);i>=0;i--)
#define fz(i,x,y) for (i=x;i<=y;i++)
#define fd(i,y,x) for (i=y;i>=x;i--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){char ss[len];scanf("%s",ss);(st)=ss;}
using namespace std;
struct bit{long long arr[400005];int lowbit(int x){return x&(-x);}void add(int x,long long y){for (int i=x;i<=400005;i+=lowbit(i)) arr[i]+=y;}long long query(int x){long long s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;long long sum,add;void update(long long x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,int x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}long long query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;long long ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
long long n,m,i,j,l,r,mid,ans,num[400015],s[400015],sum[400015],f[400015];
vector<long long> all;
bit cnt;
bool asf(long long x)
{
//	return 0;
	long long i,j,ans=0;
	s[0]=200002;
	fz1(i,n)
	{
		if (num[i]<x) f[i]=-1;
		if (num[i]>=x) f[i]=1;
	}
	fz1(i,n) s[i]=s[i-1]+f[i];
	memset(cnt.arr,0,sizeof(cnt.arr));
	fd1(i,n)
	{
		cnt.add(s[i],1);
		ans+=cnt.query(s[i-1]-1);
	}
	return ans<((n*(n+1)/2)/2+1);
}
int main()
{
	scanf("%lld",&n);
	fz1(i,n)
	{
		scanf("%lld",&num[i]);
		all.push_back(num[i]);
	}
	sort(all.begin(),all.end());
	all.resize(unique(all.begin(),all.end())-all.begin());
	fz1(i,n) num[i]=upper_bound(all.begin(),all.end(),num[i])-all.begin();
	l=ans=1;r=((int)all.size())+1;
	while (l<r)
	{
		mid=(l+r)/2;
		if (asf(mid))
		{
			l=mid+1;
			ans=mid;
		}
		else r=mid;
	}
	cout<<all[ans-1]<<endl;
	return 0;
}


Measured memory_bytes: 9332
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, n;
  cin >> h >> n;
  vector<int> v(n);
  rep(i, n) {
    cin >> v[i];
    h -= v[i];
  }

  if(h <= 0) cout << "Yes" << endl;
  else cout << "No" << endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

// Ford-Fulkerson法用名前空間(使いたかっただけ)
/*
 * 最大流量をF, 辺の数をMとして O(FM)
 * だが、蟻本曰くこんなにかかることはまずなく、一見危なそうでも意外と大丈夫らしい
 */

namespace FordFulkerson {
    const int MAX_N = 1000010;
    const ll INF = 10000000000000;

    struct edge {
        int to;
        ll cap;
        int rev; // 行先, 容量, 逆辺
    };
    int timestamp = 0;

    int used[MAX_N];
    vector<edge> G[MAX_N];

    // 辺の追加、ちょいめんどいので関数
    // f -> tに向かう流量がcr以上、c以下となるエッジを追加
    // 無向グラフの場合は cr = -cとする
    void add_edge(int f, int t, int c=0, int cr=0) {
        G[f].push_back({t, c,  (int)G[t].size()});
        G[t].push_back({f, cr, (int)G[f].size() - 1});
    }
    
    // 今の頂点v, ゴールt, vに流せる最大流量flow
    // 返り値dは最終的に流した流量
    ll dfs(int v, int t, ll flow) {
        used[v] = timestamp;
        if (v == t) return flow;
        for (auto &g:G[v]) {
            if (used[g.to] != timestamp && g.cap > 0) {
                int d = dfs(g.to, t, min(flow, g.cap));
                if (d > 0) {
                    // 容量の更新
                    g.cap -= d;
                    G[g.to][g.rev].cap += d;
                    return d;
                }
            }
        }
        return 0; // どこにも流せなければ0
    }

    ll max_flow(int s, int t) {
        ll flow = 0;
        fill(begin(used), end(used), -1);
        for (ll f; (f = dfs(s, t, INF)) > 0; timestamp++) {
            flow += f;
        }
        return flow;
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i=0, u, v, c; i<m; i++) {
        cin >> u >> v >> c;
        FordFulkerson::add_edge(u, v, c);
    }
    cout << FordFulkerson::max_flow(0, n-1) << '\n';
    return 0;
}


Measured memory_bytes: 30552
#include<cstdio>
int n,m,vis[100005],f[100005];
int main()
{
	scanf("%d%d",&n,&m);
	f[0]=1;
	for (int i=1;i<=m;i++)
	{
		int x;
		scanf("%d",&x);
		vis[x]=1;
	}
	if (!vis[1]) f[1]=1;
	for (int i=2;i<=n;i++) if (!vis[i]) f[i]=(f[i-1]+f[i-2])%1000000007;
	printf("%d\n",f[n]);
	return 0;
}

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

int main(){
	int n;
  	cin >> n;
  	vector<int> a(n+1);
  	rep(i, n) cin >> a[i+1];
  	
	vector<ll> dp(n+1);
  	dp[0] = 1000;
  	for(int i = 1; i <= n; i++){
    	dp[i] = 0;
      	for(int j = 0; j < i-1; j++){
          	int m = 999999;
        	for(int k = j+1; k < i; k++){
            	m = min(m, a[k]);
            }
          	dp[i] = max(dp[i], dp[j] / m * a[i] + dp[j] % m);
        }
    }
  
  	ll ans = 0;
  	rep(i, n+1) ans = max(ans, dp[i]);
  
  	cout << ans << endl;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int r = 0;
		for (int i = 1; i <= n; i++)
			if (in.nextInt() != i)
				r++;
		if (r <= 2)
			System.out.println("YES");
		else
			System.out.println("NO");
		in.close();
	}
}


Measured memory_bytes: 21844
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    while(sc.hasNext()){
	    	double a[] = new double[6];
	        for(int i=0;i<6;i++)a[i]=sc.nextDouble();
	        double d = a[0]*a[4]-a[1]*a[3];
	        double x = (a[4]*a[2]-a[1]*a[5])/d;
	        double y = (a[0]*a[5]-a[2]*a[3])/d;
	        if(x==0)x=0;
	        if(y==0)y=0;
	        System.out.printf("%.3f %.3f\n", x, y);
	    }
	}
}
//by TTTMongolia 11/05/2012

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.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 (b<a) { a=b; return 1; } return 0; }
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());

    ll sum = 0;
    int ans = 0;
    for(int i=1; i<n; i++){
        sum += v[i-1];
        if(v[i] > 2*sum) ans = i;
    }

    cout << n-ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    int n;
    cin >> n;

    string tmp_s;
    map<string, int> word_count;
    for (int i = 0; i < n; i++) {
        cin >> tmp_s;
        word_count[tmp_s] += 1;
    }

    int max_count = 0;
    for (auto cnt : word_count) {
        max_count = max(max_count, cnt.second);
    }

    for (auto it = word_count.begin(); it != word_count.end(); it++) {
        if (it->second == max_count) cout << it->first << endl;
    }

    return 0;
}


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

int keta(int &n) {
    string s = to_string(n);
    return s.size();
}

int main() {
    int N, M, tmp1, tmp2;
    cin >> N >> M;
    vector<vector<P>> p(N);
    rep(i, M) {
        cin >> tmp1 >> tmp2;
        p.at(tmp1 - 1).push_back(make_pair(tmp2, i));
    }
    rep(i, N) if (!p.at(i).empty()) sort(p.at(i).begin(), p.at(i).end());
    vector<P> ans(M);
    rep(i, N) if (!p.at(i).empty()) {
        int j = 0;
        for (auto x : p.at(i)) {
            ans.at(x.second) = make_pair(i + 1, j + 1);
            ++j;
        }
    }
    for (auto x : ans) {
        string res;
        rep(i, 6 - keta(x.first)) res.push_back('0');
        res = res + to_string(x.first);
        rep(i, 6 - keta(x.second)) res.push_back('0');
        res = res + to_string(x.second);
        cout << res << endl;
    }
}


Measured memory_bytes: 9364
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> A(N,0),B(N,0),C(N-1,0);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        cin>>B[i];
    }
    for(int i=0;i<N-1;i++){
        cin>>C[i];
    }
    int sum=B[A[0]-1];
    int prev=A[0];
    for(int i=1;i<N;i++){
        if(A[i]==A[i-1]+1){
            sum+=C[prev-1];
        }
        sum+=B[A[i]-1];
        prev=A[i];
    }
    cout<<sum<<endl;
    return 0;
    
}

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

using i64 = int64_t;

int main(){
    string s;
    cin >> s;
    int ans = 0, cur = 0;
    for(int i=0;i<s.size();++i){
        if(s[i] != 'A' && s[i] != 'T' && s[i] != 'C' && s[i] != 'G'){
            cur = 0;
        }else{
            cur++;
        }
        ans = max(ans, cur);
    }

    cout << ans << endl;

    return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
int solve(int x)
{
  int ans = 0;
  while(x%100 == 0)
  {
    ans++;
    x/=100;
  }
  return ans;
}
int32_t main()
{
  //c_p_c();
  int d,k;
  cin >> d >> k;
  int flag = 0,count = 0,x = 1,ans = -1;
  while(flag == 0)
  {
    if(count == k)
    {
      break;
    }
    if(solve(x) == d)
    {
      ans = x;
      count++;
    }
    x++;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <regex>
#include <climits>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define forin(i, a) for(auto i: (a))
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](auto const &a, auto const &b){ return c ;}
#define key(t, x, compare) [](const t &a, const t &b){ return a x compare b x ;}
#define unless(a) if(!(a))

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

void output__(){
  cout << endl;
}

template <class Head, class... T>
void output__(Head const &v, T const &...a) {
  if(sizeof...(a) == 0) {
    cout << v;
  } else {
    cout << v << " ";
  }
  output__(a...);
}

struct State {
  int x, y, l;
};

int main(){
  int ndir[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};

  int in(h, w);
  string list_input(field, h);
  queue<State> que;
  rep(i, h) {
    rep(j, w) {
      if(field[i][j] == '#') {
        que.push({j, i, 1});
        int max_length = -1;
        while(!que.empty()) {
          State top = que.front();
          que.pop();

          if(field[top.y][top.x] != '#') {
            continue;
          }

          field[top.y][top.x] = '.';
          if(max_length < top.l) {
            max_length = top.l;
          }

          forin(d, ndir) {
            int nx = top.x + d[0];
            int ny = top.y + d[1];

            if (0 <= nx and nx < w and 0 <= ny and ny < h) {
              que.push({nx, ny, top.l + 1});
            }
          }
        }

        if(max_length <= 1) {
          out("No");
          exit(0);
        }
      }
    }
  }
  out("Yes");
}


Measured memory_bytes: 256
//let input = "20";

function main(input){
  input = input.trim();
  let n = parseInt(input);
  let counts = [];
  for(let i=0; i<n; i++){
    counts[i]=0;
  }
  let kaisuu = Math.floor(Math.sqrt(n));
  for(let x = 1; x<=kaisuu; x++){
    for(let y = 1; y<=kaisuu; y++){
      for(let z = 1; z<=kaisuu; z++){
        let keisan = x*x+y*y+z*z+x*y+y*z+z*x;
        if(keisan<=n){
          counts[keisan-1]++;
        }
      }//z
    }//y
  }//x
  for(let i=0; i<counts.length; i++){
	  console.log(counts[i]);
  }
}
//main(input);
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 37232
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n;
        int scores[];
        while (true) {
            n = sc.nextInt();
            if (n == 0)
                break;
            scores = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                scores[i] = sc.nextInt();
                sum += scores[i];
            }
            double average = 0, a = 0, variance = 0;
            average = (double) sum / n;
            for (int i = 0; i < n; i++) {
                 a += ((double) scores[i] - average) * ((double) scores[i] - average);
            }
            variance = a / n;
            System.out.printf("%.8f\n", Math.sqrt(variance));
        }
    }
}


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

s = [input() for i in range(n)]

sort_s = []

for i in range(n):
    sort_s.append(sorted(s[i]))
    
onaji = sort_s[0]
new = []
tmp = 0

for i in range(1,n):
    new = []
    tmp = 0
    
    for j in range(len(onaji)):
        for k in range(len(s[i])):
            #   print(i,j,tmp,k,onaji)
            if tmp+k >= len(s[i]):
                break
            if onaji[j] == sort_s[i][tmp+k]:
                new.append(onaji[j])
                tmp = tmp+k+1
                break
    #tmp = 0
    onaji = new
    #new = []
            
print(*onaji,sep="")

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+123;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ a%=MOD;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=MOD;--b;}a*=a;a%=MOD;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n,i,ans=0;
    cin>>n;
    ll a[n];
    forn(i,n) cin>>a[i];
    for(i=1;i<n-1;i++){
        if(a[i]>a[i+1] and a[i]<a[i-1]) ans++;
        else if(a[i]<a[i+1] and a[i]>a[i-1]) ans++;
    }
    cout<<ans el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


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

int main()
{
    int n;
    scanf("%d",&n);
    long long array[n + 1];
    long long diff[n];
    long long sum = 0;
    for(int i = 1;i <= n;i++){
        scanf("%lld",&array[i]);
        sum += array[i];
        }
    array[0] = array[n];
    if(sum % ((long)n * (n + 1)/2)){
    printf("NO");
    return 0;
    }
    int times = sum * 2 / ((long)n * (n + 1));
    long long cnt = 0;
    for(int i = 0;i < n;i++){
            diff[i] = array[i + 1] - array[i] - times;
            if(diff[i] > 0){
            printf("NO");
            return 0;
            }
            if(diff[i] < 0){
            if(abs(diff[i]) % n){
            printf("NO");
            return 0;
            }
            cnt += abs(diff[i])/n;
            }
        }
     if(cnt > times){
     printf("NO");
     return 0;
     }
     printf("YES");
     return 0;
    }


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include<climits>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
#define MP make_pair
#define all(v) v.begin(),v.end()
#define EPS 1e-9
const ll mod = 1000000007;
const ll OO = (ll)1e18;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
ll fast_power(double base, ll power){
	if (power == 1) return base;
	if (power % 2 == 0) return fast_power((base*base), power / 2);
	else return(base*fast_power((base*base), power / 2));
}
//#pragma warning (disable : 4996)
void Qalbaz()
{
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(2);
}

int main(){

	Qalbaz();

	int n;
	cin >> n;

	cout << n / 3;
	
	return 0;
}

Measured memory_bytes: 256
list = list(map(int, input().split()))
n = list[0]
y = list[1]
 
index1 =0
answer=""
while index1<=n:
    index2 =0
    while index2<=n-index1:
        if y == index1*1000+index2*5000+(n-index1-index2)*10000:
            answer=str(n-index1-index2)+" "+str(index2)+" "+str(index1)
            print(answer)
            break
        elif index1==n and index2==0:
            answer ="-1 -1 -1"
            print(answer)
            break
        else:
            index2+=1
    if answer!= "":
        break
    index1+=1

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

int main() {
	int n , m ;
	cin >> m >> n ;
	int a[n] = {0} ;
	for(int j = 0 ; j < m; j++)
	{
		int k ; 
		cin >> k ;
		for(int i = 0 ; i < k; i++)
		{
			int temp;
			cin >> temp;
			a[temp-1]++;
		}
	}
	int counter = 0;
	for(int i = 0 ; i < n ; i++)
	{
		if(a[i]==m)
			counter++;
	}
	cout << counter ;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
#define int long long int

void solve() {
  // int x;
  // cout << endl;
}

signed main() {
  int n;
  cin >> n;
  int prev = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    int a = 0;
    cin >> a;
    if (a == prev) {
      a = 0;
      ans++;
    }
    prev = a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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-1; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
const int MAX = 510000;
const int INF =2000000000;
const int MOD = 1000000007;
//gcd,lcmセット
ll gcd(ll a, ll b){
   if (a%b == 0) return b;
   else return gcd(b, a%b);
}
ll lcm(ll a, ll b){	
   return a*b/gcd(a, b);
}
int pow_kai(int a, int n){//aのn乗を計算します。
  int x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a;
    }
    a = a*a;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}
// a^n mod を計算する
long long modPow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// a^{-1} mod を計算する
ll modInv(ll a, ll mod) {
    return modPow(a, mod - 2, mod);
}

long long fac[MAX], finv[MAX], inv[MAX];

// combinationのテーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
 
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
//dfsではvector<vector<int>> g(n);で◎
int main() {
    int n;
    string ans="APPROVED";
    cin>>n;
    int a;
    REP(i,n){
        cin>>a;
        if(a%2==1) continue;
        else if(a%3!=0&&a%5!=0){
            ans="DENIED";
            break;
        }
    }
    cout<<ans<<endl;
}

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

typedef long long int ll; 
#define MOD 1000000007
#define ON 200000
#define rep(i,n) fp(i,0,n)  
#define fp(i,a,b) for(ll i=(a);i<(b);++i)
#define fn(i,a,b) for(ll i=(a);i>(b);i--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define FF first
#define SS second
typedef pair<ll, ll> pll; 
typedef vector<pll> vpll;
typedef vector<ll> vll;
#define rs(t) string t;cin>>t
#define ri(t) int t;cin>>t
#define rll(t) long long int t;cin>>t
#define MK make_pair
#define PB push_back
#define PO pop_back
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
///// This part below is only for debug, not used /////
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
///// END /////

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  rll(a);
  rll(b);
  rll(c);
  if(a+b+c>=22){
  	cout << "bust" ;
  }
  else
  	cout << "win";

  
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,-1,0,1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
    if(a>b){
        a = b; return true;
    }
    else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
    if(a<b){
        a = b; return true;
    }
    else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
    cout << a << " " << b << " " << c << "\n";
}
const ll mod = 1e9 + 7;
//const int mod = 998244353;

struct dat{
    ll k,l,r,lr,id;
    bool operator< (const dat &d) const {
        return lr < d.lr;
    }
};

void solve(){
    ll n; cin >> n;
    vector<dat> v(n);
    rep(i,n){
        ll k,l,r; cin >> k >> l >> r;
        k--;
        v[i] = {k,l,r,r-l,i};
    }
    sort(all(v));
    set<int> se;
    rep(i,n) se.insert(i);
    vb visit(n,false);
    ll ans = 0;
    int sz = 0;
    rep(i,n){
        if(v[i].lr > 0) break;
        visit[v[i].id] = true;
        auto itr = se.upper_bound(v[i].k);
        if(itr == se.begin()){
            ans += v[i].r;
        }
        else{
            ans += v[i].l;
            itr--;
            se.erase(itr);
        }
        sz++;
    }
    se.clear();
    for(int i=sz; i<n; i++) se.insert(i);
    for(int i=n-1; i>=0; i--) if(!visit[v[i].id]){
        auto itr = se.upper_bound(v[i].k);
        if(itr == se.end()){
            ans += v[i].l;
            se.erase(se.begin());
        }
        else{
            ans += v[i].r;
            se.erase(itr);
        }
    }
    cout << ans << "\n";
}

int main(){
    ll t; cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 20416
#include<iostream>
#include<algorithm>
#include<utility>
#include<math.h>
#include<queue>
#include<vector>



using namespace std;
int main(){
  long long N;
  cin>>N;
  long long x=int(sqrt(N));
  long long sum=10110110110110;

  
  
  for(long long i=1;i<=x;i++){
  	if(N%i==0){
    	if(sum>(N/i+i)){
        	sum=N/i+i;
        }
    }
  }
  
  cout<<sum-2;
  
  
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;


int main(){
	string s,a,b;
    char c;
    ll q,t,f,R=0;
    cin>>s>>q;
    rep(i,q){
        cin>>t;
        if(t==1){R++;continue;}
        cin>>f>>c;
        if((f+R)%2)a+=c;
        else b+=c;
    }
    if(R%2){
        red(i,b.size())cout<<b[i];
        red(i,s.size())cout<<s[i];
        cout<<a<<endl;
    } 
    else {
        red(i,a.size()) cout<<a[i];
        cout<<s<<b<<endl;
    }
}


Measured memory_bytes: 1088
n = str(input())
cnt = len(n) - 1
for i in range(2**cnt):
    op = ["-"]*cnt
    for j in range(cnt):
        if (i>>j)&1:
            op[cnt - 1 -j] = "+"
    
    formula = ""
    for pn,po in zip(n,op + [""]):
        formula += (pn + po)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Measured memory_bytes: 9128
include Math

loop {
	n = gets.to_i
	break if n == 0
	points = (1..n).map { gets.split.map &:to_f }

	max = 1
	points.combination(2){|(x1, y1), (x2, y2)|
		l = hypot(x1 - x2, y1 - y2)
		next if l > 2
		k = sqrt(4 - l*l) / l
			
		u = (x1 + x2 + k * (y1 - y2)) / 2
		v = (y1 + y2 + k * (x2 - x1)) / 2
		c = points.count{|x, y| hypot(u-x, v-y) <= 1.00001}
		max = c if c > max

		u = (x1 + x2 - k * (y1 - y2)) / 2
		v = (y1 + y2 - k * (x2 - x1)) / 2
		c = points.count{|x, y| hypot(u-x, v-y) <= 1}
		max = c if c > max
	}
	p max
}

Measured memory_bytes: 8732
import Data.Functor

main :: IO ()
main = do
    [a, b] <- fmap read . words <$> getLine :: IO [Int]
    case () of
        _ | a < b     -> putStrLn "a < b"
          | a > b     -> putStrLn "a > b"
          | otherwise -> putStrLn "a == b"



Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <complex>
using namespace std;

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

	//0101... or 1010...

	vector<int> list(2);
	for(int i=0; i<S.size(); i++)
	{
		if((i%2 == 0 && S[i] == '0') ||((i%2 == 1 && S[i] == '1')))
		{
			list[0]++;
		}
		else
		{
			list[1]++;
		}
	}
	cout<<*min_element(list.begin(),list.end())<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
// #define deb(x)     cerr << (#x) << " : " << (x) << "\n"
#define ll long long int
#define ld long double
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
using namespace std;

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define deb(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define deb(...) 42
#endif

ll powmod(ll a, ll b, ll MOD = MOD){
	if(!a and !b)	return 1ll;
	if(!a)	return a;
	ll res = 1ll;
	b %= (MOD - 1ll), a %= MOD;
	while(b){
		if(b%2 == 1)	res = (res * a) % MOD;
		a = (a * a) % MOD;
		b /= 2;
	}
	return res;
}
ll col[200010], sub[200010], dpth[200010];
deque<int> que[200010];
vector<vector<int>> edges;
ll dp[200010], pre[400010];

void calc(int u, int par = -1){
	sub[u] =1;
	for(auto v : edges[u]){
		if(v != par){
			calc(v, u);
			sub[u] += sub[v];
		}
	}
}

void dfs(int u, int par = -1){
	if(par == -1)	dpth[u] = 0, pre[u] = sub[u];
	else	dpth[u] = dpth[par] + 1, pre[u] = pre[par];
	que[col[u]].push_front(u);

	for(auto v : edges[u]){
		if(v != par){
			pre[u] = sub[v]; 
			dfs(v, u);
		}
	}
	que[col[u]].pop_front();
	ll tmp = pre[que[col[u]].front()] - sub[u] + 1;
	dp[col[u]] += (tmp * sub[u]), pre[que[col[u]].front()] -= sub[u];
	tmp = sub[u] - 1;
	for(auto v : edges[u]){
		if(v != par){
			tmp -= sub[v];
			dp[col[u]] += (sub[v] * tmp);
			// if(u == 3)	deb(v, dp[col[u]]);
		}
	}
}

int main(){
    #ifdef XOX
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\Input.txt", "r", stdin);
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\OPT.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
	cin >> n;
	memset(dp, 0, sizeof(dp));
	for(int i = 1; i <= n; i++)	cin >> col[i];
	pre[0] = n;
	int u, v;
	edges.resize(n + 1);
	for(int i = 0; i < (n - 1); i++){
		cin >> u >> v;
		edges[u].push_back(v), edges[v].push_back(u);
	}

	dpth[0] = -1;
	for(int i = 1; i <= n; i++)	que[i].push_front(n + i), pre[n + i] = n;	
	calc(1);
    dfs(1);

	for(int i = 1; i <= n; i++)	cout << dp[i] << "\n";
}

Measured memory_bytes: 277316
/*
1. I'm the Future Red Coder :)
2. Hopefully, I'll be Yellow Soon.
*/
#include<bits/stdc++.h>
#define mod 998244353 //1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
ll power(ll a,ll b,ll m=mod) {
    if (b==0) return 1;
    ll c = power(a,b>>1,m);
    c = (c*c)%m;
    if (b&1) return (c*a)%m;
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}
/*struct node {
    int l,r,nq;
};
bool compare(const node& a,const node& b) {
    if (a.r != b.r) return a.r<b.r;
    return a.l<b.l;
}*/
/* ******* DSU START ****** */
/*
const int dsusize = (int)1e5+5;
struct node {
    int data;
    int rk,pn;
}dsu[dsusize];
//ll fans;
void initialize(int n) {
    REP(i,1,n) {
        dsu[i].data = 1;
        dsu[i].rk = 0;
        dsu[i].pn = i;
    }
}
int fnd(int i) {
    if (dsu[i].pn != i) dsu[i].pn = fnd(dsu[i].pn);
    return dsu[i].pn;
}
void unn(int i,int j) {
    i = fnd(i);
    j = fnd(j);
    if (i!=j) {
        //fans -= dsu[i].data*dsu[j].data;
        if (dsu[i].rk>dsu[j].rk) {
            dsu[j].pn = i;
            dsu[i].data += dsu[j].data;
        }
        else {
            dsu[i].pn = j;
            dsu[j].data += dsu[i].data;
            if (dsu[i].rk==dsu[j].rk) {
                dsu[j].rk++;
            }
        }
    }
}
*/
/* ******* DSU END****** */

const int N = (int)2e5+5;
const int Q = 250;
int a[N];
vector<int> v;
void solve() {
    int n;
    cin>>n;
    REP(i,1,n) {
        cin>>a[i];
    }
    REPN(i,n,1) {
        int cnt = 0;
        for(int j=2*i;j<=n;j+=i) {
            cnt += (a[j]==1);
        }
        a[i] = (cnt%2 != a[i]%2);
        if (a[i]==1) v.pb(i);
    }
    reverse(all(v));
    cout<<v.size()<<"\n";
    for (auto it:v) {
        cout<<it<<" ";
    }
}
int main() {
    //freopen("class_treasurer.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


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

#define ll long long
#define f first
#define s second
#define inf 1e15

#define N 300005

string s;
ll n,m,x,y,d,k;
ll a[N];

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
	int t=1;
	//cin>>t;
	while(t--){
	    
	    
	    cin>>x>>k>>d;
	    
	    if(x<0){
	        x*=-1;
	    }
	    
	    ll ans=0;
	    
	    if(k<=x/d){
	        
	        ans=x-k*d;
	    }
	    else
	    {
	        ll valr=x%d;
	        ll vall=d-x%d;
	        
	        ll used=x/d;
	        ll rem=k-x/d;
	        
	        if(rem%2==0){
	            ans=valr;
	        }
	        else
	        {
	            ans=vall;
	        }
	    }
	    
	    cout<<ans<<"\n";
	    
	    
	}
	return 0;
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(void){

    int n;
    cin >> n;
    int a,b,c,d;
    int score[1000]={0};
    int count=0;
    for(int i=0;i<n*(n-1)/2;i++){
        cin>>a>>b>>c>>d;
        if(c>d)score[a]+=3;
        else if(c<d)score[b]+=3;
        else if(c==d)score[a]++,score[b]++;

    }
    for(int i=1;i<=n;i++){
        count = 1;
        for(int j=1;j<=n;j++){
            if(score[i]<score[j])count++;
        }
        cout<<count<<endl;
    }


    return 0;
}

Measured memory_bytes: 1164