akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>

typedef long long ll;

using namespace std;

ll calCost(ll target, vector<ll>& va, vector<ll>& vb) {
    int ua = upper_bound(va.begin(), va.end(), target) - va.begin();
    int la = lower_bound(va.begin(), va.end(), target) - va.begin();
    
    int ub = upper_bound(vb.begin(), vb.end(), target) - vb.begin();
    int lb = lower_bound(vb.begin(), vb.end(), target) - vb.begin();
    
    set<int> aIndex;
    set<int> bIndex;

    if(la - 1 >= 0) {
        aIndex.insert(la - 1);
    }
    aIndex.insert(la);
    aIndex.insert(ua);
    if(ua + 1 < va.size()) {
        aIndex.insert(ua + 1);
    }
    
    if(lb - 1 >= 0) {
        bIndex.insert(lb - 1);
    }
    bIndex.insert(lb);
    bIndex.insert(ub);
    if(ub + 1 < vb.size()) {
        bIndex.insert(ub + 1);
    }
    
    ll minCost = -1;
    for(set<int>::iterator ia = aIndex.begin(); ia != aIndex.end(); ++ia) {
        for(set<int>::iterator ib = bIndex.begin(); ib != bIndex.end(); ++ib){
            ll pa = va[*ia];
            ll pb = vb[*ib];
            
            ll cost = 0;
            if(pa <= target && pb <= target) {
                cost = target - min(pa, pb);
            } else if(target < pa && target < pb) {
                cost = max(pa, pb) - target;
            } else {
                ll ca = pa > target ? (pa - target) : (target - pa);
                ll cb = pb > target ? (pb - target) : (target - pb);
                cost = min(ca, cb) + (pa > pb ? (pa - pb) : (pb - pa));
            }
            if(minCost == -1) {
                minCost = cost;
            } else {
                minCost = min(minCost, cost);
            }
        }
    }
    
    return minCost;
}

int main() {
    int a = 0, b = 0, q = 0;
    cin >> a >> b >> q;

    vector<ll> va(a, 0);
    vector<ll> vb(b, 0);
    vector<ll> vq(q, 0);

    for(int i = 0; i < a; ++i) {
        cin >> va[i];
    }
    for(int i = 0; i < b; ++i) {
        cin >> vb[i];
    }
    for(int i = 0; i < q; ++i) {
        cin >> vq[i];
    }
    
    sort(va.begin(), va.end());
    sort(vb.begin(), vb.end());
    
    for(int i = 0; i < q; ++i) {
        ll cost = calCost(vq[i], va, vb);
        cout << cost << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
A, B, C, D, E, F = map(int, input().split())

x = set()
y = set()

for i in range(F // (100 * A) + 1):
    for j in range((F - 100 * A * i) // (100 * B) + 1):
        if i + j == 0:
            continue
        x.add(A * i * 100 + B * j * 100)

for i in range(F // C + 1):
    for j in range((F - C * i) // D + 1):
        y.add(C * i + D * j)

ret_w = 1
ret_s = -1

for w in x:
    for s in y:
        if w + s <= F and w * E / 100 >= s and s / (w + s) >= ret_s / ret_w:
            ret_s = s
            ret_w = w + s

print(ret_w, ret_s)


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int N; cin >> N;
  int sum = 0, ma;
  for (int i = 1; ; i++) {
    sum += i;
    if (sum >= N) { ma = i; break; }
  }
  reps(i, ma) {
    if (sum - N == i) continue;
    cout << i << '\n';
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using vi = vector<li>;
using vs = vector<string>;


int main()
{
    li n,a,x=0,y=0;
    cin>>n;
    rep(i,n) {
        cin>>a;
        if(a%4==0) y++;
        else if(a%2==0) x++;
    }
    if(y+x/2>=n/2) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include "math.h"
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <functional>
#include <numeric>
#include <cmath>
using namespace std;


#define ll long long

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

	int n, m, k;
	cin >> n >> m >> k;

	vector<ll> a = { 0 };
	vector<ll> b = { 0 };

	int e;
	for (int i = 1; i < n + 1; i++)
	{
		cin >> e;
		a.push_back(a[i - 1] + e);
	}
	for (int i = 1; i < m + 1; i++)
	{
		cin >> e;
		b.push_back(b[i - 1] + e);
	}


	int j = m;
	int mx = 0;
	for (int i = 0; i < n + 1; i++)
	{
		if (a[i] > k) break;
		while (b[j] > k - a[i]) {
			j -= 1;
		}
		if ((i + j) > mx) mx = (i + j);
	}
	cout << mx;

	return 0;
}


Measured memory_bytes: 7932
import sys
import itertools
import bisect
from operator import itemgetter
 
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
ans = 0
ans += N//500 * 1000
N -= N//500 * 500
ans += N//5 * 5
print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization ("Ofast")
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define siz(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b) {
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b) {
	if(a<b){a=b;return true;}
	return false;
}
template<class T> inline int getidx(vector<T> &v, T a) {
	return lower_bound(all(v), a) - v.begin();
}

constexpr int mod=998244353;
constexpr int inf=3e18;


signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N;cin>>N;
	set<string>st;
	while(N--){
		string s;cin>>s;st.insert(s);
	}
	cout<<st.size()<<endl;
}


Measured memory_bytes: 19248
using System;
using System.Globalization;

class Program
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine().Split(' ');
        var a = long.Parse(line[0], CultureInfo.InvariantCulture);
        var b = int.Parse(line[1].Replace(".", ""), CultureInfo.InvariantCulture);

        var result = a * b / 100;
        Console.WriteLine(result.ToString(CultureInfo.InvariantCulture));
    }
}


Measured memory_bytes: 26028
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char[] c = new char[N];
		String line2 = sc.next();
		
		int K = sc.nextInt()-1;
		
		for(int i=0; i<N; i++) {
			c[i] = line2.charAt(i);
		}
		
		for(int i=0; i<N; i++) {
			if(c[K] != c[i]) {
				c[i] = '*';
			}
			System.out.print(c[i]);
		}
		System.out.println("");
		
		
	}
}

Measured memory_bytes: 24148
#include<iostream>
using namespace std;
int main(){
int n;
cin >>n;
int sum=0;
int total=0;
if(n<105){
    cout << 0 <<endl;
}
else if(n==105){
    cout << 1 <<endl;
}
else if(n>105){
    for(int i=1;i<=n;i++){
       for(int j=1;j<=n;j++){
           if(i%j==0){
               sum++;
           }
       }
       if(sum==8){
           total++;
       }
        sum=0;
            i++;
    }
    cout << total <<endl;
}
 
}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines 
MOD = 10**9+7

S = inpS()
ans = "No"
if S.count("A")!=3:
  if S.count("B")!=3:
    ans = "Yes"
print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			string t = Console.ReadLine();
			int n = s.Length;

			int m = 26;
			var ex = new int[m];
			var rex = new int[m];
			for (int i = 0; i < m; i++) {
				ex[i] = -1;
				rex[i] = -1;
			}

			for (int i = 0; i < n; i++) {
				int ss = s[i] - 'a';
				int tt = t[i] - 'a';
				if (ex[ss] == -1) {
					if (rex[tt] != -1) {
						Console.WriteLine("No");
						return;
					}

					ex[ss] = tt;
					rex[tt] = ss;
				} else {
					if (ex[ss] != tt) {
						Console.WriteLine("No");
						return;
					}
				}
			}

			Console.WriteLine("Yes");
		}
	}
}

Measured memory_bytes: 12512
#include<bits/stdc++.h>
#define M 100002
using namespace std;
int tr[M*36],Lson[M*36],Rson[M*36],sum[M*36],cnt[M*36],tot,f[M][19],dep[M],n;
struct ll{
	int to,col,dis;
};
vector<ll>son[M];
void Insert(int &rt,int old,int l,int r,int col,int dis){
	rt=++tot;
	Lson[rt]=Lson[old];
	Rson[rt]=Rson[old];
	cnt[rt]=cnt[old]+1;
	sum[rt]=sum[old]+dis;
	if(l==r)return;
	int mid=(l+r)>>1;
	if(mid>=col)Insert(Lson[rt],Lson[old],l,mid,col,dis);
	else Insert(Rson[rt],Rson[old],mid+1,r,col,dis);
}
void dfs(int x,int fa,int col,int dis){
	dep[x]=dep[fa]+1,f[x][0]=fa;
	if(fa)Insert(tr[x],tr[fa],1,n-1,col,dis);
	for(int i=0;i<son[x].size();i++){
		ll y=son[x][i];
		if(y.to==fa)continue;
		dfs(y.to,x,y.col,y.dis);
	}
}
int Up(int b,int step){
	for(int i=0;i<17;i++)if(step&(1<<i))b=f[b][i];
	return b;
}
int LCA(int a,int b){
	if(dep[a]>dep[b])swap(a,b);
	b=Up(b,dep[b]-dep[a]);
	if(a==b)return a;
	for(int i=16;i>=0;i--)if(f[a][i]!=f[b][i])a=f[a][i],b=f[b][i];
	return f[a][0];
}
int query(int Rt,int rt,int Lt,int l,int r,int col,int dis){
	if(l==r){
		int num=cnt[Rt]+cnt[rt]-2*cnt[Lt];
		return num*dis;
	}
	int mid=(l+r)>>1;
	if(mid>=col)return query(Lson[Rt],Lson[rt],Lson[Lt],l,mid,col,dis)+sum[Rson[Rt]]+sum[Rson[rt]]-2*sum[Rson[Lt]];
	return sum[Lson[Rt]]+sum[Lson[rt]]-2*sum[Lson[Lt]]+query(Rson[Rt],Rson[rt],Rson[Lt],mid+1,r,col,dis);
}
int main(){
	int m,u,v,x,y;
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++){
		scanf("%d%d%d%d",&u,&v,&x,&y);
		son[u].push_back({v,x,y});
		son[v].push_back({u,x,y});
	}
	dfs(1,0,0,0);
	for(int i=1;i<18;i++){
		if((1<<i)>n)break;
		for(int j=1;j<=n;j++)f[j][i]=f[f[j][i-1]][i-1];
	}
	for(int i=1;i<=m;i++){
		scanf("%d%d%d%d",&x,&y,&u,&v);
		int lca=LCA(u,v);
		printf("%d\n",query(tr[u],tr[v],tr[lca],1,n-1,x,y));
	}
	return 0;
}

Measured memory_bytes: 58752
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
bool f[20][150]; bool vis[20][150];
int A[20];
int dig;
int ans = 0;
bool dp(int i, int flag, int sum) {
#ifdef LOCAL
  // printf("State %d %d\n", i, sum);
#endif
  if(i == dig) {
    ans = std::max(ans, sum);
    return true;
  }
  if(!flag && vis[i][sum]) return f[i][sum];
  f[i][sum] = vis[i][sum] = true;
  int bd = flag ? A[i] : 9;
  for(int j = 0; j <= bd; j ++) {
    if(j == bd) {
      dp(i + 1, flag, sum + j);
    } else {
      dp(i + 1, 0, sum + j);
    }
  }
}
typedef long long ll;
int main() {
  ll v; scanf("%lld", &v);
  char buf[20]; memset(buf, 0, sizeof(buf));
  sprintf(buf, "%lld", v);
  dig = strlen(buf);
  for(int i = 0; i < dig; i ++) {
    A[i] = buf[i] - '0';
  }
  dp(0, 1, 0);
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
// ------------------------------------
// Date:2018/ 3/ 8
// Problem:ABC 061 BigArray c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

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

static const int INF = 1000000001;

//static const int MAX_DATA = 101010;
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N, K;
  cin >> N >> K;

  vector< M > data(N, make_pair(INF, INF));
  int a, b;
  REP(i, N) {
    cin >> a >> b;
    data[i] = make_pair(a, b);
  }

  sort(ALL(data));

  ll bias = 0;
  ll ans = data[0].first;
  REP(i, N) {
    ans = data[i].first;
    bias += data[i].second;
    if (bias > K - 1) break;
  }
  
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 1792
k = gets.chomp.to_i

def su(n)
  n.to_f / s(n)
end

def s(n)
  n.to_s.chars.reduce(0){|sum, i| sum + i.to_i}
end

ary = []
cnt = 0
i = 0
n = 1

until cnt == k do
  tmp = Array.new(1, ary[-1])
  until (su(n + (10 ** i)) - su(n) >= 0) do
    n = tmp[-1]
    i += 1
    tmp.push (n + (10 ** i))
  end
  if n != ary[-1]
    ary.push n
    cnt += 1
  end
  n += (10 ** i)
end

ary.each do |num|
  puts num
end

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

    static int[] X = { -1, 0, 1 };

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        long fullPattern = 1;
        long nonMatch = 1;
        for (int i = 0; i < N; i++) {
            fullPattern *= 3;

            if (a[i] % 2 == 0) {
                nonMatch *= 2;
            }
        }
        System.out.println(fullPattern - nonMatch);
    }
}


Measured memory_bytes: 21588
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {


	static int X = 0;
	static int Y = 0;
	static int Z = 0;
	static int answer = 0;

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(new InputStreamReader(System.in));

		int K = sc.nextInt();
		int S = sc.nextInt();

		sc.close();

		setNumber(K,S);

		execute(K,S);


		System.out.println(answer);

	}

	static void setNumber(int k, int s){
		if(k >= s){
			X = s;
			return;
		} else {
			X = k;
			s = s - k;
			if(k >= s){
				Y = s;
				return;
			} else {
				Y = k;
				Z = s - k;
				return;
			}
		}
	}

	static void execute(int K, int S){
		int check = 0;
		int x = X;
		int y = Y;
		int z = Z;

		for(; x >= Math.ceil((double)S/3); x--){
			for(; y >= z; y--){
				if(x >= y) {
					check = checkCombi(x,y,z);
					if(check == 0) {
						answer += 6;
					} else if(check == 2) {
						answer += 3;
					} else if(check == 3) {
						answer += 1;
					}
				}
				z++;
			}
			Y++;
			y = Y;
			z = Z;
		}
	}

	static int checkCombi(int x,int y,int z){
		if((x == y) && (x == z)){
			return 3;
		} else if ((x == y) || (x == z) || (y == z)){
			return 2;
		} else {
			return 0;
		}
	}

}

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

int main(void) {
	int N;
	cin >> N;

	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i*j==N) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


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

int main(){
  int  n,d,k,s=0;
    cin>>n>>d;
    k=2*d+1;///cati meri viziteaza un vanator
    if(n%k!=0){
        s=n/k+1;
    }
    else{
        s=n/k;
    }cout<<s;
  return 0;
}


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


using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define printfloat(x) cout << fixed << setprecision(7) << (x) << endl;
#define printbit(x) cout << bitset<15>(x) << endl;
using ll = long long int;

map<int ,int> mp;

long double pi = 3.14159265359;

int n,k,q;
int a;

int main(){
    cin >> n >> k >> q;
    rep(i,q) {
        cin >> a;
        mp[a-1]++;
    }
    rep(i,n){
        if(k > q - mp[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
return 0;
}

Measured memory_bytes: 8324
#!/usr/bin/env python3
import sys
from itertools import groupby

# RUN LENGTH ENCODING
def runLengthEncode(S: str):
    grouped = groupby(S)
    res = []
    for k, v in grouped:
        res.append((k, str(len(list(v)))))
    return res

def runLengthdecode(L: "list[tuple]"):
    res = ""
    for c, n in L:
        res += c * int(n)
    return res

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, K = map(int, input().split())
    S = input()
    compressed = runLengthEncode(S)

    # ある区間を反転させるとその両端が前後で連結するようにするのが最大化できる = 両端の操作は損
    for k in range(K):
        i = 2 * k + 1   # 奇数インデックスのみ反転させる。
        if i >= len(compressed):
            break
        compressed[i] = ('L', compressed[i][1]) if compressed[i][0] == "R" else ('R', compressed[i][1])

    reCompressed = runLengthEncode(runLengthdecode(compressed))
    ans = N - len(reCompressed)

    print(ans)

if __name__ == '__main__':
    main()


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:
ll s(int n) {
  ll sum = 0;
  while(n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int n; cin >> n;
  ll sum = 100000;
  for(int i = 1; i < n; i++) {
    int a = i, b = n-i;
    sum = min(s(a)+s(b),sum);
  }
  cout << sum << endl;

  return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  priority_queue<int> Q;
  for (int a; cin >> a;) Q.push(a);
  while (M--) {
    int q = Q.top();
    Q.pop();
    Q.push(q / 2);
  }
  long ans = 0;
  while (Q.size()) {
    ans += Q.top();
    Q.pop();
  }
  cout << ans << "\n";
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int k, n, a[101];

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
double pi=3.141592653;
double a,b,x,l,r=90.0,mid,c,d,e;
int main(){
	cin >> a >> b >> x;
	x=x*2/a;
	while(r-l>1e-8){
		mid=(l+r)/2,c=sin(mid*pi/180)*b;
		d=b*sqrt(b*b-c*c)/c,e=(a*b<x)?b*(d-a)/d:b*d/(d+a);
		if(b*d-max(0.0,e*(d-a))>x)l=mid;
		else r=mid;
	}
	printf("%.7lf",l);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <vector>
 
int main() {
  int h,w;

  std::cin >> h;
  std::cin >> w;

  std::vector<std::vector<char>> grid;
  grid.resize(h);
  for(auto&& line : grid) {
    line.resize(w);
    for(auto&& p : line) {
      std::cin >> p;
    }
  }

 bool pholder;
 for(int l = 0; l < h; l++) {
    auto&& line = grid[l];
    for(int m = 0; m < w; m++) {
      auto&& p = line[m];
        if(p == '#'){
          if(l != 0) 
            if(grid[l-1][m] == '#') continue;
          if(m != 0)
            if(line[m-1] == '#') continue;
          if(l != h - 1)
            if(grid[l+1][m] == '#') continue;
          if(m != w - 1)
            if(line[m+1] == '#') continue;
          std::cout << "No" << std::endl;
          std::exit(0);
       }
    }
  }

  std::cout << "Yes" << std::endl;
}

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

int main(){
    string str;
    int64_t s = 0;
    int64_t cur = 0, l = 0;
    char prev = '>';

    cin >> str;
    str.push_back('X');
    for(int i=0;i<str.size();++i){
        if(str[i] == prev) ++cur;
        else{
            if(prev == '<'){
                if(str[i] == 'X') ++cur;
                s += cur*(cur-1) / 2;
                l = cur;
            }
            else{
                s += cur*(cur+1) / 2;
                if(cur < l) s += l-cur;
            }
            prev = str[i];
            cur = 1;
        }
    }
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 900
#include <stdio.h>
#include <string.h>

int main (void)
{
    char str[22], temp;
    int lengthhalf, i, j;
    scanf("%s", &str);
    lengthhalf = strlen(str) / 2;
    
    i = 0;
    j = strlen(str) - 1;
    for ( ; i < lengthhalf; i++, j--){
        temp = str[i];
        str[i] = str[j];
        str[j] = temp;
        
    }
    puts(str);

    return (0);
}


Measured memory_bytes: 2024
h,w = map(int, input().split())

grid = [input() for i in range(h)]

L = [[0 for i in range(w)] for j in range(h)]
R = [[0 for i in range(w)] for j in range(h)]
D = [[0 for i in range(w)] for j in range(h)]
U = [[0 for i in range(w)] for j in range(h)]

#左上から
for i in range(h):
    for j in range(w):
        if grid[i][j] == "#":
            L[i][j] = 0
            U[i][j] = 0
        else:
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
            
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1

#右下から
for i in reversed(range(h)):
    for j in reversed(range(w)):
        if grid[i][j] == "#":
            R[i][j] = 0
            D[i][j] = 0
        else:
            if j == w-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j+1] + 1
                
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1


ans = 0
for i in range(h):
    for j in range(w):
        if grid[i][j] == "#":
            continue
        tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
        ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 185348
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX / 2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vb = vector<bool>;
using vvb = vector<vb>; 
using vvvb = vector<vvb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using psi = pair<string, int>;

int bs_cnt_less(vl& A, const ll X, bool equal) {
    if (equal) return upper_bound(A.begin(), A.end(), X) - A.begin();
    else return lower_bound(A.begin(), A.end(), X) - A.begin();
}

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

  int N; cin >> N;
  vl L(N); REP(i,N) cin >> L[i];

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

  int cnt = 0;
  REP(i,N-2) {
    FOR(j,i+1,N-1) {
      cnt += bs_cnt_less(L, L[i]+L[j], false) - (j+1);
    }
  }

  int ans = cnt;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
rec = []
for i in range(1, 100005):
    if n % i == 0:
        rec.append((i, n // i))

num = float("inf")
for p, q in rec:
    rec = max(len(str(p)), len(str(q)))
    num = min(num, rec)

print(num)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF 1023456789
#define sacnf scanf
#define CRLF <<'\n';
#define PRPAIR(x) x.first << x.second
#define DEBUG(x) do { std::cerr <<(x)<<'\n'; } while (0)

#define rep(i,a,b) for(int i=(a);i!=(int)b-((a)>(b));(a)>(b)?--i:++i)
#define trav(it,v) for(typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> pip;
typedef vector<int> vi;
typedef long long ll;


int main(){
    int n;
    scanf("%d",&n);
    ll c=0;
    rep(i,1,n+1){
        if (i*i > n)
            break;
        for(int j = i*i; j <= n; j += i){
            c+=j + (j%i==0 && j/i != i ? j:0);
        }
    }
   printf("%lld",c);

}


Measured memory_bytes: 3708
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    string S;
    cin >> S;
    int l = S.length();
    int st = -1,ed = -1;
    //DPクソもないけどoxoみたいな構造を探してやればいいらしい。そりゃそうだ
    if(l == 2){
        if(S[0] == S[1]){
            cout << "1 2" << endl;
        }else{
            cout << "-1 -1" << endl;
        }
        return 0;
    }
    REP(i,l-2){
        //cout << S[i] << S[i + 1] << S[i + 2] << endl;
        if (S[i] == S[i + 1] || S[i] == S[i + 2] || S[i + 1] == S[i + 2])
        {
            st = i+1;
            ed = i+3;
            break;
        }
    }
    cout << st << " " << ed << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define F first
#define S second
void solve(){
    int a;
    cin>>a;
    //vector<int> a(n);
    // for(int i=0;i<n;i++){
    //     cin>>a[i];
    // }
    int y= a+ pow(a,2) + pow(a,3);
    cout<< y<<endl;
}
int main() {
	int t=1;
	//cin>>t;
	while(t--){
	    solve();
	}
	return 0;
}


Measured memory_bytes: 3972
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;

const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 1e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{   
   	ll k;
   	cin >> k;
   	ll curr = 7;
   	ll tot = 1;
   	while(curr % k != 0 && tot < 1e7)
   	{
   		curr = curr % k;
   		curr = curr * 10 + 7;
   		tot++;
   	}
   	if(curr % k == 0)
   		cout << tot << '\n';
   	else
   		cout << -1 <<'\n';	

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

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

int main(void){
long long int x;
long long int now=100;
scanf("%lld",&x);
for(int i=1;;i++){
    now=now*1.01;
    if(now>=x){printf("%d\n",i);return 0;}
}
}

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

int main(){
    int n;
    cin>>n;
    int a[n];
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum%10!=0)cout<<sum;
    else{
        sort(a,a+n);
        int f=0;
        for(int i=0;i<n;i++){
            if((sum-a[i])%10!=0){
                cout<<sum-a[i];
                f=1;
                break;
            }    
        }
        if(f==0)cout<<0;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace cswork
{
    class Program
    {
        public Program() { }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<string> permList = new List<string>();
        void Omame()
        {
            cin = new Scanner();
            int n = cin.nextInt();

            string p = "";
            for (int i = 0; i < n; i++)
            {
                string pp = cin.next();
                p += pp + " ";
            }
            p = p.Substring(0, p.Length - 1);

            string q = "";
            for (int i = 0; i < n; i++)
            {
                string qq = cin.next();
                q += qq + " ";
            }
            q = q.Substring(0, q.Length - 1);

            Permutation(0, n, n);

            int a = 0;
            int b = 0;
            for (int i = 0; i < permList.Count; i++)
            {
                if (permList[i].Equals(p))
                {
                    a = i;
                }
                
                if (permList[i].Equals(q))
                {
                    b = i;
                }
            }

            Console.WriteLine(Math.Abs(a - b));
        }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                string s = "";
                for (int i = 0; i < n; i++)
                {
                    s += (perm[i] + 1) + " ";
                }
                s = s.Substring(0, s.Length - 1);
                permList.Add(s);
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();

            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next();
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }
    }
}

Measured memory_bytes: 22216
s = input()
a,b,c,d = int(s[0]), int(s[1]), int(s[2]), int(s[3])
if a+b+c+d == 7:
    print("{0}+{1}+{2}+{3}=7".format(str(a),str(b),str(c),str(d)))
elif a+b+c-d == 7:
    print("{0}+{1}+{2}-{3}=7".format(str(a),str(b),str(c),str(d)))
elif a+b-c+d == 7:
    print("{0}+{1}-{2}+{3}=7".format(str(a),str(b),str(c),str(d)))
elif a-b+c+d == 7:
    print("{0}-{1}+{2}+{3}=7".format(str(a),str(b),str(c),str(d)))
elif a+b-c-d == 7:
    print("{0}+{1}-{2}-{3}=7".format(str(a),str(b),str(c),str(d)))
elif a - b + c - d == 7:
    print("{0}-{1}+{2}-{3}=7".format(str(a), str(b), str(c), str(d)))
elif a-b-c+d == 7:
    print("{0}-{1}-{2}+{3}=7".format(str(a),str(b),str(c),str(d)))
elif a-b-c-d == 7:
    print("{0}-{1}-{2}-{3}=7".format(str(a),str(b),str(c),str(d)))

Measured memory_bytes: 38384
<?php
$input = trim(fgets(STDIN));

$n = (int)$input;
$args = explode(' ', trim(fgets(STDIN)));;
$result=[];
if ($n === 1) {
	echo $args[0];
	exit();
}elseif ($n === 2) {
	echo $args[1] . ' ' . $args[0];
	exit();
}elseif ($n === 3) {
	echo $args[2] . ' ' . $args[0] . ' ' . $args[1];
	exit();
}
if ($n%2===0) {
	for ($i=$n; $i > 1 ; $i-=2) { 
		$tmp = $i-1;
		$result[]=$args[$tmp];
	}
	$result[]=$args[0];
	for ($i=3; $i < $n ; $i+=2) { 
		$tmp = $i-1;
		$result[]=$args[$tmp];
	}
}else{
	for ($i=$n; $i > 2 ; $i-=2) { 
		$tmp = $i-1;
		$result[]=$args[$tmp];
	}
	$result[]=$args[0];
	for ($i=2; $i < $n ; $i+=2) { 
		$tmp = $i-1;
		$result[]=$args[$tmp];
	}
}
$str = implode(' ', $result);
echo $str;

Measured memory_bytes: 33520
#include<iostream>
using namespace std;
int main(){
  int W,H,x,y,r;

  cin>>W>>H>>x>>y>>r;
  if(x+r>W||y+r>H||x-r<0||y-r<0){

    cout<<"No"<<endl;}
  
  else{
    cout<<"Yes"<<endl;}

  
  return 0;

}

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

int H, W, K, ans, a[10][1000], g[10], cnt[10];

void choice(int r, int group) {
    if (r == H) {
        fill(cnt, cnt+10, 0);
        int slice = group;
        for (int j=0;j<W;++j) {
            bool exceed = false;
            for (int i=0;i<H;++i) {
                if (a[i][j]) {
                    if (++cnt[g[i]] > K) exceed = true;
                }
            }
            if (exceed) {
                slice++;
                fill(cnt, cnt+10, 0);
                for (int i=0;i<H;++i) {
                    cnt[g[i]] += a[i][j];
                    if (cnt[g[i]] > K) return;
                }
            }
        }
        ans = min(ans, slice);
        return;
    }
    g[r] = group;
    choice(r+1, group);
    choice(r+1, group+1);
}

int main() {
    scanf("%d%d%d", &H, &W, &K);
    for (int i=0;i<H;++i)
        for (int j=0;j<W;++j) scanf("%1d", &a[i][j]);
    ans = 1e9;
    choice(0, 0);
    printf("%d", ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int i,j,k,H,W;
  while(true){
    cin >> H >> W;
    if(H==0 && W==0)break;
    for(i=1;i<=H;i++){
      if(i==1 || i==H){
        for(j=1;j<=W;j++){
          cout << "#";
        }
      }else{
        for(k=1;k<=W;k++){
          if(k==1 || k==W){
            cout << "#";
          }else{
            cout << ".";
          }
        }
      }
      cout << endl;
    }
  cout << endl;
  }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back

int main() {
    ll n,x,t;
    cin>>n>>x>>t;
    ll ans;
    if(n%x!=0) {
        ans=n/x;
        ans++;
        ans*=t;
    } else {
        ans=n/x;
        ans*=t;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <string>
#include <sstream>
int fix()
{
    //example to format floating point numbers.
    double pi = 3.141592653589793;
    double r = 3.141592653589793 * 128;
    std::ios_base::fmtflags f(std::cout.flags()); //[1]
    std::cout << "default:\n  " << pi << " " << r << "\n";
    std::cout << std::setprecision(4) << "setprecision(4):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout << std::setiosflags(std::ios::fixed) << "setiosflags(std::ios::fixed):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout << std::setprecision(5) << "setprecision(5):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout.flags(f);
    std::cout << "reset:\n  " << pi << " " << r << "\n";
    //[1] https://stackoverflow.com/questions/2273330/restore-the-state-of-stdcout-after-manipulating-it
    //[2] https://stackoverflow.com/questions/4217510/how-to-cout-the-correct-number-of-decimal-places-of-a-double-value
    return 0;
}
void multipleLines()
{
    //example to parse multiple lines input.
    std::istringstream isin("1 2 3\n3 2 4\n0 0 0");

    for (std::string str; std::getline(isin, str);)
    {
        std::istringstream tisin(str);
        int a, b, c;
        tisin >> a >> b >> c;
        std::cout << a << " " << b << " " << c << "\n";
    }
    //[1]  https://stackoverflow.com/questions/19767644/c-parsing-input-string-to-variables
}
#include <vector>
#include <set>
#include <map>

int main()
{
    if ([]() {
            std::string sS;
            std::getline(std::cin, sS);
            std::string sP;
            std::getline(std::cin, sP);
            std::multimap<char, size_t> mapF;
            for (size_t i = 0; i < sS.size(); i++)
            {
                mapF.insert(std::make_pair(sS[i], i));
            }
            auto range = mapF.equal_range(sP[0]);
            for (auto it = range.first; it != range.second; ++it)
            {
                size_t pP = 1;
                for (; pP < sP.size(); pP++)
                {
                    size_t pS = (it->second + pP)%sS.size();
                    if (sP[pP] != sS[pS])
                    {
                        break;
                    }
                }
                if(pP == sP.size())
                {
                    return true;
                }
            }
            return false;
        }())
    {
        std::cout << "Yes\n";
    }
    else
    {
        std::cout << "No\n";
    }
}


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

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

void Main()
{
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans = max(ans, uf.size(i));
    }
    
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
#include <time.h>
#define int long long int
#define pb push_back
#define all(a) a.begin(), a.end()
#define scnarr(a, n) for (int i = 1; i <= n; ++i) cin >> a[i]
#define vi vector<int>
#define si set<int>
#define pii pair <int, int>
#define sii set<pii>
#define vii vector<pii>
#define mii map <int, int>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace chrono;
/*
	Things to remember : check for coners n = 1, pass references instead
*/
/* -------------------------------Solution Sarted--------------------------------------*/

//Constants
const int MOD = 1000000007; // 1e9 + 7
const int MAXN = 1000005; // 1e6 +5
const int INF = 10000000000000005; // 1e15 +5

void solve(){
	int n, k, res = -INF;
	cin >> n >> k;
	vi a(n +1), p(n +1);
	scnarr(p, n);
	scnarr(a, n);
	
	for(int i = 1; i <= n; ++i){
		int idx = i, ans = -INF, cur = 0, sum, flag = 0, cycle = 0;
		for(int j = 0; j < k; ++j){
			cur += a[idx];
			idx = p[idx];

			if(idx == i){
				if(flag)
					break;
				flag = 1;
				cycle = j +1;
				sum = cur;
			}
			ans = max(ans, cur);
			if(flag)
				ans = max(ans, cur + (k - j -1)/cycle * sum);
		}
		res = max(res, ans);
	}

	cout << res << endl;

}

signed main()
{
	faster;
#ifndef ONLINE_JUDGE
	freopen("ip.txt", "r", stdin);
	freopen("op.txt", "w", stdout);
#endif
	// int t; cin >> t; while(t--)
		solve();
	return 0;
}


//Author : Ankit Raj
//Problem Link :

/*Snippets*/
/*
sieve - prime factorization using sieve and primes in range
zpower - pow with mod
plate - Initial template
bfs 
dfs
fenwik - BIT
binary_search
segment_tree
*/
	

Measured memory_bytes: 3708
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
#include <bitset>

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

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

// a と b の最大公約数を返す関数
ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main() {
  ll N;
  ll D1[110];
  ll D2[110];
  cin >> N;
  rep(i,N){
    cin >> D1[i] >> D2[i];
  }
  
  ll chk = 0;
    
  rep(i,N){
    if(D1[i]==D2[i]){
      chk++;
    }else{
      chk=0;
    }
    if(chk==3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  
  cout << "No" << endl;

}

Measured memory_bytes: 3680
n = gets.to_i

as = gets.split.map(&:to_i)

sum = 0
leafs = as.reduce(:+)
branches = 1

(n+1).times do |i|
  sum += branches
  branches -= as[i]
  leafs -= as[i]

  if branches < 0
    p -1
    exit
  end

  branches = [0, [leafs, branches * 2].min].max
end

p sum + leafs


Measured memory_bytes: 20692
#include <bits/stdc++.h>
using namespace std;
string str;
int n,a,b;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	cin>>str;
	for(int i=0;i<str.size();i++)
	{
		if(str[i]=='R')a++;
		else b++;
	}
	int tmp = 0;
	for(int i=0;i<a;i++)
		if(str[i]=='R')tmp++;
	cout<<min(b,a-tmp);
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int n;
vector<int> g[100100];
long long w[100100],b[100100];
void dfs(int v,int from){
    for(int i=0;i<g[v].size();i++)
        if(g[v][i]!=from){
            dfs(g[v][i],v);
            w[v]=w[v]*(w[g[v][i]]+b[g[v][i]])%mod;
            b[v]=b[v]*w[g[v][i]]%mod;
        }
    //cout<<v<<" "<<w[v]<<" "<<b[v]<<endl;
}
int main(){
    cin>>n;
    for(int i=0;i<n-1;i++){
        int c,d;
        scanf("%d %d",&c,&d);
        g[c].push_back(d);
        g[d].push_back(c);
    }
    for(int i=1;i<=n;i++)
        w[i]=b[i]=1;
    dfs(1,0);
    cout<<(w[1]+b[1])%mod<<endl;
    return 0;
}

Measured memory_bytes: 14208
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="ARC")cout<<"ABC"<<endl;
    else if(s=="ABC")cout<<"ARC"<<endl;

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string s;
int main()
{
	int n;
	cin >> n;
	n %= 26;
	cin >> s;

	int length = s.length();
	for (int i = 0; i < length; i++) {
		s[i] += n;
		if (s[i] > 'Z') {
			s[i] = s[i] - 'Z' + 'A'-1;
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 256
/*
 * @author- Vardhan Shah
@Roll no AU1841138
@date-//2019
@description
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
    import java.util.Scanner;
/**
 *
 * @author vardh
 */
public class Main {
    public static void main(String[] args) {
        int x,y;
        Scanner sc = new Scanner(System.in);
        x=sc.nextInt();
        y=sc.nextInt();
        System.out.println(x*y);
    }
}


Measured memory_bytes: 35692
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long N = scan.nextLong();
    System.out.print("0 0 ");
    long A = N%1000000000>0 ? N/1000000000+1:N/1000000000;
    long B = 1000000000*A-N;
    System.out.println("1000000000 "+B+" 1 "+A);
  }
}

Measured memory_bytes: 22996
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()
a = ord('a')

al = [chr(i) for i in range(ord('a'), ord('z')+1)]
ans = 100

for c in al:
    L = list(s.split(c))
    x = 0
    for y in L:
        x = max(x,len(y))
    ans = min(x,ans)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

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

    int len = s.length();
    string ans("");
    for(int i=0; i<len; ++i){
        if(s[i] == '0'){
            ans += '0';
        }else if(s[i] == '1'){
            ans += '1';
        }else if(s[i] == 'B' && ans != ""){
            ans.pop_back();
        }
    }
    cout << ans <<endl;


    return 0;
}

Measured memory_bytes: 256
n,T = gets.split.map &:to_i

c = []
t = []

min = Float::INFINITY
n.times{
	c, t = gets.split.map &:to_i
	if c < min && t <= T then
		min = c
	end
}

if min == Float::INFINITY then
	puts "TLE"
else
	puts min
end


Measured memory_bytes: 3836
n = int(input())
alist = list(map(int, input().split()))
ans = 1
max_val = 10**18

for i, a in enumerate(alist):
  ans *= a
  if ans > max_val:
    ans = -1
    for a in alist[i:]:
      if a == 0:
        ans =0
    break
print(ans)

Measured memory_bytes: 21632
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int cake = 4;
        int donuts = 7;
        boolean ans = false;
        for (int i = 0; i <= 100; i++) {
            for (int j = 0; j <= 100; j++) {
                int total = (i * cake) + (j * donuts);
                if (total == n) {
                    ans = true;
                    break;
                }
            }
        }
        if (ans) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
const int maxn=2e5;
int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        if(a*b==15)
        {
            cout<<"*"<<endl;
        }
        else if(a+b==15)
        {
            cout<<"+"<<endl;
        }
        else
            cout<<"x"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256