akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

long long int main(void){
	long long int n,k;
	scanf("%lld %lld",&n,&k);
	n=n%k;
	if(n>abs(n-k)){
		//n=k-n;
		n=llabs(n-k);
	}
	printf("%lld\n",n);
	return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string n; cin >> n;
  string r; for(int i = n.size()-1;i>=0;--i) r.push_back(n[i]);

  if(n==r) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3592
import java.util.*;
import java.io.*;
 
public class Main{
    
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
		int X = s.nextInt();
		int N = s.nextInt();
		int[] p = new int[N];
		HashMap<Integer, Boolean> hash = new HashMap<Integer, Boolean>();
		for(int i = 0; i < N; i++){
			p[i] = s.nextInt();
			hash.put(p[i], true);
		}

		int minLen = 10000;
		int min = 0;
		for(int i = -200; i < 200; i++){
			if(hash.containsKey(i)) continue;
			if(Math.abs(i-X) < minLen){
				min = i;
				minLen = Math.abs(i-X);
			} 
		}
		System.out.println(min);
		
			
	}
} 

Measured memory_bytes: 36016
for _ in range(int(input())):
    X,Y,W,H= map(int, input().split())
    x1,y1,x2,y2=X,Y,X+W,Y+H
    cnt=0
    for _ in range(int(input())):
        x,y= map(int, input().split())
        if (x>=x1 and x<=x2) and (y>=y1 and y<=y2):
            cnt+=1
    print(cnt)

Measured memory_bytes: 7604
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();

		int ans = Math.min(n*a, b);
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 35580
#include<bits/stdc++.h>
using namespace std;
long long n,i,j,a,b,c,k,x,y;
int main()
{
  cin>>a>>b>>c>>x>>y;
  k=a*x+b*y;
  k=min(k,2*c*max(x,y));
  if(x>y)k=min(k,2*c*y+a*(x-y));
  else k=min(k,2*c*x+b*(y-x));
  cout<<k;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        # root[x]<0ならそのノードが根であり、その絶対値がそれに属する木の要素数
        # わかりやすさのために長さをN+1として1番目を1のノード,2番目を2のノード,...,n番目をnのノードとして0番目は存在しないノードである
        self.par = [-1] * (n+1)
        # self.rankに木の高さを格納する(初期状態では0)
        self.rank = [0] * (n+1)

    # xの親の検索
    # ある２つの要素が同じグループに属するか判定する
    # ある２つの要素がそれぞれ属する木の根が同じかどうかをチェックすればよい
    # つまり、親の親の親の・・・と根にたどり着くまで走査すればよい
    # ただしそのままでは、同じ値を何度について何度も検索するときに手間がかかる
    # そこで、一度調べた値については根に繋ぎなおすことにする
    def find(self, x):
        if self.par[x] < 0: # 根ならその番号を返す
            return x
        else:
            self.par[x] = self.find(self.par[x]) # 走査していく過程で親を書き換える
            return self.par[x]

    # xとyの併合
    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        # 木の高さを比較し、低いほうから高いほうに辺を張る
        elif self.rank[x] > self.rank[y]:
            self.par[x] += self.par[y]
            self.par[y] = x
        else:
            self.par[y] += self.par[x]
            self.par[x] = y
            # 木の高さが同じ(rankが同じ)なら片方を1増やす
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    # ある2つの要素x,yが同じ集合に属するかを判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # その要素xの属する集合の要素数を返す
    def size(self, x):
        return - self.par[self.find(x)]

N, M = map(int, input().split())
A = []
B = []
for _ in range(M):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

uni = UnionFind(N)
ans = [0 for _ in range(M)]
ans[M-1] = (N * (N-1)) // 2

for i in range(M-1, 0, -1): # iはM-1,M-2,...2,1
    if uni.same_check(A[i], B[i]): # A[i]とB[i]がすでに繋がっていたとき
        ans[i-1] = ans[i]
    else: # A[i]とB[i]がすでに繋がっていなかったとき
        ans[i-1] = ans[i] - uni.size(A[i]) * uni.size(B[i])
        uni.union(A[i], B[i])

for i in range(M):
    print(ans[i])

Measured memory_bytes: 17808
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    char a, b;
    cin >> a >> b;
    if (a == 'H')
    {
        cout << b << endl;
    }
    else
    {
        if (b == 'H')
        {
            cout << 'D' << endl;
        }
        else
        {
            cout << 'H' << endl;
        }
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    vector<pll> BA(N);
    rep(i,N){
        int a,b;cin >> a >> b;
        BA[i].S = a;
        BA[i].F = b;
    }
    sort(all(BA));
    LL now = 0;
    bool ok = true;
    rep(i,N){
        LL B = BA[i].F;
        LL A = BA[i].S;
        now += A;
        if(now > B)ok = false;
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3328
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int h, m, s;
		int outH, outM, outS;
		int[][] time = new int[3][3];
		
		for(int i = 0; i < 3; i++){
			h = scan.nextInt();
			m = scan.nextInt();
			s = scan.nextInt();
			outH = scan.nextInt();
			outM = scan.nextInt();
			outS = scan.nextInt();
			
			if(outS < s){
				outS += 60;
				outM--;
			}time[i][2] = outS - s;
			if(outM < m){
				outM += 60;
				outH--;
			}time[i][1] = outM - m;
			time[i][0] = outH - h;
		}
		
		for(int i = 0; i < 3; i++){
			System.out.println(time[i][0] + " " + time[i][1] + " " + time[i][2]);
		}
	}
}

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

int main(){
	int n, i, j, k, l, count[5][4][11] = {};
	cin >> n;
	for( int u = 0; u < n; u++){ cin >> i >> j >> k >>l; count[i][j][k] += l;}
	for( int u1 = 1; u1 <= 4; u1++){ for( int u2 = 1; u2 <= 3; u2++){ for( int u3 =1; u3 <= 10; u3++){ if( u1 != 4 && u2 == 3 && u3 == 10){ cout << " " << count[u1][u2][u3] << "\n####################\n";} else { if( u3 == 10 ){ cout << " " << count[u1][u2][u3] << "\n"; } else { cout << " " << count[u1][u2][u3]; } } } } }
	
return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << v.first << " " << v.second;
    return ostr;
}

int main() {
    int n, k;
    cin >> n >> k;

    if (k == 10) {
        string s = to_string(n);
        cout << s.size() << endl;
        exit(0);
    }

    int ans = 0;
    int a = 1;
    while (n >= a) {
        ans++;
        a *= k;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>                          
using namespace std;    
int a,b,c,x,y,z,ans; 
int main(){
	cin>>a>>b>>c;
	x=a*10+b+c;
	y=b*10+a+c;
	z=c*10+a+b;
	ans=max(max(x,y),z);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 100005

using namespace std;

typedef  long long ll;
typedef pair <int,int> par;
typedef pair <int ,par> tri;

int N, A[maxn], S[maxn];
ll T[maxn];

int find_set ( int nod ) {
    if ( S[nod] == nod ) return nod;
    return S[nod] = find_set ( S[nod] );
}

int main() {

    #ifdef acm
    freopen ("a.in", "r", stdin );
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> N;
    for ( int i = 1; i <= N; i ++ )
        cin >> A[i];
    sort ( A+1, A+1+N );
    for ( int i = 1; i <= N; i ++ )
        T[i] = T[i-1] + A[i];

    for ( int i = 1; i <= N; i ++ ) {
        S[i] = i;
        if ( T[i]*2 >= A[i+1] && i < N )
            S[i] = i+1;
    }
    int sol = 0;
    for ( int i = 1; i <= N; i ++ )
        sol += ( find_set(i) == N );
    cout << sol;

    return 0;
}


Measured memory_bytes: 3328
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#define ll long long
#define ull unsigned long long
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define numOfOnes(n) __builtin_popcount(n)
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//</DEFINE>

/*█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀█▄▄▄▀▀▀▀▄▄▄█▀*/
int n;
vector<int>v;
int res[100001];
//<FUNCTIONS>
ll solve(int idx = 0) {
	ll res1, res2;
	if (idx == n - 1)return 0;
	if (~(res[idx]))return res[idx];
	res1 = 1e18;
	if (idx + 2 < n)res1 = solve(idx + 2) + abs(v[idx] - v[idx+2]);
	res2 = solve(idx + 1) + abs(v[idx] - v[idx+1]);
	return res[idx] = min(res1, res2);
}
//</FUNCTIONS>		
int main() {
	Fast();
	cin >> n;
	for (int i = 0; i <= n; i++)
		res[i] = -1;
	v.resize(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	cout << solve()<<endl;
}


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

int main(){
    int n;
    vector<int64_t> L(100);
    cin >> n;
    L.at(0) = 2;
    L.at(1) = 1;
    for(int i=2;i<n+1;i++){
        L.at(i) = L.at(i-1) + L.at(i-2);
    }
    cout << L.at(n) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  Scanner sc=new Scanner(System.in);
	 int a=sc.nextInt();
	 int b=sc.nextInt();
	 int d;
	 int r;
	 double f;
	 d=a/b;
	 r=a%b;
	 f=a*1.0/b;
	 System.out.println(d+" "+r+" "+String.format("%f",f));
	  sc.close();
  }
}


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

signed main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  string ans="Yes";
  rep(i,1000){
    if(C-B<=0)break;
    if(A-D<=0){
      ans="No";
      break;
    }
    A-=D;
    C-=B;
  }
  cout<<ans<<endl;
} 

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

const int N = 101010;
typedef long long ll;

inline char get(void) {
	static char buf[100000], *S = buf, *T = buf;
	if (S == T) {
		T = (S = buf) + fread(buf, 1, 100000, stdin);
		if (S == T) return EOF;
	}
	return *S++;
}
template<typename T>
inline void read(T &x) {
	static char c; x = 0;
	for (c = get(); c < '0' || c > '9'; c = get());
	for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
}

long long n, L, T, bg, dis, delta, f1;
int x[N], w[N];
int f[N], ans[N];

int main(void) {
	read(n); read(L); read(T);
	for (int i = 1; i <= n; i++) {
		read(x[i]); read(w[i]);
		if (w[i] == 1) f[i] = (x[i] + T) % L;
		else f[i] = (x[i] - T % L + L) % L;
	}
	f1 = f[1]; T <<= 1;
	sort(f + 1, f + n + 1);
	for (int i = 2; i <= n; i++)
		if (w[i] ^ w[1]) {
            if (w[1] == 1) dis = T - x[i] + x[1] - 1;
			else dis = T - L + x[i] - x[1] - 1;
			delta += (dis < 0 ? 0 : (dis / L + 1));
		}
	if (w[1] == 2) delta = (n - delta % n) % n;
	bg = delta % n + 1;
	if (w[1] == 1) f1 = lower_bound(f + 1, f + n + 1, f1) - f;
	else f1 = upper_bound(f + 1, f + n + 1, f1) - f - 1;
	for (int i = 1; i <= n; i++) {
		ans[bg] = f[f1];
		bg = bg % n + 1;
		f1 = f1 % n + 1;
	}
	for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    string s;
    ll k;
    cin >> s >> k;
    rep(i,k){
        if(s[i]!='1'){
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
import java.util.*;

class Main{

    boolean overlap(int a, int b, int c, int d){
        if ( d <= a ) return false;
        if ( b <= c ) return false;
        return true;
    }

    void solve(){
        Scanner sc = new Scanner(System.in);
        int a, b, s, f, n;
        a = sc.nextInt();
        b = sc.nextInt();
        n = sc.nextInt();
        for ( int i = 0; i < n; i++ ){
            s = sc.nextInt();
            f = sc.nextInt();
            if ( overlap(a, b, s, f) ){
                System.out.println("1");
                return;
            }
        }
        System.out.println("0");
    }

    public static void main(String[] args){ new Main().solve(); }
}










Measured memory_bytes: 26448
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    string a, b, c;
    cin >> a >> b >> c;

    cout << a[0] << b[0] << c[0] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdint>
#include<cstdio>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<(b); ++i)
#define rep(i,n) for(int i=0; i<n; ++i)
#define all(v) begin(v), end(v)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  n *= 2;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(begin(v), end(v));
  int ans = 0;
  for (int i = 0; i < n; i+=2) {
    ans += v[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	vector<char> c;
	vector<char> v;
	int cnt=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
	c.push_back(s[i]);
	for(int i=97;i<=122;i++)
	{
		bool ok=false;
		for(int j=0;j<c.size();j++)
		{
		if(c[j]==char(i))
		ok=true;
		}
		if(ok==false)
		v.push_back(char(i));
		else
		cnt++;
	}	
	if(cnt==26)
	cout<<"None";
	else
	cout<<v[0];
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
int N, M;

int main(){
  cin >> N >> M;
  
  priority_queue<ll> goods;
  for(int i=0; i<N; i++){
    ll a; cin >> a;
    goods.push(a);
  }
  
  for(int i=0; i<M; i++){
    ll dmy = goods.top()/2;
    goods.pop();
    goods.push(dmy);
  }
  
  ll ans = 0;
  for(int i=0; i<N; i++){
    ans += goods.top();
    goods.pop();
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1400
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	double x1,y1,x2,y2,x3,y3,x4,y4;
	int n,i;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		if((int)(x1*10000000+0.5)==(int)(x2*10000000+0.5))
			if((int)(x3*10000000+0.5)==(int)(x4*10000000+0.5))
				printf("YES\n");
			else
				printf("NO\n");
		else{
			if((int)(x1*10000000+0.5)==(int)(x2*10000000+0.5))
				printf("NO\n");
			else
				if((int)( (y2-y1)/(x2-x1)*10000000 +0.5)==(int)( (y4-y3)/(x4-x3)*10000000 +0.5))
					printf("YES\n");
				else
					printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>  // ver2.2.0
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define INF 3000000000000000000  //  3.0 * 10 ^ 18 (MAXの1/3くらい)
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ
 
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

VVi a(26,Vi(0));

int ser(char c,int n){
  int m = c-'a';
  int l = a[m].size();
  int L = 0,R = l,mid = (L+R)/2;
  int ans = -1;
  
  while(L<R){
    if(a[m][mid]>n) {
      R = mid;
      ans = a[m][mid];
    }
    else if(a[m][mid]<=n) L = mid+1;
    mid = (L+R)/2;
  }
  if(ans==-1) ans = a[m][0];
  return ans;
}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  string s,t;
  cin >> s >> t;
  int L=s.size();
  int qw,er,ty,ui;
  rep(i,0,s.size()){
    qw = s[i]-'a';
    a[qw].pb(i);
  }
  
  /*rep(i,0,26){
    if(a[i].size()==0) a[i].pb(-1);
  }*/
  
  //VVout(a);
  
  Vi memo(t.size());
  int now = -1;
  char c;
  rep(i,0,t.size()){
    c = t[i];
    if(a[c-'a'].size()==0) {cout<<-1<<endl;return 0;}
    now = ser(c,now);
    memo[i] = now;
  }
  //Vout(memo);
  int ans = memo.back()+1;
  
  rep(i,1,memo.size()){
    if(memo[i]<=memo[i-1]) ans += L;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2256
#include<stdio.h>

int main(){
int h,w,i,j;
  
  while(1){
    scanf("%d%d",&h,&w);
    if(h == 0 && w == 0) break;

    for(i = 0; i < h; i++){
      for(j = 0; j < w; j++){
	if((i + j) % 2 == 0){
	  printf("#");
	}
	else {
	  printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  
  return 0;
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

void print(vector<ll> a) {
  REP(i, a.size()) {
    if (i) cout << ' ';
    cout << a[i];
  }
  cout << endl;
}

int main2() {
  int N = nextLong();
  vector<ll> A(N);
  REP(i, N) A[i] = nextLong();

  ll S = 0;
  REP(i, N) S ^= A[i];

  vector<ll> ans(N);
  REP(i, N) ans[i] = S ^ A[i];
  print(ans);
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 7944
#include <iostream>
using namespace std;
 
int main() {
	int N,T;
	int a = 1001;
	cin >> N >> T;
	for(int i = 0; i < N; i++){
		int c,t;
		cin >> c >> t;
		if(t <= T && c < a){
			a = c;
		}
	}
	if(a == 1001){
		cout << "TLE" << endl;
	} else {
		cout << a << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
#define PI 3.14159265




int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    if(s[1] == 'B'){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3616
# -*- coding: utf-8 -*-
import io, sys

def main():
    N = int( sys.stdin.readline() )
    L_list = list(map(int, sys.stdin.readline().split()))

    cnt = 0

    for i in range(len(L_list)):
        for j in range(i+1, len(L_list)):
            for k in range(j+1, len(L_list)):
                a,b,c = sorted( [L_list[i], L_list[j], L_list[k]] )

                if c < (a + b)  and  (a != b) and (b != c):
                    cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9196
n, m = gets.chomp.split(' ').map{|x| x.to_i }
x = gets.chomp.split(' ').map{|x| x.to_i }

if n >= m
  puts 0
else
	x.sort!
	d = []
	(1...m).each do |i|
  	d << x[i] - x[i-1]
	end

	puts d.sort.first(m-n).inject(:+)
end


Measured memory_bytes: 11120
import sys
import heapq
import bisect

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def main():
    N,Q = LI()
    node=[[] for _ in range(N)]
    flag = [True for _ in range(N)]
    for _ in range(N-1):
        a,b = LI()
        node[a-1].append(b-1)
        node[b-1].append(a-1)

    counter = [0] * N
    for _ in range(Q):
        p,x = LI()
        counter[p-1] += x

    cur = [[0,0]]
    while cur:
        nxt = []
        for a,c in cur:
            flag[a]=False
            counter[a]+=c
            for b in node[a]:
                if flag[b]:
                    nxt.append([b,counter[a]])
        cur = [x for x in nxt]

    r = [counter[i] for i in range(N)]

    return(" ".join(map(str,r)))

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 133060
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int mnv = input.nextInt();
		int mxv, t;
		t = input.nextInt();
		mxv = t - mnv;
		if(t < mnv)
			mnv = t;	
		for(int i = 2; i < n; i++)
		{
			t = input.nextInt();
			if(t < mnv)
				mnv = t;
			else if(mxv < t - mnv)
				mxv	= t - mnv;
		}
		System.out.println(mxv);
	}
}

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

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

    for(int i = 0; i < S.size(); i = i + 2) {
        if(S[i] != 'h' || S[i + 1] != 'i') {
            cout << "No" << endl;
            break;
        }

        if(i == S.size() - 2) {
            cout << "Yes" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define llinf 1e17
#define nllinf -4e18
 
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll,ll> 
#define vpll vector<pair<ll,ll > >
 
#define repup(a,b,i) for(i=a;i<=b;i++)
#define repdown(a,b,i) for(i=b; i>=a; i--)
#define repupx(a,b,i,x) for(i=a;i<=b;i+=x)
	
#define repit(v,it) for(it=v.begin(); it!=v.end(); it++)
#define itall(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
 
#define err(n) cout<<n<<" ";
#define t1 cout<<",";
 
ll MOD= 998244353;


int main(){
//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll i,j,k;

string s, t;
cin>>s>>t;
pair<ll, pll > a[s.length()+5][t.length()+5];
repup(0,s.length()+4,i){
	repup(0,t.length()+4,j){a[i][j]=mp(0, mp(0,0));}
}
pll prev= mp(-1,-1);  	
repup(0,s.length()-1,i){
	repup(0,t.length()-1,j){
		//err(a[i][j])
		if(s[i]==t[j]){
			a[i+1][j+1]= max(a[i+1][j+1], mp(a[i][j].fr+1,mp(i,j)));
		}

		a[i+1][j]=max(a[i+1][j], mp(a[i][j].fr, mp(i,j)));
		a[i][j+1]=max(a[i][j+1], mp(a[i][j].fr, mp(i,j)));
			
	}
	//cout<<'\n';
}
pair<ll, pll>ans= mp(-1,mp(-1,-1));
repup(0,s.length(),i){
	repup(0,t.length(),j){
		ans= max(ans, mp(a[i][j].fr, mp(i,j)));
	}
}


if(ans.fr){
	stack<char>f;
	pll cur= ans.sc;
	while(cur.fr!=0&&cur.sc!=0){
		prev= a[cur.fr][cur.sc].sc;
		if(prev==mp(cur.fr-1, cur.sc-1))f.push(s[cur.fr-1]);
		cur= prev;
	}
	
	while(f.size()){
		cout<<f.top();
		f.pop();
	}
}
else cout<<" ";
}

Measured memory_bytes: 211840
N, A, B = map(int, input().split())

ans = list(range(A))
m = 0
rest = N - A
B -= 1
if rest < B:
  print(-1)
  exit()
if rest / A > B:
  print(-1)
  exit()

while rest > B:
  s = min(A, rest - B + 1)
  ans += list(range(m - s, m))
  m -= s
  rest -= s
  B -= 1

ans += list(range(m - B, m))[::-1]
m -= B

print(" ".join([str(x - m + 1) for x in ans]))

Measured memory_bytes: 37452
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}
const int mod = 1e9 + 7;
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	int N = getint();
	int A[200000];
	ll kei = 0;
	__int128 kei2 = 0;
	rep(i, N) {
		kei += (A[i] = getint());
		kei2 += (ll)A[i] * A[i];
	}
	kei %= mod;
	kei = kei * kei % mod;

	int kari = kei2 % mod;
	kei = (kei - kari + mod) % mod;

	kei = kei * (mod / 2 + 1) % mod;

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


	Would you please return 0;
}

Measured memory_bytes: 1828
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 9 * 1e18;
const ll MOD = 1e9 + 7;

const string YES = "Yes";
const string NO = "No";

bool isYes(ll h, ll w, vl &cnts) {
  if (cnts[4] < (w / 2) * (h / 2)) {
    return false;
  }

  cnts[2] += (cnts[4] - (w / 2) * (h / 2)) * 2;

  if (h % 2 == 1) {
    if (cnts[2] < w / 2) {
      return false;
    }
    cnts[2] -= w / 2;
  }

  if (w % 2 == 1) {
    if (cnts[2] < h / 2) {
      return false;
    }
    cnts[2] -= h / 2;
  }

  return true;
}

int main() {
  ll H, W;
  cin >> H;
  cin >> W;

  map<char, ll> charCnts;
  rep(i, 0, H) {
    string str;
    cin >> str;
    rep(j, 0, W) { charCnts[str[j]]++; }
  }

  vl cnts(5);
  for (auto iter = charCnts.begin(); iter != charCnts.end(); iter++) {
    ll tmp = iter->second;
    cnts[4] += tmp / 4;
    tmp %= 4;

    cnts[2] += tmp / 2;
    tmp %= 2;

    cnts[1] += tmp;
  }

  if (isYes(H, W, cnts)) {
    print(YES);
  } else {
    print(NO);
  }
  return 0;
}


Measured memory_bytes: 256
class Array
    def quick_sort
    return self if self.length <= 1
    pivot = pop
    left, right = partition { |e| e < pivot }
    push pivot
    left.quick_sort + [pivot] + right.quick_sort
  end
end

n, k = gets.chomp.split(' ').map(&:to_i)
sticks = gets.chomp.split(' ').map(&:to_i)
total = 0

sticks.quick_sort.reverse[0..(k-1)].each do |stick|
  total += stick
end
puts total

Measured memory_bytes: 1788
#include <stdio.h>

typedef struct{
    int son[2];
    int par;
    int sib;
    int deg;
    int dep;
    int hei;
} Tree;
Tree t[25];

int hei(int u)
{
  int h1 = 0, h2 = 0;

  if(t[u].son[0] != -1) h1 = hei(t[u].son[0])+1;
  if(t[u].son[1] != -1) h2 = hei(t[u].son[1])+1;

  if(h1 >= h2) return t[u].hei = h1;
  if(h2 > h1)return t[u].hei = h2;
}

int main()
{
    int i,n,id,j,max,root;

    scanf("%d",&n);
    for ( i = 0; i < n; i++)
    {
        t[i].par=-1;
        t[i].sib=-1;
        t[i].deg=0;
        t[i].dep=0;
    }
    
    for ( i = 0; i < n; i++)
    {
        scanf("%d",&id);
        scanf("%d%d",&t[id].son[0],&t[id].son[1]);
        if (t[id].son[0]==-1&&t[id].son[1]==-1)
        {
            t[id].deg=0;
        }
        else if (t[id].son[0]!=-1&&t[id].son[1]!=-1)
        {
            t[id].deg=2;
            t[t[id].son[0]].sib=t[id].son[1];
            t[t[id].son[1]].sib=t[id].son[0];
            t[t[id].son[0]].par=id;
            t[t[id].son[1]].par=id;
        }
        else
        {
            t[id].deg=1;
            if(t[id].son[0]!=-1){
            t[t[id].son[0]].sib=t[id].son[1];
            t[t[id].son[0]].par=id;
            }
            else
            {
            t[t[id].son[1]].sib=t[id].son[0];
            t[t[id].son[1]].par=id;
            }
        }
    }

    for ( i = 0; i < n; i++)
    {
        for ( j = t[i].par; j !=-1; j=t[j].par)
        {
            t[i].dep++;
        }
        if (t[i].dep==-1) root=i;
        hei(i);
    }


    for ( i = 0; i < n; i++)
    {
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, " ,i,t[i].par,t[i].sib,t[i].deg,t[i].dep,t[i].hei);
        if (t[i].deg==0)
        {
            if (t[i].dep==0)
            {
                printf("root\n");
            }
            else
            printf("leaf\n");
        }
        else
        {
            if (t[i].dep==0)
            {
                printf("root\n");
            }
            else
            {
                printf("internal node\n");
            }

        }
    }
   return 0;
}


Measured memory_bytes: 2052
N, M = map(int, input().split())
list1 = []
for i in range(M):
  Input = input().split()
  k = int(Input[0])
  list1.append([])
  for j in range(k):
    list1[i].append(int(Input[j + 1]))
p = list(map(int, input().split()))
sum = 0
sumsum = 0
Bool = True
for l in range(2 ** N):
  onoff = format(l, 'b')
  onoff = onoff.zfill(N)
  for m in range(M):
    for n in range(len(list1[m])):
      sum += int(onoff[list1[m][n] - 1])
    if (not sum % 2 == p[m]):
      Bool = False
    sum = 0
  if Bool:
    sumsum +=1
  Bool = True
print(sumsum)

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

int main() {
  int A,B;
  string S;
  cin>>A>>B>>S;
  if(S.size()!=A+B+1){
    cout<<"No"<< endl;
    return 0;
  }
  for(int i=0;i<S.size();i++){
    if(i==A){
      if(S.at(i)!='-'){
        cout<<"No"<< endl;
        return 0;
      }
      continue ; 
    }
    if(S.at(i)=='-'){
      cout<<"No"<< endl;
      return 0;
    }
  }
  cout<<"Yes"<< endl;
  
        
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 2000018
using namespace std;
struct solve {
	int s;
	bool c;
}M[N];
int n,h,ans;
bool cmp(solve x,solve y) {
	return x.s > y.s;
}
int main() 
{
	scanf("%d%d",&n,&h);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&M[i].s);
		M[i].c = true;
		scanf("%d",&M[i+n].s);
	}
	sort(M+1,M+1+2*n,cmp);
	for(int i=1;i<=2*n;i++)
	{
		if(!M[i].c) ans++,h-=M[i].s;
		else {
			ans += h/M[i].s;
			if(h%M[i].s) ans++;
			h = -1;
		}
		if(h <= 0) break;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#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; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int MOD = 998244353;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y, int md = MOD){x += y; if(x >= md) x -= md;}
void sub_self(int &x, int y, int md = MOD){x -= y; if(x < 0) x += md;}
void mul_self(int &x, int y, int md = MOD){x = x * 1LL * y % md;}
inline int mul(int x, int y, int md = MOD){return x * 1LL * y % md;}
inline int add(int x, int y, int md = MOD){x += y; if(x >= md) x -= md; return x;}
inline int sub(int x, int y, int md = MOD){x -= y; if(x < 0) x += md; return x;}

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

vector<int> read(int n, int k){
	vector<int> vec(n);
	for(int i = 0; i < k; ++i) cin >> vec[i];
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	for(int i = k; i < n; ++i)
		vec[i] = (a * 1ll * vec[i - 2] + b * 1ll * vec[i - 1] + c) % d;
	return vec;
}

vector<int> g[MX], vis(MX);

void dfs(int x, int par = -1){
	vis[x] = true;
	for(auto &y : g[x]){
		if(y == par) continue;
		if(!vis[y])
			dfs(y, x);
	}
}

void solve(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; ++i){
		int x, y;
		cin >> x >> y;
		--x, --y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int comp = 0;
	for(int i = 0; i < n; ++i){
		if(!vis[i]){
			dfs(i);
			comp++;
		}
	}
	cout << comp - 1 << "\n";
	return;
}

int main(){

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

	// freopen("input.in", "r", stdin);
	// freopen("output.out", "w", stdout);

	int t;
	t = 1;
	// cin >> t;
	// pre();
	for(int i = 1; i <= t; ++i){
		// cout << "Case #" << i << ": ";
		solve();
		// cout << '\n';
		// cout << endl;
	}

	return 0;
}

Measured memory_bytes: 10064
<?php

fscanf(STDIN, "%d", $in_k);
fscanf(STDIN, "%d %d", $in_a, $in_b);
$ans = "NG";
//var_dump($in_k);
//var_dump($in_a);
//var_dump($in_b);

for($i = $in_a; $i <= $in_b; $i++){
    if($i % $in_k == 0){
        $ans = "OK";
        break;
    }
}
echo "$ans\n";


Measured memory_bytes: 16164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
inline bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<int> s(m);
	vector<int> c(m);
	rep(i,m) cin >> s.at(i) >> c.at(i);
	rep(i,1000){
		string t = to_string(i);
		if(t.size() != n) continue;
		bool ok = true;
		rep(j,m){
			if(t[s[j] - 1] != c[j] + '0') ok = false;
		}
		if(ok){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(c<=b)
	{
		printf("delicious");
	}
	else
	{
	if(c-b>a)
		{printf("dangerous");}
		
		else
		{
		{printf("safe");}	
		}	
	}
}

Measured memory_bytes: 128
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]
import sys

K = Int()
A,B = Ints()

for i in range(A,B+1):
    if i%K==0:
        print('OK')
        sys.exit()
print('NG')

Measured memory_bytes: 61828
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N,Q;
	cin >> N >> Q;
	map<ll,V<ll>> events;
	rep(i,N){
		ll s,t,x;
		cin >> s >> t >> x;
		events[s-x].pb(x);
		events[t-x].pb(-x);
	}
	auto it = events.begin();
	multiset<ll> st;
	rep(_,Q){
		ll d;
		cin >> d;
		while(it != events.end() && it->fs <= d){
			for(auto e : it->sc){
				if(e > 0) st.insert(e);
				else{
					auto hoge = st.lower_bound(-e);
					st.erase(hoge);
				}
			}
			it++;
		}
		if(st.empty()) cout << -1 << endl;
		else cout << *st.begin() << endl;
	}
}


Measured memory_bytes: 54400
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	ll a,b,k;
	cin>>a>>b>>k;
	if(a>=k){
		cout<<a-k<<" "<<b;
	}
	else{
		cout<<0<<" "<<max(a+b-k,0ll);
	}
	re 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
using namespace std;
set<pair<int,int>>sp[20],st,yo ;
pair<int,int>ar[100009] ;
int n,m,k,ans[12] ;
map<pair<int,int>,int>mp ;
bool check(int x , int y , int ct)
{
    if(x+2>n || y+2>m) return 0 ;
    int cc=0 ;
    for(int i = x ; i <= x+2 ; i++)
    {
        for(int j = y ; j <= y+2 ; j++)
        {
            if(st.find({i,j})!=st.end()) cc++ ;
        }
    }
    if(cc) sp[cc].insert({x,y}) ;
    if(cc) yo.insert({x,y}) ;
    return cc==ct ;
}
int32_t main()
{
    ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
    cin>>n>>m>>k ;
    for(int i = 0 ; i < k ; i++)
    {
        cin>>ar[i].F>>ar[i].S ;
        st.insert({ar[i].F,ar[i].S}) ;
    }
    //sort(ar,ar+k) ;
    for(int i = 0 ; i < k ; i++)
    {
        int x=ar[i].F,y=ar[i].S ;
        int p,q,r,s ;
        p=x ; q=y ;
        if(p-1>=1) p-- ; if(p-1>=1)p-- ;
        if(q-1>=1) q-- ; if(q-1>=1)q-- ;
        for(int i1 = p ; i1 <= x ; i1++)
        {
            for(int j1 = q ; j1 <= y ; j1++)
            {
                check(i1,j1,0);
            }
        }
    }
    for(int i = 1 ; i < 10 ; i++) ans[i]=sp[i].size() ;
    int tot=(n*m)-(2*m)-(2*n)+4 ;
    ans[0]=tot-yo.size() ;
    for(int i = 0 ; i < 10 ; i++) cout<<ans[i]<<endl ;
}


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

#define debug(...) fprintf(stderr,__VA_ARGS__)
#define PB push_back
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long LL;
const int N=7000 +10;

string f[N];
char s[N];
int  tk[N], od[N], a[N], b[N],n;
void DP();

int main(){
	#ifdef che 
	freopen("input.txt","rt",stdin);
	#endif
	scanf("%d%s", &n, s);
	int an=0, bn= 0;
	for (int i=0; i<2*n; ++i)
		if ( s[i]=='a' ){
			od[i] = an;a[an++] = i;
		}else{
			od[i] = bn;b[bn++] = i;
		}
	#ifdef che
	for (int i=0; i<2*n; ++i) debug("od[%d] = %d\n", i, od[i]);
	for (int i=0; i<n; ++i) debug("a[%d]= %d\tb[%d]=%d\n", i, a[i], i, b[i]);
	#endif
	DP();
	return 0;
}

void DP(){
	for  (int i=0; i<2*n; ++i )  f[i]="";
	for (int i=2*n-1; ~i; --i){
		f[i] = f[i+1];
		if ( s[i]=='b'){
			string t="";
			for (int j=0; j<=n; ++j) tk[j] = false;
			int ri=  a[od[i]];
			for (int j=i;j<=ri; ++j){
				if ( s[j]=='b') tk[ od[j]]= true, ri= a[od[j]];
				if ( tk[od[j]]) t+=s[j];
			}
			if ( t.size()) f[i] = max(f[i], t+f[ri+1]);
		}else
			if ( a[od[i]] < b[od[i]]) f[i] = max("ab"+f[b[od[i]]+1], f[i]);
	}
	cout<<f[0]<<endl;
}


Measured memory_bytes: 14720
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int *ary = new int[N];
    for (int i = 0; i < N; i++)
    {
        cin >> ary[i];
    }

    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        sum += ary[i];
    }

    int x = (int)round(sum / (0. + N));
    //cout << x << endl;
    int cost = 0;
    for (int i = 0; i < N; i++)
    {
        int a = ary[i] - x;
        cost += a * a;
    }
    cout << cost << endl;
    delete[] ary;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <set>
#include <list>
#include <deque>
#include <map>
#include <queue>
#include <fstream>
#include <cassert>
#include <cmath>
#include <sstream>
#include <time.h>
#include <complex>
#include <iomanip>

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<double,double> dd;
typedef pair<char,char> cc;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l4;
const double eps = 0.005;
const int maxn = 300010;
const ll mod = 1e9+7;

int n,m,q;
vi g[maxn];
int V[maxn],d[maxn],c[maxn];
int vis[maxn];
int ans[maxn];

void dfs(int cur, int dep, int col) {
    if (vis[cur] >= dep) {
        return;
    }
    if (ans[cur] == 0) {
        ans[cur] = col;
    }
    vis[cur] = dep;
    for (int i : g[cur]) {
        dfs(i,dep-1,col);
    }
}

int main() {
    scanf("%d%d",&n,&m);
    int u,v;
    for (int i = 0; i < m; i++) {
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    scanf("%d",&q);
    for (int i = 0; i < q; i++) {
        scanf("%d%d%d",&V[i],&d[i],&c[i]);
    }
    for (int i = q-1; i >= 0; i--) {
        dfs(V[i],d[i]+1,c[i]);
    }
    for (int i = 1; i <= n; i++) {
        printf("%d\n",ans[i]);
    }
}





Measured memory_bytes: 15736
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		long sum = 0;
		long count = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'W') {
				count++;
				sum += i;
			}
		}
		System.out.println(sum - count * (count - 1) / 2);
	}
}


Measured memory_bytes: 27716
N = int(input())
count = 0
nums = [int(x) for x in input().split()]
loop = True
while loop:
  if not all ([n % 2 == 0 for n in nums]):
    loop = False
    break
    
  for i, n in enumerate(nums):
    nums[i] = n//2
  count += 1
print(count)


Measured memory_bytes: 2940