akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

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;

int main() {
	int n, m, t;
	cin >> n >> m >> t;
	VI a(n); rep(i, n)cin >> a[i];

	int ans = 0;
	rep(i, n) {
		if (i == 0)ans += max(0, a[i] - m);
		else ans += max(0, a[i] - a[i - 1] - m * 2);
		if (i == n - 1)ans += max(0, t - a[i] - m);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define TEST cout << "test" << endl;
using namespace std;

int main(void){
	int n;
	cin >> n;
	vector<int> arr(n);
	for(int i = 0; i != n; i++)cin >> arr[i];
	sort(arr.begin(),arr.end());

	if(n == 3){
		if((arr[0] ^ arr[1]) == arr[2] || (arr[1] ^ arr[2]) == arr[0] || (arr[2] ^ arr[0]) == arr[1])cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else{
		int count = 1;
		vector<int> ococo(n);
		for(int i = 1; i != n; i++)if(arr[i - 1] != arr[i]){
			ococo[count - 1] = i - 1;
			count++;
		}
		//for(int i = 0; i != n; i++)cout << ococo[i] << endl;

		if(count == 1){
			if(arr[0] == 0)cout << "Yes" << endl;
			else cout << "No" << endl;
		}
		else if(count != 3 && count != 2)cout << "No" << endl;
		else if(count == 2){
			if( ((n - 1) - ococo[0]) / 2 == ococo[0] + 1 && arr[0] == 0)cout << "Yes" << endl;
			else cout << "No" << endl;
		}
		else if(count == 3){
			if((n - 1) - ococo[1] == ococo[1] - ococo[0] && ococo[1] - ococo[0] == ococo[0] + 1){
				//TEST
				if((arr[0] ^ arr[ococo[0] + 1]) == arr[n - 1])cout << "Yes" << endl;
				else cout << "No" << endl;
			}
			else cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
struct node{
	int x,y;
}a[100005];
bool cmp(node x,node y){
	return x.x<y.x;
	return x.y>y.y;
}
int main()
{
	int n,m,i,x,y,maxv=0,minv=100005,sum=1;
	cin>>n>>m;
	for(i=1;i<=m;i++){
		cin>>x>>y;
		a[i].x=x;
		a[i].y=y;
	}
	
	sort(a+1,a+m+1,cmp);
	for(i=1;i<=m;i++){
		maxv=max(maxv,a[i].x);
		minv=min(minv,a[i].y);
		
		if(maxv>=minv){
			sum++;
			maxv=a[i].x;
			minv=a[i].y;
		}
	}
	cout<<sum;
	return 0;
} 

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 5001
#define int ll


string S;
int num = 0;
int32_t main(){
	fast;
	
	cin>>S;
	
	aFOR(i,S) num += i - '0';
	
	cout<<((num % 9 == 0) ? "Yes" : "No");
	
}


Measured memory_bytes: 3732
import java.util.*;

final class Block {
	int value;
	int count;

	Block(int value, int count) {
		this.value = value;
		this.count = count;
	}
}

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = Integer.parseInt(sc.next());
		long K = Long.parseLong(sc.next());
		Block[] blocks = new Block[N];
		for (int i = 0; i < N; i++) {
			blocks[i] = new Block(Integer.parseInt(sc.next()), Integer.parseInt(sc.next()));
		}
		Arrays.sort(blocks, Comparator.comparingInt(b -> b.value));
		long sum = 0;
		for (Block block : blocks) {
			sum += block.count;
			if (sum >= K) {
				System.out.println(block.value);
				return;
			}
		}
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 63704
sx, sy, tx, ty = map(int, input().split())
x, y = tx - sx, ty - sy
print("U"*y + "R"*x + "D"*y + "L"*x +
      "L" + "U"*(y+1) + "R"*(x+1) + "D" + "R" + "D" * (y+1) + "L" * (x+1) + "U")

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

using namespace std;

int main(void) {
  int n, m;
  cin >> n >> m;

  vector<int> a(m), b(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
  }
  sort(a.begin(), a.end(), greater<int>());

  int ans = 0;
  for (int i = 0; i < m - 1; i++) {
    ans += max(0, n - a[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int n,a[15][15],d;
int main() {
	scanf("%d%d",&n,&d);
	for(int i=1; i<=n; i++)for(int j=1; j<=d; j++)scanf("%d",&a[i][j]);
	int ans=0;
	for(int i=1; i<=n; i++) {
		for(int j=i+1; j<=n; j++) {
			int now=0;
			for(int k=1; k<=d; k++)now+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			int l=sqrt(now);
			if(l*l==now)ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
from collections import deque

def main():
  h,w=map(int,input().split())
  mp=[input() for _ in range(h)]
  dist=[-1]*(h*w)
  q=deque()
  
  for i in range(h):
    for j in range(w):
      if mp[i][j]=="#":
        q.append(i*w+j)
        dist[i*w+j]=0
      else:
        dist[i*w+j]=-1
  #print(q)
 
  while q:
    c=q.popleft()
    #print(c,q)
    x=c//w
    y=c%w
    for i,j in ((1,0),(0,1),(-1,0),(0,-1)):
      xx,yy=x+i,y+j
      if (0<=xx<h and 0<=yy<w and dist[xx*w+yy]==-1):
        dist[xx*w+yy]=dist[x*w+y]+1
        q.append(xx*w+yy)
      
  print(max(dist))
  return

main()


Measured memory_bytes: 78940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int get_num(char c) { return int(c) - 48; }

int main()
{
    int N, K;
    string S;
    cin >> N >> K >> S;
    vector<int> nums;

    int c = K * 2 + 1;
    int prev = 1; // これにより、0 スタートの場合は "1 が 0 個" で始められる
    int cnt = 0;
    for(int i = 0; i < S.length(); i++) {
        if(get_num(S[i]) == prev) {
            cnt++;
        } else {
            nums.push_back(cnt);
            prev = get_num(S[i]);
            cnt = 1;
        }
    }
    nums.push_back(cnt);
    if(nums.size() % 2 == 0) {
        nums.push_back(0);
    }

    IFD {
        for(int i = 0; i < nums.size(); i++) {
            cout << nums[i];
        }
        cout << endl;
    }

    vector<int> sum(nums.size() + 1);
    for(int i = 0; i < nums.size(); i++) {
        sum[i + 1] = sum[i] + nums[i];
    }

    int ans = 0;
    for(int i = 0; i < nums.size(); i += 2) {
        ans = max(ans, sum[min(i + c, (int)nums.size())] - sum[i]);
    }

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


Measured memory_bytes: 1272
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int r = saori.saori_hayami();
		if(r < 1200){
			System.out.println("ABC");
		} else if(r < 2800){
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

class UnionFind
{
    vector<int> par;
    int groupCount;

public:
    // UnionFind uf(n)でn要素のUF木uf
    UnionFind(int n = 0)
    {
        init(n);
    }

    // n要素で初期化
    void init(int n = 0)
    {
        par.resize(n);
        fill(par.begin(), par.end(), -1);
        groupCount = n;
        return;
    }

    // xが属する集合の根を求める
    int root(int x)
    {
        if (par[x] < 0)
        {
            return x;
        }
        return par[x] = root(par[x]);
    }

    // xとyが同じ集合に属するか調べる
    bool same(int x, int y)
    {
        return root(x) == root(y);
    }

    // xが属する集合の大きさを調べる
    int size(int x)
    {
        return -par[root(x)];
    }

    // xが属する集合とyが属する集合を繋ぐ
    // 既に繋がっていたらfalseが返る
    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
        {
            return false;
        }
        if (par[y] < par[x])
        {
            swap(x, y);
        }
        par[x] += par[y];
        par[y] = x;
        --groupCount;
        return true;
    }

    // UF内にある集合の個数を調べる
    int size(void)
    {
        return groupCount;
    }
};

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

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

    UnionFind uf(n);
    for(int i = 0 ; i < m ; ++i){
        int x, y, z;
        cin >> x >> y >> z;
        uf.unite(x - 1, y - 1);
    }

    cout << uf.size() << endl;

    return 0;
}

Measured memory_bytes: 640
a, b, c, x, y = list(map(int, input().split()))

def solve():
    ans = float('inf')

    ans = min(a*x+b*y, ans)
    if (x == y):
        ans = min(c*x*2, ans)
    elif (x < y):
        ans = min(c*x*2+b*(y-x), ans)
        ans = min(c*y*2, ans)
    else:
        ans = min(c*y*2+a*(x-y), ans)
        ans = min(c*x*2, ans)
    print(ans)



if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC129_A_Airplane
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] time = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
			int[] sum = new int[3];
			sum[0] = time[0] + time[1];
			sum[1] = time[1] + time[2];
			sum[2] = time[2] + time[0];

			Console.WriteLine(sum.Min());
		}
	}
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a[100001];
  bool b[100001] = {};
  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  int crr = 1, cnt = 0;
  while(true){
    if(crr == 2){
      cout << cnt << endl;
      return 0;
    }
    if(b[crr]) break;
    b[crr] = true;
    crr = a[crr];
    cnt++;
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
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; }
const long long INF = 1LL << 60;
using Graph=vector<vector<int>>;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  lint x,c,r;
  c=1;
  cin>>x;
  r=x;
  while(r%360!=0){
    r+=x;
    c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> x(N);
    rep(i, N) cin >> x[i];
    int L;
    cin >> L;
    
    vector<vector<int>> NEXT(20, vector<int>(N));
    rep(i, N) NEXT[0][i] = upper_bound(x.begin(), x.end(), x[i] + L) - 1 - x.begin();
    for (int i = 1; i < 20; ++i) rep(j, N) NEXT[i][j] = NEXT[i - 1][NEXT[i - 1][j]];
    
    int Q;
    cin >> Q;
    rep(q, Q) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        if (a > b) swap(a, b);
        int left = 0;
        int right = N;
        while (right - left > 1) {
            int mid = (right + left) / 2;
            int now = a;
            rep(i, 20) {
                if (mid & (1 << i)) now = NEXT[i][now];
            }
            if (now >= b) right = mid;
            else left = mid;
        }
        cout << right << "\n";
    }
    return 0;
}


Measured memory_bytes: 9080
#include<iostream>
#include<vector>
//#include<stdio.h>
//#define FOR(i,k,n) for((i)=(k);(i)<(n);(i)++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define pb push_back
//#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
	int n,q,s,temp,i,j;
	int count=0;
	vector<int> S;
	cin>>n;
	REP(i,n){
		cin>>s;
		//S.push_back(s);
		S.pb(s);
	}
	
	//sort(S.begin(),S.end());
	//sort(all(S));

	//REP(i,n){
		//FOR(j,i+1,n){
			//if(S[i]==S[j])S[i]=-1;
			//else if(S[i]<S[j])break;
		//}
	//}

	cin>>q;
	REP(i,q){
		cin>>temp;
		REP(j,n){
			if(temp==S[j]){
				count++;
				break;}
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;


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

	int N, K; cin >> N >> K;
	string S; cin >> S;

	int in = 1;
	while (in < N && S[in] == S[in - 1]) in++;
	for (int i = in; i < N; i++) {
		if (S[i] != S[i - 1]) {
			K--;
			while (i < N && S[i - 1] != S[i]) {
				S[i] = S[i - 1];
				i++;
			}
		}
		if (K == 0)break;
	}
	int sum = 0;
	for (int i = 1; i < N; i++) {
		while (S[i] == S[i - 1]) {
			sum++; i++;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 512
def main():
    s = input()
    n = len(s)
    modlis = [0 for i in range(2019)]
    modlis[0]=1
    t = 0
    m = 1
    for i in range(n):
        t = (t+int(s[n-1-i])*m)%2019
        m = m*10%2019
        modlis[t]+=1

    ans = 0
    for i in range(2019):
        ans += (modlis[i]*(modlis[i]-1))//2
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9188
#include <iostream>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)




int main(){
  int N,count=1;
  cin >>N;
  char S[N];
  rep(i,N)
    cin >>S[i];
  rep(i,N-1){
    if(S[i]!=S[i+1])
      count++;
  }

  cout <<count<<endl;  
  return 0;
}


Measured memory_bytes: 384
//21171_somesh || asomesh999

#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define io ios::sync_with_stdio(false);cin.tie(NULL);
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;
long int mod=1000000007;

int main()
{
	io
	#ifdef CODE
		clock_t startTime = clock();
		freopen("input.txt","r",stdin);
	#endif

	ll n;
	cin >> n;
	ll sum = 0;
	fr(i, 1, n + 1) {
		if (!(i % 3 == 0 || i % 5 == 0)) sum += i;
	}
	cout << sum;

	#ifdef CODE
		cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
	#endif
	return 0;
}

Measured memory_bytes: 3608
<?php
$n = intval(fgets(STDIN));
for($i = 0; $i < $n; $i++){
    $map[] = intval(fgets(STDIN));
}
$current = 0;
$count = 0;
while(true){
    $prev = $current;
    if($map[$current] == -1)break;
    $current = $map[$current] - 1;
    $map[$prev] = -1;
    $count++;
    if($current == 1){
        echo $count;
        exit;
    }
}
echo -1;

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

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

int N;
vector<int> A;

void insertionSort(){
	for (int i = 1;i < N;i++){
		int v = A[i];
		int j = i-1;
		while(j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		for (int k = 0;k < N;k++){
			cout << A[k] << (k==N-1?"\n":" ");
		}
	}
	return;
}

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

	cin >> N;

	A = vector<int>(N);
	for (int i = 0;i < N;i++){
		cin >> A[i];
		cout << A[i] << (i==N-1?"\n":" ");
	}

	insertionSort();

	return 0;

}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N;
    cin>>N;
    
    VEC2i(ll,stf,N,26,0);
    REP(i,N){
        string s;
        cin>>s;
        REP(j,s.length()){
            stf[i][ll(s[j])-97]++;
        }
    }
    REP(i,26){
        ll m=999;
        REP(j,N){
            m=min(stf[j][i],m);
        }
        REP(j,m){
            cout<<char('a'+i);
        }
    }
    
    
    
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define repi(i,n) for(int i=0; i<(n); i++)

int main() {
  int X;
  cin >> X;
  if(X>=1800) cout << 1 << endl;
  else if(X>=1600) cout << 2 << endl;
  else if(X>=1400) cout << 3 << endl;
  else if(X>=1200) cout << 4 << endl;
  else if(X>=1000) cout << 5 << endl;
  else if(X>=800) cout << 6 << endl;
  else if(X>=600) cout << 7 << endl;
  else cout << 8 << endl;
  
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#define pii pair<int, int>
#define fst first
#define snd second
#define pub push_back
#define vi vector<int>
#define ll long long

using namespace std;

int s[200001], e[200001] = {};

int main()
{
	ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> s[i] >> e[i];
	}
	sort(s, s + n);
	sort(e, e + n);
	int l = s[n / 2] + ((n % 2 == 0) ? s[n / 2 - 1] : 0);
	int r = e[n / 2] + ((n % 2 == 0) ? e[n / 2 - 1] : 0);
	cout << r - l + 1 << "\n";
	return 0;
}

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

int main(void){
    int a,b;
    cin >> a >> b;
    if(a == b)cout << "Draw" << endl;
    else if(a > 1 && b > 1){
        if(a > b)cout << "Alice" << endl;
        else cout << "Bob" << endl;
    } else {
        if(a == 1)cout << "Alice" << endl;
        else cout << "Bob" << endl;
    }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int AB = sc.nextInt();
		int BC = sc.nextInt();
		int CA = sc.nextInt();

System.out.println(AB*BC/2);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int m = 1 << 30;
    while (count(a.begin(), a.end(), 0) < n - 1) {
        int idx;
        for (int i = 0; i < n; ++i) {
            if (!a[i]) continue;
            if (m > a[i]) {
                m = a[i];
                idx = i;
            }
        }
        for (int i = 0; i < n; ++i) {
            if (!a[i]) continue;
            if (i == idx) continue;
            a[i] %= m;
        }
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(1, 0); }
	V<V<pin>> qab(2);
	for (pin x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2)); }
	}
	V<vel> c(2, vel(2));
	rep(i, 2) {
		for (pin x : qab[i]) {
			int qc = (2 * x.first + x.second) % 3;
			if ((qc + 1) % 2) { c[i][0] ^= 1; }
			if (qc) { c[i][1] ^= 1; }
		}
	}
	rep(i, 2) {
		if (!c[1 - i][0] && !c[1 - i][1]) {
			pin ans = solve(qab[i], ex - 1);
			ans.first *= 2; ans.second *= 2; ans.second += i;
			return ans;
		}
	}
	for (pin& v : ab) { v.first++; }
	pin ans = solve(ab, ex); ans.first--;
	return ans;
}
signed main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long inf = 2e17;
	int n; cin >> n;
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; cin >> a >> b;
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 59);
	cout << ret.first - inf;
}

Measured memory_bytes: 103656
#include <iostream>
 
using namespace std;
 
int main (){
    int n,p,q;
    int i,j;
    char t;
    int cards[4][13]={0};
 
    cin>>n;
    for (i=1;i<=n;i++){
 
        cin>>t>>p;
        if (t=='S')q=0;
        else if (t=='H')q=1;
        else if (t=='C')q=2;
        else if (t=='D')q=3;
        p=p-1;
        cards[q][p]=1;
 
    }
     
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
 
            if (cards[i][j]==0){
                if (i==0)t='S';
                else if (i==1)t='H';
                else if (i==2)t='C';
                else if (i==3)t='D';
                cout<<t<<" "<<j+1<<endl;
            }
        }
    }
 
}

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

int main() {

    int a, b, c, k; cin >> a >> b >> c >> k;
    int ans;
    if (k <= a) ans = k;
    else if (k <= a + b) ans = a;
    else ans = a - (k - a - b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <iomanip>
#include <numeric>
#include <bitset>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef long long ll;

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

  int n; cin >> n;
  vector<int> a(n);

  rep(i, n) { cin >> a[i]; }

  int ans = 0, cnt = 1;
  rep(i, n) {
    if (a[i]== cnt) {
      ans++; cnt++;
    }
  }

  cout << (ans == 0 ? -1: n-ans) << endl;

  return 0;
}


Measured memory_bytes: 1024
n,m,x=list(map(int, input().split()))
ca=[]
for i in range (n):
    ca.append(list(map(int, input().split())))
u=[0]*m
for j in range (m):
    for i in range (n):
        u[j]+=ca[i][j+1]
det=1
for y in range (m):
    if u[y]<x:
        det=0
if det==0:
    print(-1)
else:
    cost=1300000
    for z in range(2**n):
        bi=[0]*n
        for p in range(n):
            if z>=2**(n-1-p):
                bi[p]=1
                z=z-2**(n-1-p)
        v=[0]*m
        for i in range(n):
            if bi[i]==1:
                for j in range(m): 
                    v[j]+=ca[i][j+1]
        de=1
        for y in range (m):
            if v[y]<x:
                de=0
        if de==1:
            cc=0
            for q in range (n):
                cc+=ca[q][0]*bi[q]
            if cc<cost:
                cost=cc
    print(cost)



Measured memory_bytes: 9284
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int cmp(const void*p,const void*q){return strcmp(p,q);}
char s[200010][11];

int ans[200010],anscnt,ansmax;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%s",s[i]);
	qsort(s,n,11,cmp);
	
	int cnt=0;
	for(int i=0;i<n;i++){
		cnt++;
		if(strcmp(s[i],s[i+1])){
			if(ansmax<cnt){
				ans[0]=i;
				anscnt=1;
				ansmax=cnt;
			}else if(ansmax==cnt){
				ans[anscnt++]=i;
			}
			cnt=0;
		}
	}
	for(int i=0;i<anscnt;i++)puts(s[ans[i]]);
}

Measured memory_bytes: 4808
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, A, total =0, count = 0;
    long double req,M;
    multiset<int> MS;
    cin >> N >> M;
    for (int i = 0; i<N; ++i){
        cin >> A;
        MS.insert(A);
        total +=A;
    }
    req = (1/(4*M))*total;
    for (int x : MS) if (x>=req) ++count;
    if (count>=M) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<ll> vec(n);
  for (auto &v : vec)
    cin >> v;
  partial_sum(vec.begin(), vec.end(), vec.begin());

  ll ans = 0;
  map<ll, ll> mp;
  mp[0] = 1;
  for (auto &v : vec) {
    auto itr = mp.find(v);
    if (itr != mp.end()) {
      ans += itr->second;
      ++mp[v];
    } else {
      mp[v] = 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 17136
// Problem : B - Distance 
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
#define ss second
#define ff first
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vvi vector<vi>
#define pb push_back
#define vs vector<string>
#define all(x) x.begin(),x.end()
#define mii map<int,int>
#define vd vector<double>
#define deb(x) cout<<#x<<" -> "<<x<<endl
const int inf=0x3f3f3f3f3f3f3f3f;
#define MAXN 1000005

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

void print(vi &v){
    for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
    cout<<endl;
}

// <--------------------Code Begins Here-------------------->



double dis(double a,double b){
	return pow(pow(a,2)+pow(b,2),double(0.5));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--){
        int n;
        double d;
        cin>>n>>d;
        int ans = 0;
        while(n--){
        	double a,b;
        	cin>>a>>b;
        	if(dis(a,b)<=d)ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 4408
// Garg's Code
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define set set <ll>
#define ll long long
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const ll MAX = LLONG_MAX;
const ll MIN = LLONG_MIN;
int main()
{
  fast();
  
  
  ll n,k;
  cin >> n >> k;
  ll arr[n], ans = 0;
  f(i,0,n)
  {
  	cin >> arr[i];
  	if(arr[i] >= k)
  	{
  		ans++;
  	}
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, m, t, k, a[105];
#define ari for( int i = 0 ; i < n ; i++ ) cin >> a[i];
#define ginp for( int i = 0 ; i < m ; i++ ){ int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u);}
#define pb push_back
#define ss second
#define ff first
#define fs first.second
#define fff first.first
#define sss second.second
#define sf second.first
#define mp make_pair
const ll mod = 1e9 + 7;

void add(ll& a, ll b){
	a += b;
	if( a >= mod )
		a -= mod;
	if( a < 0 )
		a += mod;
}

void sub(ll&a , ll b){
	a -= b;
	if( a >= mod )
		a -= mod;
	if( a < 0 )
		a += mod;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    ari;
    vector< ll > dp(k + 1, 0);
    ll maxi = 0;
    dp[0] = 1;
    for(int i = 0 ; i < n ; i++){
    	vector< ll > temp(k + 1, 0);
		for(int j = k ; j >= 0 ; j--){
			if( j + 1 <= j + min(a[i], k - j) ){
				add(temp[j + 1], dp[j]);
				if( a[i] + 1 <= k - j )
					sub(temp[j + min(a[i], k - j) + 1], dp[j]);
			}
		}
		ll prefix_sum = 0;
		for(int j = 0 ; j <= k ; j++){
			add(prefix_sum, temp[j]);
			add(dp[j], prefix_sum);
		}
    }
	cout << dp[k] << endl;
	return(0);
}

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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX / 2 + 2], R[MAX / 2 + 2];

llong merge(int A[], int n, int left, int mid, int right) {
	int i, j, k;
	llong cnt = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	for (i = 0; i < n1; i++)L[i] = A[left + i];
	for (i = 0; i < n2; i++)R[i] = A[mid + i];
	L[n1] = R[n2] = SENTINEL;
	i = j = 0;
	for (k = left; k < right; k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
			cnt += n1 - i;
		}
	}
	return cnt;
}

llong mergeSort(int A[], int n, int left, int right) {
	int mid;
	llong v1, v2, v3;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		v1 = mergeSort(A, n, left, mid);
		v2 = mergeSort(A, n, mid, right);
		v3 = merge(A, n, left, mid, right);
		return v1 + v2 + v3;
	}
	else return 0;
}

int main()
{
	int A[MAX], n, i;

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> A[i];
	}

	llong ans = mergeSort(A, n, 0, n);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4636
import java.util.*;
class Main
{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int x = s.nextInt();int a = s.nextInt();int b = s.nextInt();
		int ans = (x-a);
		int quot = ans/b;
		System.out.println(ans- quot*b);
	}
}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

int main() {
    ios_base::sync_with_stdio(false);
    
    ll n, m, d;
    cin >> n >> m >> d;

    double ans = 0.0;
    if(d == 0) {
        ans = (m - 1) * (n - d) / ((double) n * (double) n);
    }
    else {
        ans = ((m - 1) * 2 * (n - d)) / ((double) n * (double) n);
    }

    cout << fixed << setprecision(10) << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int n, m, r, R[8];
ll dist[8][200], g[200][200], ans = INT32_MAX;
bool used[200], usedR[8];

void dijkstra(int index) {
	for (int i = 0; i < n; i++) {
		dist[index][i] = INT32_MAX;
		used[i] = false;
	}
	dist[index][R[index]-1] = 0;
	//cout << "頂点" << (R[index] - 1) << "の距離は" << dist[index][R[index] - 1] << endl;

	while (true) {
		int v = -1;

		for (int i = 0; i < n; i++) {
			//cout << "v:" << v << " i:" << i << endl;
			if (!used[i] && (v == -1 || dist[index][v] > dist[index][i])) {
				//cout << "vの入れ替え" << endl;
				v = i;
			}
		}

		if (v == -1)break;
		//cout << "頂点" << v << endl;
		used[v] = true;

		for (int i = 0; i < n; i++) {
			dist[index][i] = min(dist[index][i], dist[index][v] + g[v][i]);
		}
		//for (int i = 0; i < n; i++)cout << dist[index][i] << " ";
		//cout << endl;
	}

	/*for (int i = 0; i < n; i++)cout << dist[index][i];
	cout << endl;
	cout << endl;*/
}

ll search(int index) {
	ll res = INT32_MAX;
	usedR[index] = true;

	for (int i = 0; i < r; i++) {
		if (!usedR[i]) {
			//cout << R[index] << "から" << R[i] << "までの距離は" << dist[index][R[i] - 1] << endl;
			res = min(res, search(i) + dist[index][R[i]-1]);
		}
	}
	usedR[index] = false;

	if (res == INT32_MAX)return 0;
	else return res;
}

int main() {
	cin >> n >> m >> r;
	for (int i = 0; i < r; i++) {
		cin >> R[i];
	}

	for (int i = 0; i < 200; i++) {
		for (int j = 0; j < 200; j++)g[i][j] = INT32_MAX;
	}

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		cin >> g[a - 1][b - 1];
		g[b - 1][a - 1] = g[a - 1][b - 1];
	}

	for (int i = 0; i < r; i++) {
		//cout << (i + 1) << "回目" << endl;
		//cout << "start:" << R[i] << endl;
		dijkstra(i);
	}

	//最短経路の表示
	/*cout << endl;
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < n; j++) {
			cout << dist[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;*/

	for (int i = 0; i < r; i++) {
		ll a = search(i);
		ans = min(ans, a);
		//cout << R[i] << "番目からの最小" << a << endl;
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int N = nint();
        int[] A = nints(N+1);
        int[] B = nints(N);
        long ans = 0;
        for (int ib = N-1; ib >= 0; ib--) {
            int b = Math.min(A[ib+1], B[ib]);
            A[ib+1] -= b;
            B[ib]   -= b;
            ans += b;
            if (B[ib] > 0) {
                int b2 = Math.min(A[ib], B[ib]);
                A[ib] -= b2;
                B[ib] -= b2;
                ans += b2;
            }
        }
        so.println(ans);
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if((a+b+c) >= 22) cout << "bust";
  else cout << "win";
}

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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=Int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

template<typename T>
T extgcd(T a,T b,T& x,T& y){
  T d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}

template<typename T>
map<T, Int> factorize(T x){
  map<T, Int> res;
  for(Int i=2;i*i<=x;i++){
    while(x%i==0){
      x/=i;
      res[i]++;
    }
  }
  if(x!=1) res[x]++;
  return res;
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n;
  cin>>n;
  if(n==1) drop(1);

  n*=2;
  auto mp=factorize(n);

  Int m=mp.size();
  // cout<<m<<endl;
  vector<Int> vs;
  for(auto[p,e]:mp){
    vs.emplace_back(1);
    for(Int i=0;i<e;i++) vs.back()*=p;
  }

  Int ans=1e18;
  Int s=1<<m;
  for(Int bit=0;bit<s;bit++){
    Int a=1,b=1;
    for(Int i=0;i<m;i++){
      if((bit>>i)&1) a*=vs[i];
      else b*=vs[i];
    }
    Int x,y;
    extgcd(a,b,x,y);
    x-=b;y-=a;
    for(Int k=0;k<5;k++){
      // if(0<x and y<0) cout<<a<<' '<<b<<' '<<x<<' '<<y<<":"<<a*x<<' '<<b*-y<<newl;
      if(0<x and y<0) chmin(ans,b*-y);
      x+=b;y+=a;
    }
  }
  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 3660
import sys
input = sys.stdin.readline
class UnionFind():
    def __init__(self, n):
        self.n = n+1
        self.parents = [-1] * (n+1)

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m, k = list(map(int, input().split()))
friend = [0]*(n+1)
tree = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    friend[a] += 1
    friend[b] += 1
    tree.union(a, b)

ans = [0]*(n+1)
for i in range(1, n+1):
    ans[i] = tree.size(i) - friend[i] - 1

for i in range(k):
    c, d = map(int, input().split())
    if tree.same(c, d):
        ans[c] -= 1
        ans[d] -= 1


print(" ".join(map(str, ans[1:])))


Measured memory_bytes: 86364
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

// { position, {start, end} }
// [start, end)
vector<pair<int, pair<int, int>>> constructions;

vector<int> ans;

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

    constructions.resize(N);
    for (int i = 0; i < N; i++) {
        int s, t, x;
        cin >> s >> t >> x;
        constructions[i] = make_pair(x, make_pair(s, t));
    }
    sort(constructions.begin(), constructions.end());

    set<int> people;
    map<int, int> start_to_id;
    for (int i = 0; i < Q; i++) {
        int d;
        cin >> d;
        people.insert(d);
        start_to_id[d] = i;
    }

    ans.resize(Q, -1);

    for (int i = 0; i < N; i++) {
        const int x = constructions[i].first;
        const int s = constructions[i].second.first - x;
        const int t = constructions[i].second.second - x;

        auto it = people.lower_bound(s);
        while (it != people.end() && *it < t) {
            ans[start_to_id[*it]] = x;
            it = people.erase(it);
        }
    }

    for (int i = 0; i < Q; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 25176
dif_max = 1-10**9
min = 10**9
n_max = 0
n_max = int(raw_input())
 
price = [0]*n_max
for i in range(0, n_max):
  price[i] = int(raw_input())
for i in range(0, n_max-1):
  if min >= price[i]:
      min = price[i]
  if dif_max <= price[i+1] - min:
      dif_max = price[i+1] - min
print dif_max

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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define PI 3.141592653589793

#define MOD 1000000007L
#define INF 100000000000

string toUpper(const string s) {
	string ns = "";
	for (size_t i = 0; i < s.size(); i++) {
		ns += (char)(s[i] - ('a' - 'A'));
	}
	return ns;
}

signed main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	string s = {s1[0], s2[0], s3[0]};
	cout << (toUpper(s)) << endl;
}


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

using namespace std;
#define ll long long
#define go ios::sync_with_stdio(0)
ll inf = 1e18;
bool zero,over;
int main()
{
    go;
    int n;
    cin>>n;
    ll x;
    cin>>x;
    if(!x)
        zero=1;
    for(int i=0;i<n-1;i++)
    {
        ll y;
        cin>>y;
        if(!y)
            zero=1;
        if(inf/x<y)
            {
                over=1;
                continue;
            }
        if(over)
            continue;
      if(zero)
        continue;
        x*=y;
    }
    if(zero)
        cout<<0;
    else if(over)
        cout<<-1;
    else
    cout<<x;
    return 0;
}


Measured memory_bytes: 3692
from operator import add, mul, sub, or_


class SegmentTree:
    '''
    セグメント木(遅延ではない)
    1-indexd セグメント木
    values : 値の配列
    op : 区間に対する関数
    ie : 初期値
    '''

    def __init__(self, values, op, ie):
        self.values = values
        vlen = len(values)
        self.op = op
        self.size = 2 ** (vlen-1).bit_length()
        self.tree = [ie]*self.size + self.values + [ie]*(self.size-vlen)
        self.ie = ie

        for i in range(self.size-1, 0, -1):
            self.tree[i] = self.op(self.tree[i*2], self.tree[i*2+1])

    def update(self, i, v):
        i += self.size
        self.tree[i] = v
        while i > 0:
            i //= 2
            self.tree[i] = self.op(self.tree[i*2], self.tree[i*2+1])

    def query(self, l, r):
        l += self.size
        r += self.size
        ret = self.ie
        while l < r:
            if l & 1:
                ret = self.op(ret, self.tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.op(ret, self.tree[r])
            l //= 2
            r //= 2
        return ret


M = 10**6
N, K = map(int, input().split())
seg = SegmentTree([0]*M, max, 0)
ans = 0
for i in range(N):
    a = int(input())
    t = seg.query(max(0, a-K), min(M, a+K+1))+1
    seg.update(a, t)
    ans = max(ans, t)
print(ans)


Measured memory_bytes: 140856
#include <iostream>
using namespace std;
 
int gcd(int a, int b) {
return a % b ? gcd(b, a % b) : b;
}
int lcm(int a, int b) {
return a / gcd(a,b) * b;
}
 
int main() {
int a, b;
while(cin >> a >> b) {
cout << gcd(a,b) << " " << lcm(a,b) << endl;
}
}

Measured memory_bytes: 1160