akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include <stack>
#include<set>
#include<cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <string.h>
#include<iterator>
#include <map>
using namespace std;
bool cmp(long long a, long long b){
    return a > b;
}
int gcd(int a, int b) {
    int t;
    while (b != 0) {
        t = b;
        b = a % b;
        a = t;
    }
    return a;
}
long long levels[100500];
void dfs(long long current, long long prev, set<long long>* sets){
    for (auto it:sets[current]){
        if (prev != it){
            levels[it] = levels[current] + 1;
            dfs(it, current, sets);
        }
    }
}

long long st[10], fin[10];
int matr[25][25], saved_matr[5][5], ish_matr[5][5];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    long long t, ch, i, curr, p = 1, x, y, weight, j, k = 0, n, m = 1, ch1, ans = 0;
    long long a, b;
    int fl, fl1, fl2, fl3;
    string s;
//    cin >> t;
    long long f, size_f, size_s, weight1, weight2;
    long long sum, k_min, k_max, s1;
    long long da, db;
//    for (auto test_case = 0; test_case < t; test_case++) {
//    }
    long long c, d;
    cin >> a >> b >> c >> d;
    ch = max(a, b);
    ch1 = max(c, d);
    long long ch3, ch4;
    ch3 = min(a, b);
    ch4 = min(c, d);
    ans = max(max(ch * ch1, ch * ch4), max(max(ch * ch4, ch1 * ch3), ch3 * ch4));
    cout << ans;
    return 0;
}

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

const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

long double a, b, x;

void input() {
    cin >> a >> b >> x;
}

long double f(long double a, long double b, long double x) {
    long double ans;
    if(a * a * b / 2.0 <= x) {
        ans = atan(2 * (a * a * b - x) / (a * a * a));
    } else {
        ans = PI / 2 - atan(2 * x / (a * b * b));
    }
    return ans;
}

void solve() {
    input();
    cout << fixed << setprecision(10) << f(a, b, x) * 180.0 / PI << endl;
    return;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <queue>
#include <functional>
using namespace std;

typedef pair<int,int> pii;

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

vector<pii> gettable(){
	int w, h, x, y;
	scanf("%d%d%d%d", &w, &h, &x, &y);

	vector<int> Ls(1, 0);
	vector<vector<int> > L(h + 2, vector<int>(w + 2, -1));
	for(int i = 1; i <= h; ++i)
	for(int j = 1; j <= w; ++j){
		scanf("%d", &L[i][j]);
		Ls.push_back(L[i][j]);
	}
	Ls.push_back(INF);
	sort(Ls.begin(), Ls.end());
	Ls.erase(unique(Ls.begin(), Ls.end()), Ls.end());
	for(int i = 1; i <= h; ++i)
	for(int j = 1; j <= w; ++j){
		L[i][j] = lower_bound(Ls.begin(), Ls.end(), L[i][j]) - Ls.begin();
	}

	vector<pii> res(Ls.size());
	for(int i = 0; i < Ls.size(); ++i){
		res[i].second = Ls[i];
	}

	priority_queue<pii,vector<pii>,greater<pii> > pq;
	pq.push(pii(L[y][x], y << 16 | x));
	++res[L[y][x]].first;
	L[y][x] = -1;
	while(!pq.empty()){
		int a = pq.top().first;
		y = pq.top().second >> 16 & 0xffff;
		x = pq.top().second & 0xffff;
		pq.pop();

		for(int i = 0; i < 4; ++i){
			int ny = y + dy[i], nx = x + dx[i];
			if(L[ny][nx] >= 0){
				int b = max(a, L[ny][nx]);
				++res[b].first;
				pq.push(pii(b, ny << 16 | nx));
				L[ny][nx] = -1;
			}
		}
	}

	for(int i = 1; i < res.size(); ++i){
		res[i].first += res[i - 1].first;
	}

	return res;
}

int main(){
	int r;
	while(scanf("%d", &r), r){
		vector<pii> v = gettable(), w = gettable();
		int ans = INF;
		for(int i = 0; i < v.size(); ++i){
			pii tmp(r - v[i].first, -INF);
			int k = lower_bound(w.begin(), w.end(), tmp)->second;
			ans = min(ans, v[i].second + k);
		}
		printf("%d\n", ans);
	}
}

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

int n,m,a[100009],b[100009],cnt; bool u[100009],used[100009];

int main() {
	cin>>n>>m;
	for(int i=1;i<=m;i++) cin>>a[i]>>b[i];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++) used[j]=false;
		used[i]=true; bool flag=false;
		for(int j=m;j>=1;j--){
			if(used[a[j]]==true && used[b[j]]==true) {
				flag=true;break;
			}
			if(used[a[j]]==true) used[b[j]]=true;
			if(used[b[j]]==true) used[a[j]]=true;
		}
		if(flag==true) u[i]=true;
	}
	for(int i=1;i<=n;i++){
		if(u[i]==true) continue;
		for(int j=1;j<=n;j++) used[j]=false;
		used[i]=true;
		for(int j=m;j>=1;j--){
			if(used[a[j]]==true) used[b[j]]=true;
			if(used[b[j]]==true) used[a[j]]=true;
		}
		for(int j=1;j<=m;j++){
			if(used[a[j]]==true) used[b[j]]=true;
			if(used[b[j]]==true) used[a[j]]=true;
		}
		for(int j=1;j<=n;j++) {
			if(used[j]==false && u[j]==false) {
				cnt++; //cout<<i<<" "<<j<<endl;
			}
		}
	}
	cout<<cnt/2<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#define N 1000000000
int kou(int ,int);
int main(){
  int x,y;
  scanf("%d %d",&x,&y);
  if(x<1&&x>N&&y<1&&y>N)exit(1);
  printf("%d\n",kou(x,y));
}
int kou(int x,int y){
  int amari;
  if(x>=y){
    while(1){
      amari=x%y;
      if(amari==0)return y;
      x=y;
      y=amari;
    }
  }
  else{
    while(1){
      amari=y%x;
      if(amari==0)return x;
      y=x;
      x=amari;
    }
  }
}



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

int solve(int n, int k, int arr[]){
  int dp[n];
  for(int i = 0; i < n; i++) dp[i] = LLONG_MAX;
  if(n == 1) return 0;
  dp[0] = 0;
  if(n == 2) return abs(arr[1] - arr[0]);
  dp[1] = abs(arr[1] - arr[0]);
  for(int i = 2; i < n; i++){
    for(int j = min(k, i); j > 0; j--){
      dp[i] = min(abs(arr[i] - arr[i-j])+dp[i-j], dp[i]);
    }
  }
  return dp[n-1];
}
 
signed main(){
  int n, k;
  cin >> n >> k;
  int arr[n];
  for(int i = 0; i < n; i++){
    cin >> arr[i];
  }
  cout << solve(n, k, arr) << "\n";
}

Measured memory_bytes: 5160
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define N 3010
#define mo 1000000007ll
ll jc[N*N],ijc[N*N],f[N][N];
int n,k;
ll qp(ll x,ll y){
	ll r=1;
	for(;y;y>>=1,x=x*x%mo)
		if(y&1)r=r*x%mo;
	return r;
}
ll c(ll y,ll x){return jc[y]*ijc[x]%mo*ijc[y-x]%mo;}
signed main(){
	jc[0]=ijc[0]=1;
	for(ll i=1;i<N*N;i++)jc[i]=jc[i-1]*i%mo;
	ijc[N*N-1]=qp(jc[N*N-1],mo-2);
	for(ll i=N*N-2;i;i--)ijc[i]=ijc[i+1]*(i+1ll)%mo;
	cin>>n>>k;
	if(k==1){
		puts("1");
		return 0;
	}
	f[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=i;j++){
			f[i][j]=f[i-1][j];
			if(j)f[i][j]=(f[i][j]+f[i][j-1]*(n-j+1)%mo*c(n*k-i-(j-1)*(k-1)-1,k-2)%mo)%mo;
		}
	cout<<f[n][n];
}

Measured memory_bytes: 188416
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g;
    string stra,strb,strc;
    cin>>stra>>strb>>strc;
    if(stra[stra.length()-1]==strb[0]&&strb[strb.length()-1]==strc[0]) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 3612
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <climits>
#include <bitset>

using namespace std;

const int SIZE = 1 << 17;
int pointer = SIZE;
char buffer[SIZE];

char Advance() {
    if (pointer == SIZE) {
        fread(buffer, 1, SIZE, stdin);
        pointer = 0;
    }
    return buffer[pointer++];
}

int Read() {
    int answer = 0;
    char ch = Advance();
    while (!isdigit(ch))
        ch = Advance();
    while (isdigit(ch)) {
        answer = answer * 10 + ch - '0';
        ch = Advance();
    }
    return answer;
}

const int MAXN = 100000;

vector<pair<int, int> > g[1 + MAXN];
int x = 0, y, z;
long long sum[1 + MAXN], answer[1 + MAXN], edge[1 + MAXN];
int n, weight[1 + MAXN];

void DFS(int node, int father) {
    weight[node] = 1;
    for (auto &son : g[node])
        if (son.first != father) {
            DFS(son.first, node);
            weight[node] += weight[son.first];
            if (weight[son.first] == n - weight[son.first]) {
                x = node;
                y = son.first;
                z = son.second;
            }
            else
                if (weight[son.first] < n - weight[son.first])
                    answer[son.second] = (sum[son.first] - sum[node]) / (n - 2 * weight[son.first]);
                else
                    answer[son.second] = (sum[node] - sum[son.first]) / (2 * weight[son.first] - n);
        }
}

void Finish(int node, int father) {
    sum[node] = 0;
    weight[node] = 1;
    for (auto &son : g[node])
        if (son.first != father) {
            Finish(son.first, node);
            sum[node] += sum[son.first] + 1LL * weight[son.first] * answer[son.second];
            weight[node] += weight[son.first];
        }
}

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        g[a].push_back(make_pair(b, i));
        g[b].push_back(make_pair(a, i));
    }
    for (int i = 1; i <= n; i++)
        scanf("%lld", &sum[i]);
    DFS(1, 0);
    if (x) {
        long long before = sum[x];
        Finish(x, 0);
        answer[z] = (before - sum[x]) / weight[y];
    }
    for (int i = 1; i < n; i++)
        printf("%lld\n", answer[i]);
    return 0;
}


Measured memory_bytes: 12928
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	int l;
	cin >> l;
	int sum = l * n + n * (n - 1) / 2;
	int ans = 1, tmp = INF;
	REP(i, n) {
		if (abs(l + i) < tmp) {
			ans = sum - l - i;
			tmp = abs(l + i);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	private class Node {
		int parent;
		private Node(int x) {
			parent = x;
		}
	}
	
	private class DisjointSet {

		private Node[] p;
		private int[] rank;
		
		public DisjointSet(int size) {
			p = new Node[size];
			rank = new int[size];
			for (int i = 0; i < size; i++) {
				makeSet(i);
			}
		}

		private void makeSet(int x) {
			p[x] = new Node(x);
			rank[x] = 0;
		}
		
		public boolean same(int x, int y) {
			return findSet(x).parent == findSet(y).parent;
		}

		private Node findSet(int x) {
			while (x != p[x].parent) {
				x = p[x].parent;
			}
			return p[x];
		}
		
		public void unite(int x, int y) {
			link(findSet(x).parent, findSet(y).parent);
		}

		private void link(int x, int y) {
			if (rank[x] < rank[y]) {
				p[x].parent = y; 
			} else {
				p[y].parent = x;
				if (rank[x] == rank[y]) {
					rank[y]++;
				}
			}
		}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		DisjointSet ds = new DisjointSet(n);
		int q = Integer.parseInt(st.nextToken());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int c = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int y = Integer.parseInt(st.nextToken());
			if (c == 0) {
				ds.unite(x, y);
			} else {
				System.out.println(ds.same(x, y)?"1":"0");
			}
		}
		reader.close();
	}
}


Measured memory_bytes: 61000
s = input()
n = len(s)
ans = 0
for i in range(2**(n-1)):
        tmp = s[0]
        for j in range(n-1):
            if (i>>j)&1:
                tmp += '+'+s[j+1]
            else:
                tmp += s[j+1]
        ans += eval(tmp)
print(ans)

Measured memory_bytes: 39280
N, M = [int(i) for i in input().split()]
UVm = [[int(i) for i in input().split()] for _ in range(M)]
S, T = [int(i) for i in input().split()]

graphs = [[] for _ in range( 3 * N)]
dists = [-1 for _ in range( 3 * N)]
for uv in UVm:
  u = uv[0] - 1
  v = uv[1] - 1
  graphs[u].append(v + N)
  graphs[u + N].append( v + 2 * N)
  graphs[u + 2 * N].append(v)
  
def dist(s, t, g):
    q = [s]
    dists = [-1]*len(g)
    dists[s] = 0
    while len(q) != 0:
        p = []
        for u in q:
            for v in g[u]:
                if dists[v] != -1:
                    continue
                p.append(v)
                dists[v] = dists[u] + 1
        q = p
    return dists[t]
print(dist(S-1, T-1, graphs)//3)



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

int main(){
    int n;
    cin >> n;
    if(n == 1) cout << 1 << endl;
    else if (1 < n && n < 4) cout << 2 << endl;
    else if (4 <= n && n < 8) cout << 4 << endl;
    else if (8 <= n && n < 16) cout << 8 << endl;
    else if (16 <= n && n < 32) cout << 16 << endl;
    else if (32 <= n && n < 64) cout << 32 << endl;
    else if (64 <= n) cout << 64 << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        long m = 100;
        long count=0;
        
        for(int i=1;;i++){
            if(m>=X){
                break;
            }
            m = m + m /100;
            count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 27088
#include <iostream>
#include <vector>
#include <array>

using namespace std;

#define ll long long
#define ar array

   
int main()
{
   int n;
   cin >> n;
   
   if (n >= 400 && n <= 599)
      cout << 8;
    if (n >= 600 && n <= 799)
      cout << 7;
    if (n >= 800 && n <= 999)
      cout << 6;
    if (n >= 1000 && n <= 1199)
      cout << 5;
    if (n >= 1200 && n <= 1399)
      cout << 4;
    if (n >= 1400 && n <= 1599)
      cout << 3;
    if (n >= 1600 && n <= 1799)
      cout << 2;
    if (n >= 1800 && n <= 1999)
      cout << 1;
   
   return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>

using IV = std::vector<int>;
IV ToFixedIntArray(std::istream& is, int n) {
	IV ret(n);
	auto* dst = ret.data();
	while(n > 0) {
		--n;
		is >> *dst++;
	}
	return ret;
}

void DisableIOSync() {
	std::cin.tie(0);
	std::cout.tie(0);
	std::ios::sync_with_stdio(false);
}
int main() {
	DisableIOSync();
	const auto input = ToFixedIntArray(std::cin, 2);
	const int result = (input[0]-1) * (input[1]-1);
	std::cout << result << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int MOD = 1000000007;
int N;
int a[25][25];
int dp[1<<21];
    
int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) cin >> a[i][j];
    }

    dp[0] = 1;
    for (int S = 1; S < (1<<N); S++) {
        int i = __builtin_popcount(S);
        for (int j = 0; j < N; j++) {
            if (((S>>j) & 1) && a[i-1][j]) {
                dp[S] += dp[S ^ (1<<j)];
                dp[S] %= MOD; 
            }
        }
    }
    cout << dp[(1<<N) - 1] << endl;
}

Measured memory_bytes: 8448
N, X = map(int, input().split())

rayers = [0] * (N+1)
rayers[0] = 1
Ps = [0] * (N+1)
Ps[0] = 1
for i in range(1,N+1):
    rayers[i] = 3 + 2*rayers[i-1] # B{L-1}P{L-1}B
    Ps[i] = 1 + 2*Ps[i-1] # そのレベルのPの数は前のレベルの数*2＋1こ

def solve(N,X):
    if N == 0:
        return 0 if X <= 0 else 1

    if X <= rayers[N-1]+1:
        # 食べる枚数が、Nレベルバーガーの中心より手前の時、その一レベル下のバーガーから底のBを一枚除いて食べるのと同じ
        return solve(N-1, X-1)
    elif X == rayers[N-1]+2:
        # Nレベルバーガーのちょうど真ん中まで食べるとき
        return Ps[N-1] + 1 
    elif X > rayers[N-1]+2:
        # 真ん中より先の方まで食べるとき
        return Ps[N-1] + 1 + solve(N-1, X - rayers[N-1] - 2)

print(solve(N,X))


Measured memory_bytes: 3064
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int n,c;
int a[35],b[35];
int dp[35][1<<16];
int main()
{
	while(cin >> n >> c&&n|c)
	{
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		memset(dp,-1,sizeof(dp));
		dp[0][0]=0;
		for(int i=0;i<n+c;i++)
		{
			int k;
			int res=0;
			for(int j=0;j<16;j++)
			{
				cin >> k;
				if(k==1)
				{
					res<<=1;
					res+=1;
				}
				else if(k==0)
				{
					res<<=1;
				}
			}
			if(i<n)a[i]=res;
			else b[i-n]=res;
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<(1<<16);j++)
			{
				if(dp[i][j]==-1)continue;
				int s=(j|a[i]);
				for(int k=0;k<c;k++)
				{
					int p=__builtin_popcount(b[k]&s);
					dp[i+1][s-(b[k]&s)]=max(dp[i+1][s-(b[k]&s)],dp[i][j]+p);
				}
			}
		}
		int ans=0;
		for(int i=0;i<(1<<16);i++)
		{
			ans=max(ans,dp[n][i]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 10132
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val data = Array(n) { sc.nextInt() to sc.nextInt() }
    data.sortBy { it.second }
    val a = data.map { it.first }.toTypedArray()
    val b = data.map { it.second }.toTypedArray()
    var sum = 0L
    for (i in 0 until n) {
        sum += a[i]
        if (sum > b[i]) {
            println("No")
            return
        }
    }
    println("Yes")
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 89380
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>vector<T> make_v(size_t a){ return vector<T>(a); }
template<typename T,typename... Ts>auto make_v(size_t a, Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int a[101010];
map<int, int>mp;

int main(){
    cin >> n;
    REP(i, n){
        cin >> a[i];
        mp[a[i]]++;
    }
    if(mp[0] == n){
        cout << "Yes" << endl;
    }else if(n % 3 == 0){
        set<int> st;
        REP(i, n){
            st.insert(a[i]);
        }
        if((int)st.size() == 2){
            if(mp[0] != n/3){
                cout << "No" << endl;
                return 0;
            }
            REP(i, n){
                if(a[i] != 0){
                    if(mp[a[i]] != n/3*2){
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
            cout << "Yes" << endl;
        }else if((int)st.size() != 3){
            cout << "No" << endl;
        }else{
            LL num = 0;
            for(auto it = st.begin();it != st.end();it++){
                if(mp[*it] != n/3){
                    cout << "No" << endl;
                    return 0;
                }
                num ^= *it;
            }
            if(num == 0){
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 7808
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

ll const MAX_N = 1005;
ll const MAX_M = 1005;

typedef pair<ll, ll> P;

ll H, W;
ll ch, cw, dh, dw;

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

ll d[MAX_N][MAX_M];
char maze[MAX_N][MAX_M + 1];

ll bfs(ll sx, ll sy) {
    queue<P> que;
    queue<P> visited;

    rep(i, H) rep(j, W) d[i][j] = INF;

    que.push(P(sx, sy));
    d[sy][sx] = 0;
    ll cnt = 0;

    while (que.size() || visited.size()) {
        if (!que.empty()) {
            P p = que.front();
            que.pop();
            visited.push(p);

            if (p.first == dw && p.second == dh) return d[dh][dw];

            for (int i = 0; i < 4; i++) {
                int nx = p.first + dx[i];
                int ny = p.second + dy[i];

                if (0 <= nx && nx < W && 0 <= ny && ny < H &&
                    maze[ny][nx] != '#' && d[ny][nx] == INF) {
                    que.push(P(nx, ny));
                    d[ny][nx] = d[p.second][p.first];
                }
            }
        } else {
            P p = visited.front();
            visited.pop();

            for (ll i = -2; i <= 2; i++) {
                for (ll j = -2; j <= 2; j++) {
                    if (i == 0 && j == 0) continue;

                    int nx = p.first + i;
                    int ny = p.second + j;

                    if (0 > nx || nx >= W || 0 > ny || ny >= H) continue;
                    if (maze[ny][nx] == '#') continue;
                    if (d[ny][nx] != INF) continue;

                    que.push(P(nx, ny));
                    d[ny][nx] = d[p.second][p.first] + 1;
                }
            }
        }
        // cout << "---" << endl;
        // rep(y, H) {
        //     rep(x, W) {
        //         if (d[y][x] >= INF)
        //             cout << "# ";
        //         else
        //             cout << d[y][x] << " ";
        //     }
        //     cout << endl;
        // }
    }

    return -1;
}

int main() {
    INIT;

    cin >> H >> W;
    cin >> ch >> cw >> dh >> dw;

    rep(i, H) {
        rep(j, W) { cin >> maze[i][j]; }
    }

    ch--;
    cw--;
    dh--;
    dw--;

    cout << bfs(cw, ch) << endl;

    return 0;
}

Measured memory_bytes: 12528
def read():
    H, W = map(int, input().split(' '))
    Ss = []
    for _ in range(H):
        Ss.append(input())
    return H, W, Ss
 
DIRS = [(-1, 0), (1, 0), (0, -1), (0, 1)]
 
def add(p1, p2):
    return (p1[0] + p2[0], p1[1] + p2[1])
 
def ans(H, W, Ss):
    if Ss[0][0] == '#':
        print('0,0 #')
        return -1
    ds =[ [-1 for _ in range(W)] for _ in range(H)]
    ds[0][0] = 1
    q = [(0, 0)]
    while q:
        p = q.pop()
        d = ds[p[1]][p[0]]
        for dr in DIRS:
            x, y = add(p, dr)
            if x < 0 or x >= W or y < 0 or y >= H:
                continue # 範囲外へは移動できない
            if Ss[y][x] == '#':
                continue # 行き止まりへは移動できない
            if ds[y][x] >= 0 and ds[y][x] <= d + 1: # すでに訪れていて短縮にもなっていない
                continue
            ds[y][x] = d + 1
            q.append((x, y))
    if ds[H-1][W-1] < 0:
        return -1
    # 白マスを数える
    ws = sum([l.count('.') for l in Ss])
    return ws - ds[H-1][W-1]
 
if __name__ == '__main__':
    H, W, Ss = read()
    print(ans(H, W, Ss))

Measured memory_bytes: 74016
#include<iostream>
using namespace std;
const int maxn=1e5+5;
int main()
{
	int n;
	int a[maxn];
	int b[maxn]={0};
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		b[a[i]]++;
	}
	for(int i=0;i<n;i++){
		a[i]++;
		b[a[i]]++;
		a[i]=a[i]-2;
		b[a[i]]++;	
	}
	int max1=1;
	for(int i=0;i<n;i++){	
		if(max1<b[i]){
			max1=b[i];
		}
	}
	printf("%d\n",max1);
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <climits>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int m[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
bool cmp(int a, int b) {
    return m[a] < m[b];
}

int dp[10001];
int main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    
    vector<int> buf(N);
    int cnt = 0;
    for (int i = 1; i < N; i++) {
        if (S[i-1] == 'A' && S[i] == 'C') cnt++;
        buf[i] = cnt;
    }
    
    REP(i, Q) {
        int l, r;
        cin >> l >> r;
        cout << buf[r-1] - buf[l-1] << endl;
    }
}


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

int main(){
	int n, a[101];

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

	unsigned long long int dp[100][21] = {0};
	dp[0][ a[0] ] = 1;
	for(int i=1 ; i < n-1 ; i++ ){
		for(int j=0 ; j <= 20 ; j++ ){
			if( dp[i-1][j] > 0 ){
				int val = j + a[i];
				if( val <= 20 ) dp[i][val] += dp[i-1][j];
				val = j - a[i];
				if( val >= 0 ) dp[i][val] += dp[i-1][j];
			}
		}
	}
	cout << dp[n-2][ a[n-1] ] << endl;
}

Measured memory_bytes: 0
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
    int n;
    cin>>n;
    ll mi=1e+14;
    vector<ll> v(n);
    rep(i,n){
        ll j;
        cin>>j;
        if(j%2!=0){
            cout<<0<<endl;
            return 0;
        }else{
            v[i]=j;
            }
        
    }
   
    ll ans=0;
while(true){
    int flag=0;
    for(int i=0;i<v.size();i++){
        if(v[i]%2==1){
            flag=1;
            break;
        }else{
        v[i]=v[i]/2;
        }
    }
    if(flag==1){
        break;
    }else{
    ans++;
    }
}
    cout<<ans<<endl;
    
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <algorithm>
#define N 312
typedef long long ll;
template <typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-')	flag = true; c = getchar(); }
	while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
	if (flag)	x = -x;
}
using namespace std;
const int P = 1e9 + 7;
inline void ADD(ll &a, ll b) {
	a += b; if (a >= P)	a -= P;
}
int n, m;
struct edge{
	int nxt, to, val;
}e[N];
int head[N], ecnt;
inline void addedge(int from, int to, int val) {
	e[++ecnt] = (edge){head[from], to, val};
	head[from] = ecnt;
}

ll f[N][N][N];
int main() {
	read(n), read(m);
	for (register int i = 1; i <= m; ++i) {
		int l, r, x; read(l), read(r), read(x);
		addedge(r, l, x);
	}
	f[1][0][0] = 3;
	for (register int i = 1; i <= n; ++i) {
		for (register int j = 0; j < i; ++j) {
			for (register int k = 0; k < i; ++k) {
				for (register int t = head[i]; t; t = e[t].nxt) {
					int l = e[t].to, x = e[t].val;
					if (x == 1) {
						if (j >= l || k >= l)	f[i][j][k] = 0;
					} else if (x == 2) {
						if ((j >= l && k >= l) || (j < l && k < l))	f[i][j][k] = 0;
					} else {
						if (j < l || k < l)	f[i][j][k] = 0;
					}
				}
				ADD(f[i + 1][j][k], f[i][j][k]);
				ADD(f[i + 1][i][k], f[i][j][k]);
				ADD(f[i + 1][j][i], f[i][j][k]);
			}
		}
	}
	ll ans = 0;
	for (register int i = 0; i < n; ++i)
		for (register int j = 0; j < n; ++j)
			ADD(ans, f[n][i][j]);
	printf("%lld\n", ans);
	return 0;
}

/*
3 1
1 3 3
//6
*/

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

int sumDigits(int num) { return num / 10000 + num % 10000 / 1000 + num % 1000 / 100 + num % 100 / 10 + num % 10; }
int main() {
    long long A, B, K;
    cin >> A >> B >> K;
    set<long long> ans;
    int cnt = 0;
    for (long long i = A; i <= B; i++) {
        if (cnt < K) {
            ans.insert(i);
            cnt++;
        } else {
            break;
        }
    }
    cnt = 0;
    for (long long i = B; i >= A; i--) {
        if (cnt < K) {
            ans.insert(i);
            cnt++;
        } else {
            break;
        }
    }
    for (auto i = ans.begin(); i != ans.end(); i++) {
        cout << *i << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define gI gi

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int maxn = 100003;

int n, gq, qm, tot, head[maxn], ver[maxn * 2], nxt[maxn * 2];
int dep[maxn], kk[maxn], fa[maxn], ans, now;

void dfs(int u, int f)
{
	dep[u] = kk[u] = dep[f] + 1, fa[u] = f;
	for (int i = head[u]; i; i = nxt[i])
	{
		int v = ver[i];
		if (v == f) continue;
		dfs(v, u);
		kk[u] = max(kk[u], kk[v]);
	}
}

inline void add(int u, int v)
{
	ver[++tot] = v, nxt[tot] = head[u], head[u] = tot;
}

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi(), gq = gi(), qm = gi();
	for (int i = 1; i < n; i+=1)
	{
		int u = gi(), v = gi();
		add(u, v), add(v, u);
	}
	dfs(qm, 0);
	now = gq;
	while (1)
	{
		if (dep[gq] - dep[now] >= dep[now] - dep[qm]) break;
		ans = max(ans, kk[now] - 1);
		now = fa[now];
	}
	printf("%d\n", ans - 1);
	return 0;
}

Measured memory_bytes: 7168
#include <stdio.h>

int main(void) {
  int n, r, rating;
  scanf("%d %d", &n, &r);
  if (n >= 10) {
    rating = r;
  } else {
    rating = r + 100 * (10 - n);
  }
  printf("%d", rating);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <string>


using namespace std;

int main() {

	string a;
	int k;
	int n;

	while (cin >> a) {
		k = a.size();
		for (int i = 0; i < k; i++) {
			if (a[i] == '@') {
				n = a[i+1] - '0';
				for (int j = 0; j < n; j++) {
					cout << a[i+2];
				}
				i = i + 2;
			} else {
				cout << a[i];
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1172
s = input()
gmp = 0

ans = 0
k = ''
for si in s:
    if si == 'g':
        if gmp > 0:
            ans += 1
            gmp -= 1
            k+='p'
        else:
            gmp += 1
            k+='g'
    else:
        if gmp > 0:
            gmp -= 1
            k+='p'
        else:
            gmp += 1
            ans -= 1
            k+='g'
# print(k)
print(ans)


Measured memory_bytes: 3316
n,q = list(map(int, input().split()))
s = input()
x = []
for i in range(q):
  x.append(list(map(int, input().split())))
  
l = [0]
for i in range(1,n):
  if s[i-1] == 'A' and s[i] == 'C':
    l.append(l[i-1] + 1)
  else:
    l.append(l[i-1])

for i in range(q):
  print(l[x[i][1]-1]-l[x[i][0]-1])

Measured memory_bytes: 30696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

int main()
{
        ll A, B;
        cin >> A >> B;
        if (A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0) {
                cout << "Possible" << endl;
        }
        else cout << "Impossible" << endl;


}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"io"
)

func main() {
	var l string
	idx := 0
	for {
		_, err := fmt.Scanln(&l)

		if err == io.EOF {
			break
		}

		if l == "0" {
			break
		}
		idx++
		fmt.Printf("Case %d: %s\n", idx, l)
	}
}



Measured memory_bytes: 1940
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int maxn = 1e5 + 50;
const ll mod = 1e9+7;
int dp[maxn];
int a[200];
int main(){
    int n, k;
    scanf("%d%d",&n, &k);
    dp[0] = 0;
    for(int i = 1; i <= n; i++) {scanf("%d", &a[i]);dp[a[i]] = 1;}
    for(int i = a[1]+1; i <= k; i++){
        dp[i] = 1;
        for(int j = 1; j <= n && a[j] <= i; j++){
            dp[i] &= dp[i-a[j]] ;
        }
        dp[i] = 1-dp[i];
    }
    if(dp[k]) puts("First");
    else puts("Second");
    return 0;
}





Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-10;

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};
// ll pas[5001][5002];

int main() {
	IOS();
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	vector<int> a(n + 1, 0), b(m + 1, 0);
	for (int i = 0; i < n; i++) {
		if (s[i] == 'A') a[i + 1] = (a[i] + 1) % 3;
		if (s[i] == 'B') a[i + 1] = (a[i] + 2) % 3;
	}
	for (int i = 0; i < m; i++) {
		if (t[i] == 'A') b[i + 1] = (b[i] + 1) % 3;
		if (t[i] == 'B') b[i + 1] = (b[i] + 2) % 3;
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int s1, s2, t1, t2;
		cin >> s1 >> s2 >> t1 >> t2;
		dump((a[s2] - a[s1 - 1] + 3) % 3 == (b[t2] - b[t1 - 1] + 3) % 3 ? "YES"
																		: "NO");
	}
	return 0;
}

Measured memory_bytes: 1744
S = input()
N = len(S)

check = 0
for i in range(int((N+1)/2)):
    if S[i] != S[N-1-i]:
        check +=1
    else:
        check +=0


S_1 = S[0:int((N-1)/2)]
N_1 = len(S_1)
check_1 = 0

for i in range(int((N_1+1)/2)):
    if S_1[i] != S_1[N_1-1-i]:
        check_1 +=1
    else:
        check_1 +=0

        
S_2 = S[int((N+1)/2):N]
N_2 = len(S_2)
check_2 = 0

for i in range(int((N_2+1)/2)):
    if S_2[i] != S_2[N_2-1-i]:
        check_2 +=1
    else:
        check_2 +=0

if check + check_1 + check_2 ==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
K = gets.to_i
A = gets.split.map(&:to_i)

if A.last != 2
  puts -1
  exit
end

max = 2
min = 2

A.reverse.each do |a|
  min = a * Rational(min, a).ceil
  max = a * (max / a) + a - 1

  if max - min + 1 < a
    puts -1
    exit
  end
end

puts [min, max].join(' ')


Measured memory_bytes: 11908
import sys
N = int(input())
if N == 1:
    print(1)
    sys.exit()

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

L = make_divisors(N)
l = len(L)
if l % 2 == 0:
    a1 = str(L[l // 2] - 1)
    a2 = str(L[l // 2])
    print(max(len(a1), len(a2)))
else:
    a1 = str(L[l // 2 - 1])
    a2 = str(L[l // 2])
    a3 = str(L[l // 2 + 1])
    d1 = max(len(a1), len(a2))
    d2 = max(len(a2), len(a3))
    print(min(d1, d2))


Measured memory_bytes: 9240
fun contains(numbers: IntArray, x: Int, y: Int): Boolean {
    var hasX = false
    var hasY = false

    for (number: Int in numbers) {
        hasX = (hasX || number == x)
        hasY = (hasY || number == y)
    }

    return (hasX && hasY)
}

fun containsInArray(numbersArray: Array<IntArray>, x: Int, y: Int): Boolean {
    var has = false

    for (numbers: IntArray in numbersArray) {
        if (contains(numbers, x, y)) {
            has = true
            break
        }
    }

    return has
}


fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(' ').map(String::toInt)
    val numbersArray: Array<IntArray> = arrayOf(intArrayOf(1, 3, 5, 7, 8, 10, 12), intArrayOf(4, 6, 9, 11), intArrayOf(2))

    val result = if (containsInArray(numbersArray, x, y)) "Yes" else "No"
    println(result)
}

Measured memory_bytes: 37964
#include<iostream>

int main()
{
    int N = 0;
    int X = 0;
    int T = 0;
    int i = 1;
    int t_num =0;

    std::cin >> N;
    std::cin >> X;
    std::cin >> T;
 
    t_num = i * X;

    for(i=1; t_num < N;) 
    {
	    i++;
        t_num = i * X;
    }

    std::cout << T*i;

    return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long Int;
Int gcd(Int a, Int b)
{   
  return b != 0 ? gcd(b, a % b) : a; }

Int lcm(Int a, Int b) {
  return a * b / gcd(a, b);
}

main() {
  Int a,b;
  while((cin>>a>>b)) {
    Int gc = gcd(a,b);
    cout << gc << " " << a*b/gc << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=600005,INF=1<<30;

int n;
ll dat[2*MAX-1];

void init(int n_){
    n=1;
    while(n<n_) n*=2;
    for(int i=0;i<2*n-1;i++){
        dat[i]=-INF;
    }
}

void update(int k,ll a){
    k+=n-1;
    dat[k]=a;
    
    while(k>0){
        k=(k-1)/2;
        dat[k]=max(dat[k*2+1],dat[k*2+2]);
    }
}

ll query(int a,int b,int k,int l,int r){
    
    if(r<=a||b<=l) return -INF;
    if(a<=l&&r<=b) return dat[k];
    else{
        ll vl=query(a,b,2*k+1,l,(l+r)/2);
        ll vr=query(a,b,2*k+2,(l+r)/2,r);
        return max(vl,vr);
    }
}

bool compare(pair<int,int> a,pair<int,int> b){
    if(a.second==b.second) return a.first>b.first;
    return a.second>b.second;
}

int main(){
    
    int N,M;cin>>N;M=N;
    vector<pair<int,int>> X(N),Y(M),asort(N+M),bsort(N+M);
    for(int i=0;i<N;i++){
        cin>>X[i].first>>X[i].second;
        asort[i]={X[i].first,i};
        bsort[i]={X[i].second,i};
    }
    
    for(int i=0;i<M;i++){
        cin>>Y[i].first>>Y[i].second;
        asort[i+N]={Y[i].first,i+N};
        bsort[i+N]={Y[i].second,i+N};
    }
    
    sort(all(asort));
    sort(all(bsort));
    
    for(int i=0;i<N+M;i++){
        asort[i].first=i+1;
        bsort[i].first=i+1;
        
        if(asort[i].second<N) X[asort[i].second].first=asort[i].first;
        else Y[asort[i].second-N].first=asort[i].first;
        
        if(bsort[i].second<N) X[bsort[i].second].second=bsort[i].first;
        else Y[bsort[i].second-N].second=bsort[i].first;
    }
    
    sort(all(X),compare);
    
    init(N+M);
    
    for(int i=0;i<M;i++){
        update(Y[i].first,Y[i].second);
    }
    
    int ans=0;
    
    for(int q=0;q<N;q++){
        if(query(X[q].first,n+1,0,0,n)<X[q].second) continue;
        int left=X[q].first,right=N+M;
        while(right-left>1){
            int mid=(left+right)/2;
            if(query(X[q].first,mid+1,0,0,n)<X[q].second) left=mid;
            else right=mid;
        }
        ans++;
        update(right,-INF);
    }
    
    cout<<ans<<endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	int xmax;
	cin >> xmax;
	for(int i=1; i<n; i++){
		int tmp;
		cin >> tmp;
		xmax = max(xmax, tmp);
	}
	int ymin;
	cin >> ymin;
	for(int i=1; i<m; i++){
		int tmp;
		cin >> tmp;
		ymin = min(ymin, tmp);
	}
	if(ymin>xmax && y>xmax && x<ymin)
		cout << "No War" << endl;
	else
		cout << "War" << endl;
	return 0;
}

Measured memory_bytes: 256
($N,$M)=glob<>;
/ /,${$`}{$'+0}=${$'+0}{$`}=1for<>;

sub f{
	my$c=$c[$i=pop];
	for(keys%$i){
		if($c[$_]){
			if($c[$_]==$c){
				exit!print$N*($N-1)/2-$M
			}
		}else{
			$c[$_]=-$c;
			f($_)
		}
	}
}
$c[1]=1;
f 1;

print grep($_>0,@c)*grep($_<0,@c)-$M


Measured memory_bytes: 94976
#include<bits/stdc++.h>				//written by thidailoc
using namespace std;				//team three wolves
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
#define fu(i,a,b)   for(ll i=a;i<b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define ms(a,x) 	memset(a, x, sizeof a)
#define prec(n) 	fixed<<setprecision(n)
#define pb(i)	    push_back(i)
#define popb()    	pop_back()
#define sc(a) 	    cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)	    cout<<a<<" "
#define pr2(a,b)    cout<<a<<" "<<b<<" "
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)	lower_bound(a.begin(),a.end(),x) -a.begin()
#define all(x) 		(x).begin(), (x).end()
#define sz(a) 		(ll)a.size()
#define le			length()						
#define re 			return 	
#define	mp(a,b)  	make_pair(a,b)
#define se			second
#define fi			first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)

double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17;
ll arr[1000000],mark[10000000];


ll Solves(){
//	INPUT;
	ll n,k,cnt=0,ans=1,x,p,test,sum=0,query,a,b,c,d;
	// PROCESSING IN HERE
	sc(n);
	fu(i,0,n)sc(arr[i]);
	sort(arr,arr+n);
	pr(arr[n-1]-arr[0]);
	
	re 0;
}


int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	Solves();
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=4005,INF=1<<30;
ll dp[MAX][MAX];

ll inv[MAX],fac[MAX],finv[MAX];

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b||b<0) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    make();
    
    string S;cin>>S;
    int N=S.size();
    int cana=0,canb=0;
    dp[0][0]=1;
    if(S[0]=='0'){
        dp[1][1]=1;
        cana=2;
    }else if(S[0]=='1'){
        dp[1][1]=1;
        dp[1][0]=1;
        cana=1;
        canb=1;
    }else{
        dp[1][0]=1;
        canb=2;
    }
    
    for(int i=1;i<N;i++){
        if(S[i]=='0') cana++;
        else if(S[i]=='1'){
            cana++;
            canb++;
        }else canb++;
        
        for(int j=0;j<=i+1;j++){
            if(canb>=i+1-j) dp[i+1][j]+=dp[i][j];
            if(cana>=j&&j) dp[i+1][j]+=dp[i][j-1];
            
            dp[i+1][j]%=mod;
        }
        
        if(S[i]=='0') cana++;
        if(S[i]=='2') canb++;
    }
    
    ll ans=0;
    
    for(int j=0;j<=N;j++){
        ans+=dp[N][j]*comb(N,cana-j);
        ans%=mod;
    }
    
    cout<<ans<<endl;
    
}



Measured memory_bytes: 62208
f=lambda x:x if p[x]<0else f(p[x])
def u(x,y):
  x,y=f(x),f(y)
  if x!=y:
    if p[x]>p[y]:x,y=y,x
    p[x]+=p[y]
    p[y]=x
h,*s=open(0)
h,w=map(int,h.split())
r=range(h*w)
p=[-1]*h*w
for i in r:
  j,k=i//w,i%w
  h>j+1and s[j][k]!=s[j+1][k]and u(i,i+w)or w>k+1and s[j][k]!=s[j][k+1]and u(i,i+1)
d=[[0,0]for _ in r]
for i in r:d[f(i)][s[i//w][i%w]<'.']+=1
print(sum(i*j for i,j in d))

Measured memory_bytes: 21612
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>
#include <list>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
//#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
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; }

using namespace std;

int main(void)
{
    int N, M; cin >> N >> M;
    vector<int> H(N); rep(i, 0, N)cin >> H[i];
    vector<bool> T(N, true);
    rep(i, 0, M) {
        int A, B; cin >> A >> B;
        A--; B--;
        if (H[A] > H[B])T[B] = false;
        else if (H[A] < H[B])T[A] = false;
        else {
            T[A] = false;
            T[B] = false;
        }
    }
    
    int ans = 0; 
    rep(i, 0, N)if (T[i])ans++;
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3724
//============================================================================
// Name        : HelloWorld.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int N,X;
	int L[101];
    int R=1;
    int sum=0;
	cin>>N>>X;
    for(int i=0;i<N;i++){
    	cin>>L[i];
    	sum+=L[i];
    	if(sum<=X)R++;
    }
    cout<<R<<endl;
	return 0;
}


Measured memory_bytes: 384
N,C = map(int,input().split())
A = [[0 for _ in range(C)] for j in range(100001)]
for i in range(N):
    s,t,c = map(int,input().split())
    for j in range(s-1,t):
        A[j][c-1] = 1
R = 0
for i in range(100001):
    sumA = sum(A[i])
    if R < sumA:
        R = sumA
print(R)


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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int ans = min(K, A);
  ans -= K - A - B > 0 ? min(K - A - B, C) : 0;
  cout << ans << endl;
}

Measured memory_bytes: 3620