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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 5000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int a[N][N];
int b[N][N];
vector<char> var = {'R', 'Y', 'G', 'B'};

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    int n, m, d;
    cin >> n >> m >> d;
    if (d % 2 == 1)
    {
        rep(i, 0, n)
        {
            rep(j, 0, m)
                cout << var[i % 2 * 2 + j % 2];
            cout << "\n";
        }
        return 0;
    }
    rep(i, 0, N)
        rep(j, 0, N)
            a[i][j] = (i / d) % 2 * 2 + (j / d) % 2;
    rep(i, 0, N)
        rep(j, 0, N)
            if ((i + j) % 2 == 0)
            {
                int x = (i + j) / 2, y = (i - j) / 2;
                if (x >= 0 && x < N && y >= 0 && y < N)
                    b[x][y] = a[i][j];
            }
    rep(i, 0, n)
    {
        rep(j, 0, m)
            cout << var[b[2000 + i][j]];
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 194304
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;

static const double eps = 1e-8;

inline double dist(double dx, double dy) { return sqrt(dx*dx + dy*dy); }

int main()
{
  int n, x[400], y[400], visited[400];

  while (scanf("%d", &n), n) {
    memset(visited, false, sizeof(visited));
    for (int i = 0; i < n; ++i) {
      scanf("%d%d", x+i, y+i);
    }

    int curr_x = 0, curr_y = 0;
    int prev_x = 0, prev_y = -1;
    double length = 0;

    for (int i = 0; i < n; ++i) {
      int dx1 = curr_x - prev_x;
      int dy1 = curr_y - prev_y;
      int dist1 = dist(dx1, dy1);

      double max_cos = -2.0;
      double min_dist;
      int index;

      for (int j = 0; j < n; ++j) {
        if (visited[j])
          continue;

        int dx2 = x[j] - curr_x;
        int dy2 = y[j] - curr_y;
        double dist2 = dist(dx2, dy2);
        double cos = (dx1*dx2 + dy1*dy2) / (dist1 * dist2);

        if (cos - max_cos > eps || (fabs(cos - max_cos) < eps && dist2 < min_dist)) {
          max_cos = cos;
          min_dist = dist2;
          index = j;
        }
      }

      prev_x = curr_x;
      prev_y = curr_y;
      curr_x = x[index];
      curr_y = y[index];
      visited[index] = true;
      length += min_dist;
    }

    printf("%.1lf\n", length);
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N+1, 0), B(M+1, 0);
    for(int i=0; i<N; ++i) cin >> A[i];
    for(int j=0; j<M; ++j) cin >> B[j];
    sort(begin(A), end(A), greater<int>());
    sort(begin(B), end(B), greater<int>());

    long long res = 1;
    int a = 0, b = 0;
    for(int x=N*M; x>0; --x) {
        if(A[a] > x || B[b] > x) {
            cout << 0 << endl;
            return 0;
        }
        
        long long tmp;
        if(A[a] == x && B[b] == x) {
            ++a;
            ++b;
            tmp = 1;
        } else if(A[a] == x) {
            ++a;
            tmp = b;
        } else if(B[b] == x) {
            ++b;
            tmp = a;
        } else {
            tmp = a * b - (N * M - x);
            if(tmp <= 0) {
                cout << 0 << endl;
                return 0;
            }
        }

        res = (res * tmp) % MOD;
    }

    cout << res << endl;
}

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

using namespace std;

typedef long long int ll;

#define FOR(i,l,r) for(i=l;i<r;i++)

#define REP(i,n) FOR(i,0,n)

#define ALL(x) x.begin(),x.end()

#define P pair<ll,ll>

#define F first

#define S second

signed main(){

  ll X,i=100,ans=0;cin>>X;

  while(i<X){
    ans++;
    i+=i/100;
  }
  cout<<ans<<endl;

  return 0;

}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
using namespace std;
int deg[110001],v[110001],i,j,k,n,m;
struct scmp{
	bool operator() (int x,int y){
		return deg[x]<deg[y]||deg[x]==deg[y]&&x<y;
	}
};
set<int> g[110001];
set<int,scmp> s;
set<int>::iterator it;
void work(int x){
	int j,k;
	k=*g[x].begin();s.erase(k);v[k]=1;
	for (it=g[k].begin();it!=g[k].end();it++){
		j=*it;
		if (v[j]) continue;
		s.erase(j);deg[j]--;s.insert(j);
		g[j].erase(k);
	}
}
int main(){
	scanf("%d",&n);
	for (i=1;i<=n;i++) deg[i]=v[i]=0,g[i].clear();
	for (i=1;i<n;i++) scanf("%d%d",&j,&k),deg[j]++,deg[k]++,g[j].insert(k),g[k].insert(j);
	s.clear();
	for (i=1;i<=n;i++) s.insert(i);
	while (!s.empty()){
		k=*s.begin();s.erase(k);v[k]=1;
		if (!deg[k]){
			puts("First");return 0;
		}
		if (deg[k]>1) break;
		work(k);
	}
	puts("Second");
	return 0;
}

Measured memory_bytes: 20224
n,k = map(int,raw_input().split())
l = []
s = list()
for i in range(n):
    v,count = map(int,raw_input().split())
    l.append((count,v))

l = sorted(l, key=lambda x: x[1])

countTmp = 0
for count,v in l:
    countTmp = countTmp + count
    if k <= countTmp:
       print v
       break
       

Measured memory_bytes: 22004
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define reps(i,o,n) for(int i=o;i<n;++i)
#define eb emplace_back
#define pb push_back
#define X first
#define Y second
#define all(X) X.begin(), X.end()

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

int main(){
  ios_base::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  int n;
  cin>>n;
  vector<pair<string,int>> ps(n);
  rep(i,n) cin>>ps[i].X, ps[i].Y=i;
  sort(all(ps));
  vector<int> re(n);
  for(auto p:ps){
    int l=lower_bound(all(ps),make_pair(p.X,0))-ps.begin();
    int r=lower_bound(all(ps),make_pair(p.X,n))-ps.begin();
    re[p.Y]=l*2+r-1;
  }
  rep(i,n) cout<<re[i]<<"\n";
  return 0;
}

Measured memory_bytes: 8844
#include<cstdio>
#include<cstring>
using namespace std;
long long n;
char num[100];
#ifdef WIN32
#define lld "%I64d"
#else
#define lld "%lld"
#endif
int main()
{
	long long ans=0;
	scanf(lld,&n);
	sprintf(num,lld,n);
	ans=1ll*(strlen(num)-1)*9;
	if((n+1)%10==0)ans++;
	ans+=num[0]-'0'-1;
	if(n<10)ans=n;
	printf(lld"\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
   ll n,i,c=0,c1=0;
  cin>>n;
  vector<pair<int,int>> v(n);
  for(i=0;i<n;i++) {
  cin>>v[i].first>>v[i].second;
  }
  for(i=0;i<n;i++) {
  if(v[i].first==v[i].second) c++;
   else{
     if(c>=3){
       c=0;c1=1;
     break;
     }
     c=0;}
  }
  if(c!=0){
      if(c>=3){
          c1=1;c=0;
      }
  }
  if(c1==1) cout<<"Yes";
  else cout<<"No";
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];



void solve() {
  int x,a; cin >> x >> a;
  if (x < a) cout << 0 << endl;
  else cout << 10 << endl;
}

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





Measured memory_bytes: 256
import collections
n = int(input())
line = list(map(int, input().split( )))
arr = sorted(line)
coll = collections.Counter(arr)
#最大値
Ma = arr[-1]
#ソートしたn番目のやつの判定はn+1以降でおっけい. 
#同じ数字がある敵は無視
s = set()
for i in range(n):
  if coll[arr[i]] >= 2:
    s.add(arr[i])
  for j in range(2, Ma//arr[i]+1):
    s.add(arr[i]*j)
cnt = 0

#print(s)
for a in arr:
  if a in s: continue
  cnt += 1
print(cnt)

Measured memory_bytes: 94228
#include<cstdio>
#include<algorithm>

using namespace std;

int N;
int X[200000];
int Y[200000];
int main() {
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) {
        scanf("%d", X+i);
    }
    for(int i = 0; i < N; ++i) {
        Y[i] = X[i];
    }
    sort(Y, Y+N);
    int mean = Y[N/2];
    for(int i = 0; i < N; ++i) {
        if(X[i] >= mean) {
            printf("%d\n", Y[N/2-1]);
        }
        else {
            printf("%d\n", mean);
        }
    }
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n;
  cin >> n;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];

  int ans = 0;

  for (int i = 0; i < n; ++i) {
    bool flag = true;
    for (int j = 0; j < i; ++j) {
      if (i == j) continue;
      if (h[i] < h[j]) {
        flag = false;
        break;
      }
    }
    if (flag) ans += 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
a, b, c = input(), input(), input()
mode = 'a'
while(1):
    if mode == 'a':
        if a == '':
            ans = 'A'
            break
        mode = a[0]
        a = a[1:]
    elif mode == 'b':
        if b == '':
            ans = 'B'
            break
        mode = b[0]
        b = b[1:]
    elif mode == 'c':
        if c == '':
            ans = 'C'
            break
        mode = c[0]
        c = c[1:]
print(ans)

Measured memory_bytes: 3064
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')



def convertToTitle(num):
    capitals = [chr(x) for x in range(ord('a'), ord('z')+1)]
    result = []
    while num > 0:
        result.append(capitals[(num-1)%26])
        num = (num-1) // 26
    result.reverse()
    return ''.join(result)

n=ii()
print(convertToTitle(n))


















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

int main(void){
    int N, abuf;
    vector<int> a;
    cin >> N;
    int suma = 0;
    for(int i=0; i<N; i++){
        cin >> abuf;
        a.push_back(abuf);
        suma = suma^abuf;
    }
    for(int i=0; i<N-1; i++){
        cout << (suma^a[i]) << " ";
    }
    cout << (suma^a[N-1]) << endl;
    return 0;
}

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

using namespace std;

void showArray(vector<int> a, int n) {
    for (int i=0; i<n; i++) {
        cout << a[i] << ' ';
    } cout << endl;
}

void showArray(int a[], int n) {
    for (int i=0; i<n; i++) {
        cout << a[i] << ' ';
    } cout << endl;
}

int main() {
    int n;
    int a, b;
    cin >> n;
    if (n == 1) {
        cout << "Hello World" << endl;
    } else {
        cin >> a >> b;
        cout << a+b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
D = int(input())
c = list(map(int, input().split()))
last = [0] * 26
ans = []
S = []
prev_score = 0
maxsi_list = []

for d in range(1, D+1):
    s = list(map(int, input().split()))
    S += [s]
    maxs = float('-inf')
    maxss = float('-inf')
    maxi = -1
    maxii = -1
    cumsump = 0
    for i in range(26):
        tmp = -c[i] * (d - last[i])
        cumsump += tmp
    for i in range(26):
        tmp = -c[i] * (d - last[i])
        tmp2 = s[i] + cumsump - tmp
        if tmp2 > maxs:
            maxs = tmp2
            maxi = i
        if s[i] > maxss:
            maxii = i
            maxss = s[i]
    ans += [maxi+1]
    last[maxi] = d
    prev_score += maxs
    maxsi_list += [maxii+1]

for tt in range(31):
    for dd in range(D):
        last = [0] * 26
        score = 0
        for d in range(1, D+1):
            if dd == (d-1):
                maxc = 0
                maxci = -1
                for i in range(26):
                    cost = c[i] * (d - last[i])
                    if maxc < cost:
                        maxc = cost
                        maxci = i+1
                prev_a = ans[dd]
                ans[dd] = maxci
            td = ans[d-1] - 1
            cumsump = 0
            for i in range(26):
                if td != i:
                    tmp = -c[i] * (d - last[i])
                    cumsump += tmp
            last[td] = d
            score += S[d-1][td]+cumsump
        if score <= prev_score:
            ans[dd] = prev_a
        else:
            prev_score = score

    for dd in range(D):
        last = [0] * 26
        score = 0
        prev_a = ans[dd]
        ans[dd] = maxsi_list[dd]
        for d in range(1, D+1):
            td = ans[d-1] - 1
            cumsump = 0
            for i in range(26):
                if td != i:
                    tmp = -c[i] * (d - last[i])
                    cumsump += tmp
            last[td] = d
            score += S[d-1][td]+cumsump
        if score <= prev_score:
            ans[dd] = prev_a
        else:
            prev_score = score

for a in ans:
    print(a)

Measured memory_bytes: 78080
def main():
    def f(c, n):
        chars = [chr(i) for i in range(ord('A'), ord('Z')+1)]
        p = (chars.index(c) + n) % 26
        return chars[p]

    N = int(input())
    S = input()
    ans = ''
    for si in S:
        ans += f(si, N)
    print(ans)

    
  

if __name__ == "__main__":
    main()

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

int main(){
  int N,D;
  cin >> N >> D;
  vector< vector<int> > X(N,vector<int>(D));
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin >> X.at(i).at(j);
    }
  }
  int ans=0;
  double p;
  bool flag=true;
  int sum=0;
  double sq;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      for(int k=0;k<D;k++){
        p=pow(X.at(i).at(k)-X.at(j).at(k),2);
        if((int)p!=p){
          flag=false;
          break;
        }else{
          sum+=p;
        }
      }
      if(flag){
        sq=pow(sum,0.5);
        if((int)sq==sq){
          ans++;
        }
      }else{
        flag=true;
      }
      sum=0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;

int main()
{
	int N;
	string S,T;
	cin>>N>>S>>T;
	rep(i,N)cout<<S[i]<<T[i];
	cout<<endl;
	return 0;
}


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

using namespace std;


int main() {
	int n;cin >> n;
  	vector<int> input(n);
  	for(int & x : input)
      cin >> x;
  
  	long long ans = 0;
  	for(int i = 0;i < n; ++i)
      for(int j = i + 1;j < n; ++j)
        ans += input[i] * input[j];
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;

	int a[3*n];
	for(int i=0;i<3*n;i++) cin >> a[i];
	
	sort(a,a+3*n,greater<int>());

	ll ans=0;
	for(int i=0;i<n;i++){
		ans+=a[i*2+1];
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1408
/**
 * author:    Ziel
 * created:   13.04.2020 10:06:43
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin, x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define bpc __builtin_popcountl
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const db EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

inline ll pw(ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

main() {
#ifdef ZVER
	cerr << "Ready\n";
#endif
	fre("");
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	ll n, a, b;
	cin >> n >> a >> b;
	
	ll ans = pw(2, n) - 1;
	
	ll res = 1;
	for (int i = 1; i <= a; i++)
		res = res * ll(n - a + i) % MOD * pw(i, MOD - 2) % MOD;
	ans -= res;
	if (ans < 0) ans += MOD;
	res = 1;
	for (int i = 1; i <= b; i++)
		res = res * ll(n - b + i) % MOD * pw(i, MOD - 2) % MOD;
	ans -= res;
	if (ans < 0) ans += MOD;
	
	cout << ans;
	return 0;
}

// uniform_int_distribution<int>(l, r)(rng) -> random in range [l, r]
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation


Measured memory_bytes: 256
n = int(input())
num_list = list(map(int, input().split()))
sum_ = 0
for i in num_list:
    sum_ += i
mean = sum_ / n
min_ = 1000000000000000
for i in range(n):
    if abs(mean - num_list[i]) < min_:
        min_ = abs(mean - num_list[i])
        thumbnail = i
print(thumbnail)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
		printf("Possible");
	else
		printf("Impossible");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef vector<int> vi;
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
const int MAXN = 5050;
const int INF = 0x3f3f3f3f;
int dp[MAXN][MAXN];
vector<pii> prt;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n;
	cin >> n;
	rep (i, 1, n) {
		int h, p;
		cin >> h >> p;
		prt.emplace_back(h, p);
	}
	sort(all(prt), [&] (pii a, pii b) {
		return a.fst + a.sed < b.fst + b.sed;
	});
	memset(dp, -1, sizeof(dp));
	dp[0][0] = 0;
	auto chkMin = [&] (int & a, int b) {
		a = ~a ? min(a, b) : b;
	};
	int res = 0;
	rep (i, 1, n) {
		int h = prt[i - 1].fst;
		int p = prt[i - 1].sed;
		rep (j, 0, i - 1) if (~dp[i - 1][j]) {
			chkMin(dp[i][j], dp[i - 1][j]);
			if (dp[i - 1][j] <= h) {
				res = max(res, j + 1);
				chkMin(dp[i][j + 1], dp[i - 1][j] + p);
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 100096
#include<bits/stdc++.h>
using namespace std;
#define mx 100000
#define md 1000000007ll

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

    vector<int>ar[m+2];
    for(int i=1;i<=m;i++){
        int x;
        cin>>x;
        for(int j=0;j<x;j++){
            int y;
            cin>>y;
            ar[i].push_back(y);
        }
    }
    int p[m+2];
    for(int i=1;i<=m;i++)cin>>p[i];
    int res=0;
    for(int i=0;i<(1<<n);i++){
        bool fl =0;
        for(int j=1;j<=m;j++){
            int cnt = 0;
            for(int k=0;k<ar[j].size();k++){
                int f =ar[j][k]-1;

                if((i&(1<<f)))cnt++;
            }
            if(cnt%2!=p[j])fl=1;

        }
        if(!fl)res++;
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int h, w, n;
int a[114514];
int c[105][105];
signed main() {
	cin >> h >> w >> n;
	rep(i, n) {
		cin >> a[i];
	}
	int memo = 0;
	rep(i, h) {
		if (i % 2 == 0) {
			rep(j, w) {
				c[i][j] = memo;
				a[memo]--;
				if (a[memo] == 0)memo++;
			}
		}
		else {
			for (int j = w - 1; j >= 0; j--) {
				c[i][j] = memo;
				a[memo]--;
				if (a[memo] == 0)memo++;
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << c[i][j] + 1 << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 512
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;
#define SIZE 262144
typedef long long ll;
#define INF 1000000000000000000LL
class segtree
{
public:
	ll seg[SIZE * 2];
	void update(int a, ll b)
	{
		a += SIZE;
		seg[a] = b;
		for (;;)
		{
			a /= 2;
			if (a == 0)break;
			seg[a] = min(seg[a * 2], seg[a * 2 + 1]);
		}
	}
	ll get(int beg, int end, int node, int lb, int ub)
	{
		if (ub < beg || end < lb)return INF;
		if (beg <= lb&&ub <= end)return seg[node];
		return min(get(beg, end, node * 2, lb, (lb + ub) / 2), get(beg, end, node * 2 + 1, (lb + ub) / 2 + 1, ub));
	}
};
segtree tree1, tree2;
ll dp[SIZE];
int main()
{
	int num, query, s1, s2;
	scanf("%d%d%d%d", &num, &query, &s1, &s2);
	s1--, s2--;
	int bef = s2;
	fill(dp, dp + num, INF);
	dp[s1] = 0;
	for (int i = 0; i < num; i++)tree1.update(i, dp[i] + i);
	for (int i = 0; i < num; i++)tree2.update(i, dp[i] - i);
	ll dif = 0;
	for (int p = 0; p < query; p++)
	{
		int z;
		scanf("%d", &z);
		z--;
		ll t1 = tree2.get(0, z, 1, 0, SIZE - 1) + dif + z;
		ll t2 = tree1.get(z, num - 1, 1, 0, SIZE - 1) + dif - z;
		dif += abs(z - bef);
		if (dp[bef] + dif > min(t1, t2))
		{
			dp[bef] = min(t1, t2) - dif;
			tree1.update(bef, dp[bef] + bef);
			tree2.update(bef, dp[bef] - bef);
		}
		bef = z;
	}
	ll mini = INF;
	for (int i = 0; i < num; i++)mini = min(mini, dp[i] + dif);
	printf("%lld\n", mini);
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef priority_queue<double, vector<double>, less<double> > QUE_double;
typedef priority_queue<int, vector<int>, less<int> > QUE_int;//lessは大きい順にならべるよ
const int MAX = pow(10, 5)+1;//+1しないとREになる(out of rangeになるんかな?? )

ll g1(ll n, int p){// n!を素因数分解したときに 素因数pの個数を求める関数
  if(n == 0) return 0;
  return n/p + g1(n/p, p);
}

ll g2(ll n, int p){// n!!を素因数分解したときに 素因数pの個数を求める関数
  if(n%2 == 1) return g1(n,p) - g2(n-1,p);//nが奇数なら...
  
  ll num = g1(n/2,p);
  if(p==2) num += n/2;//素数ｐ=2の時は n/2を足す
  return num;
}

int main(){
  ll N;
  cin >> N;
  
  //cout << " g1(10, 5): " << g1(10, 5) << endl;
  //cout << " g2(10, 5): " << g2(10, 5) << endl;
  //ll ans = g2(N, 5); //答えは N!! を　素因数分解したときの 因数5の個数 
  ll ans = min(g2(N, 2), g2(N, 5));//↑だと奇数のときも解が1以上になってしまう
  cout << ans << endl; 
  
}



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

typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9+10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert
#define era erase
typedef vector<int> vi;
typedef queue<int> qi;
typedef greater<int> gi;
typedef priority_queue<int> pqi;
typedef priority_queue<int,vi,gi> pqgi;

int read() {
	int xx=0,ww=1;
	char ch=getchar();
	while(ch>'9'||ch<'0') {
		if(ch=='-') ww=-ww;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		xx=10*xx+ch-48;
		ch=getchar();
	}
	return xx*ww;
}

int n,a,b;
int p[110];
int ans1,ans2,ans3,ans;

int main() {
	n=read();
	a=read();
	b=read();
	for(int i=1;i<=n;i++) p[i]=read();
	for(int i=1;i<=n;i++)
		if(p[i]<=a) ans1++;
		else if(p[i]>a&&p[i]<=b) ans2++;
		else ans3++;
	ans=min(ans1,min(ans2,ans3));
	printf("%d\n",max(ans,0));
	return 0;
}


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

int main()
{
	int a1;
	std::cin >> a1;

	std::vector< uint64_t > vec( a1 );

	for( auto &it : vec )
	{
		std::cin >> it;
	}

	std::sort( vec.begin(), vec.end() );

	bool diffs = true;
	bool oneshot = false;
	uint64_t old = 0;

	for( auto &it : vec )
	{
		if( oneshot )
		{
			if( old == it )
			{
				diffs = false;
				break;
			}
		}
		else
		{
			oneshot = true;
		}
		old = it;
	}

	std::cout << ( diffs ? "YES" : "NO" ) << std::endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAX 1400

int getLargestSquare( int H, int W, int G[MAX][MAX] ) {
  int dp[MAX][MAX];
  int maxWidth = 0;
  for ( int i = 0; i < H; i++ )
    for ( int j = 0; j < W; j++ ) {
      dp[i][j] = (G[i][j] + 1) % 2;
      maxWidth |= dp[i][j];
    }

  for ( int i = 1; i < H; i++ )
    for ( int j = 1; j < W; j++ ) {
      if ( G[i][j] ) {
        dp[i][j] = 0;
      } else {
        dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
        maxWidth = max(maxWidth, dp[i][j]);
      }
    }

  return maxWidth * maxWidth;
}

int main() {
  int H, W, G[MAX][MAX];
  scanf("%d %d", &H, &W);

  for ( int i = 0; i < H; i++ )
    for ( int j = 0; j < W; j++ ) scanf("%d", &G[i][j]);

  printf("%d\n", getLargestSquare(H, W, G));

  return 0;
}


Measured memory_bytes: 18020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

struct UnionFind {
    vector<int> d;
    int cc_cnt;
    UnionFind(int n): d(n, -1) { cc_cnt = n; }
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        cc_cnt--;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

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

    int n,m;
    cin>>n>>m;
    UnionFind uf(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        uf.unite(a,b);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans=max(ans,uf.size(i));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3988
#include <stdio.h>
int main(void) {
  char S[5];
  scanf("%s", S);
  switch (S[1]) {
    case 'B':
      printf("%s\n", "ARC");
      break;
    case 'R':
      printf("%s\n", "ABC");
      break;
  }
  return 0;
}

Measured memory_bytes: 1648
n,q = map(int,input().split())
s = input()
l = [[0,0] for _ in range(q)]
for i in range(q):
    l[i][0],l[i][1] = map(int,input().split())
cnt = [0] * n
for i in range(1,n):
    if s[i] == 'C' and s[i-1] == 'A':
        cnt[i] = cnt[i-1] + 1
    else:
        cnt[i] = cnt[i-1]
cnt.insert(0,0)
for i in range(q):
    print(cnt[l[i][1]]-cnt[l[i][0]])

Measured memory_bytes: 22844
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
const int CHARACTER = 26;
vector<vector<int> > nx_init(const string &str) {
  int n = str.size();
  vector<vector<int> > nx(n, vector<int>(CHARACTER, n));
  nx[n - 1][str[n - 1] - 'a'] = n - 1;
  for (int i = n - 2; i >= 0; --i) {
    REP(j, CHARACTER) nx[i][j] = nx[i + 1][j];
    nx[i][str[i] - 'a'] = i;
  }
  return nx;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s, t; cin >> s >> t;
  auto nx = nx_init(s);
  int n = s.length(), pos = 0;
  long long ans = 0;
  REP(i, t.length()) {
    int now = t[i] - 'a';
    if (nx[0][now] >= n) {
      cout << -1 << '\n';
      return 0;
    }
    if (nx[pos][now] >= n) {
      ans += n - pos;
      pos = 0;
    }
    ans += nx[pos][now] - pos + 1;
    pos = nx[pos][now] + 1;
    if (pos == n) pos = 0;
  }
  cout << ans << '\n';
  return 0;
}


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

int main() {
  ll n; cin>>n;
  vector<ll> v(5);
  rep(i,n){
    string s; cin>>s;
    if(s.at(0)=='M'){v[0]++;}
    if(s.at(0)=='A'){v[1]++;}
    if(s.at(0)=='R'){v[2]++;}
    if(s.at(0)=='C'){v[3]++;}
    if(s.at(0)=='H'){v[4]++;}
  }
  ll a= v[0]*v[1]*(v[2]+v[3]+v[4])
    +v[0]*v[2]*(v[3]+v[4])
    +(v[0]+v[1]+v[2])*v[3]*v[4]
    +v[1]*v[2]*(v[3]+v[4]);
  cout<<a;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(s: [chars]);
    let c = s.iter().filter(|&s| s == &"E869120".chars().collect::<Vec<_>>()).count();
    puts!("{}\n", c);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



Measured memory_bytes: 1600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define de cout<<"siktim seni\n";
ll int a,i,b,ans;
int main(){
	cin>>a>>b;
	if(a>9 or b>9){cout<<"-1";return 0;}
	cout<<(a*b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int n, m, s, t;
vi adj[100001];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
    }
    cin >> s >> t;
    queue<pair<int, int> > q;
    q.emplace(s, 0);
    vector<vi> d(n + 1, vi(3, -1));
    d[s][0] = 0;
    while (!q.empty())
    {
        int x, k;
        tie(x, k) = q.front();
        q.pop();
        for (int y : adj[x])
        {
            if (d[y][(k + 1) % 3] == -1)
            {
                d[y][(k + 1) % 3] = d[x][k] + 1;
                q.emplace(y, (k + 1) % 3);
            }
        }
    }
    if (d[t][0] == -1)
        cout << -1;
    else
        cout << d[t][0] / 3;
}


Measured memory_bytes: 11264
k = int(input())
s = input()
mod = 10**9+7
maxn = 2000005
fact = [0 for i in range(maxn)]
fact[0] = 1
for i in range(1,maxn):
	fact[i] = (i*fact[i-1])%mod
n = len(s)
ans = pow(26,n+k,mod)
for m in range(n):
	calc = (fact[n+k]%mod * pow(fact[m],mod-2,mod))%mod
	calc = (calc * pow(fact[n+k-m],mod-2,mod))%mod
	p = pow(25,n+k-m,mod)
	val = (calc*p)%mod
	ans = (ans-val)%mod
print(ans%mod)

Measured memory_bytes: 207876
#include<iostream>
#include<cmath>
#include<map>
#include<string>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;

string s,t;
int a,b;
string u;
map<string,int>m;
int main(){
    cin>>s>>t;
    cin>>a>>b;
    m[s]+=a;
    m[t]+=b;
    cin>>u;
    m[u]--;
    printf("%d %d",m[s],m[t]);
}

Measured memory_bytes: 256
from math import ceil, floor


def p_d():
    S = input()

    st = 0
    ans = []

    while st < len(S):

        rc = 0
        while st < len(S) and S[st] == "R":
            rc += 1
            st += 1

        lc = 0
        while st < len(S) and S[st] == "L":
            lc += 1
            st += 1

        l = ceil(rc / 2) + lc // 2
        r = rc // 2 + ceil(lc / 2)

        ans.extend([0] * (rc - 1))
        ans.append(l)
        ans.append(r)
        ans.extend([0] * (lc - 1))

    print(*ans)
    
p_d()

Measured memory_bytes: 62012
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    int64_t a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a<0){
        if(b<0){
            if(c<0){
                if(d<0){
                    cout<<a*c<<endl;
                }
                else{
                    cout<<a*c<<endl;
                }
            }
            else{
                cout<<b*c<<endl;
            }
        }
        else{
            if(c<0){
                if(d<0){
                    cout<<a*c<<endl;
                }
                else{
                    cout<<max(a*c,b*d)<<endl;
                }
            }  
            else{
                cout<<b*d<<endl;
            }
        }
    }
    else{
        if(c<0){
            if(d<0){
                cout<<a*d<<endl;
            }
            else{
                cout<<b*d<<endl;
            }
        }
        else{
            cout<<b*d<<endl;
        }
    }
}

Measured memory_bytes: 3632
import sys

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

def main():
    md=10**9+7
    n=II()
    xx=LI()
    fac=[1]*n
    for k in range(1,n):
        fac[k]=fac[k-1]*k%md
    rfac=[n-1]*n
    for k in range(n-2,-1,-1):
        rfac[k]=rfac[k+1]*k%md
    ans=0
    coff=0
    for i,(x0,x1) in enumerate(zip(xx,xx[1:]),1):
        d=x1-x0
        if i+1<n:coff+=fac[i-1]*rfac[i+1]
        else:coff+=fac[i-1]
        #print(coff)
        ans+=d*coff
        ans%=md
    print(ans)

main()

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

int main()
{
    long long int a, b, c, d , sum;
    cin>> a>> b >> c >> d;
    long long int ara[5];
    ara[0]= a*c;
    ara[1]= a*d;
    ara[2]= b*c;
    ara[3]= b*d;
    sort(ara, ara+4);
    sum= ara[3];
    cout<< sum << endl;
    return 0;
}

Measured memory_bytes: 3552
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }


int main() {
    string s, s_;
    cin >> s;

    rep(i, s.size()){
        char c = s[i];
        if(c == '0' || c == '1')
            s_ += c;
        else if (s_.size())
            s_.erase(s_.size() - 1);
    }
    cout << s_ << ln;
}
    


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
#include <cctype>
#include <ctype.h>
#define ll long long
using namespace std;
int main()
{

    ll a, b;
    cin >> a >> b;
    if (a > b)
        swap(a, b);

    for (int i = 1; i <= a; i++)
    {
        if (b * i % a == 0)
        {
            cout << b * i;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;

// Ð¡Ð¸ÑÑ‚ÐµÐ¼Ð° Ð½ÐµÐ¿ÐµÑ€ÐµÑÐµÐºÐ°ÑŽÑ‰Ð¸Ñ…ÑÑ Ð¼Ð½Ð¾Ð¶ÐµÑÑ‚Ð²

const int MAXN = 100000;

int p[MAXN];

void init_dsu(int n) {
	for (int i = 0; i < n; i++)
		p[i] = -1;
}

int find_set(int n) {
    return (p[n] < 0 ? n : p[n] = find_set(p[n]));
}

bool unite(int a, int b) {
    a = find_set(a); b = find_set(b);
    if (a != b) {
        p[b] = a; return true;
    }
    return false;
}

int a[MAXN];
int n, m;

map <int, int> mp;
map <int, int> :: iterator it;

vector < pair <int, int> > v;

vector < multiset <int> > x;

multiset <int> s;
multiset <int> :: iterator sit;

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	init_dsu(n);
	for (int x, y, j = 0; j < m; j++) {
		cin >> x >> y;
		unite(x, y);
	}
	
	for (int x, i = 0; i < n; i++) {
		x = mp[find_set(i)];
		if (!x) mp[find_set(i)] = a[i];
			else mp[find_set(i)] = min(x, a[i]);
	}
	
	for (it = mp.begin(); it != mp.end(); it++)
		v.push_back(make_pair(it->second, it->first));
	
	sort(v.begin(), v.end());
		
	for (size_t i = 0; i < v.size(); i++)
		mp[v[i].second] = i;
	/*
	for (it = mp.begin(); it != mp.end(); it++)
		cout << it->first << " ! " << it->second << endl;
	*/
	x.resize(mp.size());
		
	for (int i = 0; i < n; i++)
		x[mp[find_set(i)]].insert(a[i]);
	
	/*
	for (size_t i = 0; i < x.size(); i++) {
		cout << "I : " << i << endl;
		for (sit = x[i].begin(); sit != x[i].end(); sit++)
			cout << *sit << " ";
		cout << endl;
	}	
	*/
	
	size_t pos = 0;
	for (size_t i = 1; i < x.size(); i++)
		if (x[pos].size() < x[i].size())
			pos = i;
	
	long long ans = 0; s = x[pos];
	for (size_t i = 0; i < x.size(); i++) {
		if (pos == i) continue;
		//cout << i << " " << s.size() << endl;
		if ((s.empty()) || (x[i].empty())) {
			cout << "Impossible" << endl;
			return 0;
		}
		ans += *s.begin(); s.erase(s.begin());
		ans += *x[i].begin(); x[i].erase(x[i].begin());
		while (!x[i].empty()) {
			s.insert(*x[i].begin());
			x[i].erase(x[i].begin());
		}
	}
	
	cout << ans << endl;
	/*
	for (size_t i = 0; i < x.size(); i++) {
		cout << i << endl;
		for (sit = x[i].begin(); sit != x[i].end(); sit++)
			cout << *sit << " ";
		cout << endl;
	}
	*/
	return 0;
}

Measured memory_bytes: 15864
#include<stdio.h>
int main(void) {
	long int X, Y;
	scanf("%ld %ld", &X, &Y);
	long int A = X;
	int i = 0;
	while (A <= Y) {
		A *= 2;
		i++;
	}
	printf("%d", i);
	return 0;
}

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

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

  while(1) {
    if(1 + c *(a - 1) >= b) {
      break;
    } else {
      c++;
    }
  }

  cout << c << endl;
}

Measured memory_bytes: 256
#複数の整数入力を受け付ける関数
def datain(num):

    data = []
    iscnt = True

    while iscnt:
        for val in map(int,input().split()):
            data.append(val)
            if len(data) == num:
                iscnt = False
                break
        
    return data

INF = 10**8
data1 = datain(2)
data2 = datain(data1[0])
count = [INF for i in range(data1[0]+1)]
num = 0
ans = 0

for val in data2:
    if count[val] == INF:
        count[val] = 0
        num += 1
    count[val] += 1

count.sort()
#print(count);print(num)

if num >= data1[1]:
    for val in count[0:(num-data1[1])]:
        ans += val

print(ans)

Measured memory_bytes: 26032
#include <bits/stdc++.h>
using namespace std;
 //Compiler version g++ 6.3.0
#define MOD 998244353
int InvMod(int a){
	int b=MOD-2,Ans=1,P=a;
	for(int i=0;(1<<i)<=b;++i){
		if((1<<i)&b){
			Ans=1LL*Ans*P%MOD;
		}
		P=(1LL*P*P)%MOD;
	}
	return Ans;
}
int fact[300001];
int C(int n,int k){
	return 1LL*fact[n]*InvMod(fact[k])%MOD*InvMod(fact[n-k])%MOD;
}
 int main(){
 	fact[0]=1;
 	for(int i=1;i<=300000;++i)
 	    fact[i]=1LL*i*fact[i-1]%MOD;
 	int n,a,b;
 	long long k;
 	scanf("%d %d %d %lld",&n,&a,&b,&k);
 	int ct=0;
 	for(int i=0;i<=n;++i){
 		long long aux=k-1LL*i*a;
 		if(aux<0||aux%b!=0) continue;
 		int j=aux/b;
 		if(j>n) continue;
 		ct=(ct+1LL*C(n,i)*C(n,j)%MOD)%MOD;
 	}
 	printf("%d",ct);
 }

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

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }

    int count=0;
    for(int i=0; i<n; i++){
        if(i+1==a.at(a.at(i)-1)) count++;
    }
    cout << count/2 << endl;
}

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

#define ll long long int

void solve() {
	int n;
	bool is_zero = 0, is_more = 0;
	cin >> n;
	ll num, product = 1, limit = 1e18;
	for(int i = 0; i < n; ++i) {
		cin >> num;
		is_more = (num > limit) ? 1 : is_more;
		product *= num;
		(num) ? limit /= num : is_zero = 1;
	}
	(is_zero) ? cout << "0" << endl : ((is_more) ? cout << "-1" << endl : cout << product << endl);
}

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

Measured memory_bytes: 3564
import sys
sys.setrecursionlimit(200000)

mod = 10**9 +7
N,K = map(int,input().split())
edges = [[] for _ in range(N+1)]
for _ in range(N-1):
    a,b = map(int,input().split())
    edges[a].append(b)
    edges[b].append(a)


def dfs(cur,p,nei):
    #curにいる状態で、選べる色がcandi通りある場合の、塗り方の場合の数。
    #pが親,neiがcurの距離2以下のノードの数（curの子、弟ノードは除く）。neiが0,1のとき子に渡すneiはnei+1+兄の数、
    # neiが2のとき、子に渡すneiは、2+兄の数。
    res = K-nei 
    nxnei = min(nei+1,2)
    for nx in edges[cur]:
        if nx != p:
            res = res * dfs(nx,cur,nxnei) % mod
            nxnei += 1
    return res

print(dfs(1,0,0))

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

/*
void DebugPrint(vector<int> p){
  rep(idx,p.size()){
    cout << p.at(idx) << " ";
  }
  cout << endl;
}
*/

int main() {
  int N,M;
  cin >> N >> M;
  
  vector<int> Ai;
  vector<int> Bi,Ci;
  
  rep(i,N){
    int tmpAi;
    cin >> tmpAi;
    Ai.push_back(tmpAi);
  }
  
  vector<pair<int, int>> p(M);
  rep(i,M){
    int cinBi,cinCi;
    cin >> cinBi >> cinCi;
    p.at(i) = make_pair(cinCi,cinBi);
  }
  
  sort(Ai.begin(), Ai.end());
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  
  int64_t ans = 0;
  
  int N_idx = 0;
  
  rep(i,M){
    int tmpBi,tmpCi;
    tie(tmpCi,tmpBi) = p.at(i);
    
    if(N_idx >= N){
      break;
    }else{
	    rep(i,tmpBi){
          ans += max(Ai.at(N_idx),tmpCi);
          N_idx++;
          if(N_idx == N) break;
        }
    }
    
    //DebugPrint(Ai);
  }
  
  if(N_idx < N){
    rep2(i,N_idx,N){
      ans += Ai.at(i);
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1528
# Educational DP Contest F-LCS

def f():
    s = input()
    t = input()
    ls, lt = len(s), len(t)
    dp = [[0]*(ls+1) for _ in range(lt+1)]
    for i in range(lt):
        for j in range(ls):
            if t[i] == s[j]:
                dp[i+1][j+1] = dp[i][j] + 1
            else:
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])
                
    ans = ""
    while lt > 0 and ls > 0:
        if dp[lt][ls] == dp[lt-1][ls]:
            lt -= 1
        elif dp[lt][ls] == dp[lt][ls-1]:
            ls -= 1
        elif dp[lt][ls] == dp[lt-1][ls-1] + 1:
            ans += t[lt-1]
            lt -= 1
            ls -= 1
    print(ans[::-1])
    
if __name__ == "__main__":
    f()

Measured memory_bytes: 111580
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int h,w;
    cin >> h >> w;
    char s[h+2][w+2];
    REP(i,h+2)REP(j,w+2)s[i][j]='.';
    REP(i,h){
        REP(j,w){
            cin >> s[i+1][j+1];
        }
    }

    REP(i,h){
        REP(j,w){
            if(s[i+1][j+1]=='#'){
                if(s[i][j+1]=='.' and s[i+1][j] == '.' and s[i+2][j+1] == '.' and s[i+1][j+2] == '.'){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int m,d;
	int ans=0;
	scanf("%d%d",&m,&d);
	for(int i=4;i<=m;i++)
	{
		for(int j=2;j<=d/10;j++)
		  for(int k=2;k<=9;k++)
		  {
		  	  if(j*10+k<=d)
		  	  {
		  	  	if(j*k==i)
		  	  	  ans++;
			  }
		  }
	}
	printf("%d\n",ans);
	return 0;
 } 

Measured memory_bytes: 256