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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int N, M; cin >> N >> M;
	vector<int> A(N);
	rep(i, N) cin >> A[i];
	sort(all(A));

	vector<pair<int, int>> vp(M);
	rep(i, M) {
		int b, c; cin >> b >> c;
		vp[i] = make_pair(c, b);
	}
	sort(all(vp), greater<pair<int, int>>());

	int min_a = 0;
	rep(i, M) {
		if (A[min_a] >= vp[i].first) break;
		rep (j, vp[i].second) {
			if (A[min_a] >= vp[i].first) break;
			A[min_a] = vp[i].first;
			min_a++;
		}
	}

	ll ans = 0;
	rep(i, N) ans += A[i];
	cout << ans << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<string>vec;
    string ch;
    int t;
    cin>>t;
    while(t--)
    {
        cin>>ch;
        vec.push_back(ch);
    }
    sort(vec.begin(),vec.end());
    vec.erase(unique(vec.begin(),vec.end()),vec.end());
    cout<<vec.size()<<endl;
}


Measured memory_bytes: 11552
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
// int mI(int a, int m)  {return power(a, m - 2, m);}
vector<vector<int>> dir = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1},{1,2},{1,-2},{-1,2},{-1,-2}};

void solve(){
    vec v(5);
    fo(i,5){
        cin >> v[i];
    }
    fo(i,5){
        if(v[i]==0){
            cout << i + 1;
            return;
        }
    }

}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3608
package main

import (
	"fmt"
	"unicode/utf8"
)

func main() {
	var s, t string
	_, _ = fmt.Scanf("%s", &s)
	_, _ = fmt.Scanf("%s", &t)

	fmt.Println(answer167A(s, t))
}

func answer167A(s string, t string) string {
	tLength := utf8.RuneCountInString(t)

	if t[:tLength-1] == s {
		return "Yes"
	}
	return "No"
}


Measured memory_bytes: 1832
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int p[110000];
int cnt[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	cnt[0]=3;
	long long ret=1;
	for(int i=0;i<a;i++){
		if(cnt[p[i]]==0){
			ret=0;break;
		}
		ret=ret*cnt[p[i]]%mod;
		cnt[p[i]]--;
		cnt[p[i]+1]++;
	}
	printf("%lld\n",ret);
}


Measured memory_bytes: 896
N = int(input())
S = input()
S = '.' + S

b_tot, w_tot = 0, 0
for s in S:
    if s == '.':
        w_tot += 1
    else:
        b_tot += 1

b_left, w_left = 0, 0
tmp = 3 * 10**5
for s in S:
    if s == '.':
        w_left += 1
    else:
        b_left += 1
    tmp = min(tmp, b_left + w_tot - w_left)
print(tmp)

Measured memory_bytes: 3628
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


int main()
{
    int N;
    cin >> N;

    ll s = 0;

    reple(i, 1, N)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            s += i;
        }
    }


    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3636
// Apna Time Aayega :)
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define MOD 1000000007
#define vpi vector<pair<int, int>>
#define ll long long int
#define MAX 1000000
#define inf 1000000000
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#include <chrono>

vector< pair<int, int> > findSubArrays(int arr[], int n) 
{ 
    // create an empty map 
    unordered_map<int, vector<int> > map; 
   
    // create an empty vector of pairs to store 
    // subarray starting and ending index 
    vector <pair<int, int>> out; 
   
    // Maintains sum of elements so far 
    int sum = 0; 
   
    for (int i = 0; i < n; i++) 
    { 
        // add current element to sum 
        sum += arr[i]; 
   
        // if sum is 0, we found a subarray starting 
        // from index 0 and ending at index i 
        if (sum == 0) 
            out.push_back(make_pair(0, i)); 
   
        // If sum already exists in the map there exists 
        // at-least one subarray ending at index i with 
        // 0 sum 
        if (map.find(sum) != map.end()) 
        { 
            // map[sum] stores starting index of all subarrays 
            vector<int> vc = map[sum]; 
            for (auto it = vc.begin(); it != vc.end(); it++) 
                out.push_back(make_pair(*it + 1, i)); 
        } 
   
        // Important - no else 
        map[sum].push_back(i); 
    } 
   
    // return output vector 
    return out; 
} 

int main() {
    FIO
    int N; cin>>N;
    bool ans = false;
    while(N!=0){
        int l = N%10;
        N = N/10;
        if(l==7) ans = true;
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> V(N), C(N);
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }
    int sum = 0;
    for (int i = 0; i < N; i++) {
        if (V[i] >= C[i]) {
            sum += V[i] - C[i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
f=range
h,w,k=map(int,input().split())
g=[[int(i) for i in input()] for _ in f(h)]
s=[[0]*-~w for _ in f(h+1)]
for i in f(h):
  for j in f(w):
    s[i+1][j+1]=s[i+1][j]+s[i][j+1]+g[i][j]-s[i][j]
a=h+w
for i in f(2**~-h):
  u=d=l=r=c=0
  e=[]
  while d<h:
    d+=1
    if i>>d-1&1: e+=[(u,d)]; c+=1; u=d
  e+=[(u,h)]
  while r<w:
    if max(s[d][r+1]-s[u][r+1]-s[d][l]+s[u][l] for u,d in e)>k:
      if r==l: break
      c+=1; l=r
    r+=1
  else: a=min(a,c)
print(a)

Measured memory_bytes: 43868
#include<cstdio>
#include<cstring>
#define MN 300000
#define MOD 1000000007
char s[MN+5];
int p[MN+5],f[MN+5][3][3];
inline void rw(int&a,int b){if((a+=b)>=MOD)a-=MOD;}
int main()
{
	int n,i,j,k,ans=0;
	scanf("%s",s+1);n=strlen(s+1);
	for(p[n+1]=1,i=n;i;--i)p[i]=(p[i+1]<<(s[i]=='?'))%MOD;
	for(f[0][0][0]=i=1;i<=n;++i)for(j=0;j<3;++j)for(k=0;k<3;++k)
	{
		if(s[i]!='0')
			if(k)rw(f[i][j][k-1],f[i-1][j][k]);
			else if(j<2)rw(f[i][j+1][k],f[i-1][j][k]);
			else rw(ans,1LL*f[i-1][j][k]*p[i+1]%MOD);
		if(s[i]!='1')rw(f[i][j][k<2?k+1:1],f[i-1][j][k]);
	}
	rw(ans,f[n][1][0]);
	rw(ans,f[n][2][1]);
	printf("%d",ans);
}

Measured memory_bytes: 12160
let () =
  let ns =
    let ss = Str.split (Str.regexp " ") (read_line ()) in
    List.map int_of_string ss in
  let result = (match ns with
    | [a; b; c] when a < b && b < c -> "Yes"
    | _ -> "No") in
  print_endline result

Measured memory_bytes: 2116
#include<stdio.h>
int main(){
  int n,count=0,i;
  char x[200002];
  scanf("%d",&n);
  scanf("%*c%s",x);
  for(i=0;i<n;i++){
    if(x[i]=='1')
      count++;
  }
  int popcount[200002];
  popcount[0]=0;
  for(i=1;i<200001;i++){
    int temp=i,check=0;
    while(temp!=0){
      if(temp%2==1)
        check++;
      temp/=2;
    }
    popcount[i]=popcount[i%check]+1;
  }
  int mod[n][2];
  int num[2]={0,0};
  for(i=n-1;i>=0;i--){
    if(i==n-1){
      mod[n-1][0]=1;
      mod[n-1][1]=1;
    }
    else{
      mod[i][0]=(2*mod[i+1][0])%(count+1);
      if(count>1)
        mod[i][1]=(2*mod[i+1][1])%(count-1);
      else
        mod[i][1]=0;
    }
    if(x[i]=='1'){
      num[0]=(num[0]+mod[i][0])%(count+1);
      if(count>1)
        num[1]=(num[1]+mod[i][1])%(count-1);
    }
  }
  for(i=0;i<n;i++){
    int ans;
    if(x[i]=='1' && count-1==0)
      ans=0;
    else if(x[i]=='1')
      ans=popcount[(num[1]-mod[i][1]+count-1)%(count-1)]+1;
    else
      ans=popcount[(num[0]+mod[i][0])%(count+1)]+1;
    printf("%d\n",ans);
  }
  return 0;
}

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

using namespace std;

int n, m, x, ans = 1e9;
int a[13][13], c[13], level[13];

void dfs(int cur, int money) {
    if (cur == n + 1) {
        for (int i = 1; i <= m; i++)
            if (level[i] < x) return;
        ans = min(ans, money);
        return;
    }
    for (int i = 1; i <= m; i++)
        level[i] += a[cur][i];
    dfs(cur + 1, money + c[cur]);
    for (int i = 1; i <= m; i++)
        level[i] -= a[cur][i];
    dfs(cur + 1, money);
}

int main() {
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m >> x;
    for (int i = 1; i <= n; i++) {
        cin >> c[i];
        for (int j = 1; j <= m; j++) 
            cin >> a[i][j];
    }
    dfs(1, 0);
    cout << (ans == 1e9 ? -1 : ans) << endl;
    return 0;
}


Measured memory_bytes: 3620
S = input()
N = len(S)
cand1 = '01' * (N // 2) + '0' * (N % 2)
cand2 = '10' * (N // 2) + '1' * (N % 2)

count1 = 0
count2 = 0
for i in range(N):
    if S[i] != cand1[i]:
        count1 += 1
    if S[i] != cand2[i]:
        count2 += 1
        
ans = min(count1, count2)
print(ans)

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

cand_index = [0] 
for i in range(n-1):
    if s[i] != s[i+1]:
        cand_index.append(i+1)
cand_index.append(n)

count = []
for i in range(len(cand_index)-1):
    index = min(i+2*k+int(s[cand_index[i]]=="1"), len(cand_index)-1)
    count.append(cand_index[index]-cand_index[i])
        
print(max(count))

Measured memory_bytes: 11132
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int Y=sc.nextInt();
		int X=sc.nextInt();
		for(int i=0; i<Y; i++) {
			for(int j=0;j<X; j++) {
				String tmp=sc.next();
				if(tmp.equals("snuke")) {
					pl(((char)('A'+j))+""+(i+1));
					System.exit(0);
				}
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
const int mod=1000000007;
const int INF=1e18;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    string s;
    cin>>s;
    n=s.length();
    int flag=0;
    f(i,0,n/2)
    {
        if(s[i]!=s[n-i-1])
            flag=1;
    }
    n/=2;
    f(i,0,n)
    {
        if(s[i]!=s[n-i-1])
            flag=1;
    }
    if(flag==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MAX(a,b) ((a>b)?a:b)
#define MIN(a,b) ((a>b)?b:a)
using namespace std;


int gcd(int a, int b)
{
	if (static_cast<int>(MAX(a, b) % MIN(a, b)) == 0)
		return static_cast<int>(MIN(a, b));

	return gcd(MAX(a, b), static_cast<int>(MAX(a, b) % MIN(a, b)));
}

int main()
{
	int A, B, K;
	cin >> A >> B >> K;
	int GCD = gcd(A, B);

	for (int i = GCD, j = 0; i > 0; i--)
	{
		if ((A % i == 0) && (B % i == 0))
			j++;

		if (j == K)
		{
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
// Package main provides
//
// File:  1237.go
// Author: ymiyamoto
//
// Created on Wed Jul 11 10:35:26 2018
//
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func comb(ns []string, aux [][]string) [][]string {
	if len(ns) == 0 {
		return aux
	}
	v := ns[0]
	a := [][]string{}
	for _, au := range aux {
		tmp := make([]string, len(au))
		copy(tmp, au)
		tmp[len(tmp)-1] += v
		a = append(a, tmp)

		au = append(au, v)
		a = append(a, au)
	}

	return comb(ns[1:], a)
}

func main() {
	for {
		var d int
		var num string
		fmt.Scan(&d, &num)
		if d == 0 {
			break
		}

		var min int
		ns := strings.Split(num, "")
		for i := range ns {
			v, _ := strconv.Atoi(ns[i])
			min += v
		}

		var ans int
		var pat []string
		var hasSame bool
		for _, c := range comb(ns[1:], [][]string{{ns[0]}}) {
			var total int
			for _, v := range c {
				n, _ := strconv.Atoi(v)
				total += n
			}
			if ans == total {
				hasSame = true
			} else if ans < total && total <= d {
				ans = total
				pat = c
				hasSame = false
			}
		}

		if ans == 0 {
			fmt.Println("error")
		} else if hasSame {
			fmt.Println("rejected")
		} else {
			fmt.Println(ans, strings.Join(pat, " "))
		}
	}
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;


int main(){
    ll n;cin >>n;
    vector<ll>dp(n+1,INF);
    vector<ll>yen;
    yen.push_back(1);
    ll r=6,l=9;
    while(r<=n){
        yen.push_back(r);
        r*=6;
    }
    while(l<=n){
        yen.push_back(l);
        l*=9;
    }
    dp[0]=0;
    for (int i = 0; i < n; ++i) {
        for(ll u:yen){
            if(i+u<=n){
                dp[i+u]=min(dp[i]+1,dp[i+u]);
            }
        }
    }
    cout <<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
/* B - Product Max */

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

int main(){
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long max = a * c;
  if(max < a * d){
    max = a * d;
  }
  if(max < b * c){
    max = b * c;
  }
  if(max < b * d){
    max = b * d;
  }
  cout << max << endl;
}


Measured memory_bytes: 3568
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
#include <memory.h>

// pi = atan(1)*4;

#define MAX 2100000000
#define PI 3.14159265358979323846
const int Mod = 100000007;

using namespace std;

int main(void)
{
	string n;

	cin >> n;

	if (((n[0] == n[1]) && (n[0] == n[2])) || ((n[1]==n[2]) && (n[1]==n[3])))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

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

const int mxN = 2e5 + 2;
int n, points[mxN][3], dp[mxN][3];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> points[i][0] >> points[i][1] >> points[i][2];
    }

    for (int i = n - 1; i >= 1; i--)
    {
        for (int j = 0; j < 3; j++)
        {
            int ret = -1;
            for (int t = 0; t < 3; t++)
            {
                if (t == j)
                    continue;
                ret = max(ret, points[i][t] + dp[i + 1][t]);
            }
            dp[i][j] = ret;
        }
    }

    cout << max({points[0][0] + dp[1][0], points[0][1] + dp[1][1], points[0][2] + dp[1][2]});
}

Measured memory_bytes: 5904
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan =new Scanner(System.in);
		int a=scan.nextInt();
		int a2=a*a;
		int a3=a*a*a;
		int sum=a+a2+a3;
		System.out.println(sum);
	}

}


Measured memory_bytes: 35540
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
 
typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;
 
const double PI = 3.141592653589793238463;
 
using namespace std;
 
const int MAXN = 1000500;
// const int MAXN = 1050;
// const long long int mod = 1000003;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;
 
i64 mod = 1000000009;
 
i64 n, m, r;
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	cout.precision(16);
 
	cin >> r;
	cout << 2 * r*PI << endl;
 
 
	//a.resize(n + 1);
	//dp.assign(n + 1, -1);	
 
	return 0;
}

Measured memory_bytes: 3228
import sys
def input(): return sys.stdin.readline().strip()


def main():
    A = list(map(int, input().split()))
    K = int(input())

    def dfs(k):
        if k == 0: return sum(A)
        A[0] *= 2
        cand1 = dfs(k - 1)
        A[0] //= 2
        A[1] *= 2
        cand2 = dfs(k - 1)
        A[1] //= 2
        A[2] *= 2
        cand3 = dfs(k - 1)
        A[2] //= 2
        return max(cand1, cand2, cand3)

    print(dfs(K))

if __name__ == "__main__":
    main()


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

using ll = long long;

const int mod = 1e9 + 7;
vector<int> x[15], y[15];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        x[i].resize(A);
        y[i].resize(A);
        for (int j = 0; j < A; j++) {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    int ans = 0;
    for (int bit = 0; bit < (1 << N); bit++) {
        bool ok = 1;
        for (int i = 0; i < N; i++) {
            if (((bit >> i) & 1) == 0)
                continue;
            for (int j = 0; j < x[i].size(); j++) {
                if (((bit >> x[i][j]) & 1) != y[i][j]) {
                    ok = 0;
                    break;
                }
            }
            if (!ok)
                break;
        }
        int cnt = 0;
        for (int i = 0; i < N; i++) {
            if (bit & (1 << i))
                cnt++;
        }
        if (ok)
            ans = max(ans, cnt);
    }
    cout << ans << endl;
}

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

int main(){
	int l[10],v1,v2;
	while(scanf("%d",&l[0])!=EOF){
		int dis=l[0];
		for(int i=1;i<10;i++){
			scanf(",%d",&l[i]);
			dis+=l[i];
		}
		scanf(",%d,%d",&v1,&v2);
		double time=(double)dis/(v1+v2);
		double conf=(double)v1*time;
		double len=0.0;
		for(int i=0;i<10;i++){
			len+=l[i];
			if(len>=conf){
				cout<<i+1<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1208
MODE = "stdio"

line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = "\
  3 2
  2 2
  5 3
  0 0
  ".split("\n")
  tmp.each{|s|
    line << s.strip
  }
end


list = Array.new

list = line.map{|s| s.split(" ")}
  
list.each do|l|
  l.map!(&:to_i)
  l.sort!
end

list.each do |a,b|
  puts "#{a} #{b}" if !(a==0 && b==0)
end

Measured memory_bytes: 8792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	ll a, b, c, k; cin >> a >> b >> c >> k;
	ll ans;
	if(k%2==0)ans=a-b;
	else ans=b-a;
	if(abs(ans)>1e18)cout << "Unfair" << endl;
	else cout << ans << endl;	
	return;
}

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


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

using namespace std;
 
int main() {
    string s;
    cin>>s;
    if(s[0] == '7' || s[1] == '7'||s[2] == '7') cout<<"Yes";
    else cout<<"No";
    return 0;
}

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

bool cmp(int p[], int q[]){
  int flag,res=0;
  for(int i=0;i<3;i++){
    flag=0;
    for(int j=0;j<3;j++){
      flag+=(p[i]==q[j])?1:0;
    }
    res+=(flag==0)?0:1;
  }
  return (res==3)?true:false;
}

int main(){
  int N,res=0,diff;
  cin >> N;
  int p[N][3];
  for(int i=0;i<N;i++){
    cin >> p[i][0] >> p[i][1] >> p[i][2];
  }
  for(int i=0;i<N-1;i++){
    diff=0;
    for(int j=i+1;j<N;j++){
      diff+=cmp(p[i],p[j])?1:0;
    }
    res+=(diff>0)?1:0;
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 3144
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        ArrayList<Integer> natural = new ArrayList<>();
        ArrayList<Integer> minus = new ArrayList<>();
        for(int i=0;i<n;i++){
            int m = Integer.parseInt(sc.next());
            if(m<0){
                minus.add(m);
            }else{
                natural.add(m);
            }
        }
        sc.close();
        Collections.sort(natural);
        Collections.sort(minus, Collections.reverseOrder());
        List<int[]> q = new ArrayList<>();
        int ans;
        if(minus.size() > 0){
            int x = minus.get(0);
            for(int i=0;i<natural.size();i++){
                int y = natural.get(i);
                if(i < natural.size() - 1){
                    int[] query = {x,y};
                    q.add(query);
                    x -= y;
                }else{
                    int[] query = {y,x};
                    q.add(query);
                    x = y-x;
                }
            }
            for(int i=1;i<minus.size();i++){
                int y = minus.get(i);
                int[] query = {x,y};
                q.add(query);
                x -= y;
            }
            ans = x;
        }else{
            int x = natural.get(0);
            for(int i=1;i<natural.size();i++){
                int y = natural.get(i);
                if(i < natural.size() - 1){
                    int[] query = {x,y};
                    q.add(query);
                    x -= y;
                }else{
                    int[] query = {y,x};
                    q.add(query);
                    x = y-x;
                }
            }
            ans = x;
        }
        System.out.println(ans);
        for(int[] v : q){
            System.out.println(v[0] + " " + v[1]);
        }
    }
}

Measured memory_bytes: 73772
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	string s; cin >> s;
	vector<vector<int>> dp(n + 1, vector<int>(n + 1, 0));
	for (int i = n - 1; i >= 0; --i)for (int j = n - 1; j >= 0; --j)
	{
		if (s[i] == s[j])dp[i][j] = dp[i + 1][j + 1] + 1;
	}
	int res = 0;
	rep(i, n)rep(j, n)
	{
		res = max(res, min(dp[i][j], i - j));
	}
	cout << res << endl;
}

Measured memory_bytes: 98176
class NormalInput {
  input: string[];
  pointer: number;
  constructor(raw: string) {
    this.input = raw.split(/ |\n/);
    this.pointer = 0;
  }
  read<T>(parser: (v: string) => T): () => T {
    return () => {
      const ret = parser(this.input[this.pointer]);
      this.pointer++;
      return ret;
    };
  }
  int = this.read((str) => parseInt(str, 10));
  ints = (length: number): number[] => {
    let ret: number[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.int());
    }
    return ret;
  };
  str = (): string => {
    const ret = this.input[this.pointer];
    this.pointer++;
    return ret;
  };
  strs = (length: number): string[] => {
    let ret: string[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.str());
    }
    return ret;
  };
  bint = (): bigint => {
    const ret = BigInt(this.input[this.pointer]);
    this.pointer++;
    return ret;
  };
  bints = (length: number): bigint[] => {
    let ret: bigint[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.bint());
    }
    return ret;
  };
}
function rep(a: number, b: number) {
  let arr = [];
  for (let i = a; i < b; i++) arr.push(i);
  return arr;
}

function Main({ int, str, strs, ints, bints }: NormalInput) {
  const [N, M] = ints(2);
  const H: bigint[] = bints(N);
  let A: number[] = [];
  let B: number[] = [];
  rep(0, M).forEach((i) => {
    const [a, b] = ints(2);
    A.push(a - 1);
    B.push(b - 1);
  });
  let ans = rep(0, N).map(() => true);
  rep(0, M).forEach((m) => {
    const [a, b] = [A[m], B[m]];
    if (H[a] <= H[b]) ans[a] = false;
    if (H[a] >= H[b]) ans[b] = false;
  });
  console.log(ans.filter((a) => a).length);
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 86376
function main(data){
    input = data.split("\n");
    len = input[0];
    temp = input[1].split(" ");
    list = [];
    index = 0;
    for(var i = 0; i < len; i+=1){
        num = Math.floor(temp[i] / 400);
        if(num > 7){
            index += 1;
        }else if(list.indexOf(num) === -1){
            list.push(num);
        }
    }
    if(list.length === 0){
        console.log("%d %d", 1, index);
    }else{
        console.log("%d %d", list.length, list.length + index)
    }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(void){
    const ll mod = 1000000007LL;
    int S;
    cin >> S;
    vector<ll> dp(S + 1, 0);
    dp[0] = 1;
    for(int i = 0; i <= S; i++){
        for(int j = 3; i + j <= S; j++){
            dp[i + j] += dp[i];
            dp[i + j] %= mod;
        }
    }
    cout << dp[S] << endl;
    return 0;
}


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

int	main() {
	int N;
	cin >>N;
	if (1==N) {
		cout <<1 <<endl;
		return 0;
	}
	int S=1;
	char s, s1;
	cin >>s;
	for (int i=1; i<N; i++) {
		cin >>s1;
		if (s!=s1) {
			s=s1;
			S++;
		}
	}
	cout <<S <<endl;
	return 0;
};


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

int main(){
	int N,K,X,Y,ans;
	scanf("%d %d %d %d",&N,&K,&X,&Y);
	if(N <= K) ans = N * X;
	else ans = (K * X) + ((N - K) * Y);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int N, s[101] = { 0 };
	int sum = 0, si, i, x;

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &si);
		s[si]++;
	}
	/*printf("N:%d\n", N);
	for (i = 0; i < 100; i++) {
		if (s[i] != 0) {
			printf("si:%d*%d\n", i, s[i]);
		}
	}*/
	for (i = 0; i < 101; i++) {
		if (s[i] != 0) sum += i*s[i];
	}
	//printf("sum:%d\n", sum);
	if (sum % 10 != 0) {
		printf("%d\n", sum);
		return 0;
	}

	for (i = 0; i < 101; i++) {
		if (s[i] != 0) {
			if (i % 10 != 0) {
				x = i;
				printf("%d\n", sum - x);
				return 0;
			}
		}
	}

	printf("0\n");

	return 0;
}

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

int main() {
  string S;
  cin >> S;

  if(S.at(0)==S.at(1) || S.at(1)==S.at(2) || S.at(2)==S.at(3))
    cout << "Bad";
  else
    cout << "Good";
  cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
  public static void main(String[] args){
	Scanner in=new Scanner(System.in);
    int N=in.nextInt();
    int X=in.nextInt();
    int D[]=new int[N+1];
    int L[]=new int[N];
    for(int i=0;i<N;i++){
    	L[i]=in.nextInt();
    }
    int count=1;
    for(int i=1;i<N+1;i++){
    	D[i]=D[i-1]+L[i-1];
      	if(D[i]<=X)
          count++;
      	else
          break;
    }
    System.out.println(count);
    in.close();
  }
}

Measured memory_bytes: 22996
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    S = str(input().strip())

    A =[0 for _ in range(N+1)]
    for i in range(1, N+1):
        if S[i-1] == 'I':
            A[i] = A[i-1] + 1
        else:
            A[i] = A[i-1] -1

    return max(A)


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
typedef long long   ll;
typedef long double ld;
const int N  = 2e5+10;
const ll mod = 1e9+7;
const ll inf = 1e18;
 
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb              push_back
#define mp              make_pair
#define ub              upper_bound                 // first element >  val(itr)
#define lb              lower_bound                 // first element >= val(itr) 
#define all(x)          (x).begin(),(x).end()
#define reset(a,x)      memset(a,x,sizeof(a))       // x can be 0 or -1
#define leadzero(a)     __builtin_clz(a)            // count leading zeroes
#define trailzero(a)    __builtin_ctz(a)            // count trailing zeroes
#define bitcount(a)     __builtin_popcount(a)       // count set bits
#define test            int t; cin>>t; while(t--)
#define forn(i,a,e)     for(ll i = a; i < e; i++)
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define sp              <<" "<<

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;    }
ll powm(ll base,ll exp){ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
ll add(ll a,ll b)  { return (a%mod+b%mod)%mod;        }
ll sub(ll a, ll b) { return (a%mod+mod-b%mod)%mod;    }
ll mult(ll a,ll b) { return ((a%mod)*(b%mod))%mod;    }

int main()
{
    fast
    string s;
    cin>>s;
    
    ll cnt1=0,cnt2=0;

    forn(i,0,s.length())
    {
        if(i%2)
        {
          if(s[i]=='1')
            cnt1++;
          else
            cnt2++;
        }
        else
        {
          if(s[i]=='1')
            cnt2++;
          else
            cnt1++;
        }
    }

    cout<<min(cnt1,cnt2);

    return 0;
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll N;
  cin>>N;
  ll ans=30;
  for(ll i=0;i<N;i++) {
ll A;
    cin>>A;
    ll count=0;
    while(A%2==0) {
A/=2;
      count++;
    }
    ans=min(ans,count);
  }
  
  
  cout<<ans<<endl;
}
    
    

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N;
	cin>>N;
	vector<int> W(N);
	FDS(i,N){
		cin>>W[i];
	}
	vector<int> ruiseki(N);
	ruiseki[0]=W[0];
	int sum=W[0],ans=INF,sub=INF;
	FDS(i,N-1){
		ruiseki[i+1]=ruiseki[i]+W[i+1];
		sum+=W[i+1];
	}
	FDS(i,N-1){
	    if(sub>abs((sum-ruiseki[i])-ruiseki[i])){
	        ans=i+1;
	        sub=abs((sum-ruiseki[i])-ruiseki[i]);
	    }
	}
    	cout<<sub<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
string a;
char a1[100010];
int main()
{
	cin>>a;
	int k=0;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]!='B') a1[++k]=a[i];//01B
		else
		{
			k--;
			if(k<0) k=0;
		}
	}
	for(int i=1;i<=k;i++) cout<<a1[i];
	cout<<endl;
	return 0;
}

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

using namespace std;

struct s
{
    int x;
    bool operator < (s t) const{
        return t.x > x;
    }
} t;
priority_queue 
 q;

int n, T;
long long first, top = 1e9+1;

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &T);
        q.push({T});
    }
    while(!q.empty())
    {
        t = q.top(); q.pop();
        if(first && top > t.x)
        {
            top = t.x;
        }
        else if(first && top == t.x)
        {
            long long ans = first*top;
            printf("%lld", ans);
            return 0;
        }
        if(!first && top > t.x)
        {
            top = t.x;
        }
        else if(!first && top == t.x)
        {
            first = t.x;
            top = 1e9+1;
        }
    }
    printf("0");
}


Measured memory_bytes: 892
MOD = 998244353

def solve():
    if D[0] != 0 or 0 in D[1:]:
        print(0)
        return

    tree_dict = dict()
    max_dist = 0
    for idx, dist in enumerate(D):
        tree_dict[dist] = tree_dict.get(dist, 0) + 1
        max_dist = max(max_dist, dist)
    ret = 1

    for dist in range(max_dist + 1):
        if not dist in tree_dict:
            print(0)
            return
        ret = (ret * pow(tree_dict.get(dist - 1, 1), tree_dict[dist])) % MOD
    print(ret)

if __name__ == "__main__":
    N = int(input())
    D = list(map(int, input().split()))
    solve()

Measured memory_bytes: 23816
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

int main(){
  int n;
  cin >> n;
  vint A(n);
  rep(i,n) cin >> A[i];
  map<int,int> odd;
  map<int,int> even;
  rep(i,n){
    if(i%2 == 0){
      if(even[A[i]] == 0){
        even[A[i]] = (n+1)/2-1;
      }
      else{
        even[A[i]]--;
      }
    }
    else{
      if(odd[A[i]] == 0){
        odd[A[i]] = n/2-1;
      }
      else{
        odd[A[i]]--;
      }
    }
  }
  int evenkey = 1000000;
  int evenvalue = (n+1)/2;
  int oddkey = 1000000;
  int oddvalue = n/2;
  int evenkey2 = 1000000;
  int evenvalue2 = (n+1)/2;
  int oddkey2 = 1000000;
  int oddvalue2 = n/2;
  for(auto p:even){
    auto key = p.first;
    auto value = p.second;
    if(value < evenvalue){
      evenvalue = value;
      evenkey = key;
    }
  }
  for(auto p:even){
    auto key = p.first;
    auto value = p.second;
    if(key != evenkey){
      if(value < evenvalue2){
        evenvalue2 = value;
        evenkey2 = key;
      }
    }
  }
  for(auto p:odd){
    auto key = p.first;
    auto value = p.second;
    if(value < oddvalue){
      oddvalue = value;
      oddkey = key;
    }
  }
  for(auto p:odd){
    auto key = p.first;
    auto value = p.second;
    if(key != oddkey){
      if(value < oddvalue2){
        oddvalue2 = value;
        oddkey2 = key;
      }
    }
  }
  if(evenkey != oddkey){
    cout << oddvalue + evenvalue << endl;
   // cout << "a" << endl;
  }
  else{
    if(evenvalue2 < oddvalue2){
      cout << oddvalue + evenvalue2 << endl;
     // cout << "b" << endl;
    }
    else{
    //  cout << evenvalue <<" " <<  oddvalue2 << endl;
      cout << evenvalue + oddvalue2 << endl;
     // cout << "c" << endl;
    }
  }
}


Measured memory_bytes: 5376
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
while(1){
int a,b,c,q,w,e[301],l[1000][4],n;
cin>>a>>b>>c;
if(a==0&&b==0&&c==0)break;
cin>>n;
for(q=1;q<=a+b+c;q++)e[q]=2;
for(q=0;q<n;q++){
cin>>l[q][0]>>l[q][1]>>l[q][2]>>l[q][3];
if(l[q][3]==1){
e[l[q][0]]=1;e[l[q][1]]=1;e[l[q][2]]=1;
}
}
for(q=0;q<n;q++){
for(w=0;w<n;w++){
if(l[w][3]==0&&e[l[w][0]]==1&&e[l[w][1]]==1)e[l[w][2]]=0;
if(l[w][3]==0&&e[l[w][2]]==1&&e[l[w][1]]==1)e[l[w][0]]=0;
if(l[w][3]==0&&e[l[w][0]]==1&&e[l[w][2]]==1)e[l[w][1]]=0;
}
}
for(q=1;q<=a+b+c;q++)cout<<e[q]<<endl;
}
return 0;
}



Measured memory_bytes: 3080
# coding: utf-8
# Your code here!

class Dice:
    def __init__(self,lst):
        self.face=lst
        self.order="NNNNWNNNWNNNENNNENNNWNNN"
    
    def roll(self,x):
        tmp=self.face
        if x=="E":
            self.face=[tmp[3],tmp[1],tmp[0],tmp[5],tmp[4],tmp[2]]
        if x=="W":
            self.face=[tmp[2],tmp[1],tmp[5],tmp[0],tmp[4],tmp[3]]
        if x=="N":
            self.face=[tmp[1],tmp[5],tmp[2],tmp[3],tmp[0],tmp[4]]
        if x=="S":
            self.face=[tmp[4],tmp[0],tmp[2],tmp[3],tmp[5],tmp[1]]
    
    def showDown(self):
        return self.face[0]
    
    def query(self,lst):
        tmp=self.face
        ans=-1
        for i in self.order:
            self.roll(i)
            if self.face[0]==lst[0] and self.face[1]==lst[1]:
                ans=self.face[2]
                break
        self.face=tmp
        return ans
    
dice=Dice(list(map(int,input().split(" "))))
num=int(input())
q=[list(map(int,input().split())) for i in range(num)]
for i in q:
    print(dice.query(i))


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)turn idx;
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

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

static const int MAX = 200001;
static const ll INFTY = 1e15;
static const int WHITE = 0; // 未到達
static const int GRAY = 1; // 到達
static const int BLACK = 2; // 探索済み

// <node, cost>
vector<pair<int, ll>> adj[MAX]; // 重み付き有向グラフの隣接リスト表現
int color[MAX];
ll d[MAX];
int p[MAX];

void dijkstra(int s) {
  // <cost, node>
  priority_queue<pair<ll, int>> PQ;
  for (int i = 0; i < MAX; i++) {
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[s] = 0;
  PQ.push(make_pair(0, s));
  color[s] = GRAY;

  while (!PQ.empty()) {
    pair<ll, int> f = PQ.top();
    PQ.pop();
		// node
    int u = f.second;
    color[u] = BLACK;

    for (int j = 0; j < adj[u].size(); j++) {
			// node
      int v = adj[u][j].first;
      if (color[v] == BLACK) continue;
      if (d[v] > d[u] + adj[u][j].second) {
        d[v] = d[u] + adj[u][j].second;
        p[v] = u;
        // priority_queueはデフォルトで大きい値を優先するため-1をかける
        PQ.push(make_pair(d[v] * (-1), v));
        color[v] = GRAY;
      }
    }
  }
};

int main() {
	int N, M;
	cin >> N >> M;
	int L, R, C;
	rep(i, 0, N) {
		int idx = N - i;
		adj[idx].pb({ idx - 1, (ll) 0 });
	}
	rep(i, 0, M) {
		cin >> L >> R >> C;
		adj[L].pb({ R, (ll) C });
	}
	dijkstra(1);

	if (d[N] == INFTY) {
		cout << -1 << endl;
	} else {
		cout << d[N] << endl;
	}
};


Measured memory_bytes: 14456
#include <iostream>
#include <array>
#include <cmath>

using namespace std;
const int maxd = 85;

void solve(int n, const array<long long, maxd>& a) {
    bool has = false;
    bool up = false;
    long long curr_s = 0;
    long long curr_p = 1000;

    for (int i = 0; i < n-1; i ++) {
        if (a[i] < a[i+1] && !up) {
            has = 1;
            up = true;
            curr_s = floor(curr_p / a[i]);
            curr_p -= curr_s * a[i];
        }
        if (a[i] > a[i+1] && up) {
            has = 0;
            up = false;
            curr_p += curr_s * a[i];
            curr_s = 0;
        }
    }
    if (curr_s > 0) {
        curr_p += curr_s * a[n-1];
    }
    cout << curr_p << endl;
}

int main() {
    int n;
    array<long long, maxd> a;
    cin >> n;
    for (int i = 0; i < n; i ++) {
        cin >> a[i];
    }
    solve(n, a);
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
      //fast;
     int t=1;
   
    while(t--)
    {
        int a[10];
      for(int i = 1; i <=5; i++) cin >> a[i];
      int res;
      for(int i  = 1; i<=5; i++){
        if(a[i]==0) res = i;
      }
      cout << res << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	ll n;
	ll total=0;

	cin>>n;

	rep(i,n+1){
		total+=i;
	}

	cout<<total<<endl;

	return 0;
}


Measured memory_bytes: 256
# include "iostream"
# include "cstdio"

using namespace std;

int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a+b>=c && a<=c){
		printf("YES");
	}else{
		printf("NO");
	}
	return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int sx = in.nextInt();
            int sy = in.nextInt();
            int tx = in.nextInt();
            int ty = in.nextInt();

            StringBuilder sb = new StringBuilder();
            for (int x = sx; x < tx; x++) {
                sb.append("R");
            }
            for (int y = sy; y < ty; y++) {
                sb.append("U");
            }
            for (int x = tx; x > sx; x--) {
                sb.append("L");
            }
            for (int y = ty; y > sy; y--) {
                sb.append("D");
            }

            sb.append("D");
            for (int x = sx; x < tx + 1; x++) {
                sb.append("R");
            }
            for (int y = sy - 1; y < ty; y++) {
                sb.append("U");
            }
            sb.append("L");
            sb.append("U");
            for (int x = tx; x > sx - 1; x--) {
                sb.append("L");
            }
            for (int y = ty + 1; y > sy; y--) {
                sb.append("D");
            }
            sb.append("R");
            System.out.println(sb.toString());
        }
    }
}


Measured memory_bytes: 23252
def cut(d, w, s):
    s %= d + w
    if 0 < s < w:
        p1, p2 = (d, s), (d, w - s)
    else:
        s -= w
        p1, p2 = (s, w), (d - s, w)
    if p1[0] * p1[1] > p2[0] * p2[1]:
        p1, p2 = p2, p1
    return [p1, p2]


while True:
    N, W, D = map(int, input().split())
    if not (N | W | D):
        break
    square = [(D, W)]
    for _ in range(N):
        p, s = map(int, input().split())
        d, w = square.pop(p - 1)
        square.extend(cut(d, w, s))
    print(*sorted(d * w for d, w in square))

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

const int INF = 1 << 29;

int W;

int main() {
    while (true) {
        cin >> W;
        if (W == 0) break;

        int min_cost[5000];
        fill(min_cost, min_cost+W+1, INF);
        min_cost[0] = 0;

        int g[6] = {200, 300, 500, 1000, 1200, 1500};
        int c[6] = {380, 550, 850, 1520, 1870, 2244};

        for (int j = 0; j < 6; ++j) {
            for (int k = g[j]; k <= W; ++k) {
                min_cost[k] = min(min_cost[k], min_cost[k-g[j]] + c[j]);
            }
        }

        cout << min_cost[W] << endl;
    }
    return 0;
}

Measured memory_bytes: 3080
#include<cstdio>

using namespace std;

long long n,m,k,ans;

int main () {
	scanf("%lld",&n);
	k=1; ans=0;
	while (n>=1) {
		ans+=k; k*=2; n/=2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
string str;
void solve()
{
    stack < char > st;
    for (int i=0;i<str.length();i++)
    {
        if (str[i]!='B') st.push(str[i]);
        else if (st.size()) st.pop();
    }
    string ans;
    while(st.size())
    {
        ans.push_back(st.top());
        st.pop();
    }
    for (int i=ans.size()-1;i>=0;i--)
        cout<<ans[i];
    cout<<endl;
}
int main()
{
    while(cin>>str)
        solve();
}

Measured memory_bytes: 256