akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define int long long

constexpr int INF = 1LL << 60;

constexpr int MAX_N = 505;
constexpr int MAX_M = 50005;

typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

struct UF
{
    int n, par[MAX_N], rank[MAX_N];

    void init(int pn)
    {
        n = pn;
        for (int i = 1; i <= n; i++)
        {
            par[i] = i;
            rank[i] = 0;
        }
    }

    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank[x] < rank[y])
        {
            par[x] = y;
        }
        else
        {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }

    int find(int x)
    {
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};

int n, m;
pipii edges[MAX_M];
vector<int> nomi;
UF uf;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m;
    uf.init(n);
    for (int i = 0; i < m; i++)
    {
        int s, d, c;
        cin >> s >> d >> c;
        edges[i] = {c, {s, d}};
    }

    sort(edges, edges + m);

    int cost = 0;
    for (int i = 0; i < m; i++)
    {
        const auto p = edges[i].second;
        if (uf.same(p.first, p.second)) continue;
        uf.unite(p.first, p.second);
        nomi.emplace_back(i);
        cost += edges[i].first;
    }

    int ansCount = 0, ansCost = 0;
    for (const auto idx : nomi)
    {
        uf.init(n);
        int tmpCost = 0;
        for (int i = 0; i < m; i++)
        {
            if (idx == i) continue;
            const auto p = edges[i].second;
            if (uf.same(p.first, p.second)) continue;
            uf.unite(p.first, p.second);
            tmpCost += edges[i].first;
        }
        if (cost != tmpCost)
        {
            ansCount++;
            ansCost += edges[idx].first;
        }
    }

    cout << ansCount << " " << ansCost << endl;
}



Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    vector<ll> t(N,0);
    vector<ll> d(N,0);
    for(ll i=0;i<N;i++)cin>>t[i]>>d[i];
    priority_queue<P> pq;
    for(ll i=0;i<N;i++)pq.emplace(P(d[i],t[i]));
    vector<ll> cho(0);
    vector<ll> ncho(0);
    vector<bool> check(N+1,0);
    ll sum=0;ll pat=0;
       /* cout<<"ここから"<<endl;
    while(pq.size()){
        cout<<pq.top().first<<" "<<pq.top().second<<endl;
        pq.pop();
    }return 0;*/
    for(ll i=0;i<K;i++){
        P x=pq.top();
        sum+=x.first;
        if(check[x.second]){
            cho.emplace_back(x.first);
        }
        else pat++;
        check[x.second]=1;
        pq.pop();
    }
    while(!pq.empty()){
        P x=pq.top();
        if(!check[x.second]){
            ncho.emplace_back(x.first);
        }
        check[x.second]=1;
        pq.pop();
    }
    ll D=min(cho.size(),ncho.size());
    reverse(cho.begin(), cho.end());
    ll ans=sum+pat*pat;
    for(ll i=0;i<D;i++){
        sum-=cho[i];
        sum+=ncho[i];
        chmax(ans,sum+(pat+i+1)*(pat+i+1));
    }
    print(ans)
    return 0;
}

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

string S;
set<char> chars;

int main() {
  cin >> S;
  for(int i=0; i<S.size(); i++) {
    chars.insert(S.c_str()[i]);
  }
  if(chars.size()==2) {
    int cnt=0;
    for(int i=1; i<S.size(); i++) {
      if(S.c_str()[0] == S.c_str()[i]) cnt++;
    }
    if(cnt==1) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int ans = 0;
		int max, mid, min;
		int [] list = {sc.nextInt(), sc.nextInt(), sc.nextInt()};

		Arrays.sort(list);
		min = list[0];
		mid = list[1];
		max = list[2];

		for ( int i = mid; i < max; i++) {
			ans++;
			min++;
		}
		for ( int i = min; i < max; i += 2) {
			ans ++;
			min += 2;
		}
		if (max == min) {
			System.out.println(ans);
		}else {
			System.out.println(ans + 1);
		}


		}
}


Measured memory_bytes: 21844
# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')

N = iin()
A = iln()

counter = dict()

possible = True
for a in A:
    if a in counter:
        counter[a] += 1
        if a == 0 and counter[a] > 1:
            possible = False
        elif a != 0 and counter[a] > 2:
            possible = False
    else:
        counter[a] = 1
if possible:
    print(2**(N//2)%MOD)
else:
    print(0)


Measured memory_bytes: 15988
grid = [list(map(int,input().split(' ')))]
grid.append(list(map(int,input().split(' '))))
grid.append(list(map(int,input().split(' '))))

flg =False
for i in range(100):
    b0,b1,b2  = grid[0][0]-i,grid[0][1]-i,grid[0][2]-i
    a1,a2 = grid[1][0]-b0,grid[2][0]-b0
    if grid[1][1] == a1+b1 and grid[1][2] == a1+b2 and grid[2][1] == a2+b1 and grid[2][2] == a2+b2:
        if grid[0][0] == i+b0 and grid[0][1] == i+b1 and grid[0][2] == i+b2 and grid[1][0] == a1+b0 and grid[2][0] == a2+b0:
            flg =True
            break
    if min([b0,b1,b2]) < 0:
        break
    
if flg:
    print('Yes')
    
else:
    print('No')
    


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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int cnt = 0;
    while(a>=b){
        b *= 2;
        cnt++;
    }
    if(cnt>k){
        cout << "No" << endl;
        return 0;
    }
    while(b>=c){
        c *= 2;
        cnt++;
    }
    if(cnt>k){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){
  double a[2],b[2],c[2],r[2];
  while(cin >>a[0]>>a[1]>>b[0]>>b[1]>>c[0]>>c[1]>>r[0]>>r[1]){
    b[0]-=a[0];
    c[0]-=a[0];
    r[0]-=a[0];
    b[1]-=a[1];
    c[1]-=a[1];
    r[1]-=a[1];
    double m[2][2],ans[2],rev[2][2];
    m[0][0] = b[0];
    m[0][1] = c[0];
    m[1][0] = b[1];
    m[1][1] = c[1];
    ans[0] = r[0];
    ans[1] = r[1];
    double det = m[0][0]*m[1][1]-m[0][1]*m[1][0];
    rev[0][0] = m[1][1]/det;
    rev[0][1] = -m[0][1]/det;
    rev[1][0] = -m[1][0]/det;
    rev[1][1] = m[0][0]/det;
    double s = ans[0]*rev[0][0]+ans[1]*rev[0][1];
    double t = ans[0]*rev[1][0]+ans[1]*rev[1][1];
    if(s>0 && t>0 &&s+t<1){cout <<"YES"<<endl;}
    else{cout <<"NO"<<endl;}
  }
  return 0;
}

Measured memory_bytes: 0
N, M = map(int, input().split())  #頂点, 辺
g = [[] for _ in range(N)]  #iはjと繋がっている
for _ in range(M):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

#1度通った頂点をTrueにする
is_checked = [False] * N

import sys
sys.setrecursionlimit(10 ** 8)
def dfs(i):
    cnt = 0
    is_checked[i] = True
    if not(False in is_checked):
        return 1
    else:
        for j in g[i]:
            if not(is_checked[j]):
                cnt += dfs(j)
                is_checked[j] = False
        return cnt
            
ans = dfs(0)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
  int i,j,k,x[5];
  scanf("%d", &x[0]);
  scanf("%d", &x[1]);
  scanf("%d", &x[2]);
  scanf("%d", &x[3]);
  scanf("%d", &x[4]);
  scanf("%d", &k);

  for(int m = 0; m < 5; m++){
    for(int i = m + 1; i < 5 ; i++){
      int n = x[m] - x[i];
      if(n<0){
        n = -n;
      }
      if(n > k){
        printf(":(");
        return 0;
      }
    }
  }
  printf("Yay!");
}


Measured memory_bytes: 128
#include <cstdio>
bool A[200001];
inline char tc(void){
  static char fl[10000],*A=fl,*B=fl;
  return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;  
}
inline int read(void){
  int a=0;static char c;
  while((c=tc())<'0'||c>'9');
  while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
  return a;
}
int main(){
  int n,m,a,b;n=read();m=read();
  while(m--){a=read();b=read();
    if(a==1){
      if(A[b]==true)return puts("POSSIBLE"),0;
      A[b]=true;
    }
    if(b==n){
      if(A[a]==true)return puts("POSSIBLE"),0;
      A[a]=true;
    }
  }
  puts("IMPOSSIBLE");
  return 0;
}

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

int main()
{
  int n, x, sum;
  int a, b, c;

  for (int i = 0; i < 1000; i++) {
    cin >> n >> x;
    if (n == 0 && x == 0) break;    

    sum = 0;
    for (a = fmax(1,x-n-(n-1)); ; a++) {
      b = fmax(a+1, x-a-n);
      c = x-a-b;
      if (a >= b || b >= c) break;
      sum += (c - b + 1) / 2;
    }
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define mod 998244353

using namespace std;
typedef bitset<4005> poly;

llint n;
poly x;
poly a[6];
llint beki[4005];

void adjust(string &s, poly &bs){
	bs.reset();
	reverse(s.begin(), s.end());
	for(int i = 0; i < s.size(); i++) bs[i] = s[i]-'0';
}

llint deg(poly &a)
{
	for(int i = (int)a.size()-1; i >= 0; i--){
 		if(a[i]) return i;
	}
	return -1;
}

poly rem(poly a, poly b)
{
	int A = deg(a), B = deg(b);
	for(int i = A-B; i >= 0; i--){
		if(a[i+B]) a ^= (b << i);
	}
	return a;
}

poly gcd(poly a, poly b)
{
 	if(b.none()) return a;
  	return gcd(b, rem(a, b));
}

int main(void)
{
	cin >> n;
	
	string s;
	cin >> s;
	adjust(s, x);
	for(int i = 0; i < n; i++){
		cin >> s;
		adjust(s, a[i]);
	}
	
	poly d;
	for(int i = 0; i < n; i++) d = gcd(d, a[i]);
	llint D = deg(d);
	
	beki[0] = 1;
	for(int i = 1; i < 4005; i++) beki[i] = beki[i-1] * 2 % mod;
	
	llint ans = 0, X = deg(x); poly y;
	for(int i = X-D; i >= 0; i--){
	  if(x[i+D]) ans += beki[i], ans %= mod;
	  if(x[i+D] != y[i+D]) y ^= (d << i);
	}
	bool flag = true;
	for(int i = D-1; i >= 0; i--){
		if(x[i] > y[i]) break;
		if(x[i] < y[i]) flag = false;
	}
	if(flag) ans++, ans %= mod;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3456
#include<cstdio>
int N,K;
char S[400010];
int main(){
	scanf("%d%d%s",&N,&K,S);
	int l=0,r=N,rev=0;
	while(K--&&l<N){
		if((S[l]^rev)=='A')S[l]^=3;
		else l++,rev^=3,S[r++]='A'^rev;
	}
	if(N%2==1&&K%2==0)S[l]^=3;
	for(int i=l;i<r;i++)putchar(S[i]^rev);
}

Measured memory_bytes: 768
char=input()

if char[0]==char[1] and char[1]==char[2]:
	print("No")
elif char[0]==char[1] and char[2]==char[3]:
	print("Yes")
elif char[0]==char[2] and char[1]==char[3]:
	print("Yes")
elif char[0]==char[3] and char[1]==char[2]:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 3060
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}
	
	int n = read.to!int;
	int m = read.to!int;
	
	Node[] nodes;
	foreach(i; 0 .. n) nodes ~= new Node(i);
	
	foreach(j; 0 .. m){
		int a = read.to!int - 1;
		int b = read.to!int - 1;
		nodes[a].nodes ~= nodes[b];
		nodes[b].nodes ~= nodes[a];
	}
	
	// 奇数があると駄目
	foreach(nd; nodes){
		if(nd.nodes.length % 2 != 0){
			print!1("odd");
			"No".writeln;
			return;
		}
	}
	
	int d2count, d4count, d6count; // d6は次数6以上
	foreach(nd; nodes){
		if(nd.nodes.length == 2) d2count += 1;
		else if(nd.nodes.length == 4) d4count += 1;
		else d6count += 1;
	}
	
	// 6以上があればOK
	if(d6count > 0){
		print!1("6");
		"Yes".writeln;
		return;
	}
	
	// 4が1個以下だとだめ
	if(d4count <= 1){
		print!1("no or only one 4s");
		"No".writeln;
		return;
	}
	
	// 4が3個以上はOK
	if(d4count >= 3){
		print!1("many 4s");
		"Yes".writeln;
		return;
	}
	
	// 4が2個のときは判別が必要
	// 1つの4から辿っていって他方の4を通らずに行けない部分があればOK
	Node nd4;
	foreach(nd; nodes){
		if(nd.nodes.length == 4) nd4 = nd;
	}
	bool f = 0;
	nd4.search4(nd4.id);
	foreach(nd; nodes){
		if(! nd.isVisited){
			f = 1;
			break;
		}
	}
	print!1("two 4s");
	if(f == 1) "Yes".writeln;
	else "No".writeln;
	return;
	
}

/*

すべての点の次数が偶数であることは大前提
次数2の点しかないときは無理

次数2の点は省略して考える

次数6の点があるときは必ずOK

次数4の点が1個のときは無理
次数4の点が2個で、自己ループがないときは無理

*/

class Node{
	long _b, _w;
	int id;
	Node[] nodes;
	Node[] kids;
	Node parent;
	bool isVisited;
	this(int id){
		this.id = id;
	}
	void search4(int okid){
		print!1("-", this.id + 1);
		this.isVisited = 1;
		if(this.id != okid && this.nodes.length == 4) return;
		foreach(nd; nodes) if(! nd.isVisited) nd.search4(okid);
	}
	
	override string toString(){
		return "id:" ~ id.to!string ~ " b:" ~ _b.to!string ~ " w:" ~ _w.to!string ~ " kids:" ~ kids.map!(x => x.id).to!string;
	}
}


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

using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

int main()
{
    int N;
    ll K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0;i<N;++i){
        cin >> A[i];
    }
    // 内部
    ll ans1, ans2, ans;
    ans = ans1 = ans2 = 0;
    for(int i=0;i<N;++i){
        for(int j=i+1;j<N;++j){
            if(A[i] > A[j]){
                ++ans1;
            }
        }
    }
    // 外部
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            if(A[i] > A[j]){
                ++ans2;
            }
        }
    }

    ans1 = (ans1 * K) % MOD;
    ans = ans2 * ((K * (K-1) / 2) % MOD) % MOD;
    cout << (ans1 + ans) % MOD << endl;
}


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

using namespace std;

int main()
{
   int a[3];
   
   cin >> a[0] >> a[1] >> a[2];
   
   sort (a,a+3);
   
   cout << a[0] << " " << a[1] << " " << a[2] << endl;
   
   return 0;
}


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

int main(){
	int n,m; cin >> n >> m;
    scc_graph G(n);
    rep(i,m){
        int u,v; scanf("%d%d",&u,&v);
        G.add_edge(u,v);
    }
    auto scc = G.scc();
    cout << scc.size() << "\n";
    for(auto v : scc){
        cout << v.size() << " ";
        for(auto t : v) cout << t << " ";
        cout << "\n";
    }
}

Measured memory_bytes: 40552
def main():
    N, K = map(int, input().split())
    MOD = 1_000_000_007
    l = 0
    r = 0
    ans = 0
    for i in range(N + 1):
        l += i
        r += N - i
        if i + 1 >= K:
            ans += r - l + 1
            ans %= MOD
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int a, b, c;
    cin>>a>>b>>c;
    if(a + b + c > 21) cout<<"bust\n";
    else cout<<"win\n"; 
    return 0;
}

Measured memory_bytes: 256
class Process():
    name = ""
    time = 0

    def __init__(self, name, time):
        self.name = name
        self.time = time


n, q = map(int, input().split(" "))

queue = []
for i in range(n):
    n, t = input().split(" ")
    queue.append(Process(n, int(t)))

qw = q
lap_time = 0
while len(queue) > 0:
    p = queue.pop(0)
    if qw != q and p.time - qw - q > 0:
        lap_time += qw + q
        p.time = p.time - qw - q
        qw = q
        queue.append(p)
    elif p.time - qw > 0:
        lap_time += qw
        p.time = p.time - qw
        qw = q
        queue.append(p)
    else:
        lap_time += p.time
        qw = q
        print(p.name, lap_time)



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

using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;

int main() {
    string s;
    cin >> s;
    bool a = false;

    rep(i,s.length()) {
        if(i%2==1) {
            if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D') {
                a = true;
            } else {
                a = false;
                break;
            }
        } else if(i%2==0) {
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D') {
                a = true;
            } else {
                a = false;
                break;
            }
        }
    }
    if(a) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

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

    int n;
    cin >> n;

    vector<vector<pair<int, int>>> v(n);
    rep(i, n){
        int a;
        cin >> a;
        rep(j, a){
            int x, y;
            cin >> x >> y;
            v[i].push_back(make_pair(--x, y));
        }
    }

    int ans = 0;
    for(int bit=0; bit<(1<<n); bit++){
        int tmp_ans = 0;    //正直の人の人数
        int check[15] = {}; //パターン記録用
        for(int i=0; i<n; i++){
            if(bit & (1<<i)){
                check[i] = 1;   //パターン　0101など　1が正直
                tmp_ans++;
            }
        }
        bool ok = true;
        rep(i, n){
            if(check[i]){   //i人目の人が正直なら証言を確認する
                for(const auto& x : v[i]){
                    if(x.second != check[x.first]){
                        //証言と違ったら,矛盾しているので、最初からやり直し
                        ok = false;
                        break;
                    }
                }
            }
        }
        if(ok)
            ans = max(ans, tmp_ans);
    }
    cout << ans << endl;

    return 0;
}

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

int64_t func(int64_t n) {
  int64_t ret = 0;
  int64_t q = (n + 1) / 2;
  ret += q % 2;
  if (n % 2 == 0) ret ^= n; 
  return ret;
}

int main() {
  int64_t a, b; cin >> a >> b;
  int64_t ans = 0;
  if (a == 0) ans = func(b);
  else ans = func(b) ^ func(a-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
char s[1000005];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	bool f1=0;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans++;
		if(s[i]==s[i+1]&&!f1)
			i++,f1=1;
		else
			f1=0;
	}
	printf("%d",ans);
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n,m;
int l[100000];
int r[100000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m;
    for(int i=0;i<m;i++) {
        cin>>l[i]>>r[i];
    }
    int mina=l[0];
    int maxa=r[0];
    for(int i=1;i<m;i++){
        if(l[i]>mina){
            mina=l[i];
        }
        if(r[i]<maxa){
            maxa=r[i];
        }
    }
    int ans=maxa-mina+1;
    if(ans<0){
        ans=0;
    }
    cout <<ans<< "\n";
}

Measured memory_bytes: 1024
N = int(input())
if N % 10 == 3:
    print('bon')
elif N % 10 == 2:
    print('hon')
elif N % 10 == 4:
    print('hon')
elif N % 10 == 5:
    print('hon')
elif N % 10 == 7:
    print('hon')
elif N % 10 == 9:
    print('hon')
elif N % 10 == 0:
    print('pon')
elif N % 10 == 1:
    print('pon')
elif N % 10 == 6:
    print('pon')
elif N % 10 == 8:
    print('pon')

Measured memory_bytes: 9200
import java.util.*;
import java.io.*;
public class Main {
	public static void main(String... args) {
		Main m = new Main();
		m.solve();
		m.close();
	}

	private Scanner sc;
	private PrintWriter pw;

	public Main() {
		sc = new Scanner(System.in);
		pw = new PrintWriter(System.out);
	}
	private void close() {
		pw.flush(); pw.close();
	}
	private boolean has() { return sc.hasNextInt(); }
	private int nint()    { return sc.nextInt();    }

	private void solve() {
		HashMap<Integer, List<Integer>> m = new HashMap<Integer, List<Integer>>();
		int[][] x = new int[10][4];
		for(int i = 0; i < 10; i++) {
		for(int j = 0; j < 10; j++) {
		for(int k = 0; k < 10; k++) {
		for(int l = 0; l < 10; l++) {
			int T = i+j+k+l;
			if(m.containsKey(T)) {
				m.get(T).add(1);
			} else {
				List<Integer> list = new ArrayList<Integer>();
				list.add(1);
				m.put(T,list);
			}
		}}}

		}

		while(has()) {
			Object obj = m.get(nint());
			int ans = obj == null ? 0 : ((List)obj).size();
			pw.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int k;
double p, e, t;

double ans = 0;

void dfs(double l, double r, int cnt, double x) {
	if(r < t - e) return;
	if(l > t + e) return;
	if(t - e <= l && r <= t + e) {
		ans += x;
		return;
	}

	double h = (l + r) / 2;

	if(cnt == k) {
		if(t - e <= h && h <= t + e) ans += x;
		return;
	}

	if(h >= t) {
		dfs(l, h, cnt + 1, (1.0 - p) * x);
		dfs(h, r, cnt + 1, p * x);
	} else {
		dfs(h, r, cnt + 1, (1.0 - p) * x);
		dfs(l, h, cnt + 1, p * x);
	}
}

int main() {
	double l, r;
	cin >> k >> l >> r;
	cin >> p >> e >> t;

	dfs(l, r, 0, 1.0);

	cout << fixed;
	cout.precision(20);
	cout << ans << endl;

	return 0;
}

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

int main()
{
  vector< vector<int> > c(3,vector<int>(3));
  vector<int> a(3), b(3);
  int i, j, k;
  int check;
  string ans;
  for(i=0; i<3; i++)
  {
    for(j=0; j<3; j++)
    {
      cin >> c[i][j];
    }
  }
  ans = "No";
  for(i=0; i<=c[0][0]; i++)//a1をiと仮定
  {
    check = 0;
    a[0] = i;
    for(j=0; j<3; j++)
    {
      b[j] = c[0][j] -a[0];
      a[j] = c[j][0] -b[0];
    }
    
    for(j=0; j<3; j++)//あってるかチェック
    {
      for(k=0; k<3; k++)
      {
        if(c[j][k] == a[j] +b[k]) check++; 
      }
    }
    if(check == 9)
    {
      ans = "Yes";
      break;
    }
  }
  cout << ans <<endl;
  return 0;
}


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

def solve():
    MOD = 1000000007
    N, M = list(map(int, input().split()))
    dp = [0 for i in range(0, N+1)]
    A = set()
    for i in range(M):
        A.add(int(input()))
    
    dp[0] = 1
    dp[1] = 0 if 1 in A else 1

    for i in range(2, N+1):
        if i in A:
            continue
        dp[i] = (dp[i-1]%MOD + dp[i-2]%MOD)%MOD
    
    print(dp[N])


if __name__ == "__main__":
    solve()


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

#define fto(i, l, r) for(int i = l; i <= r; ++i)
#define fdto(i, r, l) for(int i = r; i >= l; --i)
#define debug(a) cout << #a << ": " << a << endl

using namespace std;
const int oo = 1000000007;
const int MAXN = 300005; 

int n, q;
char s[MAXN];
set<int> pos;

struct Node {
  int m, val;
};

Node t[4*MAXN];

void propagate(const int &id, const int &l, const int &r) {
  int &x = t[id].val;
  if (x != 0) {
    fto(i, 0, 1) {
      t[2*id + i].m += x;
      t[2*id + i].val += x;
    }
    x = 0;
  }
}

void update(int id, int l, int r, const int &i, const int &j, const int &x) {
  if (j < l || i > r) return;
  if (i <= l && r <= j) {
    t[id].val += x;
    t[id].m += x;
    return;
  }
  // printf("%d %d %d %d\n", id, l, r, t[id].m);
  propagate(id, l, r);
  int m = (l + r)/2;
  update(2*id, l, m, i, j, x); update(2*id+1, m+1, r, i, j, x);
  t[id].m = min(t[2*id].m, t[2*id+1].m);
}

void check(int id, int l, int r) {
  // printf("%d %d %d %d %d\n", id, l, r, t[id].m, t[id].val);
  if (l < r) {
    int m = (l+r)/2;
    check(2*id, l, m);
    check(2*id+1, m+1, r);
  }  
}

int query(int id, int l, int r, const int x) {
  // printf("%d %d %d %d %d\n", id, l, r, x, t[id].m);
  if (t[id].m >= x)
    return l;
  if (l == r)
    return l+1;
  propagate(id, l, r);
  int m = (l+r)/2;
  int ans = query(2*id+1, m+1, r, x);
  if (ans == m+1)
    ans = query(2*id, l, m, x);
  return ans;
}

void flip(int i) {
  if (s[i] == '(') {
    s[i] = ')';
    update(1, 0, n-1, i, n-1, -2);
    pos.insert(i);
  } else {
    s[i] = '(';
    update(1, 0, n-1, i, n-1, 2);
    pos.erase(i);
  }
}

int main() {
  scanf("%d%d", &n, &q);
  scanf("%s", s);

  fto(i, 0, n-1) {
    // debug(i);
    if (s[i] == ')') {
      pos.insert(i);
      update(1, 0, n-1, i, n-1, -1);
    } else 
      update(1, 0, n-1, i, n-1, 1);
  }

  // check(1, 0, n-1);

  fto(i, 1, q) {
    int p; scanf("%d", &p);
    --p;

    // debug(i);
    int ans;
    if (s[p] == '(') {
      flip(p);
      ans = *pos.begin();
    } else {
      flip(p);
      // if (i == 2)
      //   check(1, 0, n-1);
      ans = query(1, 0, n-1, 2);
    }
    
    flip(ans);
    // printf("%s\n", s);
    // for(int x: pos)
    //   printf("%d ", x);
    // puts("");
    printf("%d\n", ans+1);
  }
  
  return 0;
}


Measured memory_bytes: 18748
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include <string>
#include <math.h>
#include <queue>
#include <stack>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >>y[i];
typedef long long int ll;
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

int main(){
   int n; cin >>n;
   vector<int> a(n),b(n);
   cinf(n,a,b);
   vector<pair<int,int> > v;
   for(int i=0;i<n;i++){
    v.push_back(make_pair(b[i],a[i]));
   }
   sort(v.begin(),v.end());
   reverse(v.begin(),v.end());
   int now=v[0].first;
   for(int i=0;i<n;i++){
    if(v[i].first<now){
        now=v[i].first;
        now-=v[i].second;
    }
    else{
        now-=v[i].second;
    }
   }
   if(now>=0){
    cout << "Yes" << endl;
   }
   else{
    cout << "No" << endl;
   }
}

Measured memory_bytes: 3956
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	n := nextInt()
	k := nextInt()
	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = nextInt()
	}
	sort.Ints(h)
	for i := 0; i < k && i < n; i++ {
		h[n-i-1] = 0
	}
	// log.Println(h)
	fmt.Println(sum(h))
}

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

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

LLI power(LLI n, LLI p, LLI m){
  LLI ret = 1;
  while(p>0){
    if(p&1) (ret *= n) %= m;
    (n *= n) %= m;
    p /= 2;
  }
  return ret;
}

LLI mod_inv(LLI n, LLI p){return power(n,p-2,p);}

const LLI mod = 1e9+7;

LLI inv[101000];
LLI fac[101000];

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

  fac[0] = 1;

  FORE(i,1,100000){
    (inv[i] = inv[i-1] + mod_inv(i,mod)) %= mod;
    (fac[i] = fac[i-1] * i) %= mod;
  }

  int N;
  while(cin >> N){
    vector<int> A(N); cin >> A;

    LLI ans = 0;

    REP(i,N){
      (ans += A[i] * fac[N] % mod * ((inv[i+1] + inv[N-i] - inv[1] + mod) % mod) % mod) %= mod;
    }
    
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 2176
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n * 2);
  for (int i = 0; i < n * 2; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  int ret = 0;
  for (int i = 0; i < n * 2; i += 2) {
    ret += a[i];
  }
  printf("%d\n", ret);
  return 0;
}


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

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

const ll MOD_VERYBIG = 1e15;
const ll MOD_VERYBIG2 = 1e13;


int main(void){
    ll x;
    cin >> x;
    ll kane_l = 100;
    ll kane_h = 0;
    ll ans;
    FOR(i,1,4000){
        kane_l = (kane_l * 101) / 100 + ((kane_h * 101) % 100) * MOD_VERYBIG2;
        //cout << kane_l << " ";
        kane_h = (kane_h * 101) / 100 + kane_l / MOD_VERYBIG;
        //cout << kane_h << " ";
        kane_l %= MOD_VERYBIG;
        //cout << (kane_h+kane_l) << endl;
        if((kane_h * MOD_VERYBIG + kane_l) >= x){
            cout << i << endl;
            break;
        } 
    }
    return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int a, b, c, d, e, f, i, j;
	cin >> a >> b >> c >> d >> e >> f;
	vector<bool> mizu(f + 1,false);
	mizu[0] = true;
	for (i = 0; i <= f; i+=100) {
		if (mizu[i]) {
			if (i + 100 * a <= f) {
				mizu[i + 100 * a] = true;
			}
			if (i + 100 * b <= f) {
				mizu[i + 100 * b] = true;
			}
		}
	}
	vector<bool> satou(f + 1, false);
	satou[0] = true;
	for (i = 0; i <= f; i++) {
		if (satou[i]) {
			if (i + c <= f) {
				satou[i + c] = true;
			}
			if (i + d <= f) {
				satou[i + d] = true;
			}
		}
	}
	//DEBUG_VEC(mizu);
	//DEBUG_VEC(satou);
	double M = -1;
	int max_mizu=0, max_satou=0;
	for (i = 0; i <= f; i += 100) {
		for (j = 0; j <= f; j++) {
			if (i + j > f) {
				break;
			}
			if (mizu[i] && satou[j]) {
				if (j <= e*i / 100) {
					if ((double)j / (i + j) > M) {
						M = (double)j / (i + j);
						max_mizu = i;
						max_satou = j;
					}
				}
				else {
					break;
				}
			}
		}
	}
	cout << max_mizu+max_satou << " " << max_satou << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n,d,ans;
    cin >> n >> d >> ans;
    int k,tmp;
    for(int i = 0;i<n;i++){
        cin >> k;
        tmp = 1;
        while(tmp<=d){
            ans++;
            tmp+=k;
        }
    }
    cout << ans << endl;
}

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

int main()
{
  int s;
  cin >> s;
  int h = s / 3600;
  s %= 3600;
  int m = s / 60;
  s %= 60;
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}

Measured memory_bytes: 1164
using System;
using System.Collections.Generic;
using System.Linq;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = Math.Abs(r[0] - r[1]);
            var b = Math.Abs(r[0] - r[2]);
            if (a < b)
            {
                Console.WriteLine("A");   
            }
            else
            {
                Console.WriteLine("B");
            }
        }
        

    }
}

Measured memory_bytes: 13396
a,b,c = map(int,input().split())
ar = []
if a + c > b:
    d = b+1
else:
    d = a+c
for i in range(a,d):
    ar.append(i)
if b - c < a:
    e = a
else:
    e = b-c+1
for i in range(e,b+1):
    ar.append(i)
br = set(ar)
cr = sorted(br)
for i in cr:
    print(i)

Measured memory_bytes: 3064
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    aa=LI()
    aa.sort()
    print(aa[n//2]-aa[n//2-1])

main()

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
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;}



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

    int ans = 0;

    REP(i, 1000){
        string t;
        t += '0' + i%10;
        t += '0' + (i/10)%10;
        t += '0' + i/100;
        reverse(all(t));

        int p = 0;
        REP(j, n){
            if(t[p] == s[j]) p++;
            if(p == size(t)){
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
s = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
ans = 0

for i in range(1<<n):
    for j in range(m):
        cnt = 0
        for num in s[j]:  
            if i&(1<<(num-1)) != 0:
                cnt += 1
        if cnt%2 != p[j]: #j番目の電球でアウト
            break
    else: #すべての電球でパス
        ans += 1

print(ans)

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

using namespace std;

int solve(int N)
{
    int ans = 0;
    
    do
    {
        ans += (N % 10);
        N /= 10;
    } while (N);

    return ans == 1 ? 10 : ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    auto ans = solve(N);

    cout << ans;

    return 0;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    ll n,m;
    cin >> n >> m;
    if(m>=2*n)
    {
        cout << (m+2*n)/4 << endl;
        return 0;
    }
    cout << m/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void debug() { cerr << "ok" << endl; }
template <class T>
void printv(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void readv(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a, b, n;
    cin >> a >> b >> n;
    cout << ll(a * min(n, b - 1LL) / b) << '\n';
}

Measured memory_bytes: 3640
map{*I=-$_;<>=~$",vec($I,$`-1,8)=$'+49for 1..<>;$Z.='{0,2}'}1..<>;printf sort{$b-$a}map{map{$i=0;for$c(/./g){$i--;$c-2or$_|=$$i}}($_)x5;!/3/*y/2//}glob$Z

Measured memory_bytes: 5168
import math
a,b,c,d = map(int,input().split())

a -= 1
a_b = c * d // math.gcd(c, d)
#print(a_b)
ans_a = a - (a // c + a // d - a // a_b)
ans_b = b - (b // c + b // d - b // a_b)

print(int(ans_b-ans_a))


Measured memory_bytes: 61924
N, Q = map(int, input().split())
graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

C = [0] * (N + 1)
for _ in range(Q):
    p, x = map(int, input().split())
    C[p] += x

se = set([1])
stack = [1]
while stack:
    # print(C)
    x = stack.pop()
    for y in graph[x]:
        if y in se:
            continue
        stack.append(y)
        se.add(y)
        # 親x, 子y
        C[y] += C[x]

print(' '.join(str(i) for i in C[1:]))


Measured memory_bytes: 75012
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(string S) {
    auto y = S[0 .. 4].to!int;
    auto m = S[5 .. 7].to!int;
    auto d = S[8 .. $].to!int;
    return y < 2019 || (y <= 2019 && m < 4) || (y <= 2019 && m <= 4 && d <= 30) ? "Heisei" : "TBD";
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    string S;
    S = input.front.to!string;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(S);
    else
        solve(S).writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e18
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  ll D, N;
  cin >> D >> N;
  if(N==100){
    ll ans = (N + 1) * pow(100, D);
    printf("%lld\n", ans);
    return 0;
  }
  cout << (N * pow(100, D)) << endl;

  return 0;
}

Measured memory_bytes: 256