akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<cat> A(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	cat ans_min = 2, ans_max = 2;
	for(int i = N-1; i >= 0; i--) {
		ans_max -= ans_max % A[i];
		if(ans_max < ans_min) {
			cout << "-1\n";
			return 0;
		}
		if(ans_min % A[i] != 0) ans_min += A[i] - ans_min % A[i];
		ans_max += A[i]-1;
	}
	cout << ans_min << " " << ans_max << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  string s, t;
  int q;
  cin >> s >> t >> q;
  vector<int> ss(s.size() + 1), ts(t.size() + 1);
  REP(i, s.size()) { ss[i+1] = (int)'C' - s[i]; }
  REP(i, s.size()) { ss[i+1] += ss[i]; }
  REP(i, t.size()) { ts[i+1] = (int)'C' - t[i]; }
  REP(i, t.size()) { ts[i+1] += ts[i]; }
  REP(i, q) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    --a; --c;
    int flag = (ss[a] - ss[b] - ts[c] + ts[d]) % 3;
    cout << (flag ? "NO" : "YES") << endl;
  }
  return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll X;
    string S;
    cin >> X;

    ll tmp = 0;
    ll i = 1;

    while (X > tmp)
    {
        tmp = i * (i + 1) / 2;
        i++;
    }
    if (X == tmp)
    {
        cout << i - 1 << endl;
    }
    else
    {
        cout << i-1 << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

typedef long long ll;

void maximumMonsters(int& N, int monsters[], int heroCapacity[])
{
    ll maxKilled = 0;

    for (int i = N-1; i >= 0; i--)
    {
        int nextKilled = std::min(monsters[i+1], heroCapacity[i]);
        monsters[i+1] -= nextKilled;
        heroCapacity[i] -= nextKilled;

        int currKilled = std::min(monsters[i], heroCapacity[i]);
        monsters[i] -= currKilled;
        heroCapacity[i] -= currKilled;

        maxKilled += nextKilled + currKilled;
    }

    printf("%lld\n", maxKilled);
}


int main()
{
    int N;
    
    scanf("%d", &N);

    int monsters[N+1];
    int heroCapacity[N];

    for (int i = 0; i < N+1; i++) { scanf("%d", &monsters[i]); }
    for (int i = 0; i < N; i++) { scanf("%d", &heroCapacity[i]); }

    maximumMonsters(N, monsters, heroCapacity);

    return 0;
}

Measured memory_bytes: 896
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

print('bust' if sum(LI()) >= 22 else 'win')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


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



Measured memory_bytes: 3108
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
#define rep(i,n) for (ll i=0;i<n;i++)
using namespace std;

struct UnionFind {
    vector<ll> par;
    vector<ll> rank;

    UnionFind(ll N) : par(N),rank(N){
        // 初期化
        rep(i,N) {
            par[i] = i;
            rank[i] = 0;
        }
    }


    ll root(ll x){
        // unionfind木をたどって頂点を探す
        if(par[x]==x) return x;
        else return par[x] = root(par[x]);
    }

    void unite(ll x,ll y){
        // 高さを考慮し、結合する。
        ll rx = root(x);
        ll ry = root(y);
        if(rx==ry) return;
        if(rank[x]<rank[y]){
            par[rx] = y;
        }else{
            par[ry] = x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(ll x,ll y){
        // 親が同じなら同じグループ
        return root(x)==root(y);
    }

};


void solve(){

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

    ll n,m;
    cin >> n >> m;
    vector<string> a(n);
    vector<string> b(m);

    rep(i,n){
        cin >> a[i];
    }
    rep(i,m){
        cin >> b[i];
    }
    bool q = false;
    for(ll i=0;i<=n-m;i++){
        for(ll j = 0;j<=n-m;j++){
            bool w = true;
            rep(k,m){
                if(a[k+j].substr(i,m)!=b[k]){
                    w = false;
                    break;
                }
            }
            if(w){
                cout << "Yes";
                return 0;
            }
        }
    }

    cout << "No";

    return 0;
}

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

// 間隔gだけ離れた要素のみを対象とした挿入ソート
void insertionSort(vector<int> &A, int n, int g, int &cnt)
{
  for (int i = g; i < n; i++)
  {
    int v = A.at(i);
    int j = i - g;
    while (j >= 0 && A.at(j) > v)
    {
      A.at(j + g) = A.at(j);
      j -= g;
      cnt++;
    }
    A.at(j + g) = v;
  }
}

// シェルソート、Gはmain関数内で生成
void shellSort(vector<int> &A, int n, vector<int> G, int &cnt)
{
  int m = G.size();
  for (int i = 0; i < m; i++)
  {
    insertionSort(A, n, G.at(i), cnt);
  }
}

int main()
{
  // 入力
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++)
  {
    scanf("%d", &A.at(i));
  }

  // 処理
  vector<int> G;
  // Gを生成
  int v = 1;
  for (int i = 0;; i++)
  {
    if (v > n)
    {
      break;
    }
    G.push_back(v);
    v = v * 3 + 1;
  }
  reverse(G.begin(), G.end());

  int cnt = 0;
  shellSort(A, n, G, cnt);

  int m = G.size();

  // 出力
  // 1行目
  cout << m << endl;
  // 2行目
  for (int i = 0; i < m; i++)
  {
    if (i == m - 1)
    {
      cout << G.at(i) << endl;
    }
    else
    {
      cout << G.at(i) << " ";
    }
  }
  // 3行目
  cout << cnt << endl;
  // 4行目
  for (int i = 0; i < n; i++)
  {
    cout << A.at(i) << endl;
  }
}



Measured memory_bytes: 6764
import numpy as np
N,W = map(int,input().split())
#N = int(input())
dp =[[0 for i in range(W+1)] for j in range(N+1)]
w = np.zeros(W+1)
v = [0]*N
ndp = np.zeros(W + 1, dtype=np.int64)
for i in range(N):
  w[i],v[i] =  map(int,input().split())
for i in range(N):
  ndp[w[i]:] = np.maximum(ndp[:-w[i]] + v[i], ndp[w[i]:])
print(ndp[W])

Measured memory_bytes: 94128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n,k;cin>>n>>k;
    ll a[n];
    f(i,0,n)cin>>a[i];
    vector<ld>v;
    f(i,0,n){
        ll sum=(a[i]*(a[i]+1))/2;
        ld p=(ld)sum/a[i];
        v.pb(p);
    }
    ld pre[n];
    pre[0]=v[0];
    f(i,1,n){
        pre[i]=pre[i-1]+v[i];
    }
    ld maxi=pre[k-1];
    f(i,k,n){
        maxi=max(maxi,pre[i]-pre[i-k]);
    }
    cout<<setprecision(12)<<fixed<<maxi;
    return 0;  
} 

Measured memory_bytes: 9236
// ABC051B - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int K, S;
	cin >> K >> S;

	ull ans = 0;

	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++){
			if ((0 <= (S - i - j))&&((S - i - j) <= K)) {
				++ans;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import deque
N,M = list(map(int,input().split()))
edges = [[] for i in range(N+1)]
for i in range(M):
    A,B = list(map(int,input().split()))
    edges[A].append(B)
    edges[B].append(A)

queue = deque()
queue.append(1)

guideposts = [-1]*(N+1)
guideposts[1] = 0
while queue:
    room = queue.popleft()
    for next_room in edges[room]:
        if guideposts[next_room] == -1:
            guideposts[next_room] = room
            queue.append(next_room)

for i in range(2,N+1):
    if guideposts[i] == -1:
        print('No') #なんか常にYesな気がする
        break
else:
    print('Yes')
    for i in range(2,N+1):
        print(guideposts[i])

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

int main() {
  ll N, K;
  cin >> N >> K;
  map<ll, ll> num;
  vector<pair<ll, ll>> pairs;
  for (int i = 0; i < N; i++) {
    ll A;
    cin >> A;
    if (num.count(A)) {
      num[A]++;
    }
    else {
      num[A] = 1;
    }    
  }
  for (auto p : num) {
    ll key = p.first;
    ll value = p.second;
    pairs.push_back(make_pair(value, key));
  }
  sort(pairs.begin(), pairs.end());
  ll ans = 0;
  ll kind = num.size();
  ll i = 0;
  if (kind <= K) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < kind - K; i++) {
    ans += pairs[i].first;
  }
  cout << ans << endl;
}



Measured memory_bytes: 17520
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
int main(){
    int N;
    cin >> N;
    vector<long long> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    vector<long long> cnt(N + 1);
    map<long long, long long> m;
    int MAX = 0, ind = 0;
    vector<P> vec;
    vec.push_back(P(0, -1));
    for(int i = 0; i < N; i++){
        if(MAX < a[i]){
            MAX = a[i];
            ind = i;
            vec.push_back(P(a[i], i));
        }
    }
    reverse(vec.begin(), vec.end());
    int n = vec.size();
    int right = N;
    for(int i = 0; i < n - 1; i++){
        P v = vec[i];
        int now = v.second;
        for(int i = now; i < right; i++){
            m[a[i]]++;
        }
        long long nex = vec[i + 1].first;
        vector<P> temp;
        for(auto ite = m.rbegin(); ite != m.rend(); ite++){
            auto u = *ite;
            if(u.first <= nex) break;
            cnt[now] += (u.first - nex) * u.second;
            temp.push_back(u);
        }
        for(P u: temp){
            m[nex] += u.second;
            m.erase(u.first);
        }
        right = now;
    }
    for(int i = 0; i < N; i++){
        cout << cnt[i] << endl;
    }
}

Measured memory_bytes: 13164
#include<stdio.h>
#include<queue>
#include<algorithm>
using namespace std;
double ijk[30][31][31];
int v[30][31][31];
int g[30][30];
int lim[30][30];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		int S,T;
		scanf("%d%d",&S,&T);
		S--;T--;
		for(int i=0;i<a;i++)
			for(int j=0;j<a;j++)
				g[i][j]=-1;
		for(int i=0;i<b;i++){
			int p,q,r,s;
			scanf("%d%d%d%d",&p,&q,&r,&s);
			p--;q--;
			g[p][q]=g[q][p]=r;
			lim[p][q]=lim[q][p]=s;
		}
		for(int i=0;i<a;i++)
			for(int j=0;j<31;j++)
			for(int k=0;k<31;k++){ijk[i][j][k]=99999999;v[i][j][k]=0;}
		priority_queue<pair<double,pair<pair<int,int>,int> > >Q;
		Q.push(make_pair(0,make_pair(make_pair(S,30),1)));
		ijk[S][30][1]=0;
		while(Q.size()){
			double cost=-Q.top().first;
			int at=Q.top().second.first.first;
			int prev=Q.top().second.first.second;
			int ver=Q.top().second.second;
			Q.pop();
			if(~prev&&v[at][prev][ver])continue;
			if(~prev)v[at][prev][ver]=1;
			for(int i=0;i<a;i++){
				if(ver&&~g[at][i]&&lim[at][i]>=ver&&prev!=i){
					if(ijk[i][at][ver-1]>cost+(double)g[at][i]/ver){
						ijk[i][at][ver-1]=cost+(double)g[at][i]/ver;
						Q.push(make_pair(-ijk[i][at][ver-1],make_pair(make_pair(i,at),ver-1)));
					}
					if(ijk[i][at][ver]>cost+(double)g[at][i]/ver){
						ijk[i][at][ver]=cost+(double)g[at][i]/ver;
						Q.push(make_pair(-ijk[i][at][ver],make_pair(make_pair(i,at),ver)));
					}
					if(ver<30&&ijk[i][at][ver+1]>cost+(double)g[at][i]/ver){
						ijk[i][at][ver+1]=cost+(double)g[at][i]/ver;
						Q.push(make_pair(-ijk[i][at][ver+1],make_pair(make_pair(i,at),ver+1)));
					}
				}
			}
		}
		double ret=99999999;
		for(int i=0;i<a;i++)ret=min(ret,ijk[T][i][0]);
		if(ret>9999999)printf("unreachable\n");
		else printf("%f\n",ret);
	}
}

Measured memory_bytes: 2328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;


int main() {long A, B, K, X, Y;
cin >> A >> B >> K;
bool turn = true;
erep(i, K){
    if(turn == true){
        X = A; Y = B;
    }
    else{
        X = B; Y = A;
    }
    if(X % 2 == 1) X--;
    X = X /2;
    Y += X;
    if(turn == true){
        A = X; B = Y;
    }
    else{
        B = X; A = Y;
    }
    turn = !turn;
}
cout << A << ' ' << B << endl;






 return 0;
 
}



Measured memory_bytes: 256
N = int(input())
s = input().split(" ")
d = {}
for w in s:
    if w in d.keys():
        d[w] += 1
    else:
        d[w] = 1

for n in range(N):
    if str(n + 1) in d.keys():
        print(d[str(n + 1)])
    else:
        print(0)

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

void input ();
void solve ();

typedef long long ll;
typedef std::vector <ll> vl;

const ll MOD = (ll)1e9 + 7;
ll n, k;
vl arr, fac;
vl lt, ltb, lta;

ll sum (int i) {
	ll x = (((lta [i] + ((lt [i] * k) - ltb [i])) % MOD) * (k % MOD)) % MOD;
	return x * 500000004;
}

void input () {
	scanf ("%lld%lld", &n, &k);
	for (ll i = 0, a; i < n; i++) {
		scanf ("%lld", &a);
		arr.push_back (a);
	}
	solve ();
}

void solve () {
	for (int i = 0; i < n; i++) {
		ll c = 0;
		for (int j = (i + 1) % n; j != i; j = (j + 1) % n)
			if (arr [i] > arr [j])
				c++;
		lt.push_back (c);
	}

	for (int i = 0; i < n; i++) {
		ll c = 0;
		for (int j = 0; j < i; j++)
			if (arr [i] > arr [j])
				c++;
		ltb.push_back (c);
	}

	for (int i = 0; i < n; i++) {
		ll c = 0;
		for (int j = i + 1; j < n; j++)
			if (arr [i] > arr [j])
				c++;
		lta.push_back (c);
	}

	ll ans = 0;
	for (int i = 0; i < n; i++) {
		//printf ("{%lld, %lld}\n", lta [i], (lt [i] * k) - ltb [i]);
		ans += (sum (i)) % MOD;
	}
	printf ("%lld\n", (ans) % MOD);
}

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


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

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

	vector <int > q;
	rep1(i, 999)
	{
		int sum = 0;
		for (int j = 1; j <= i; j++)
			sum += j;
		q.push_back(sum);
	}
	rep(i, q.size() -1 )
	{
		if (q[i] - a == q[i+1] - b)
		{
			cout << q[i] - a << endl;
			return 0;
		}
	}
	return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
using namespace std;
typedef long long int ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a, ans = 0;
	bool dp[110][10010] = {};
	cin >> n;
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		for (int j = 0; j <= 100 * i; j++) if (dp[i - 1][j] ||(j-a>=0&& dp[i - 1][j - a]))dp[i][j] = 1;
	}
	for (int i = 10000; i >= 0; i--) {
		if (dp[n][i] && i % 10) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT_ON(bit, i) (((bit >> i) & 1) > 0)

typedef long long LL;
template<typename T> std::vector<T> make_v(size_t a){return std::vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a, Ts... ts){ return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}    // C++14
template<typename T,typename V> typename std::enable_if<std::is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename std::enable_if<std::is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }
template<typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }
template<class T> inline std::vector<T> unique(std::vector<T> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v;
}
// 初項s, 交差dのn個の数列の和
long long sum_of_arithmetic_progression(long long s, long long d, long long n) {
    return n * (2 * s + (n - 1) * d) / 2;
}

const int INF = 1 << 30;
const double EPS = 1e-9;
const long double PI = acos(-1.0);
const std::vector<int> dy4 = {0, -1, 0, 1}, dx4 = {1, 0, -1, 0};
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };


using namespace std;


long long xor_from0(long long n){
    if (n < 0) {
        return 0;
    }
    switch(n % 4) {
        case 0: return n;
        case 1: return 1;
        case 2: return n+1;
        case 3: return 0;
    }
}

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

    LL A, B;
    cin >> A >> B;

    print(xor_from0(B) ^ xor_from0(A - 1));

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <sstream>
using namespace std;
#define rep(i,n) for (int i=0; i<n; i++)
typedef long long ll;


int main(){
    int n;
    cin >> n;
    int k;
    cin >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int cnt = 0;

    rep(i,n) {
        if (h[i] >= k) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N, M, C, T, B[20];

int main(void){
	//IO("test.in", "test.out");
	scanf("%d%d%d", &N, &M, &C);
	for(int i = 0; i < M; i++) scanf("%d", &B[i]);
	for(int i = 0; i < N; i++){
		int w, t = 0;
		for(int j = 0; j < M; j++) scanf("%d", &w), t += w * B[j];
		if(t + C > 0) T++;
	}
	printf("%d\n", T);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 10000
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

double n;

signed main() {
	cin >> n;
	int a = (n + 1) / 2;
	double ans = a / n;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define rep(i,n) for(int i=0; i<n; ++i)
  

  int a[12][12];

int min(int a,int b){
  int temp;
  if(a>b)return b;
  if(a<=b)return a;
}


int main(){

  int n,m,x;
  scanf("%d%d%d",&n,&m,&x);

  int c[n];

  rep(i,n){
    scanf("%d",&c[i]);
    rep(j,m) scanf("%d",&a[i][j]);
  }

  int result;
  int ans = 1001001001;
  int d[m];
  for(int bit=0; bit<(1<<n); bit++){
    int cost = 0;
    rep(i,m) d[i]=0;
    for(int i=0; i<n; i++){
      if((bit>>i)&1){
        cost += c[i];
        for(int j=0; j<m; j++){
            d[j] += a[i][j];
            //printf("%d ",d[j]);
        }
        //printf("\n");
      }

      result = 1;
      for(int j=0; j<m; j++){
        if(d[j]<x) result = 0;
      }
      if(result){
        ans = min(ans,cost);
      }
    }
  }
  
  if(ans == 1001001001){
    printf("-1");
  }else{
    printf("%d",ans);
  }

  return 0;
}


Measured memory_bytes: 1708
#include<iostream>
using namespace std;
int main() {

	int N, a, b,i=0;
	cin >> N;
	for (a = 1; a <= 9; a++) {
		for (b = 1; b <= 9; b++) {
			if (a * b == N) {
				i++;
			}
		}
	}
		if (i == 0)cout << "No" << endl;
		else {
			cout << "Yes" << endl;
		}
		return 0;
	
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

void get() {

}

int n;
int mod(int a, int b)
{
	if(a < 0 && a%b != 0){
		n = a / b + 1;
		return a - (a / b + 1) * b;//返回非负余数
	}
	n = a / b;
	return a % b;
}

class CBase2Number {
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> n;
		vector<int>v;
		v.clear();
		int sum = 0, i = 0;
		if(n == 0){out << 0 << '\n'; return; }
		while (n!=0){
			v.push_back(mod(n, -2));
//			n /= (-2);
		}
		for (int i = v.size()-1; i >= 0; --i) {
			out << v[i];
		}
		out << endl;
	}
};


int main() {
	CBase2Number solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a,dp[44];
	while (1) {
		cin >> a;
		if (a == 0) {
			goto a;
		}
		a = a + 1;
		for (int i = 0; i <= 43; i++) {
			dp[i] = 0;
		}
		dp[1] = 1;
		for (int i = 1; i <= a; i++) {
			if (i >= 4) {
				for (int m = i - 3; m < i; m++) {
					dp[i] = dp[i] + dp[m];
				}
			}
			if (i == 3) {
				for (int m = i - 2; m < i; m++) {
					dp[i] = dp[i] + dp[m];
				}
			}
			if (i == 2) {
				for (int m = i - 1; m < i; m++) {
					dp[i] = dp[i] + dp[m];
				}
			}
		}
		int ans;
		ans = dp[a] / 3650;;
		if (dp[a] % 365 >= 0) {
			ans = ans + 1;
		}
		cout << ans << endl;
	}
a:;
}


Measured memory_bytes: 3020
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int gcd(int a, int b) {
  if (a < b) swap(a, b);

  int r;
  while (b > 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    int c; cin >> c;
    v.at(i) = abs(x - c);
  }

  int res = v.at(0);
  if (n == 1) {
    res = v.at(0);
  } else {
    for (int i = 0; i < n; ++i) {
      res = gcd(res, v.at(i));
    }
  }
  cout << res << endl;
  return 0;
}

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

int main()
{
    ll N;
    cin >> N;
    vector<ll> X(N);
    ll maxIn = 0;

    for(ll i = 0; i < N; i++)
    {
        cin >> X[i];
        maxIn = max(maxIn,X[i]);
    }

    ll countMin = pow(10,9);

    for(ll i = 0; i <= maxIn; i++)
    {
        ll count = 0;
        for(ll j = 0; j < N; j++)
        {
            ll diff = i - X[j];
            count += diff * diff;
        }
        countMin = min(countMin,count);
    }

    cout << countMin << endl;
    return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

int added_edge[222222];
vector<int> adj[222222];

int nim(int v, int p = -1) {
  int result = 0;
  for (auto u: adj[v]) if (u != p) {
    int r = nim(u, v);
    result ^= r + 1;
  }
  return result;
}

int main() {
  int N;
  scanf("%d", &N);

  REP(i,N-1) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x, --y;
    adj[x].pb(y);
    adj[y].pb(x);
  }

  bool alice = nim(0);
  printf(alice ? "Alice\n" : "Bob\n");
}


Measured memory_bytes: 13312
#include <iostream>
#include <string>

int main()
{
	int a, b, c, d;
	std::cin >> a >> b >> c >> d;

	std::string s = "Balanced";
	if( ( a + b ) > ( c + d ) ) {
		s = "Left";
	}
	if( ( a + b ) < ( c + d ) ) {
		s = "Right";
	}

	std::cout << s << std::endl;
	return 0;
}



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

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

	int a,b;
	cin >> a >> b;

	cout << a*b << " " << a+b+a+b << endl;
	return 0;
}



Measured memory_bytes: 3180
#include <stdio.h>

int main(void)
{
	int soukei,s,a;
	soukei=0;
	for(s=1;s<11;s++){
		scanf("%d",&a);
		soukei=soukei+a;
	}
	printf("%d\n",soukei);
	
	return 0;
}


Measured memory_bytes: 2112
N=int(input())
A=list(map(int,input().split()))

def check(a):
    cnt=0
    for i in range(10**9):
        if a%2==0:
            cnt+=1
            a=a//2
        else:
            break
    return cnt
ans=0
for i in range(N):
    ans+=check(A[i])

print(ans)


Measured memory_bytes: 4148
#include <stdlib.h> 
#include <stdio.h>
#include <iostream>


using namespace std; 

int main()
{
    int x1,x2,x3,x4,x5;
    int arr[5];

    cin>>x1;
    cin>>x2;
    cin>>x3;
    cin>>x4;
    cin>>x5;

    arr[0] = x1;
    arr[1] = x2;
    arr[2] = x3;
    arr[3] = x4;
    arr[4] = x5;  

    for ( int i = 0; i < 5 ; i++)
    {
        if(arr[i] == 0) cout<<i+1;
    }


}



Measured memory_bytes: 3624
#### import ####
import sys
sys.setrecursionlimit(10**7)
import math
from collections import defaultdict

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

N = I()
a = [0] + III()

from heapq import heapify,heappush,heappop
red = [0]*(3*N+1)
blue = [0]*(3*N+1)

q1 = a[1:N+1]
red[N] = sum(q1)
heapify(q1)

for k in range(N+1,2*N+1):
  heappush(q1,a[k])
  red[k] = red[k-1] + a[k] -q1[0]
  heappop(q1)

q2 = a[2*N+1:3*N+1]
blue[2*N] = sum(q2)
q2 = [(-x,x) for x in q2]
heapify(q2)

for k in range(N,2*N)[::-1]:
  heappush(q2,(-a[k+1],a[k+1]))
  blue[k] = blue[k+1] + a[k+1] -q2[0][1]
  heappop(q2)
  
ans = -float('inf')
for i in range(N,2*N+1):
  temp = red[i]-blue[i]
  if temp > ans:
    ans = temp
print(ans)

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

int main(){
    unsigned int a_pos=0,p_pos=0;
    string sent;

    getline(cin,sent);

    for(int i=0;i+4<sent.length();i++){
        if(sent.substr(i,5) == "apple"){
            sent.replace(i,5,"peach");
        }else if(sent.substr(i,5) == "peach"){
            sent.replace(i,5,"apple");
        }
    }

    cout<<sent<<endl;
    return 0;
}

Measured memory_bytes: 1184
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		if(r < 1200) {
			System.out.println("ABC");
		} else if(r < 2800) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}
	}
}


Measured memory_bytes: 23764
w = int(input())
n = int(input())
ans = [0 for i in range(w)]
list = []

for i in range(n):
    ll = input().split(",")
    a, b = ll[0], ll[1]
    a = int(a)
    b = int(b)
    list.append([a,b])

# print(list)
for i in range(1,w+1):
    position = i-1

    for ll in list:
        a, b = ll[0], ll[1]
        if position == a-1:
            position = b-1
        elif position == b-1:
            position = a-1
        else:
            pass
    ans[position] = i
for j in ans:
    print(j)

Measured memory_bytes: 7644
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n = II()
ans = 0
for _ in range(n):
    x, u = LS()
    x = float(x)
    if u == 'BTC':
        x *= 380000
    ans += x
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
  int n;
  scanf("%d",&n);
  
  int a[n+1];
  int b[n];
  
  for(int i = 0;i<n+1;i++){
    scanf("%d",&a[i]);
  }
  for(int j = 0;j<n;j++){
    scanf("%d",&b[j]);
  }
  long long s=0;
  for(int m = n-1;m>=0;m--){
    if(a[m+1] >b[m]){
      s = s+b[m]; 
      b[m] = 0;
    }else{
      s = s+a[m+1];
      b[m] = b[m]-a[m+1];
    }
    if(b[m]>0){
      if(b[m]>a[m]){
        s = s+a[m];
        a[m] = 0;
      }else{
        s = s +b[m];
        a[m] = a[m]-b[m];
      }
    }//ifbm
  }//for
  printf("%lld\n",s);
  
  return 0;
}
      


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

int H,W;
char F[110][110];
int del[110][110];

int main(){
    cin >> H >> W;
    for(int i=1;i<=H;i++) for(int j=1;j<=W;j++) cin >> F[i][j];
    for(int i=1;i<=H;i++){
        bool ok = true;
        for(int j=1;j<=W;j++) if(F[i][j]=='#') ok = false;
        if(ok) for(int j=1;j<=W;j++) del[i][j] = 1;
    }
    for(int j=1;j<=W;j++){
        bool ok = true;
        for(int i=1;i<=H;i++) if(F[i][j]=='#') ok = false;
        if(ok) for(int i=1;i<=H;i++) del[i][j] = 1;
    }
    for(int i=1;i<=H;i++){
        bool printed = false;
        for(int j=1;j<=W;j++) if(!del[i][j]){
            cout << F[i][j]; printed = true;
        }
        if(printed) cout << endl;
    }
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> s;
    for (int i = 0; i < n; ++i) {
        string temp;
        cin >> temp;
        if(temp.front() == 'M' ||
                temp.front() == 'A' ||
                temp.front() == 'R' ||
                temp.front() == 'C' ||
                temp.front() == 'H')
        {
            s.push_back(temp);
        }
    }
    long long int ms = 0, as = 0, rs = 0, cs = 0, hs = 0;
    for (int i = 0; i < s.size(); ++i) {
        //cout << s[i] << endl;
        if(s[i][0] == 'M')
        {
            ms++;
        }else if(s[i][0] == 'A')
        {
            as++;
        }else if(s[i][0] == 'R')
        {
            rs++;
        }else if(s[i][0] == 'C')
        {
            cs++;
        }else if(s[i][0] == 'H')
        {
            hs++;
        }
    }
    //cout << ms << " " << as << " " << rs << " " << cs  << " " << hs << endl;
    int available  = 0;
    if(ms != 0) available++;
    if(as != 0) available++;
    if(rs != 0) available++;
    if(cs != 0) available++;
    if(hs != 0) available++;

    //cout << available << endl;

    auto comb = [](int x, int y)
    {
        ///xからy個選ぶ xCy
        long long int tempy = 1;
        for (long long int i = 1; i <= y; ++i) {
            tempy *= i;
        }
        long long int tempx = x;
        for (long long int i = x - 1; i >= x - y + 1; i--) {
            tempx *= i;
        }
        return tempx / tempy;
    };
    if(available < 3)
    {
        cout << 0 << endl;
    }else{
        long long int result = 0;
        ///m a r
        if(ms != 0 && as != 0 && rs != 0)
        {
            result += ms * as * rs;
        }
        ///m a c
        if(ms != 0 && as != 0 && cs != 0)
        {
            result += ms * as * cs;
        }
        ///m a h
        if(ms != 0 && as != 0 && hs != 0)
        {
            result += ms * as * hs;
        }
        ///m r c
        if(ms != 0 && rs != 0 && cs != 0)
        {
            result += ms * rs * cs;
        }
        ///m r h
        if(ms != 0 && rs != 0 && hs != 0)
        {
            result += ms * rs * hs;
        }
        ///m c h
        if(ms != 0 && cs != 0 && hs != 0)
        {
            result += ms * cs * hs;
        }
        ///a r c
        if(as != 0 && rs != 0 && cs != 0)
        {
            result += as * rs * cs;
        }
        ///a r h
        if(as != 0 && rs != 0 && hs != 0)
        {
            result += as * rs * hs;
        }
        ///a c h
        if(as != 0 && cs != 0 && hs != 0)
        {
            result += as * cs * hs;
        }
        ///r c h
        if(rs != 0 && cs != 0 && hs != 0)
        {
            result += rs * cs * hs;
        }
        cout << result << endl;
    }
    return 0;
}


Measured memory_bytes: 5748
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

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

	int64_t x, k, d; cin >> x >> k >> d;
	x = abs(x);

	int64_t r = x / d;
	if (k < r) {
		cout << x - (k * d) << endl;
		return 0;
	}

	int64_t r2 = x % d;
	if ((k - r) & 1) {
		cout << d - r2 << endl;
	}
	else {
		cout << r2 << endl;
	}

	return 0;
}

Measured memory_bytes: 3648
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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; }

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

    int N, M;
    cin >> N >> M;

    vs A(N);
    rep(i, N) cin >> A[i];

    vs B(M);
    rep(i, M) cin >> B[i];


    rep(n, N)
    {
        rep(i, N - M + 1)
        {
            bool flg = true;

            auto pos = A[n].find(B[0], i);

            if (pos == std::string::npos) break;

            //2行目以降をチェック
            repl(j, 1, M)
            {
                auto pos2 = A[i + j].find(B[j], i);

                if (pos2 != pos)
                {
                    flg = false;
                    break;
                }
            }

            if (flg)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+9;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL my_pow(int x, int y){
	LL a=1;
	REP(i,y){
		a *= x;
		a %= MOD;
	}
	return a % MOD;
}

LL gcd(LL a, LL b){
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

LL lcm(LL a, LL b){
    return a * b / gcd(a, b);
}
void Main()
{
	int a,b;
	cin>>a>>b;

	cout << lcm(a,b) << endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

typedef long long ll;

int main()
{
    ll n;
    scanf("%lld",&n);
    ll lim = sqrt(n)+1;
    ll res = 0;
    for(ll i=2;i<lim;i++) {
        ll cnt = 0;
        ll top = 1;
        while(n%i == 0) {
            n/=i;
            cnt++;
            if(cnt >= top) {
                cnt -= top;
                top++;
                res++;
            }
        }
    }
    if(n!=1) res++;
    cout << res << endl;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long ll;
const int mod=1e+9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
mint modpow(mint a,int n){
    mint r=1;
    while(n){
        r=r*((n%2)?a:1);
        a*=a;
        n>>=1;
    }
    return r;
}
int main(){
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    //エラトステネスの篩
    map<int,int> mp;
    rep(i,n){
        map<int,int> mpp;
        int buf=a[i];
        for(int i=2;i*i<=buf;i++){
            while(buf%i==0){
                buf/=i;
                mpp[i]++;
            }
        }
        if(buf>1) mpp[buf]++;
        for(auto& p:mpp){
            mp[p.first]=max(p.second,mp[p.first]);
        }
    }
    mint lcm=1;
    for(auto& p:mp){
        lcm*=modpow(p.first,p.second);
    }
    mint res=0;
    rep(i,n){
        res+=lcm*modpow(a[i],mod-2);
    }
    cout<<res.x<<endl;
}

Measured memory_bytes: 768
import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
    aa = bisect.bisect_left(a,b[i])
    ca = n-bisect.bisect_right(c,b[i])
    ans += aa * ca
print(ans)


Measured memory_bytes: 29248
import sys
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(200000)
N=int(input())
s=[[]for i in range(N)]
c=[None]*N
for i in range(N-1):
    u,v,w=map(int,input().split())
    s[v-1].append((u,w%2))
    s[u-1].append((v,w%2))
def mu(n,l,co):
    for i in l:
        if c[i[0]-1]==None:
            if co==i[1]%2:
                c[i[0]-1]=0
                mu(i,s[i[0]-1],0)
            else:
                c[i[0]-1]=1
                mu(i,s[i[0]-1],1)
mu(1,s[0],0)
print(*c,sep="\n")

Measured memory_bytes: 76464
using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		new Sol().Solve();
	}
}

class Sol{
	public void Solve(){
		
		while(true){
			var d=ria();
			N=d[0];M=d[1];P=d[2];
			if(N==0&&M==0&&P==0)return;
			int Inf=(int)1e9;
			int[][] WF=new int[N][];
			for(int i=0;i<N;i++){
				WF[i]=new int[N];
				for(int j=0;j<N;j++){
					WF[i][j]=(i==j)?0:Inf;
				}
			}
			
			E=new List<Pair>[N];
			for(int i=0;i<N;i++)E[i]=new List<Pair>();
			
			for(int i=0;i<M;i++){
				d=ria();
				E[d[0]].Add(new Pair(d[1],d[2]));
				E[d[1]].Add(new Pair(d[0],d[2]));
				WF[d[0]][d[1]]=WF[d[1]][d[0]]=d[2];
			}
			
			for(int k=0;k<N;k++){
				for(int i=0;i<N;i++){
					for(int j=0;j<N;j++){
						WF[i][j]=Math.Min(WF[i][j],WF[i][k]+WF[k][j]);
					}
				}
			}
			
			//0->N-1???????????????????????????????????§??????????????????
			//???????????????
			Pair[] tmp=new Pair[N];
			for(int i=0;i<N;i++){
				tmp[i]=new Pair(i,WF[i][N-1]);//???->N-1??????????????¢
			}
			Array.Sort(tmp,(x,y)=>x.Cost>y.Cost?-1:x.Cost<y.Cost?1:0);
			
			double[] dp=new double[N];//dp[i]:0??????i???????????????????????°
			dp[0]=1;
			for(int i=0;i<N;i++){
				int now=tmp[i].Pos;
				foreach(var next in E[now]){
					if(WF[now][N-1]==next.Cost+WF[next.Pos][N-1]){
						dp[next.Pos]+=dp[now];
					}
				}
			}
			for(;P>0;P--){
				int c=ri();
				double[] dp2=new double[N];//dp2[i]:c??????i???????????????????????°
				dp2[c]=1;
				for(int i=0;i<N;i++){
					int now=tmp[i].Pos;
					foreach(var next in E[now]){
						if(WF[now][N-1]==next.Cost+WF[next.Pos][N-1]){
							dp2[next.Pos]+=dp2[now];
						}
					}
				}
				Console.WriteLine("{0:F12}",((double)dp[c]/(double)dp[N-1])*(double)dp2[N-1]);
			}
			Console.WriteLine();
		
		}
	}
	
	int N,M,P;
	List<Pair>[] E;
	
	class Pair{
		public int Pos,Cost;
		public Pair(int p,int c){
			Pos=p;Cost=c;
		}
	}
	
	
	

	public Sol(){
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

Measured memory_bytes: 6776
#include<cstdio>

int n;

int main()
{
	scanf("%d", &n);
	int a = 0;
	for (int s = 0; s < n; s++)
	{
		int b; scanf("%d", &b);
		a ^= b;
	}
	if (a) printf("No\n");
	else printf("Yes\n");
}


Measured memory_bytes: 128
s = input()

n = len(s)

l = s[:int((n)/2)]
r = s[int((n)/2)+1:]


if l != r:
    print("No")
    exit()

lr = l[::-1]
rr = r[::-1]

if lr != l or rr != r:
    print("No")
    exit()

print("Yes")

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
	int N;
	cin >> N;
	string ans;
	if (N == 0) {
		cout << 0 << endl;
		return;
	}
	while(N != 0) {
		if (N & 1) {
			ans += '1';
			N--;
		} else {
			ans += '0';
		}
		N /= -2;
	}
	reverse(all(ans));
	cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int main(){
  int ans = 0;
  rep(i,3){
    int t; cin >> t;
    ans += t;
  }
  
  if(ans >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
  
  return 0;
}

Measured memory_bytes: 256