akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    vector<int> t(N+1, 0), x(N+1, 0), y(N+1, 0);

    for(int i=1; i<=N; ++i) cin >> t[i] >> x[i] >> y[i];

    bool flg = true;
    for(int i=0; i<N; ++i){
        int d = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
        if(t[i+1]-t[i] < d || d%2 != (t[i+1]-t[i])%2){
            flg = false;
            break;
        }
    }

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>

const int Mod = 998244353;

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[50001];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = ++(h->size), j = i >> 1;
	data tmp;
	h->obj[i] = x;
	while (j > 0) {
		if (h->obj[i].key < h->obj[j].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j <<= 1;
		} else break;
	}
	return output;
}

int main()
{
	int h, i, N, num[100001] = {};
	scanf("%d", &N);
	N *= 2;
	for (i = 1; i <= N; i++) {
		scanf("%d", &h);
		num[h]++;
	}
	
	long long fact[100001], fact_inv[100001], pow[100001], pow_inv[100001];
	for (i = 1, fact[0] = 1; i <= N; i++) fact[i] = fact[i-1] * i % Mod;
	for (i = N - 1, fact_inv[N] = div_mod(1, fact[N], Mod); i >= 0; i--) fact_inv[i] = fact_inv[i+1] * (i + 1) % Mod;
	for (i = 1, pow[0] = 1; i <= N; i++) pow[i] = pow[i-1] * 2 % Mod;
	for (i = N - 1, pow_inv[N] = div_mod(1, pow[N], Mod); i >= 0; i--) pow_inv[i] = pow_inv[i+1] * 2 % Mod;
	
	int j, k, l;
	long long ans = fact[N] * fact_inv[N/2] % Mod * pow_inv[N/2] % Mod;
	long long *a[100001] = {};
	data d, e, f;
	min_heap heap;
	heap.size = 0;
	d.key = 1;
	d.id = 0;
	push(d, &heap);
	a[0] = (long long*)malloc(sizeof(long long) * 2);
	a[0][0] = 1;
	for (i = 0, j = 1; i <= 100000; i++) {
		if (num[i] < 2) continue;
		a[j] = (long long*)malloc(sizeof(long long) * (num[i] / 2 + 2));
		for (k = 0; k <= num[i] / 2; k++) a[j][k] = fact[num[i]] * fact_inv[num[i]-k*2] % Mod * pow_inv[k] % Mod * fact_inv[k] % Mod;		
		d.key = num[i] / 2 + 1;
		d.id = j++;
		push(d, &heap);
	}
	while (heap.size > 1) {
		d = pop(&heap);
		e = pop(&heap);
		f.key = d.key + e.key - 1;
		f.id = j;
		push(f, &heap);
		
		a[j] = (long long*)malloc(sizeof(long long) * (f.key + 1));
		for (i = 0; i < f.key; i++) a[j][i] = 0;
		for (i = 0; i < d.key; i++) {
			for (k = 0; k < e.key; k++) a[j][i+k] += a[d.id][i] * a[e.id][k] % Mod;
		}
		for (i = 0; i < f.key; i++) a[j][i] %= Mod;
		j++;
		free(a[d.id]);
		free(a[e.id]);
	}
	d = pop(&heap);
	j = d.id;
	for (i = 1; i < d.key; i++) {
		if (i % 2 == 1) ans = (ans + (Mod - a[j][i]) * fact[N-i*2] % Mod * fact_inv[N/2-i] % Mod * pow_inv[N/2-i]) % Mod;
		else ans = (ans + a[j][i] * fact[N-i*2] % Mod * fact_inv[N/2-i] % Mod * pow_inv[N/2-i]) % Mod;
	}
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 7672
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;




public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7);
	static long cf = 998244353;
    static final int N = (int) 1e3+10;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static int col = 20;
    public static int[] Bit;
    public static long[] fact,inv;
    public  static int[] prime; 
	public static Map<Integer, Integer> map; 
	static char ch = 'z';
	static FastReader sc = new FastReader();
	public static void main(String[] args) {
	//	Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[n+1];
		for(int i=1;i<=n;++i) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		long[] dp = new long[h+1];
		Arrays.fill(dp,Integer.MAX_VALUE);
		
		 dp[0] = 0;
		for(int i=1;i<=h;++i) {
			for(int j=1;j<=n;++j) {
				if(i-a[j] >= 0) {
					dp[i] = Math.min(dp[i],dp[i-a[j]] + b[j]);
				}else {
					dp[i] = Math.min(dp[i],b[j]);
				}
			}
		}
		out.print(dp[h]);
	out.close();
	}
	
}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s; 
  cin >> s;

  int ans = 0;
  REP(i, s.size()){
    if(s[i] == '+') ans++;
    else ans--;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    int ans = 0;
    // if (s[n - 1] == 'L') {
    // 	b++;
    // } else {
    // 	a++;
    // }
    if (s[n - 1] == 'L') {
    	d++;
    } else {
    	c++;
    }
    //LR - a
    //RL - b
    int can = 0;
    for (int i = n - 2; i >= 0; i--) {
    	if (s[i] != s[i + 1]) {
    		if (k > 0) {
    			if (s[i + 1] == 'R') {
    				//LRLR
    				//LRRL
    				if (b > 0) {
    					ans += 2;
    					b--;
    					k--;
    				} else {
    					a++;
    				}
    				if (c > 0) {
    					c--;
    					can++;
    				}
    			} 
    			if (s[i + 1] == 'L') {
    				//RLRL
    				//RLLR
    				if (a > 0) {
    					ans += 2;
    					a--;
    					k--;
    				} else {
    					b++;
    				}
    				if (d > 0) {
    					d--;
    					can++;
    				}
    			}
    		}
    	} else {
    		ans++;
    	}
    	cerr << a << ' ' << b << endl;
    }
    ans += min({k, can, a + b});
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int N;
unsigned int shougen_bits[15];
unsigned int exist_bits[15];

int numofbits(unsigned int bits)
{
    unsigned int num;

    num = (bits >> 1) & 03333333333;
    num = bits - num - ((num >> 1) & 03333333333);  
    num = ((num + (num >> 3)) & 0707070707) % 077;

    return num;
}

void printData()
{
  int i;

  for ( i=0; i<N; i++ ) {
    printf("shougen_bits[%d]: %x\n", i, shougen_bits[i]);
    printf("exist_bits[%d]: %x\n", i, exist_bits[i]);
  }
}

int main()
{
  int ret, i, j, x, y, ok_flag, max;
  unsigned int a;

  ret = scanf("%d", &N);
  for ( i=0; i<N; i++ ) {
    shougen_bits[i] = 0;
    exist_bits[i] = 0;
    ret = scanf("%d", &a);
    for ( j=0; j<a; j++ ) {
      ret = scanf("%d %d", &x, &y);
      if ( y == 1 )
	shougen_bits[i] |= (1 << (x-1));
      exist_bits[i] |= (1 << (x-1));
    }
  }

  a = 0;
  for ( i=0; i<N; i++ )
    a |= (1 << i);

#if 0
  printData();
  printf("a = %d\n", a);
#endif
  
  max = 0;
  for ( i=1; i<=a; i++ ) {
    ok_flag = 1;
    for( j=0; j<N; j++ ) {
      if ( (i & (1<<j)) != 0 ) {
	if ( (shougen_bits[j] & exist_bits[j]) != (i & exist_bits[j]) ||
	     ((~shougen_bits[j]) & exist_bits[j]) != ((~i) & exist_bits[j]) ) {
	  ok_flag = 0;
	  j = N;
	}
      }
    }
    if ( ok_flag ) {
#if 0
      printf("i = %d(%d)\n", i, numofbits(i));
#endif
      if ( numofbits(i) > max )
	max = numofbits(i);
    }
  }
  printf("%d\n", max);
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N, M; cin >> N >> M;
  vector<pair<int, int>> vs;
  rep(_, M) {
    int a, b; cin >> a >> b;
    vs.emplace_back(a, b);
  }
  sort(vs.begin(), vs.end());
  // 1. vsの右から先頭部分を1本取り除く
  // 2. 右端が取り除いた辺の左端以下のとき、1ほん取り除く
  // 3. 2を繰り返す
  int ans = 0, right = inf;
  for (int i = vs.size() - 1; i >= 0; i--) {
    if (right >= vs[i].second) {
      ans++;
      right = vs[i].first;
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 1400
n = int(input())
a = list(map(int, input().split()))

dp = [0]*n
dp[1] = abs(a[0] - a[1])

if n > 2:
    for i in range(2,n):
        dp[i] = min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]))

print(dp[n-1])

Measured memory_bytes: 20644
#include <iostream>

using namespace std;



int main()
{
    int a,b,k,i,j=0;
    cin>>a>>b>>k;
    if (b<a)
    {i=b+1;
    while(j<k)
    {
        i--;
        if((a%i==0)&&(b%i==0))
            {j++; }

    }
    }
    else
    { i=a+1;
    while(j<k)
    {
        i--;
        if((a%i==0)&&(b%i==0))
            {j++; }

    }
    }
    cout<<i;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll N = 1e6 +9;
const ll p = 31;
const ll m = 1e9 + 7;
const ll inf= 1e14;
ll mod = 1e9+7;
ll powm(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }

int main() {   
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
     
     ll q = 1;
     // cin>>q;
 
     while(q--){
          ll a,b,k;cin>>a>>b>>k;
          ll na = max(a-k,0ll);
          k-=(a-na);
          ll nb = max(b-k,0ll);
          cout<<na<<" "<<nb;
     }
}         


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
using namespace std;
typedef pair<int, int> P;
typedef long long LL;

#define _CRT_SECURE_NO_WARNINGS
int K;
int a[100010];
LL newMin(int n,LL _min) {
	if (_min%n==0) {
		return _min;
	}
	else {
		return _min - _min % n + n;
	}
}
LL newMax(int n,LL _max) {
	return _max - _max%n + n-1;
}
int main() {
	scanf("%d",&K);
	for (int i = 0; i < K;i++) {
		scanf("%d",&a[i]);
	}
	LL min=2, max=2;
	bool f = false;
	for (int i = K - 1; i >= 0;i--) {
		min = newMin(a[i], min);
		if (min>max) {
			f = true;
			break;
		}
		max = newMax(a[i], max);
	}

	if (f) {
		printf("-1\n");
		return 0;
	}
	printf("%lld %lld\n",min,max);
	return 0;
}

Measured memory_bytes: 512
import statistics


def main():
    n = int(input())
    a = [0 for _ in range(n)]
    b = [0 for _ in range(n)]
    for i in range(n):
        a[i], b[i] = map(int, input().split())

    amed = statistics.median(a)
    bmed = statistics.median(b)

    if n % 2:
        print(int(bmed - amed + 1))
    else:
        print(int((bmed - amed) * 2 + 1))


if __name__ == '__main__':
    main()


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

//両端から累積和でiにおける左の '<' の数を右の '>' の数がわかる

int main(){
  string s;
  cin >> s;
  int n = sz(s);
  vector<ll> a(n+1,0), b(n+1,0);
  rep(i,n) {
    if (s[i] == '<') a[i+1] = a[i] + 1;
    else a[i+1] = 0;

    if (s[n-i-1] == '>') b[n-i-1] = b[n-i] + 1;
    else b[n-i-1] = 0;
  }
 
  ll res = 0;
  rep(i,n+1) {
    res += max(a[i], b[i]);
  }
 
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 8836
n, k = map(int, input().split())

if k == 0:
    print(n**2)
    exit()

answer = 0
for i in range(k + 1, n + 1):
    q = n // i; r = n % i
    answer += (i - k) * q
    if r >= k:
        answer += r - k + 1

print(answer)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll grid[1005][1005];
const ll inf=1e10;
int main(){
  int h,w;
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      char c;
      cin>>c;
      if(c=='.') grid[i][j]=inf;
      else grid[i][j]=0;
    }
  }
  for(int i=1;i<h;i++){
    for(int j=0;j<w;j++){
      grid[i][j]=min(grid[i][j],grid[i-1][j]+1);
    }
  }
  for(int i=h-2;i>=0;i--){
    for(int j=0;j<w;j++){
      grid[i][j]=min(grid[i][j],grid[i+1][j]+1);
    }
  }
  for(int i=0;i<h;i++){
    for(int j=1;j<w;j++){
      grid[i][j]=min(grid[i][j],grid[i][j-1]+1);
    }
  }
  for(int i=0;i<h;i++){
    for(int j=w-2;j>=0;j--){
      grid[i][j]=min(grid[i][j],grid[i][j+1]+1);
    }
  }
  ll ans=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      ans=max(ans,grid[i][j]);
      //cout<<grid[i][j]<<" ";
    }
    //cout<<endl;
  }
  cout<<ans<<endl;
}


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

int cnt[4];

int main(void)
{
	int n, x;
	scanf("%d", &n);
	for(int i = 0;i < n;i++)
	{
		scanf("%d", &x);
		cnt[x%4]++;
	}

	int a = cnt[0], b = cnt[1]+cnt[3]+min(1, cnt[2]);
	int sz = a+b;
	if(a < b)
	{
		if(sz%2 && a == b-1) printf("Yes\n");
		else printf("No\n");
	}
	else printf("Yes\n");
}

Measured memory_bytes: 256
N = int(input())
d = input().split()
d = [int(i) for i in d]
l = []
for i in range(N):
  for j in range(i+1,N):
    p = d[i] * d[j]
    if i == j:
      p = 0
    l.append(p)
print(sum(l))

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int a,b,c,d,e,f;

int main(){
	cin>>a>>b>>c>>d>>e>>f;
	a*=100;
	b*=100;
	vi dp(f+1),DP(f+1);
	dp[0]++;
	DP[0]++;
	for(int i=1;i<=f;i++) if(i>=a&&dp[i-a]||i>=b&&dp[i-b]) dp[i]++;
	for(int i=1;i<=f;i++) if(i>=c&&DP[i-c]||i>=d&&DP[i-d]) DP[i]++;
	vi g;
	for(int i=0;i<=f;i++) if(DP[i]) g.push_back(i);
	int A=0,B=-1;
	for(int i=1;i<=f;i++) if(dp[i]){
		int C=i/100*e;
		auto it=upper_bound(g.begin(),g.end(),min(C,f-i))-1;
		if(B*(i+*it)<*it*A){
			A=i+*it;
			B=*it;
		}
	}
	cout<<A<<' '<<B<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<long long> L(N);
  for(int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  int cnt = 0;
  for(int i = 0; i < N; i++) {
    for(int j = i+1; j < N; j++) {
      for(int k = j+1; k < N; k++) {
        if(L.at(i) != L.at(j) && L.at(j) != L.at(k) && L.at(i) != L.at(k)) {
          if(L.at(i)+L.at(j)>L.at(k)&&L.at(j)+L.at(k)>L.at(i)&&L.at(k)+L.at(i)>L.at(j)) {
            cnt++;
          }
        }
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H, N, sum=0;
  cin >> H >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
    sum += A[i];
  }
  if(H <= sum){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
#include<iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <iomanip>

#define pi 3.14159265358979
#define mod 1000000007

using namespace std;

int main(void) {
	
	double r;
	
	cin >> r;

	cout << fixed << setprecision(15) << r * 2 * pi << endl;
	return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
int main(){
 int a,b,c;
 cin >> a >> b >>c;
 if((b/a)>=c){
   cout << c;
 }
 else if((b/a)<c){
   cout << b/a;
 }
 else if(b<a){
   cout << 0;
 }
 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);

    if (a < b) {
        if (b < c){
            printf ("Yes\n");
        } else {
            printf ("No\n");
        }
    } else {
        printf ("No\n");
    }       

    return 0;
}


Measured memory_bytes: 2140
class Heap
	def initialize
		@array = []
	end

	def add(obj, key)
		@array << [obj, key]
		lift_up(@array.size - 1)
	end

	def swap(i, j)
		tmp = @array[i]
		@array[i] = @array[j]
		@array[j] = tmp
	end

	def lift_up(i)
		return if i == 0
		j = (i - 1) / 2
		if @array[i][1] < @array[j][1]
			swap(i, j)
			lift_up(j)
		end
	end

	def del_min
		min = @array[0]
		if size > 1
			@array[0] = @array.pop
			lift_down(0)
		else
			@array.pop
		end
		min
	end

	def min_obj
		@array[0][0]
	end

	def min_key
		@array[0][1]
	end

	def lift_down(i)
		j = 2 * i + 1
		k = j + 1
		if k >= size
			return if j >= size
			if @array[i][1] > @array[j][1]
				swap(i, j)
				lift_down(j)
			end
		else
			l = (@array[j][1] < @array[k][1] ? j : k)
			if @array[i][1] > @array[l][1]
				swap(i, l)
				lift_down(l)
			end
		end
	end

	def empty?
		@array.empty?
	end

	def size
		@array.size
	end
end

n = gets.to_i
friends = (1..n).map{ gets.split(/\s+/).map(&:to_i) }.sort

queue = Heap.new
max = 0
(1..n+1).each{|k|
	queue.add(*friends.shift) while !friends.empty? && friends[0][0] == k
	max = k - 1 if queue.size >= k - 1
	queue.del_min while !queue.empty? && queue.min_key == k 
}
puts max

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
vector<ll> A(200002);
ll N,K;


bool check(ll value){
    ll count = 0;
    REP(i,N){
        count += ((A[i] + value - 1) / value) - 1;
    }

    if (count <= K) return true;
    else return false;
}


ll binary_search(ll key){
	// lower_bound (a-1,b] (ans = [a,b])
	// <= left never satisfy
	// right <= always satisfy

	ll left = 0; 
	ll right = 1e9+1; // index of size + 1;

	while(right - left > 1){
			ll mid = left + (right - left) / 2;

			if (check(mid)) right = mid;
			else left = mid;
	}

	// left is the maximum that don't satisfy the condition.
	// right is the minimum that satisfies the condtion.
	
	return right; 

}

int main() {
    cin >> N >> K;
    REP(i,N){
        cin >> A[i];
    }

    ll ans = binary_search(100);
    cout << ans << endl;
}

Measured memory_bytes: 4696
#include<iostream>
#include<math.h>
using namespace std;
string s,t,re;
long long f[3003][3003];
main()
{
	cin>>s>>t;
	s = " "+s;
	t = " "+t;
	for(int i = 1;i < s.size();i++)
		for(int j = 1;j < t.size();j++)
		{
			if(s[i] == t[j])
				f[i][j] = f[i-1][j-1]+1;
			else
				f[i][j] = max(f[i-1][j],f[i][j-1]);
		}
	int a = s.size()-1,b = t.size()-1;
	while(b > 0 && a > 0)
	{
		if(f[a][b] != max(f[a-1][b],f[a][b-1]))
		{
			re.push_back(s[a]);
			a--;
			b--;
		}
		else
			if(f[a][b] == f[a-1][b])a--;
			else b--;
	}
	for(int i = re.size()-1;i >= 0;i--)
		cout<<re[i];
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	ll t,n,i,j,k,l,f;
	cin>>n;
	vc a(n+1);ll sum=0;
	for(i=1;i<=n;i++){cin>>a[i];}
	sort(a.begin()+1,a.end(),greater<ll>());
	sum+=a[1];
	k=n-2;
	for(i=2;i<=k/2+1;i++)
	{
	    sum+=2*a[i];
	}
	if(k&1)sum+=a[k/2+2];
	cout<<sum<<"\n";
	return 0;
}

Measured memory_bytes: 4784
#include<stdio.h>

int main(){
  int n, F[50];
  F[0] = 1;
  F[1] = 1;
  scanf("%d", &n);

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

  printf("%d\n", F[n]);

  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int x,y,z;cin>>x>>y>>z;

    cout<<z<<" "<<x<<" "<<y<<"\n";

    return 0;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>



int main() {
  int i, j, k, N = 0, num, g[4020], b[4020], r[4020];
  long long ans = 0;
  char S[4020], I, J, K;
  scanf("%d %s", &N, S);
  num = 0;
  for (i = 0; i < N; i++) {
    if (S[i] == 'G') num++;
    g[i] = num;
  }
  num = 0;
  for (i = 0; i < N; i++) {
    if (S[i] == 'B') num++;
    b[i] = num;
  }
  num = 0;
  for (i = 0; i < N; i++) {
    if (S[i] == 'R') num++;
    r[i] = num;
  }
  for (i = 0; i < N - 2; i++) {
    I = S[i];
    for (j = i + 1; j < N - 1; j++) {
      J = S[j];
      if (I != J) {
        num = j + j - i;
        K = 'R' + 'G' + 'B' - I - J;
        if (K == 'R') {
          ans += r[N - 1] - r[j];
          if (num < N && S[num] == 'R') ans--;
        }
        else if (K == 'G') {
          ans += g[N - 1] - g[j];
          if (num < N && S[num] == 'G') ans--;
        }
        else {
          ans += b[N - 1] - b[j];
          if (num < N && S[num] == 'B') ans--;
        }
      }
    }
  }
  printf("%lld", ans);
  return 0;
}


Measured memory_bytes: 1756
#include <iostream>

using namespace std;
int a, b, c, d;
int main()
{
    cin >> a >> b >> c >> d;
    if(a + b > c + d){
        cout << "Left";
    } else if (a + b == c + d){
        cout << "Balanced";
    } else if (a + b < c + d){
        cout << "Right";
    }
    return 0;
}


Measured memory_bytes: 256
n=list(input())
a=list('abcdefghijklmnopqrstuvwxyz')

b=[0]*26

for i in range(len(n)):
    for j in range(26):
        if n[i]==a[j]:
            b[j]+=1
f=0
for i in range(26):
    if b[i]>1:
        f=1
if f==0:
    print('yes')
else:
    print('no')

Measured memory_bytes: 3064
use std::collections::VecDeque;
use std::io::*;
use std::str::FromStr;

fn main() {
    let (n, m): (usize, usize) = (read(), read());
    let s: Vec<char> = read::<String>().chars().collect();
    let mut graph: Vec<Vec<usize>> = vec![Vec::new(); n];
    let mut count: Vec<(i32, i32)> = vec![(0, 0); n];
    for _ in 0..m {
        let (a, b) = (read::<usize>() - 1, read::<usize>() - 1);
        graph[b].push(a);
        if s[a] == 'A' {
            count[b].0 += 1;
        } else {
            count[b].1 += 1;
        }
        if a == b {
            continue;
        }
        graph[a].push(b);
        if s[b] == 'A' {
            count[a].0 += 1;
        } else {
            count[a].1 += 1;
        }
    }
    let mut que: VecDeque<usize> = VecDeque::new();
    let mut deleted = vec![false; n];
    for i in 0..n {
        if count[i].0 <= 0 || count[i].1 <= 0 {
            deleted[i] = true;
            que.push_back(i);
        }
    }
    while !que.is_empty() {
        let p = que.pop_front().unwrap();
        for i in &graph[p] {
            if deleted[*i] {
                continue;
            }
            if s[p] == 'A' {
                count[*i].0 -= 1;
            } else {
                count[*i].1 -= 1;
            }
            if count[*i].0 <= 0 || count[*i].1 <= 0 {
                deleted[*i] = true;
                que.push_back(*i);
            }
        }
    }
    let mut ok = false;
    for i in 0..n {
        if count[i].0 > 0 && count[i].1 > 0 {
            ok = true;
        }
    }
    println!("{}", if ok { "Yes" } else { "No" });
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 18684
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
  int n;
  cin >> n;
  VI a(n);
  ll sum=0;
  map<int ,int> cnt;
  rep(i,n){
     cin >> a[i];
     sum+=a.at(i);
     if(cnt.count(a[i])){
        cnt.at(a[i])++;
     }
     else{
        cnt[a[i]]=1;
     }
     }
  
  int q;
  cin >> q;
  VI b(q);
  VI c(q);
  rep(i,q){
     cin >> b[i] >> c[i];
  }
  rep(i,q){
     if(cnt.count(b[i])){
        sum+=(cnt.at(b[i]))*(c[i]-b[i]);
        if(cnt.count(c[i])){
           cnt.at(c[i])+=cnt.at(b[i]);
           cnt.erase(b[i]);
        }
        else{
           cnt[c[i]]=cnt.at(b[i]);
           cnt.erase(b[i]);
        }
     }
     cout << sum << endl;
  }

}
    

Measured memory_bytes: 7352
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359

int main(){
  ll N;
  cin>>N;
vector<ll> ans;
ll ttt =0;
  for(ll i=1;i<=N;i++){
    ttt+=i;
    ans.push_back(i);

    if(ttt==N){
      break;
    }

    if(ttt>N){
      ll dt = ttt-N;
      for(ll j=0;j<ans.size();j++){
        if(ans[j]==dt){
          ans[j]=-10;
        }
      }
break;
    }
  }

  for(ll i=0;i<ans.size();i++){
    if(ans[i]>=0){
      cout<<ans[i]<<endl;
    }
  }

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    set<ll> st,st1;
    for(int i = 0 ; i < n; i++)
    {
        ll x,y;
        cin>>x>>y;
        st.insert(x+y);
        st1.insert(x-y);
       // cout<<(x+y)<<" "<<(x-y)<<endl;
    }
    ll fst=abs(*st.rbegin()-*st.begin());
    ll scnd=abs(*st1.rbegin()-*st1.begin());
    cout<<max(fst,scnd)<<endl;
    return 0;
}


Measured memory_bytes: 22376
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("fma,avx")

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    char ch;
    cin >> ch;
    if ('a' <= ch && ch <= 'z') {
        cout << 'a';
    } else {
        cout << 'A';
    }

    return 0;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

string S;

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

  int ans = 0;
  int l = S.size();
  for (int i = 0; i < l / 2; i++) {
    if (S[i] != S[l - i - 1]) {
      ans++;
    }
  }

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

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<String, Integer> hash = new HashMap<String, Integer>();
		po:for(int j = 0;j<n;j++){
			String l = "";
			for(int i = 0;i<n;i++){
				String po = sc.next();
				if(!po.substring(0,1).equals(l)){
					if(i > 0){
						break po;
					}
				}
				if(hash.containsKey(po)){
					break po;
				}else{
					hash.put(po, 1);
				}
				l = po.substring(po.length()-1);
				
			} 
			System.out.println("Yes");
			System.exit(0);
		}
		System.out.println("No");
		
		
		
	}
}


Measured memory_bytes: 23252
import bisect

n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(m)]  # 市iの順番を保つ
py_list = [[] for _ in range(n)]  # 市iの(属する県, 誕生年)

for p, y in data:
    py_list[p-1].append(y)

for i in range(n):
    py_list[i].sort()

for p, y in data:
    pos = bisect.bisect_left(py_list[p-1], y) + 1
    print("%06d%06d" % (p, pos))

Measured memory_bytes: 76632
#include <stdio.h>
int main(){
	int a[3],max =0,k,i,sum;
	scanf("%d",&a[0]);
	for(i =1;i<3;i++){
		scanf("%d",&a[i]);
		if(a[i]>a[i-1]) max=i;
	}
	scanf("%d",&k);
	sum = a[max];
	for(i= k;i>0;i--){
		sum = sum *2;
	}
	sum =sum +a[0]+a[1]+a[2]-a[max];
	printf("%d\n",sum );
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()

using namespace std;

const int MSIZE = 16;

int g[MSIZE][MSIZE];
long long Precalc[1 << MSIZE];
vector<int> indexes[1 << MSIZE];
long long dp[1 << MSIZE];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> g[i][j];
        }
    }
    for (int mask = 0; mask < (1 << n); mask++) {
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if ((mask >> i) & (mask >> j) & 1) {
                    Precalc[mask] += g[i][j];
                }
            }
        }
        for (int i = 0; i < n; i++) {
            if (((mask >> i) & 1) == 0) {
                indexes[mask].push_back(i);
            }
        }
    }

    vector<pair<int,int> > masks(1 << n);
    for (int mask = 0; mask < (1 << n); mask++) {
        masks[mask] = make_pair(__builtin_popcount(mask), mask);
    }
    sort(all(masks));

    for (int i = 1; i < (1 << n); i++) {
        int mask = masks[i].second;
        int sz = indexes[mask].size();
        for (int mask2 = mask; mask2 > 0; mask2 = (mask2 - 1) & mask) {
            dp[mask] = max(dp[mask ^ mask2] + Precalc[mask2], dp[mask]);
        }
    }
    cout << dp[(1 << n) - 1] << endl;
}


Measured memory_bytes: 8704
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	int n, ans = 0;
	double t, a, temp = 700;
	cin >> n >> t >> a;
	for (int i = 1; i <= n; i++) {
		double h;
		cin >> h;
		if (abs(a - (t - h * 0.006)) < temp) {
			temp = abs(a - (t - h * 0.006));
			ans = i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
loop do
  x, y, z = gets.chomp.split.map{|i| i.to_i}.sort
  break if x == 0 && y == 0 && z == 0

  r = Math::sqrt( x ** 2 + y ** 2 ) / 2

  n = gets.chomp.to_i
  n.times do
    l = gets.chomp.to_i
    puts r < l ? "OK" : "NA"
  end
end

Measured memory_bytes: 6124
#include<iostream>
using namespace std;
int main()
{
    int w,j=0;
    char a[1100];
    string s;
    cin>>s;
    cin>>w;
    for(int i=0;i<s.size();i+=w)
    {
        a[j++]=s[i];
    }
    for(int k=0;k<j;k++)
    {
        cout<<a[k];
    }
    return 0;
}


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

int main() {
	
	string table = "abcdefghijklmnopqrstuvwxyz.?! ",s,t;
	int i,l;
	
	while(cin>>s){
		l=s.length();
		t="";
		
		if(l%2)
			t="NA";
		else
			for(i=0;i<l;i+=2){
				if(s[i]<=54&&s[i]>=49&&s[i+1]<=53&&s[i+1]>=49)
					t += table[s[i]*5+s[i+1]-294];
				else{
					t="NA";break;
				}
			}
		cout<<t<<endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    string o, e;
    cin >> o >> e;
    string ret(o.size() + e.size(), ' ');
    for (int i = 1; i <= ret.size(); ++i) {
        if (i % 2 == 0)
            ret[i - 1] = e[i / 2 - 1];
        else
            ret[i - 1] = o[(i - 1) / 2];
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    if((n-1)%(k-1)==0) 
        cout<<(n-1)/(k-1)<<endl;
    else 
        cout<<(n-1)/(k-1)+1<<endl;
    return 0;
}

Measured memory_bytes: 3944
from math import factorial
N, A, B = map(int, input().split())
MOD = 10 ** 9 + 7

def calc(n):
    ret = 1
    for i in range(n):
        ret = ret * (N - i) % MOD
    return ret * pow(factorial(n), MOD - 2, MOD) % MOD

print(max(0, (pow(2, N, MOD) - ((calc(A) + calc(B)) % MOD) - 1) % MOD))

Measured memory_bytes: 5344
X,N=map(int,input().split())
p_list=set(map(int,input().split()))

ans1 = X
ans2 = X

while True:
  if ans2 not in p_list:
    print(ans2)
    exit()
  if ans1 not in p_list:
    print(ans1)
    exit()

  ans1 += 1
  ans2 -= 1


Measured memory_bytes: 61736
#!/usr/bin/env python3
import sys, itertools

def solve(S: str):
    ans = 0
    for i in range(1<<(len(S)-1)):
        # i の bit が記号の挿入位置に当たる
        # print(i, format(i, 'b'), len(format(i,'b'))-1)
        tmp =int(S[0])
        for j in range(len(S)-1):
            # print(format(i, 'b'), j, bool(i & (1<<j))) # 挿入位置の判定
            if i & (1<<j): ans+=tmp;tmp=0;
            tmp*=10
            tmp+=int(S[j+1])
        ans+=tmp
    print(ans)
def main():
    def read(): return sys.stdin.readline().rstrip()
    solve(read())

if __name__ == '__main__':
    main()
# s = list(sys.stdin.rea

Measured memory_bytes: 67848
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	string S; cin >> S;
	int N = S.size() - 1;
	ll ans = 0;
	for (ll bit = 0; bit < (1 << N); ++bit) {
		ll tmp = S[0] - '0';
		for (int i = 0; i < N; ++i) {
			if (bit & (1 << i)) {
				ans += tmp;
				tmp = S[i + 1] - '0';
			} else {
				tmp = tmp * 10 + (S[i + 1] - '0');
			}
		}
	    ans += tmp;
	}
	cout << ans << endl;
}

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


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val matrix = Array.fill[Array[Int]](3)(Array.fill[Int](3)(0))
    for (i <- 0 until 3; j <- 0 until 3) {
      matrix(i)(j) = sc.nextInt()
    }
    val a = Array.fill[Int](3)(0)
    val b = Array.fill[Int](3)(0)
    for (i <- 0 until 3) {
      b(i) = matrix(0)(i) - a(0)
    }
    for (i <- 0 until 3) {
      a(i) = matrix(i)(0) - b(0)
    }

    var ans = true
    for (i <- 0 until 3; j <- 0 until 3) {
      if (matrix(i)(j) != a(i) + b(j)) {
        ans = false
      }
    }

    if (ans) println("Yes")
    else println("No")
  }
}


Measured memory_bytes: 27460
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

for i in range(len(S)):
	if i % 2 == 0:
		if (S[i] == "R") or (S[i] == "U") or (S[i] == "D"):
			continue
		else:
			print("No")
			exit()
	else:
		if (S[i] == "L") or (S[i] == "U") or (S[i] == "D"):
			continue
		else:
			print("No")
			exit()

print("Yes")

Measured memory_bytes: 59688
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
T = input()

ans = 0
for s, t in zip(S, T):
    if s != t:
        ans += 1
print(ans)


Measured memory_bytes: 10340
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* class */
class DisjointSet {
    public:
    vector<int> d;
    DisjointSet(int size) : d(size, -1) {}
    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;
        return true;
    }
};
/* global variables */
/* function */
/* main */
int main(){
    int N, M, a, b;
    cin >> N >> M;
    DisjointSet ds = DisjointSet(N);
    vector<int> p(N);
    for (int i = 0; i < N; i++) {cin >> a; a--; p[i] = a;}
    for (int i = 0; i < M; i++) {
        cin >> a >> b; a--, b--;
        ds.unite(a, b);
    }
    set<int> roots;
    for (int i = 0; i < N; i++) { roots.insert(ds.find(i)); }
    map<int, int> mp;
    int l = 0;
    for (auto itr = roots.begin(); itr != roots.end(); itr++, l++) {
        mp[*itr] = l;
    }
    vector<set<int> > A(roots.size(), set<int>()), B(roots.size(), set<int>());
    int root;
    for (int i = 0; i < N; i++) {
        root = ds.find(i);
        A[mp[root]].insert(i);
        B[mp[root]].insert(p[i]);
    }
    int ans = 0;
    set<int> res;
    for (int i = 0; i < roots.size(); i++) {
        set_intersection(A[i].begin(), A[i].end(),
                    B[i].begin(), B[i].end(),
                    inserter(res, end(res)));
        ans += res.size();
        res.clear();
    }
    cout << ans << '\n';
}

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

using namespace std;

int bit[64];

void addBitCount(unsigned long long t) {
    bit[0] += ((t - 1) / 2 + 1) % 2;
    for (unsigned long long k = 63; 0 < k; --k) {
        unsigned long long m = (1ULL << k);
        if (t & m) { 
            bit[k] += ((t - m) + 1) % 2;
            t %= m;
        }
    }
}

void minusBitCount(unsigned long long t) {
    bit[0] -= ((t - 1) / 2 + 1) % 2;
    for (unsigned long long k = 63; 0 < k; --k) {
        unsigned long long m = (1ULL << k);
        if (t & m) { 
            bit[k] -= ((t - m) + 1) % 2;
            t %= m;
        }
    }
}

int main() {
    unsigned long long i, j; cin >> i >> j;
    if (i == j) {
        cout << i << endl;
        return 0;
    }
    addBitCount(i - 1);
    minusBitCount(j);

    unsigned long long res = 0;
    for (int i = 0; i < 64; ++i) {
        if (bit[i] % 2) {
            res |= (1ULL<<i);
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#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[i];
  }
  
  int btn = 1,count = 0;
  for ( int i = 0; i < n; i++){
    btn = a[btn-1];
    count++;
    if ( btn == 2 ){
      cout << count << endl;
      return 0;
    }     
  }
  
  cout << -1 << endl;
  
}

Measured memory_bytes: 640
/*
ID: seekho
PROG: friday
LANG: C++14                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 100005;

int n;
int memo[101][N];
int val[101], wt[101];

int go(int i, int left) {
	if(i >= n) return 0;
	if(memo[i][left] != -1)
		return memo[i][left];

	int &ans = memo[i][left];

	if(left-wt[i] >= 0)
		ans = val[i] + go(i+1,left-wt[i]);
	ans = max(ans, go(i+1,left));
	return ans;
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);

    int w;cin >> n >> w;
    rep(i,n) cin >> wt[i] >> val[i];
    rep(i,n) {
    	rep(j,w+1) memo[i][j] = -1;
    }

    cout << go(0,w) << '\n';
}

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

int main() {
    long long int a, b, c, k;
    cin >> a >> b >> c >> k;
    int maior;
    if(a > b){
        if(a > c){
            maior = a;
        }
        else{
            maior = c;
        }
    }
    else{
        if(b > c){
            maior = b;
        }
        else{
            maior = c;
        }
    }

    int total = a + b + c - maior;


    for(int i =0; i < k; i++){
        maior += maior;
    }
    
    total += maior;
    cout << total <<endl;
}

Measured memory_bytes: 256