akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll a, b, c, d, n, k, x,l,r;
    string s, t;
    ll ans = 0;
    double dans = 0;
    string sans = "Good";

    cin  >> s;
    int head = stoi(s.substr(0,2));
    int tail = stoi(s.substr(2,2));

    if(head > 0 && head < 13 && tail > 0 && tail < 13) sans = "AMBIGUOUS";
    else if(head >0 && head < 13) sans = "MMYY";
    else if(tail > 0 && tail < 13) sans = "YYMM";
    else sans = "NA";

    // std::cout << ans << endl; 
    std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))

def CountingSort(A,B,k):
  C = [0]*(k+1)

  for i in range(n):
    C[A[i]] += 1

  for i in range(1,k+1):
    C[i] = C[i] + C[i-1]

  for i in range(n-1,-1,-1):
    B[C[A[i]]-1 ] = A[i]
    C[A[i]] -= 1
  return B


data = [0]*(n)
data = CountingSort(A,data,max(A))

print(*data)



Measured memory_bytes: 224380
import bisect


def submit():
    n = int(input())
    llist = list(map(int, input().split()))

    llist.sort()
    ans = 0
    for a in range(n):
        for b in range(a + 1, n):
            c_min = llist[b] - llist[a]
            c_max = llist[a] + llist[b]
            cs = bisect.bisect_right(llist, c_min, lo=b + 1)
            ce = bisect.bisect_left(llist, c_max, lo=b + 1)
            ans += ce - cs

    print(ans)


if __name__ == "__main__":
    submit()

Measured memory_bytes: 43868
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include <set>

struct Edge {
	int to, length;
};
int main() {
	std::cin.tie(0); std::cin.sync_with_stdio(false);
	int n; std::cin >> n;
	std::vector<std::vector<Edge>> nodes(n);
	for (auto i = 1; i < n; ++i) {
		int a, b, c; std::cin >> a >> b >> c; --a; --b;
		nodes[a].push_back(Edge{ b, c });
		nodes[b].push_back(Edge{ a, c });
	}
	int q, k; std::cin >> q >> k; --k;
	std::vector<long long int> min_distance(n, -1);
	std::stack<int> stack;
	min_distance[k] = 0; stack.push(k);
	while (!stack.empty()) {
		const auto top = stack.top(); stack.pop();
		for (const auto edge : nodes[top]) if (min_distance[edge.to] == -1) {
			min_distance[edge.to] = min_distance[top] + edge.length;
			stack.push(edge.to);
		}
	}
	for (auto i = 0; i < q; ++i) {
		int x, y; std::cin >> x >> y; --x; --y;
		std::cout << min_distance[x] + min_distance[y] << '\n';
	}
}


Measured memory_bytes: 8820
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main() {
    int n,a;
    cin>>n>>a;
    if(n%500<=a){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


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

int main(){
	int N,K,ans=0;
	cin >> N >> K;
	vector<int> x(N);
	vector<int> y(N);
	
	for(int i=0;i<N;i++){
		int X,Y;
		char C;
		cin >> X >> Y >> C;
		if(C=='W')Y+=K;
		X%=2*K;
		Y%=2*K;
		x[i]=X;
		y[i]=Y;
	}
	
	int board[2*K][2*K];
	int sum[2*K+1][2*K+1];
	for(int i=0;i<2*K;i++)for(int j=0;j<2*K;j++)board[i][j]=0;
	for(int i=0;i<2*K+1;i++)for(int j=0;j<2*K+1;j++)sum[i][j]=0;
	for(int i=0;i<N;i++)board[x[i]][y[i]]++;
	for(int i=0;i<2*K;i++)for(int j=0;j<2*K;j++){
		sum[i+1][j+1]=sum[i+1][j]+sum[i][j+1]-sum[i][j]+board[i][j];
	}
	
	for(int i=0;i<K;i++)for(int j=0;j<K;j++){
		int count=0;
		
		count+=sum[K+i][K+j]-sum[i][K+j]-sum[K+i][j]+sum[i][j];
		count+=sum[i][j];
		count+=sum[i][2*K]-sum[i][K+j];
		count+=sum[2*K][j]-sum[K+i][j];
		count+=sum[2*K][2*K]-sum[2*K][K+j]-sum[K+i][2*K]+sum[K+i][K+j];
		
		count=max(count,N-count);
		ans=max(ans,count);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 32384
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    void solve(){
        ll N;
        cin>>N;
        if(N%2){
            cout<<0<<'\n';
            return ;
        }
        ll ans=0;
        ll tmp=10;
        while(N/tmp){
            ans+=N/tmp;
            tmp*=5;
        }
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

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

int main()
{
	string s,t;
	cin>>s>>t;
	int n,k;
	n=s.length();
	k=t.length();
	int dp[n+1][k+1];
	for( int i=0;i<=n;i++)
	{
		for( int j=0;j<=k;j++)
		{
			if(i==0 || j==0)
				dp[i][j]=0;
			else if(s[i-1]==t[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	//cout<<"P"<<endl;
	int p=dp[n][k],l=dp[n][k];
	//cout<<"T"<<endl;
	string a;
	int i=n,j=k;
	//cout<<"L"<<endl;
	while(i>0 && j>0)
	{
		if(s[i-1]==t[j-1])
		{
			a.push_back(s[i-1]);
			i--;j--;
		}
		else if(dp[i-1][j]>dp[i][j-1])
			i--;
		else
			j--;
	}
	reverse(a.begin(),a.end());
	cout<<a<<endl;
}

Measured memory_bytes: 38804
n,m=map(int,input().split())
lr=[[int(i) for i in input().split()] for _ in range(m)]
l=[lr[i][0] for i in range(m)]
r=[lr[i][1] for i in range(m)]
print(min(r)-max(l)+1 if min(r)>=max(l) else 0)

Measured memory_bytes: 67076
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = int.Parse(ReadLine().Replace(" ", ""));
        WriteLine(n % 4 == 0 ? "YES" : "NO");
    }
}



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

ll NUM = 1000000007;

int main(){
 int n,m;
  cin >>n >> m;
  vector<int> a(m);
  rep(i,m) cin >> a[i];
  vector<ll> dp(n+1, 1);
  rep(i,m) dp[a[i]] = 0;

  
  for(int i = n-2; i>=0; i--){
    if(dp[i]>0) dp[i]= dp[i+1]%NUM + dp[i+2]%NUM;
  }
  ll ans = dp[0]%NUM;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b;
signed main()
{
	cin>>a>>b;
	if(b>a){
		cout<<0;
	}else{
		cout<<10;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100
#define M 26
using namespace std;
string s;
int p,len;
 
string bnf(bool rev){
  string res;
  int c=0;
  while(p!=len){
    char t=s[p];
    if(t=='+')p++,c++;
    if(t=='-')p++,c--;
    if('A'<=t&&t<='Z')
      res+=((s[p++]+c+M*N)-'A')%M+'A',c=0;
    if(t=='?')res+=s[p++],c=0;
    if(t=='[')p++,res+=bnf(true);
    if(t==']'){
      p++;
      break;
    }
  }
  if(rev)reverse(res.begin(),res.end());
  return res;
}
 
int main(){
  while(1){
    cin>>s;
    if(s==".")break;
    len=s.size();
    p=0;
    string ans=bnf(false);
    for(int i=0;i<(int)ans.size();i++)
      if(ans[i]=='?')ans[i]='A';
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 178, task d, 2020/09/13
//ms,

/*
動的計画法。解けなくていいよ今日は。
勉強はしようね。
https://atcoder.jp/contests/dp
↑こちらdpの練習問題
*/

#define LAW 1000000007

int main(void){
  int S;
  vector<int> d(2001);

  cin >>S;
  d[0]=1; d[1]=0; d[2]=0;
  for(int i=3;i<=S;i++){
    d[i]=0;
    for(int j=0;j<=i-3;j++){
      d[i]+=d[j];
      d[i]%=LAW;
    }
  }

  cout <<d[S] <<endl;
  return 0;
}
/*
何か木を使いそうね。なんもわからんけど。
残念ハズレ、動的計画法でした。
二乗オーダーまでは余裕のたえ。
*/


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














char c;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> c;
	if ('A' <= c && c <= 'Z') cout << "A" << endl;
	else cout << "a" << endl;
}







Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30));
const ll linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    int ans = -1;
    int tmp = 0;
    for(int i=0; i<n; i++)
    {
        if(tmp==1)
        {
            ans = i;
            break;
        }
        tmp = a[tmp];
        tmp--;
    }
    cout << ans << endl;
}



Measured memory_bytes: 640
#define LEN 105
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int numStack[LEN];
int top = 0;

void push(int x) {
    numStack[++top] = x;
}

int pop() {
    return numStack[top--];
}

int main() {
    char str[15];
    int a, b = 0;
    while (scanf("%s", str) != EOF) {
        if (str[0] == '+') {
            a = pop();//后操作数
            b = pop();
            push(a + b);
        }
        else if (str[0] == '-') {
            a = pop();//后操作数
            b = pop();
            push(b - a);
        }
        else if (str[0] == '*') {
            a = pop();//后操作数
            b = pop();           
            push(a * b);
        }
        else {
            push(atoi(str));
        }
    }
    printf("%d\n", pop());
    return 0;
}


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

using namespace std;

typedef long long ll;

int solve(){
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    int res = k * x;
    if(n < k){
        cout << n * x << "\n";
    }
    else{
        res = res + (n - k) * y;
        cout << res << "\n";
    }
    return 0;
 }

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
  int N,K,d,Aj;int Re=0;
  scanf("%d",&N);
  scanf("%d",&K);
  int A[100];
  for(int i=0;i<N;i++)
    A[i]=0;
  for(int x=0;x<K;x++)
  {
    scanf("%d",&d);
    for(int j=0;j<d;j++)
    {
      scanf("%d",&Aj);
      Aj--;
      A[Aj]++;
    }
  }
  for(int v=0;v<N;v++)
    if(A[v]==0)
      Re++;
  printf("%d",Re);
  return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void print(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void print(H head, T ...tail) { cout << head << " "; print(tail...); }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	ll x; read(x);
	ll ans = x / 11 * 2;
	if (x % 11 == 0) ;
	else if (x % 11 <= 6) ans++;
	else ans += 2;
	cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
S = [input() for i in range(n)]

ans = 0
a = 0
b = 0
c = 0
for i in range(n):
    for j in range(len(S[i]) - 1):
        if S[i][j:j+2] == "AB":
            ans += 1
    if S[i][-1] == "A":
        a += 1
    if S[i][0] == "B":
        b += 1
    if S[i][-1] == "A" and S[i][0] == "B":
        c += 1
# print(ans)
ans += min(a, b)
if a == c and a == b and a > 0:
    ans -= 1

print(ans)

Measured memory_bytes: 46040
import java.util.*;


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

        final int m = sc.nextInt();
        Map<String,Integer> smap = new HashMap<String,Integer>();
        for(int i=0; i<m; i++){
            String tmp = sc.next();
            if(smap.get(tmp)!=null){
                smap.put(tmp,smap.get(tmp)+1);
            }
            else{
                smap.put(tmp,1);
            }
        }

        final int n = sc.nextInt();
        for(int i=0; i<n; i++){
            String tmp = sc.next();
            if(smap.get(tmp)!=null)
                smap.put(tmp,smap.get(tmp)-1);
        }
        int max=0;
        for(String str: smap.keySet()){
            if(max<smap.get(str))
              max=smap.get(str);
        }
        System.out.println(max>0?max:0);

    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	long long N,K;
	cin >> N>>K;
	vector <pair<int,int>>ab(N);
	for (int i=0;i<N;i++){
		cin>>ab.at(i).first;
		cin>>ab.at(i).second;
	}
	sort(ab.begin(),ab.end());
	long long  count=0;
	int k=0;
	while(count<K){
		count+=ab.at(k).second;
		k++;
	}
	k--;
	cout<<ab.at(k).first<<endl;
	
}
 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

struct unionfind{
	vector<int> data;
	vector<int> size;
	unionfind(int n){
		for(int i=0;i<n;i++){
			data.push_back(i);
			size.push_back(1);
		}
	}
	
	int find(int x){
		if(data[x]==x)return x;
		return data[x]=find(data[x]);
	}
	
	bool unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return false;
		if(size[x]>size[y])swap(x,y);
		data[x]=y;
		size[y]+=size[x];
		return true;
	}
	
	bool check(int x,int y){
		return (find(x)==find(y));
	}
	
	int get_size(int x){
		int X = find(x);
		return size[X];
	}
};

int main(){
	
	int N;
	cin>>N;
	
	vector<int> a(N),b(N);
	for(int i=0;i<N;i++)cin>>a[i];
	for(int i=0;i<N;i++)cin>>b[i];
	int x = 0,y=0;
	for(int i=0;i<N;i++){
		x ^= a[i];
		y ^= b[i];
	}
	
	a.push_back(x);
	b.push_back(y);
	
	
	vector<int> A=a,B=b;
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	
	if(A!=B){
		cout<<-1<<endl;
		return 0;
	}
	
	vector<pair<int,int>> P;
	for(int i=0;i<=N;i++){
		if(a[i]!=b[i]||i==N){
			P.emplace_back(a[i],b[i]);
		}
	}
	
	sort(P.begin(),P.end());
		
	int ans = P.size()-1;
	if(x!=y)ans--;
	
	
	vector<int> t;
	for(int i=0;i<P.size();i++)t.push_back(P[i].first);
	sort(t.begin(),t.end());
	t.erase(unique(t.begin(),t.end()),t.end());
	
	for(int i=0;i<P.size();i++){
		P[i].first = distance(t.begin(),lower_bound(t.begin(),t.end(),P[i].first));
		P[i].second = distance(t.begin(),lower_bound(t.begin(),t.end(),P[i].second));
	}
	
	
	unionfind uf(t.size());
	
	for(int i=0;i<P.size();i++)uf.unite(P[i].first,P[i].second);

	for(int i=0;i<t.size();i++){
		if(uf.find(i)==i)ans++;
	}
	
	if(x==y)ans--;
	
	cout<<ans<<endl;
	
	

	return 0;
}


Measured memory_bytes: 7556
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 * @author k15115kk
 */
public class Main {

    /**
     * @param args the command line arguments
     * @throws java.io.IOException
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);
        String b = br.readLine();
        int S = Integer.parseInt(b);
        if(S >= 0 && S <= 86400){
        int h = S / 3600;
        S = S - h * 3600;
        int m = S / 60;
        int s = S - m * 60;
        System.out.println(h+":"+m+":"+s);
        }
    }

}

Measured memory_bytes: 24192
#include<bits/stdc++.h>
using namespace std;
int v[1000],n,s,a,b,c,i;
int main()
{
	cin>>n;
    for(i=1;i<=n;i++)
    {
    cin>>v[i];
    s+=v[i];
	}
	s/=n;
	for(i=1;i<=n;i++)
	{
		a+=(v[i]-s+1)*(v[i]-s+1);
		b+=(v[i]-s)*(v[i]-s);
		c+=(v[i]-s-1)*(v[i]-s-1);
	}
	cout<<min(min(a,b),c);
}

Measured memory_bytes: 256
d, g = map(int, input().split())
a = []
c = []
for i in range(d):
    a.append(list(map(int, input().split())))
for i in range(2 ** d):
    summ = 0
    count = 0
    j = list(bin(i)[2:].zfill(len(bin(2 ** d - 1)[2:])))
    for k in range(len(j)):
        summ += int(j[k]) * a[k][0] * (k+1) * 100
        if j[k] == '1':
            count += a[k][0]
            summ += a[k][1]
    if summ >= g:
        c.append(count)
        continue
    elif summ < g:
        idx = 0
        for l in range(len(j) - 1, 0, -1):
            if j[l] == '0':
                idx = l
                break
        for m in range(1, a[idx][0]):
            summ += (idx+1) * 100
            count += 1
            if summ >= g:
                c.append(count)
                break

print(min(c))

Measured memory_bytes: 3188
def f(n):
	if n%4 == 3:
		return 0
	elif n%4 == 0:
		return n
	elif n%4 == 1:
		return 1
	else:
		return n+1

def xor(x,y):
	c = 0
	k = 0
	while 2**k < max(x,y)+1:
		c += (2**k) * ( (((x//(2**k))%2) + ((y//(2**k))%2)) %2 )
		k += 1
	return c

a,b = list(map(int,input().split()))
print(xor(f(a-1),f(b)))

Measured memory_bytes: 3064
package main

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

func main() {
	h, a := readI(), readI()

	fmt.Println((h + a - 1) / a)
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
	os << "(" << pair_var.first << ", " << pair_var.second << ")";
	return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	os << "{";
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
	}
	os << "}";
	return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
	os << "{";
	repi(itr, map_var) {
		os << *itr;
		itr++;
		if (itr != map_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
	os << "{";
	repi(itr, set_var) {
		os << *itr;
		itr++;
		if (itr != set_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}

#define DUMPOUT cerr

void dump_func() {
	DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
	DUMPOUT << head;
	if (sizeof...(Tail) > 0) {
		DUMPOUT << ", ";
	}
	dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {

	string s;
	cin >> s;
	int N = s.length();

	int A=0;
	int ans = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A') A++;
		else if (i < N - 1 && s[i] == 'B' && s[i + 1] == 'C') {
			ans += A;
			i++;
		}
		else {
			A = 0;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int w,h,n; cin>>w>>h>>n;
    int x[n],y[n],a[n];
    for(int i=0; i<n; i++) cin>>x[i]>>y[i]>>a[i];
    int xbegin=0;
    int ybegin=0;
    int xend=w;
    int yend=h;
    for(int i=0; i<n; i++){
        if(a[i]==1 && xbegin<x[i]) xbegin += x[i]-xbegin;
        if(a[i]==2 && x[i] < xend) xend -= xend-x[i];
        if(a[i]==3 && ybegin<y[i]) ybegin += y[i]-ybegin;
        if(a[i]==4 && y[i] < yend) yend -= yend-y[i];
    }
    int ans=0;
    int xi=xend-xbegin;
    int yi=yend-ybegin;
    if(xi>0 && yi>0) ans = xi*yi;

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

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

// macros
#define overload_rep(_1, _2 ,_3 ,name, ...) name
#define re_p(i, n) for(int i = 0; i < (n); ++i)
#define r_ep(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, r_ep, re_p)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// AtCoder Beginner Contest 144
typedef long long ll;

int main(){

    int a, b;
    cin >> a >> b;
    if(a < 10 & b < 10){
        cout << a * b << '\n';
    } else cout << "-1\n";

}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = new List<string>();
            var N = int.Parse(Console.ReadLine());
            for(int i=0;i<N;i++)
            {
                var input = Console.ReadLine();
                inputs.Add(input);
            }

            double sum = 0;
            foreach(var item in inputs.Select(s=>s.Split(' ')))
            {
                sum += item[1] == "BTC"? 380000.0 * double.Parse(item[0]) : double.Parse(item[0]);
            }

            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 n, x;
  cin >> n >> x;
  if (x == 1 || x == 2 * n - 1) { cout << "No\n"; return 0; }
  if (n == 2) { cout << "Yes\n1 2 3\n"; return 0; }
  
  vector<i64> a(2 * n - 1);
  vector<bool> b(2 * n - 1);
  if (x == 2) {
    a[n - 2] = 3;
    a[n - 1] = 2;
    a[n] = 1;
    a[n + 1] = 4;
    b[1] = b[2] = b[3] = b[4] = true;
  } else {
    a[n - 2] = 1;
    a[n - 1] = x;
    a[n] = x + 1;
    a[n + 1] = 2;
    b[1] = b[x] = b[x + 1] = b[2] = true;
  }
  for (i64 i = 0, v = 1; i < 2 * n - 1; ++i) {
    while (b[v]) ++v;
    if (a[i] == 0) {
      a[i] = v;
      ++v;
    }
  }
  cout << "Yes\n";
  for (i64 v : a) cout << v << '\n';
  return 0;
}



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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>

using namespace std;

typedef long long ll;

int main() {
  int N, Y, tmp;
  cin >> N >> Y;
  tmp = Y / 1000 - N;
  rep(i, N + 1) {
    rep(j, N + 1) {
      if (i + j > N) continue;
      if (tmp == 9 * i + 4 * j) {
        cout << i << ' ' << j << ' ' << N - i - j << endl;
        return 0;
      }
    }
  }
  cout << -1 << ' ' << -1 << ' ' << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vi vector<int>
#define sl set<ll>
#define sc set<char>
#define pi pair<int,int>
#define pl pair<ll,ll>
#define mpi map<ll,ll>
#define mpc map<char,ll>
#define forn(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define inf        10000000

int main()
{
	ll n,w;
	cin>>n>>w;
	ll dp[w+1]={0};
	forn(i,n)
	{
		ll a,v;
		cin>>a>>v;
		for(ll j=w-a;j>=0;j--)
		{
			dp[j+a]=max(dp[j+a],dp[j]+v);
		}
	}
	ll ans=0;
	forn(i,w+1)
	ans=max(ans,dp[i]);
	cout<<ans;
}

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

int main() {
    int n, t;
    std::cin >> n;
    std::vector<int> v(100010);
    for (int i = 0; i < n; i++) {
        std::cin >> t;
        v[t]++;
        v[t + 1]++;
        v[t + 2]++;
    }
    int m = 0;
    for (int i = 0; i < v.size(); i++) if (v[i] > m) m = v[i];
    std::cout << m << std::endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;

//clang++ -std=c++11 -stdlib=libc++ 
int main() {
  int K, X; cin >>K>>X;
  puts(500*K>=X?"Yes":"No");
  return 0;
}

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

const int INF = 1 << 25;
pair<string, string> cross[1000];
int dist[200][200];
int wf[200][200];
int same[200][200];

int main() {
	int n, m;
	while(cin >> n, n) {
		int sn = 0;
		map<string, int> indexer;
		for(int i = 0; i < n; i++) {
			string s, s1, s2;
			cin >> s;
			int pos = s.find('-');
			s1 = s.substr(0, pos);
			s2 = s.substr(pos + 1, s.size() - (pos + 1));
			cross[i].first = s1;
			cross[i].second = s2;
			if(indexer.count(s1) == 0) {
				indexer[s1] = sn++;
			}
			if(indexer.count(s2) == 0) {
				indexer[s2] = sn++;
			}
		}

		cout << sn << endl;

		for(int i = 0; i < sn; i++) {
			for(int j = 0; j < sn; j++) {
				dist[i][j] = (i == j) ? 0 : INF;
				same[i][j] = wf[i][j] = i == j;
			}
		}
		for(int i = 0; i < n; i++) {
			int v1 = indexer[cross[i].first], v2 = indexer[cross[i].second];
			dist[v1][v2] = dist[v2][v1] = 1;
			wf[v1][v2] = 1;
		}

		for(int i = 0; i < sn; i++) {
			for(int j = i + 1; j < sn; j++) {
				bool flag1 = false, flag2 = true;
				for(int k = 0; k < sn; k++) {
					if(wf[i][k] && wf[j][k]) flag1 = true;
					if(wf[k][i] && wf[k][j]) flag1 = true;
					if(wf[i][k] && wf[k][j]) flag2 = false;
					if(wf[j][k] && wf[k][i]) flag2 = false;
				}
				same[i][j] = same[j][i] = flag1 && flag2;
			}
		}

		for(int i = 0; i < sn; i++) {
			for(int j = 0; j < sn; j++) {
				if(same[i][j]) wf[i][j] = 1;
			}
		}
		for(int k = 0; k < sn; k++) {
			for(int i = 0; i < sn; i++) {
				for(int j = 0; j < sn; j++) {
					dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
					wf[i][j] |= wf[i][k] && wf[k][j];
				}
			}
		}

		cin >> m;
		for(int i = 0; i < m; i++) {
			string s, s1, s2;
			cin >> s;
			int pos = s.find('-');
			s1 = s.substr(0, pos);
			s2 = s.substr(pos + 1, s.size() - (pos + 1));
			if(indexer.count(s1) == 0 || indexer.count(s2) == 0) {
				cout << "NO" << endl;
				continue;
			}
			int v1 = indexer[s1], v2 = indexer[s2];
			int d = dist[v1][v2];
			if(d != INF && d % 2 && wf[v1][v2]) {
				cout << "YES" << endl;
			}
			else {
				cout << "NO" << endl;
			}
		}
	}

}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int s; cin >> s;
	map<ll, ll> m;
	int a[1000005];
	for(int i=1;i<=1000000;i++){
		if(i==1) a[i] = s;
		else if(a[i-1]%2==0){
			a[i] = a[i-1]/2;
		}
		else if(a[i-1]%2==1){
			a[i] = 3*a[i-1]+1;
		}
		// cout << a[i] << endl;
		m[a[i]]++;
		if(m[a[i]]==2){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  ll A, B, C, K;
  cin >> A >> B >> C >> K;

  ll ans = K % 2 == 0 ? A - B : B - A;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <class T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

bool isPrime(ll num) {
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    for (ll i = 3; i * i <= num; i += 2) {
        if (num % i == 0) { return false; }
    }

    return true;
};

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
bool is_integer(T x) {
    return std::floor(x) == x;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    int X = 1.0 * N / 1.08;
    if (int(X * 1.08) == N) {
        cout << X << endl;
    } else if (int((X + 1) * 1.08) == N) {
        cout << X + 1 << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}


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

using namespace std;

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

    string S;
    vector<long long> cnt(5, 0); /* MARCH の5文字それぞれ */
    for ( int i=0; i<N; i++ ) {
        cin >> S;
        if ( S.at(0) == 'M' )
            cnt.at(0)++;
        if ( S.at(0) == 'A' )
            cnt.at(1)++;
        if ( S.at(0) == 'R' )
            cnt.at(2)++;
        if ( S.at(0) == 'C' )
            cnt.at(3)++;
        if ( S.at(0) == 'H' )
            cnt.at(4)++;
    }

    long long ans=0;
    for ( int i=0; i<5; i++ ) {
        for ( int j=i+1; j<5; j++ ) {
            for ( int k=j+1; k<5; k++ ) {
                ans += cnt.at(i) * cnt.at(j) * cnt.at(k);
            }
        }
    }
    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 all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

map<long long,int> mp;
vector<long long> prime_factorization(long long n){
    vector<long long> v;
    if(n==1) v.push_back(1);
    long long i=2;
    while(n>1){
        if(n<i*i){
            v.push_back(i);
            mp[n]++;
            return v;
        }
        if(n%i==0){
            n/=i;
            v.push_back(i);
            mp[i]++;
        }else{
            i++;
        }
    }
    return v;
}
int main(){
    long long n,p; cin>>n>>p;
    if(n==1){
        cout<<p<<endl;
        return 0;
    }
    vector<long long> v=prime_factorization(p);
    long long ans=1;
    for(auto i:mp){
        ans*=pow(i.first,i.second/n);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <cstdio>
#include <vector>
#include <set>

using namespace std;

map<string, int> data;
vector<string> mem[100];
bool vis[100];
int n;
set<string> ans;

void solve(int p){
  int res = 0;
  vis[p] = true;
  for(int i=0;i<mem[p].size();i++){
    if(data.find(mem[p][i]) == data.end()){
      ans.insert(mem[p][i]);
    }else{
      int tmp = data[mem[p][i]];
      if(vis[tmp]) continue;
      solve(tmp);
    }
  }
}

main(){
  while(cin >> n && n){
    data.clear();
    getchar();
    ans.clear();
    for(int i=0;i<n;i++){
      mem[i].clear();
      string in;
      char c;
      while(1){
        scanf("%c", &c);
        if(c == ':'){
          data[in] = i;
          break;
        }
        in += c;
      }
      in = "";
      while(1){
        scanf("%c", &c);
        if(c == ','){
          mem[i].push_back(in);
          in = "";
          continue;
        }else if(c == '.'){
          mem[i].push_back(in);
          break;
        }
        in += c;
      }
      getchar();
    }
    fill(vis, vis+n, false);
    solve(0);
    cout << ans.size() << endl;
  }
}

Measured memory_bytes: 0
/*---------------------------------- NEVER GIVE UP --------------------------------------------*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef double ld;
typedef pair<ll,ll> pii;
typedef tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug1(x) cerr<<#x<<" : "<<x<<endl
#define debug2(x,y) cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define debug3(x,y,z) cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL) ; cout.tie(NULL)

const ll modd=1e9+7;
const ll inff=1e18;

ll poww(ll a,ll b){
  ll ans=1;
  while(b){
    if(b&1LL) ans=(ans*a);
    a=(a*a);
    b=b>>1LL;
  }
  return ans;
}

/*-----------------------------------------------------------------------------------------------*/

int main(){
  fastt;
   
  ll tc;
  cin >> tc;

  while(tc--){
      ll n;
      cin >> n;

      ll k[n+1] , l[n+1] , r[n+1];

      for(ll i = 1; i <= n; i++) cin >> k[i] >> l[i] >> r[i];

      ll max_happiness = 0;
      map <ll,vector<ll>> map1 , map2;
      multiset <ll> ms1 , ms2;

      for(ll i = 1; i <= n; i++){
            max_happiness += min(l[i],r[i]);
            if(l[i] >= r[i]) map1[k[i]].pb(l[i]-r[i]);
            else if(r[i] > l[i]) map2[n-k[i]].pb(r[i]-l[i]);
      }

      for(auto j : map1){
          for(auto k : j.se){
              ms1.insert(k);
              max_happiness += k;
          }
          while(ms1.size() > j.fi){
              max_happiness -= *ms1.begin();
              ms1.erase(ms1.begin());
          }
      }

      for(auto j : map2){
          for(auto k : j.se){
              ms2.insert(k);
              max_happiness += k;
          }
          while(ms2.size() > j.fi){
              max_happiness -= *ms2.begin();
              ms2.erase(ms2.begin());
          }
      }

      cout << max_happiness << '\n';
  }
 
  return 0;
}

Measured memory_bytes: 33928
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
	ll A, B, C;
	cin >> A >> B >> C;
	ll ans = 0;
	cout << max(ans, C - (A - B)) << endl;
}

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

int n, m, q;
int a[50], b[50], c[50], d[50];
int ans = 0;
int A[10];

void dfs(int id, int pre) {
    if (id == n)
    {
        int score = 0;
        for (int i = 0; i< q; i++)  {
            if (A[b[i]-1]-A[a[i]-1] == c[i]) score += d[i]; 
        }
        ans = max(ans, score);
    }
    else
    {
        for (int i = pre; i <= m; i++) 
        {
            A[id] = i;
            dfs(id+1, i);
        }
    }
}

int main() {
    cin >> n >> m >> q;
    for (int i =0; i< q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(0,1);
    cout << ans;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N], n;
int getAns(int fna = 0) {
	int od = 0, ev = 0, gd = 0, bad = 0;
	for (int i = 0; i < n; i++)
		od += (a[i] % 2), ev += 1 - (a[i] % 2);
	if (ev % 2 == 1)
		return fna + 1;
	if (od > 1)
		return fna;
	for (int i = 0; i < n; i++)
		a[i] -= (a[i] % 2), bad += (a[i] == 0) , gd = __gcd(gd, a[i]);
	if (bad)
		return 0 + fna;
	for (int i = 0; i < n; i++)
		a[i] /= gd;
	return getAns(1) + fna;
}	
int main() {
	cin >> n;
	if (n == 1) {
		cout << "Second";
		return 0;
	}
	for (int i = 0; i < n; i++)
		cin >> a[i];
	if (getAns() % 2 == 1)
		cout << "First";
	else
		cout << "Second";
	return 0;
}

Measured memory_bytes: 4028
#include <iostream>
#include <utility>
#include <queue>
using namespace std;

const int MAX_SIZE = 1000;
typedef pair<int, int> P;
typedef pair<int, P> Q;

int calc(int f[][MAX_SIZE], queue<Q> q, int H, int W) {
  P d[] = {P(-1, -1), P(-1, 0), P(-1, 1), P(0, -1), P(0, 1), P(1, -1), P(1, 0), P(1, 1)};
  int n = 0;
  while (q.size()) {
    int c = q.front().first;
    P p = q.front().second;
    q.pop();
    if (c > n) n++;
    for (int k = 0; k < 8; ++k) {
      int i = p.first  + d[k].first;
      int j = p.second + d[k].second;
      if (i >= 0 && i < H && j >= 0 && j < W && --f[i][j] == 0) {
        q.push(Q(c + 1, P(i, j)));
      };
    }
  }
  return n;
}

int main() {
  int H, W;
  int f[MAX_SIZE][MAX_SIZE];
  queue<Q> q;
  char c[MAX_SIZE];

  cin >> H >> W;
  for (int i = 0; i < H; ++i) {
    cin >> c;
    for (int j = 0; j < W; ++j) {
      if (c[j] == '.') {
        f[i][j] = 0;
        q.push(Q(0, P(i, j)));
      } else {
        f[i][j] = c[j] - '0';
      }
    }
  }
  cout << calc(f, q, H, W) << endl;
}

Measured memory_bytes: 5692
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a==b){
		cout<<"Yes";
	}
	else
	cout<<"No";
}

//     *    *  *  ****    *    *   *
//    *	*   * *   *      * *   *   *
//   *****  **    ****  *****  *****
//   *   *  * *      *  *   *      *
//   *   *  *  *  ****  *   *  *****

//   ****   ****  *
//   *   *   **   *
//   ****    **   *
//   *   *   **   *
//   ****   ****  ****

//   ****   ****  *       *
//   *       **   *      * *
//   ****    **   *     *****
//      *    **   *     *   *
//   ****   ****  ****  *   *



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
bool broken[100001];
ll dp[100001];
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;
		broken[a] = 1;
	}
	dp[0] = 1;
	for (int i = 1; i <= N; i++) {
		if (broken[i]) {
			dp[i] = 0;
		}
		else {
			dp[i] = dp[i - 1];
			if (i >= 2) (dp[i] += dp[i - 2]) %= MOD;
		}
	}
	cout << dp[N] << endl;
}

Measured memory_bytes: 1152
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }.toList()

fun main(args: Array<String>) {
    var (A, B, K) = readInts()
    var count = 0

    while (true) {
        if (K <= count) break

        if (A % 2 != 0) A--
        B += A / 2
        A /= 2
        count++


        if (K <= count) break

        if (B % 2 != 0) B--
        A += B / 2
        B /= 2
        count++
    }

    println("$A $B")
}

Measured memory_bytes: 37948
# include <iostream>
# define pf push_front
# define pb push_back
# define mp make_pair
# define pr printf
# define se second
# define si size()
# define sc scanf
# define fi first
# define er erase
# define be begin
# define ss size
# define Int __int64
# define INF 100000000000000008
# define MOD 1000000007
# define MN 500500
# define eps 0.0000000000000000018
# define mem(a) memset(a,0,sizeof(a))
# define cpy(b,a) memcpy(b,a,sizeof(a))
#define fast ios_base::sync_with_stdio(false)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
using namespace std;

int main() {
	int a,b,c,ans;
	cin>>a>>b>>c;
	ans=a^b^c;
	cout<<ans;
	return 0;
}
/* and its only us now */


Measured memory_bytes: 256