akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int N,K;
	string S;
	cin>>N>>K>>S;
	
	S.at(K-1)+='a'-'A';
	ce(S)
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  string S;
  cin >> S;
  
  ll Sum = 0, sum = 0;
  for(int i = 0; i < (1 << 9); i++){
    bitset<9> op(i);
    int opc = 0;
    sum = S.at(opc) - 48;
    
    for(int j = 0; j < S.size() - 1; j++){
      if(op.test(j)){
        Sum += sum;
        opc++;
        sum = S.at(opc) - 48;
      }
      else {
        sum *= 10;
        opc++;
        sum += S.at(opc) - 48;
      }
    }
    Sum += sum;
    sum = 0;
    if(i == pow(2, S.size() - 1) - 1){
      cout << Sum << endl;
      return 0;
    }
  }
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int CM = 314;
const LL mod = 1e9 + 7;
LL dp[CM][CM][CM];
int N,M;
vector<P2> V[CM];
bool u = 1;

int main(){
	scanf("%d%d" , &N , &M);
	repp(i,0,M){
		int a,b,c;
		scanf("%d%d%d" , &a , &b , &c);
		V[b].PB(MP(a,c));
		if(c>1) u = 0;
	}
	dp[0][0][0] = 1;
	repp(k,0,N+1){
		repp(j,0,max(1,k)){
			repp(i,0,max(1,j)){
				for(auto z : V[k]){
					if(z.second == 3){
						if(i<z.first) dp[i][j][k] = 0;
					} else if(z.second == 2){
						if(i>=z.first || j<z.first) dp[i][j][k] = 0;
					} else {
						if(j>=z.first) dp[i][j][k] = 0;
					}
				}
				(dp[i][j][k+1] += dp[i][j][k]) %= mod;
				if(j != k) (dp[i][k][k+1] += dp[i][j][k]) %= mod;
				if(i != j) (dp[j][k][k+1] += dp[i][j][k]) %= mod;
				//printf("%d %d %d %lld\n" , i , j , k , dp[i][j][k]);
			}
		}
	}
	LL ans = 0;
	repp(j,0,N){
		repp(i,0,max(1,j)){
			(ans += dp[i][j][N]) %= mod;
		}
	}
	ans = ans * 6 % mod;
	if(u) ans = (ans + mod - 3) % mod;
	printf("%lld\n" , ans);
	return 0;
}


Measured memory_bytes: 231552
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x, y = map(int, readline().split())
    ans = 0
    if x < y:
        if x >= 0:
            ans = y - x
        elif y >= 0:
            ans = min(y - x, abs(y - abs(x)) + 1)
        else:
            ans = y - x
    else:
        if y >= 0:
            ans = min(x - y + 2, x + y + 1)
        elif x >= 0:
            ans = abs(x - abs(y)) + 1
        else:
            ans = abs(y) - abs(x) + 2

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61904
N,M = input().split()
N = int(N)
M = int(M)
ans = 0

AB = []

for i in range(N):

    A,B = input().split()
    AB.append([int(A),int(B)])

AB.sort()

for i in range(N):

    if (AB[i][1] < M):

        M -= AB[i][1]
        ans += AB[i][0] * AB[i][1]

    else:
        ans += AB[i][0] * M
        break

print (ans)


Measured memory_bytes: 20012
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  set<int> s;
  for(int i = 0; i < 3; i++) {
    int a; cin >> a;
    s.insert(a);
  }
  if(s.size() == 2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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

#define REP(i, n) for(ll i = 0; i < n; i++)




















int main(){
    string s;
    cin >> s;
    string x(s.size(), 'x');
    cout << x << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define EPS 1e-10
  
using namespace std;
typedef long long int ll;
  
double add(double a, double b){
    if(abs(a+b)<EPS*(abs(a)+abs(b))) return 0;
    return a+b;
}
  
struct P{
    double x, y;
    P() {}
    P(double x, double y): x(x), y(y){
    }
    P operator+ (P p){
        return P(add(x, p.x), add(y, p.y));
    }
    P operator- (P p){
        return P(add(x, -p.x), add(y, -p.y));
    }
    P operator* (double d){
        return P(x*d, y*d);
    }
    double dot(P p){
        return add(x*p.x, y*p.y);
    }
    double det(P p){
        return add(x*p.y, -y*p.x);
    }
    bool operator< (const P& p) const{
        if(abs(x-p.x)>EPS){
            return x<p.x;
        }else{
            return y<p.y-EPS;
        }
    }
};
  
bool on_seg(P p1, P p2, P q){
    return (p1-q).det(p2-q)==0 && (p1-q).dot(p2-q)<=0;
}
  
P intersection(P p1, P p2, P q1, P q2){
    return p1+(p2-p1)*((q2-q1).det(q1-p1) / (q2-q1).det(p2-p1));
}
 
int main()
{
    while(1){
        int n;
        scanf("%d", &n);
        if(n==0) return 0;
        P p1[100], p2[100];
        set<P> st;
        for(int i=0; i<n; i++){
            double x1, y1, x2, y2;
            scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
            p1[i]=P(x1, y1), p2[i]=P(x2, y2);
            st.insert(p1[i]);
            st.insert(p2[i]);
        }
        int v, e=st.size();
        for(int i=0; i<n; i++){
            set<P> st1;
            for(int j=0; j<n; j++){
                if(i==j) continue;
                if((p1[i]-p2[i]).det(p1[j]-p2[j])==0) continue;
                P q=intersection(p1[i], p2[i], p1[j], p2[j]);
                if(-100+EPS<q.x && q.x<100-EPS && -100+EPS<q.y && q.y<100-EPS){
                    st1.insert(q);
                    st.insert(q);
                }
            }
            e+=(st1.size()+1);
        }
        v=st.size();
        printf("%d\n", e-v+1);
    }
    return 0;
}


Measured memory_bytes: 3428
#include <iostream>
using namespace std;
long long dist(long long a, long long b, long long c, long long d){
	return abs(a-c)+abs(b-d);
}

int main() {
	int N, M;
	cin >> N >> M;
	long long s[N][2];
	long long p[M][2];
	for (int i=0; i<N; i++){
		cin >> s[i][0] >> s[i][1];
	}
	for (int i=0; i<M; i++){
		cin >> p[i][0] >> p[i][1];
	}
	
	for (int i=0; i<N; i++){
		long long x = dist(s[i][0],s[i][1],p[0][0],p[0][1]);
		int order = 1;
		for (int j=1; j<M; j++){
			long long y = dist(s[i][0],s[i][1],p[j][0],p[j][1]);
			if (y<x){ 
				x = y;
				order = j+1;
			}
		}
		cout << order << '\n';
	}
}

Measured memory_bytes: 256
import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

let MOD = 1_000_000_007

private func pow(_ b: Int, _ n: Int, _ p: Int) -> Int {
    var (b, n) = (b, n)
    var x = 1
    while n > 0 {
        if n % 2 == 0 {
            b = b * b % p
            n /= 2
        } else {
            x = x * b % p
            n -= 1
        }
    }
    return x % p
}

func main() {
    // 考察過程
    // 対称性、偶奇性
    // A_iが0になるのは、nが奇数のとき。
    // nが奇数なら全てが偶数? 0は一つだけ。他は二つずつ。
    // nが偶数なら全てが奇数。二つずつ。
    // あとは重複あり順列? 人の位置はほぼ固定なので違った。
    // 二通り が n/2(小数点切り捨て)個分。
    // - 🐻 - - - 🐰 -
    // - 🐰 - - - 🐻 -
    // こんな感じ

    let n = Int(readLine()!)!
    let A = readWords { Int($0)! }
    var counter = [Int:Int]()
    for i in A {
        counter[i, default: 0] += 1
    }

    if n % 2 == 0 {
        for i in 1..<n where i % 2 == 1 {
            if let c = counter[i] {
                if c != 2 {
                    print(0)
                    return
                }
            } else {
                print(0)
                return
            }
        }
    } else {
        for i in 0..<n where i % 2 == 0 {
            if let c = counter[i] {
                if i == 0 && c != 1 || i != 0 && c != 2 {
                    print(0)
                    return
                }
            } else {
                print(0)
                return
            }
        }
    }

    
    print(pow(2, n/2, MOD))
}


main()

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

#define ris   return *this
#define tmplt template<class T
#define dbgo  debug& operator<<
tmplt > struct rge { T b, e; };
tmplt > rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
~debug(){cerr<<endl;}
tmplt > dbgo(T x){cerr<<boolalpha<<x;ris;}
tmplt, class C > dbgo(pair<T, C> x){ris<<"("<<x.first<<", "<<x.second<<")";}
tmplt > dbgo(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}ris<<"]";}
tmplt > dbgo(vector<T> x){ris<<range(x.begin(),x.end());}
#else
tmplt > dbgo(const T&){ris;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
   a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
   a = max(a, b); 
}


int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   
   long long a, v, b, w, t;
   cin >> a >> v >> b >> w >> t;
   if(a > b) {
      swap(a, b);
   }
   a += t * v;
   b += t * w;
   if(a >= b) {
      cout << "YES\n";
   }
   else {
      cout << "NO\n";
   }
}















// Author: blondie


Measured memory_bytes: 3592
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	a := make([]int, N+1)
	b := make([]int, N+1)
	c := make([]int, N+1)
	for i := 1; i < N+1; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d %d", &a[i], &b[i], &c[i])
	}

	dp := make([][]int, N+1)
	for i := 0; i < len(dp); i++ {
		dp[i] = make([]int, 3)
	}

	dp[0][0] = 0
	dp[0][1] = 0
	dp[0][2] = 0
	for i := 1; i < N+1; i++ {
		dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2])
		dp[i][1] = b[i] + max(dp[i-1][2], dp[i-1][0])
		dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1])
	}

	ans := max(dp[N][0], dp[N][1], dp[N][2])
	fmt.Println(ans)
}

func max(ns ...int) int {
	ret := math.MinInt64
	for _, n := range ns {
		if n > ret {
			ret = n
		}
	}
	return ret
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define ll long long
#define p pair<double, double>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
    vector<int> idx(n);
    int del = 1;
    for (int i = 0; i < n; i++) idx[i] = i, del *= (i + 1);
    double sum = 0;
    do {
        for (int i = 0; i < n - 1; i++) {
            double xx = x[idx[i]] - x[idx[i + 1]];
            double yy = y[idx[i]] - y[idx[i + 1]];
            sum += sqrt(xx * xx + yy * yy);
        }
    } while (next_permutation(idx.begin(), idx.end()));
    cout << fixed << setprecision(10) << sum / del << endl;
    return 0;
}

Measured memory_bytes: 384
import math
def insertionSort(A, N, h):
    global cnt
    for i in range(h, N):
        v = A[i]
        j = i - h
        while j >= 0 and A[j] > v:
            A[j + h] = A[j]
            j = j - h
            cnt += 1
        A[j + h] = v

N = int(input())
A = [int(input()) for _ in range(N)]
G = [int((3 ** i - 1) // 2) for i in range(1, int(math.log(2 * N + 1)) + 1) if int((3 ** i - 1) // 2) < N]
if G == []: G.append(1)
G.reverse()
cnt = 0
for h in G:
    insertionSort(A, N, h)
print(len(G))
print(*G)
print(cnt)
print(*A, sep = '\n')



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

using namespace std;

int main() {

  int a, b;
  int c, d;
  int L, R;

  cin >> a >> b >> c >> d;

  L = a + b;
  R = c + d;

  if (L > R) cout << "Left" << endl;
  if (L < R) cout << "Right" << endl;
  if (L == R) cout << "Balanced" << endl;

  return(0);
}

Measured memory_bytes: 3560
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    s[3]='8';
    cout<<s<<"\n";
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{
	ll a,v;
	ll b,w;
	ll t;
	scanf("%lld%lld",&a,&v);
	scanf("%lld%lld",&b,&w);
	scanf("%lld",&t);
	if(a==b){
		printf("YES");
	}
	else if(a<b){
		a+=v*t;
		b+=w*t;
		if(a>=b){
			printf("YES");
		}
		else{
			printf("NO");
		}
	}
	else if(a>b){
		a-=v*t;
		b-=w*t; 
		if(a<=b){
			printf("YES");
		}
		else{
			printf("NO");
		}
	}
}


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

const int N = (int) 2e5 + 5;
const long long INF = (long long) 1e18;

int n, k;
long long s[N], fw[N];

void compress() {
	vector <long long> zip; zip.push_back(-INF);
	for (int i = 0; i <= n; i++) {
		zip.push_back(s[i] - 1LL * i * k);
	}
	sort(zip.begin(), zip.end());
	zip.resize(distance(zip.begin(), unique(zip.begin(), zip.end())));
	for (int i = 0; i <= n; i++) {
		s[i] = lower_bound(zip.begin(), zip.end(), s[i] - 1LL * i * k) - zip.begin();
	}
}

void upd (int i) {
	for (; i <= n + 1; i += i & -i) fw[i]++;
}

long long get(int i) {
	long long res = 0;
	for (; i >= 1; i -= i & -i) res += fw[i];
	return res;
}

int main() {
	//freopen(".inp", "r", stdin); freopen(".out", "w", stdout);
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; i++) {
		int v; scanf("%d", &v);
		s[i] = s[i - 1] + v;
	}
	compress();
	long long ans = 0;
	upd(s[0]);
	for (int i = 1; i <= n; i++) {
		ans += get(s[i]);
		upd(s[i]);
	}
	printf("%lld\n", ans);
	return 0;
}

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

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

const int INF=1e9;

ll mod_pow(ll x, ll n, ll MOD){ //べき乗
    ll ans=1;
    x%=MOD;
    while(n!=0){
        if(n&1) ans=ans*x%MOD;
        x=x*x%MOD;
        n=n>>1;
    }
    return ans%MOD;
}

int main(){
    ll N; cin >> N;
    string x; cin >> x;
    ll cnt=0;
    for(int i=0;i<N;i++){
        if(x[i]=='1') cnt++;
    }
    ll sum1=0; ll sum2=0;
    for(int i=0;i<N;i++){
        if(x[i]=='0') continue;
        sum1+=mod_pow(2,N-1-i,cnt+1);
        sum1%=(cnt+1);
        if(cnt-1>0){
            sum2+=mod_pow(2,N-1-i,cnt-1);
            sum2%=(cnt-1);
        }
    }
    for(int i=0;i<N;i++){
        ll ans=1;
        if(x[i]=='0'){
            ll res=(sum1+mod_pow(2,N-1-i,cnt+1))%(cnt+1);
            while(res){
                ll tmp=res;
                ll c=0;
                while(tmp){
                    if(tmp%2) c++;
                    tmp/=2;
                }
                res=res%c;
                ans++;
            }
        }else{
            if((cnt-1)==0){
                cout << 0 << endl;
                continue;
            }
            ll res=(sum2+(cnt-1)-mod_pow(2,N-1-i,cnt-1))%(cnt-1);
            while(res){
                ll tmp=res;
                ll c=0;
                while(tmp){
                    if(tmp%2) c++;
                    tmp/=2;
                }
                res=res%c;
                ans++;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3756
n = gets.to_i
data = Array.new
sum = 0
n.times do
  r = gets.to_i
  data << r
  sum += r
end
result = sum
if sum % 10 == 0
  data.sort!
  data.each do |item|
    if item % 10 != 0
      result -= item
      break
    end
  end
  if result == sum
    result = 0
  end
end
puts result

Measured memory_bytes: 1788
#include <cstdio>
#include <utility>
#include <cctype>
#include <algorithm>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	int A {in}, B {in}, C {in}, d {A * 7 + B};
	outl(C / d * 7 + min(7, (C % d + A - 1) / A));
}


Measured memory_bytes: 2624
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <limits.h>
#include <memory.h>


using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef vector<double> vec;
typedef vector<vec> mat;

ll luc[100];

ll go(ll v){
	ll v1,v2;
	if(v==1)
		return 1;
	if(v==0)
		return 2;
	if(luc[v-1]>=0)
		v1=luc[v-1];
	else
		v1=go(v-1);
	if(luc[v-2]>=0)
		v2=luc[v-2];
	else
		v2=go(v-2);
	luc[v-1]=v1;
	luc[v-2]=v2;
	return v1+v2;
	
}

int main() {
	memset(luc,-1LL,sizeof(luc));
	luc[0]=2;
	luc[1]=1;
	ll v;
	cin>>v;
	cout << go(v) << endl;
	return 0;
}




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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n;
    scanf(" %d", &n);
    vector<int> a(n);
    rep(i,n) scanf(" %d", &a[i]);

    int ans=0;
    int now=0;
    while(now<n)
    {
        ++ans;
        // printf("now = %d\n", now);

        int dir=0;
        while(now+1<n)
        {
            // printf(" now = %d, dir= %d\n", now,dir);

            if(dir==1)
            {
                if(a[now]>a[now+1])
                {
                    ++now;
                    break;
                }
            }
            else if(dir==-1)
            {
                if(a[now]<a[now+1])
                {
                    ++now;
                    break;
                }
            }
            else
            {
                if(a[now]<a[now+1]) dir=1;
                else if(a[now]>a[now+1]) dir=-1;
            }
            ++now;
        }

        if(now==n-1)
        {
            if(dir==1 && a[now-1]>a[now]) ++ans;
            if(dir==-1 && a[now-1]<a[now]) ++ans;
            break;
        }
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
  string s;
  int res = 0;

  cin >> s;

  int n = s.length();

  for(int i = 0; i < n / 2; i++)
    if(s[i] != s[n - 1 - i])
      res++;

  cout << res << endl;

  return 0;
}


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

using namespace std;
int main() {
	string s, t;
	cin>>s>>t;
	int ans = 0;
	for(int i=0;i<3;i++) {
		if(s[i] == t[i])
			ans++;
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
import sys
from operator import itemgetter

mod = 10**9 + 7
inf = 1<<30

def solve():
    N, M = map(int, sys.stdin.readline().split())
    sects = []

    for i in range(N):
        li, ri = map(int, sys.stdin.readline().split())

        sects.append((li - 1, ri, ri - li + 1))

    sects.sort(key=itemgetter(2))

    # print(sects)

    print(N)

    left = 0

    ft = FenwickTree([0]*(M + 1))

    for d in range(2, M + 1):
        for j in range(left, N):
            if sects[j][2] >= d:
                left = j
                break
            else:
                ft.add(sects[j][0], 1)
                ft.add(sects[j][1], -1)
        else:
            left = N

        # print('left', left)
        # print(ft.data)

        ans = N - left + sum(ft.get_sum(j) for j in range(d, M + 1, d))
        
        print(ans)

class FenwickTree:
    def __init__(self, a):
        self.n = len(a)
        self.data = [0] + a[:]

        for i in range(1, self.n + 1):
            if i + (i & (-i)) <= self.n:
                self.data[i + (i & (-i))] += self.data[i]

    def add(self, i, x):
        ''' a[i] += x '''
        i += 1 # 0-oringn -> 1-origin

        while i <= self.n:
            self.data[i] += x
            i += i & (-i)

    def get_sum(self, r):
        ''' sum[a_0 .. a_r) '''
        res = 0

        while r > 0:
            res += self.data[r]
            r -= r & (-r)

        return res


if __name__ == '__main__':
    solve()

Measured memory_bytes: 116052
#include <stdio.h>
#define SIZE 3005
  double dp[SIZE];

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

        dp[0] = 1;
        for(int i=1; i<=n; i++) {
           double mon;
           scanf("%lf",&mon);
           for(int j=i; j>=0; j--) dp[j] = (!j ? 0 : dp[j-1])*mon + dp[j]*(1-mon);
        }
        double ans = 0;
        for(int i=1; i<=n; i++) if(i>n-i) ans += dp[i];

        printf("%.9lf",ans);
        return 0;
  }





Measured memory_bytes: 256
import  java.util.*;
class Main{
  static class UnFd{
    int n;
    int[] par;
    int[] siz;
    int forest;
    UnFd(int n){
      this.n=n;
      par=new int[n];
      siz=new int[n];
      for(int i=0;i<n;i++){
        par[i]=i;
        siz[i]=1;
      }
      forest=n;
    }
    int forest(){
      return forest;
    }
    boolean isRoot(int i){
      return i==par[i];
    }
    int rootOf(int i){
      if(isRoot(i)){
        return i;
      }
      return par[i]=rootOf(par[i]);
    }
    int sizeOf(int i){
      return siz[rootOf(i)];
    }
    boolean isSame(int i,int j){
      return rootOf(i)==rootOf(j);
    }
    void merge(int i,int j){
      i=rootOf(i);
      j=rootOf(j);
      if(i==j){
        return;
      }
      par[Math.max(i,j)]=Math.min(i,j);
      siz[Math.min(i,j)]+=siz[Math.max(i,j)];
      forest--;
    }
  }
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    int k=sc.nextInt();
    int[] sub=new int[n];
    UnFd uf=new UnFd(n);
    for(int i=0;i<m;i++){
      int a=sc.nextInt()-1;
      int b=sc.nextInt()-1;
      uf.merge(a,b);
      sub[a]++;
      sub[b]++;
    }
    for(int i=0;i<k;i++){
      int c=sc.nextInt()-1;
      int d=sc.nextInt()-1;
      if(uf.isSame(c,d)){
        sub[c]++;
        sub[d]++;
      }
    }
    for(int i=0;i<n-1;i++){
      System.out.print((uf.sizeOf(i)-sub[i]-1)+" ");
    }
    System.out.println((uf.sizeOf(n-1)-sub[n-1]-1));
  }
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  int coin = 0;
  
  for(int i = 0; i < 2; i++) {
    if(A >= B) {
      coin += A;
      A -= 1;
    }
    else if(B > A) {
      coin += B;
      B -= 1;
    }
  }
  
    cout << coin << endl;
}

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

const int MAX = 44;
int F[MAX];

int fib(int n){
  if(n==0 || n==1) return F[n];
  if(F[n] != -1) return F[n];
  return F[n] = fib(n-1) + fib(n-2);
}


int main() {
    ios::sync_with_stdio(false);

    F[0] = F[1] = 1;
    for(int i=2; i<=MAX; i++) F[i] = -1;

    int n;
    cin >> n;
    cout << fib(n) << endl;
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <cstring>

#define rep(a, b, c) for (int a = b; a < (c); a++)
#define repe(a, b, c) for (int a = b; a <= (c); a++)
#define repr(a, b, c) for (int a = b; a > (c); a--)
#define repre(a, b, c) for (int a = b; a >= (c); a--)

using namespace std;

int main() {
    int K, T;
    cin >> K >> T;
    int max_num = 0;
    rep(i, 0, T) {
        int tmp;
        cin >> tmp;
        max_num = max(max_num, tmp);
    }
    if (T == 1) {
        cout << max_num - 1 << endl;
    } else {
        cout << max(0, max_num + max_num - K - 1) << endl;
    }
    return 0;
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

struct edge{
    int to;
    int cost;
};

typedef pair<ll, int> P;
int N;
vector<edge> G[100000];
ll d[100000];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> pq;
    fill(d, d+N, INF);

    d[s] = 0;
    pq.push(P(0, s));

    while(!pq.empty()){
        P p = pq.top();
        pq.pop();
        
        int now = p.second;
        if(p.first > d[now]) continue;
        for(int i = 0; i < G[now].size(); i++){
            edge e = G[now][i];
            if(d[e.to] > d[now] + e.cost){
                d[e.to] = d[now] + e.cost;
                pq.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(void){
    int M; cin >> N >> M;
    for(int i = N-1; i >= 1; i--){
        edge e; e.to = i-1; e.cost = 0;
        G[i].push_back(e);
    }
    rep(i, M){
        int l, r; ll c; cin >> l >> r >> c;
        l--; r--;
        edge e; e.to = r; e.cost = c;
        G[l].push_back(e);
    }
    dijkstra(0);
    if(d[N-1] == INF) cout << -1 << endl;
    else cout << d[N-1] << endl;
    return 0;
}

Measured memory_bytes: 8568
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int turn = 1;
        while(1){
           if(turn % 2){
               c -= b;
           }else{
               a -= d;
           }
           if(a <= 0 || c <= 0){
               break;
           }
           turn++;
        }
        if(a <= 0){
            cout << "No\n";
        }else{
            cout << "Yes\n";
        }
    }
}

Measured memory_bytes: 34196
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int count =0,m=0;
  for (int i=0;i<s.size();i++){
    if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
      count++;
    }
    else {
      m=max(m,count);
      count =0;
    }
  }
  m=max(m,count);
  cout << m << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define int long long

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i];
    if(i == SZ(s)-1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}

signed main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n, w; cin >> n >> w;
  vector<int> c(n), v(n);
  REP(i, n) cin >> c[i] >> v[i];
/*   printv(c);
  printv(v); */

  vector<vector<int>> dp(n, vector<int>(w+1, 0));
  dp[0][c[0]] = v[0];
  for(int i=1;i<n;++i) {
    for(int j=0;j<w+1;++j) {
      dp[i][j] = max(dp[i][j], dp[i-1][j]);
      if(j-c[i] >= 0) dp[i][j] = max(dp[i][j], dp[i-1][j-c[i]] + v[i]);
    }
  }

/*   REP(i, n) {
    printv(dp[i]);
  } */
  
  int ans = 0;
  for(int j=0;j<w+1;++j) {
    ans = max(ans, dp[n-1][j]);
  }
  cout << ans << endl;
}


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

int main(){ 
  int N;
  vector<int> X(100);

  cin >> N;
  for(int i=0; i<N; i++) cin >> X[i];

  int ans = 1e7;
  for(int i=1; i<=100; i++){
    int cur = 0;
    for(int j=0; j<N; j++){
      cur += (X[j]-i)*(X[j]-i);
    }
    ans = min(ans, cur);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N,A[100],i,j,key,B[100],minj;
  char Ac[100],keyc,Bc[100];

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf(" %c%d",&Ac[i],&A[i]);
    B[i]=A[i];
    Bc[i]=Ac[i];
  }

  for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
        key=A[j];
        keyc=Ac[j];
        A[j]=A[j-1];
        Ac[j]=Ac[j-1];
        A[j-1]=key;
        Ac[j-1]=keyc;
      }
    }
  }
  for(i=0;i<N-1;i++){
    printf("%c%d ",Ac[i],A[i]);
  }
  printf("%c%d\nStable\n",Ac[N-1],A[N-1]);

  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(B[j]<B[minj]){
        minj=j;
      }
    }

    key=B[i];
    keyc=Bc[i];
    B[i]=B[minj];
    Bc[i]=Bc[minj];
    B[minj]=key;
    Bc[minj]=keyc;
  }
    for(i=0;i<N-1;i++){
    printf("%c%d ",Bc[i],B[i]);
  }
  printf("%c%d\n",Bc[N-1],B[N-1]);

  for(i=0;i<N;i++){
    if(Ac[i]!=Bc[i]){
      printf("Not stable\n");
      break;
    }
    else if(i==N-1 && Ac[i]==Bc[i]){
      printf("Stable\n");
      break;
    }
  }

  return 0;

}



Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void insert(set<string> &st, string s1, string s2) {
    st.insert(s1 + s2);
    reverse(all(s1));
    st.insert(s1 + s2);
    reverse(all(s2));
    st.insert(s1 + s2);
    reverse(all(s1));
    st.insert(s1 + s2);
}

int main() {
    int m;
    cin >> m;
    rep(i, m) {
        set<string> st;
        string s;
        cin >> s;
        rep(j, s.size()) if (j) {
            auto s1 = s.substr(0, j);
            auto s2 = s.substr(j, s.size() - j);
            insert(st, s1, s2);
            insert(st, s2, s1);
        }
        cout << st.size() << endl;
    }
    return 0;
}

Measured memory_bytes: 3212
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int A = int.Parse(s[0]) == 1 ? 14 : int.Parse(s[0]);
        int B = int.Parse(s[1]) == 1 ? 14 : int.Parse(s[1]);
        Console.WriteLine(A == B ? "Draw" : A > B ? "Alice" : "Bob");
    }
}


Measured memory_bytes: 11092
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, S: str):
    Slist = list(S)
    Slist[K-1] = Slist[K-1].lower()
    
    S = ''.join(Slist)
    print(S)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, K, S)

if __name__ == '__main__':
    main()


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

int main()
{
  int r, D, x;
  cin  >> r >> D >> x;
  int ans;
  for(int i=0;i<10; i++){
    ans = r * x - D;
    cout << ans <<"\n";
    x=ans;
  }
  
  return 0;
}


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

using namespace std;

#define int long long
#define sz(x) (int)x.size()
#define yes cout << "Yes\n"
#define  no cout << "No\n"
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ft first
#define sd second
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<int> vi;
typedef vector<bool> vb;
mt19937_64 rnd(time(0));

void start() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(10);
    // cerr << fixed << setprecision(10);
#ifdef MY
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}

signed main() {
    start();
    string s, t;
    cin >> s >> t;

    vector<vi> d(sz(s) + 1, vi(sz(t) + 1));
    s = ' ' + s;
    t = ' ' + t;
    //d[i][j] - длина наибольшей общей подпоследовательности где взяли
    // <= i элементов из s и <= j элементов из t
    // i

    for (int i = 1; i < sz(s); ++i) {
        for (int j = 1; j < sz(t); ++j) {
            d[i][j] = max(d[i - 1][j], d[i][j - 1]);
            if (s[i] == t[j])
                d[i][j] = max(d[i][j], d[i - 1][j - 1] + 1);
        }
    }
    int x = sz(s) - 1, y = sz(t) - 1;
    if (d[x][y]) {
        string ans;
        while (x && y) {
            if (s[x] == t[y]) {
                ans.push_back(s[x]);
                x--;
                y--;
            } else {
                if (d[x][y] == d[x - 1][y]) {
                    x--;
                } else {
                    y--;
                }
            }
        }
        reverse(all(ans));
        cout << ans;
    }


}


Measured memory_bytes: 73672
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int add = A + B;
		int sub = A - B;
		int mul = A * B;
		int max = Math.max(add, sub);
		max = Math.max(max, mul);
		System.out.println(max);
		scanner.close();
	}
}

Measured memory_bytes: 21844
n,p=map(int,input().split())
l=[(1,n)]
for i in range(2,-int(-p**0.5)+1):
    count=0
    while p%i==0:
        p//=i
        count+=1
    if count>0:
        l.append((i,count))
if p>1:
    l.append((p,1))
ans=1
for i in l:
    if i[1]>=n:
        ans *= i[0]**(i[1]//n)
print(ans)
        

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

int main(){
  int N, K;
  cin >> N >> K;
  
  int res = 1;
  rep(i, N){
    if((res*2)<(res+K)){
      res *= 2;
    }
    else{
      res += K;
    }
  }
  cout << res << endl;
}

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

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, A);
    CIN(int, B);
    CIN(int, C);

    cout << min(B / A, C) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int>a(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  int tmp = a[0];
  for (int i = 0; i < n; ++i)
    tmp = __gcd(tmp, a[i]);
  cout << tmp;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc085/tasks/abc085_b

int main() {
    int N; cin >> N;
    int d;
    set<int> st;
    REP(i, N) {
        cin >> d;
        st.insert(d);
    }

    cout << st.size() << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int,int>>> graph;
vector<int> ans;
int n,maxi=0;

void dfs(int curr , int par , int color){
    int v = 0;
    for(pair<int,int> i : graph[curr]){
        if(i.first != par){
            v += 1;
            if(v == color){
                v += 1;
            }
            maxi = max(maxi,v);
            ans[i.second] = v;
            dfs(i.first,curr,v);
        }
    }
}

int main(){
    cin >> n;
    ans.resize(n+1);
    graph.resize(n+1);
    for(int i = 0 ; i < n-1 ; i += 1){
        int a,b;
        cin >> a >> b;
        graph[a].push_back({b,i+1});
        graph[b].push_back({a,i+1});
    }
    dfs(1,0,0);
    cout << maxi << endl;
    for(int i = 1 ; i <= n-1 ; i += 1){
        cout << ans[i] << " ";
    }
}

Measured memory_bytes: 7424
import collections
N = int(input())
l = []
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            f = x**2 + y**2 + z**2 + x*y + y*z + z*x
            l.append(f)
answer = collections.Counter(l)
for i in range(1, N+1):
    print(answer[i])

Measured memory_bytes: 50516
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	int N;
	uint64_t mizuhasu = 0;
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		char x[128];
		char u[8];
		if (scanf("%127s%7s", x, u) != 2) return 1;
		if (u[0] == 'J') {
			uint64_t kitaeri;
			if (sscanf(x, "%" SCNu64, &kitaeri) != 1) return 2;
			mizuhasu += kitaeri * 10000;
		} else {
			uint64_t mikakosi, parunyasu;
			if (sscanf(x, "%" SCNu64 ".%" SCNu64, &mikakosi, &parunyasu) != 2) return 1;
			mizuhasu += (mikakosi * UINT64_C(100000000) + parunyasu) * 38;
		}
	}
	printf("%.4f\n", mizuhasu / 10000.0);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		String a = sc.next();
		String b = sc.next();

		if (a.equals("H") && b.equals("H")) {
			System.out.println("H");
		} else if (a.equals("H") && b.equals("D")) {
			System.out.println("D");
		} else if (a.equals("D") && b.equals("H")) {
			System.out.println("D");
		} else {
			System.out.println("H");
		}
		
		sc.close();
	}
}


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

int main(void) {
  vector<string> S(2);
  cin >> S[0] >> S[1];
  for (int i = 0, len = S[0].length() + S[1].length(); i < len; i++) {
    cout << S[i % 2][i / 2];
  }
  return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  vector<pair<int,int>> CB(M);
  for (int i=0;i<M;i++){
    int B,C;
    cin >> B >> C;
    CB[i]=make_pair(C,B);
  }
  sort(CB.begin(),CB.end());
  reverse(CB.begin(),CB.end());
  int changed=0;
  for (int i=0;i<M;i++){
    while(CB[i].first>A[changed]&&CB[i].second>0&&changed<N){
      A[changed]=CB[i].first;
      changed++;
      CB[i].second--;
    }
    if (CB[i].second>0){
      break;
    }
  }
  long long ans=0;
  for (int i=0;i<N;i++){
    ans+=A[i];
  }
  cout << ans << endl;
} 

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

long long K;
long long N;
vector<long long> A(100001);

long long xorsum(long long n) {
	long long sum = 0;
	for (int i = 0; i < N; i++) {
		sum += n^A[i];
	}
	return sum;
}

void solve(long long N, long long K, vector<long long> A){
	long long ideal = 0, res = 0, com = 0;
	for (long long i = 0; i < 40; i++) {
		long long count = 0;
		for (long long j = 0; j < N; j++) {
			if (A[j]>>i & 1) count++;
		}
		if (N-count > N/2) ideal += 1LL<<i;
	}


	for (long long i = 0; i < 40; i++) {
		com = 0;
		if (!((K+1)>>i & 1)) {
			continue;
		}
		for (long long j = 39; j > i; j--) {
			if ((K+1)>>j & 1) com += 1LL<<j;
		}
		for (long long j = i-1; j >= 0; j--) {
			if ((ideal)>>j & 1) com += 1LL<<j;
		}
		res = max(res,xorsum(com));
	}
	printf("%lld\n", res);
}

int main(){
	scanf("%lld",&N);
	scanf("%lld",&K);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, K, A);
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll n,cn[4][4010]={},ch[400]={},vis[4]={},ans=0;
string s;

int main(){
	cin>>n>>s;
	ll i,j,k;
	ch['R']=1;
	ch['G']=2;
	ch['B']=3;
	for(i=1;i<=n;++i){
		for(j=i+1;j<=n;++j){
			++cn[ch[s[j-1]]][i];
		}
	}
	/*for(i=1;i<=n;++i){
		cout<<cn[1][i]<<" "<<cn[2][i]<<" "<<cn[3][i]<<"\n";
	}*/
	for(i=1;i<n-2;++i){
		
		vis[ch[s[i-1]]]=1;
		
		for(j=i+1;j<=n-1;++j){
			if(!vis[ch[s[j-1]]]){
				//cout<<i<<" "<<j<<endl;
				vis[ch[s[j-1]]]=1;
				for(k=1;k<=3;++k){
					if(!vis[k])
						break;
				}
				ans+=cn[k][j];
				//cout<<s[i-1]<<s[j-1]<<s[j-i+j-1]<<endl;
				if(j-i+j<=n){
					if(!vis[ch[s[j-i+j-1]]])
						--ans;
				}
				//cout<<ans<<endl;
				vis[ch[s[j-1]]]=0;
			}
		}
		vis[ch[s[i-1]]]=0;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3748