akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAX 100000

int main()
{
  int x,i;
  int A[MAX+1];

  scanf("%d",&x);

  for(i=1;i<=x;i++)
    {
      scanf("%d",&A[i]);
    }

  for(i=1;i<=x;i++)
    {
      printf("node %d: key = %d, ",i,A[i]);
      if(i/2>=1)
	{
	  printf("parent key = %d, ",A[i/2]);
	}
      if(i*2<=x)
	{
	  printf("left key = %d, ",A[i*2]);
	}
      if(i*2+1<=x)
	{
	  printf("right key = %d, ",A[i*2+1]);
	}
      printf("\n");
    }
      return 0;
}



Measured memory_bytes: 2104
N = int(input())
H = list(map(int,input().split()))
ans = 0
tag = 0

if N == 1:
  print(ans)
  exit()

for i in range(N-1):
  if H[i] < H[i+1]:
    tag = 0
  else:
    tag += 1
    if tag > ans:
      ans = tag

print(ans)

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

using namespace std;

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int m1,d1,m2,d2;
    cin >>m1>>d1>>m2>>d2;

    if(d2==1)flag=true;

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << dig(n) << endl;

    if(flag)cout << "1" <<endl;
    else cout << "0" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        var tmp = ReadIntArray();
        int n = tmp[0], m = tmp[1], q = tmp[2];

        int[,] s = new int[n+1, n+1];

        for (int i = 0; i < m; i++)
        {
            tmp = ReadIntArray();
            int l = tmp[0], r = tmp[1];
            s[l, r]++;
        }

        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= n; j++)
            {
                s[i, j] += s[i-1, j] + s[i, j-1] - s[i-1, j-1];
            }
        }

        for (int i = 0; i < q; i++)
        {
            tmp = ReadIntArray();
            int x = tmp[0], y = tmp[1];
            WriteLine(s[y, y] - s[x-1, y] - s[y, x-1] + s[x-1, x-1]);
        }
    }
}


Measured memory_bytes: 18684
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

template <class X> X lcm(X a, X b){
    X mm = a, nn = b, tmp;
    while(a % b != 0){
        tmp = b;
        b = a % b;
        a = tmp;
    }
    return mm * nn / b;
}
int main() {
    int A, B, K;
    cin >> A >> B >> K;
    int N = min(A, B);
    int cnt = 0;
    for(int i = N; i >= 1; i--){
        if(A % i == 0 and B % i == 0){
            cnt++;
            if(cnt == K){
                cout << i << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll n;string s;
bool ans=false;
bool ch[100010];
void dep(bool one){
	for(ll i=1;i<n;i++){
		bool now=true;
		if(s[i]=='x'){
			now=false;
		}
		ll nex=i+1;
		if(nex==n){
			nex=0;
		}
		if(now==ch[i]){
			ch[nex]=ch[i-1];
		}
		else{
			ch[nex]=abs(ch[i-1]-1);
		}
	}
	if(ch[0]!=one){
		return;
	}
	bool nex;
	bool fi=true;
	if(s[0]=='x'){
		fi=false;
	}
	if(ch[0]==fi){
		nex=ch[n-1];
	}
	else{
		nex=abs(ch[n-1]-1);
	}
	if(ch[1]==nex){
		for(ll i=0;i<n;i++){
			if(ch[i]){
				cout << "S";
			}
			else{
				cout << "W";
			}
		}
		ans=true;
	}
}
int main() {
	cin>>n>>s;
	ch[0]=true;ch[1]=true;
	dep(ch[0]);
	if(ans){
		return 0;
	}
	ch[0]=true;ch[1]=false;
	dep(ch[0]);
	if(ans){
		return 0;
	}	
	ch[0]=false;ch[1]=false;
	dep(ch[0]);
	if(ans){
		return 0;
	}	
	ch[0]=false;ch[1]=true;
	dep(ch[0]);
	if(ans){
		return 0;
	}	
	cout << -1;
	// your code goes here
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	double ans=0;
	for(int i=0;i<n;++i){
		double x; string u; cin>>x>>u;
		if(u=="JPY"s)ans+=x;
		else ans+=x*380000;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
// *max_element(all(d))
// priority_queue<int,vector<int>,greater<int>>
int solve(){
  int n,c,k;
  cin >> n >> c >> k;
  vector<int>v(n);
  rep(i,n)cin >> v[i];
  sort(all(v));
  int ca = 0,ans = 0;
  while(ca < n){
    int nx = ca;
    while(nx < n && nx - ca < c && v[nx] - v[ca] <= k)nx++;
    ans++;
    ca = nx;
  }
  cout << ans << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}


Measured memory_bytes: 640
(* O(2^|s|) *)
let s = read_line () in
let ds = Array.init (String.length s) @@ fun i -> int_of_char s.[i] - 48 in
let f bits =
  let n = ref ds.(0) in
  let m = Array.length ds - 1 in
  let acc = ref 0 in
  for i = 1 to m do
    if bits lsr (m - i) land 1 = 1 then
      (acc := !acc + !n;
      n := ds.(i))
    else n := !n * 10 + ds.(i)
  done;
  !acc + !n in
let sum = ref 0 in
for i = 0 to 1 lsl (Array.length ds - 1) - 1 do
  sum := !sum + f i
done;
Printf.printf "%d\n" !sum

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=1e6;
const ll mod=1e9+7;
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define se second
#define fi first
#define pi acos(-1)
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define SIZE 5000 + 1

ll expo(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*expo((x*x)%M,(n-1)/2,M))%M;

}


void solve()
{
   ll n;
   cin>>n;ll ans=0;
   for(int i=1;i<=n;i++)
   {
       for(int j=1;j<=n;j++)
       {
           for(int k=1;k<=n;k++)
           {
               ans+=__gcd(i,__gcd(j,k));
           }
       }
   }
   cout<<ans<<endl;
}

int main()
{
  boost;
  ll t=1;
  //cin>>t;
  while(t--)
  {
      solve();
  }
}


Measured memory_bytes: 3640
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();
        int N = r.i();
        int t = 0;
        int x = 0;
        int y = 0;
        boolean flag = true;
        for(int i = 0; i < N; i++){
            int[] a = r.ii();
            int cost = Math.abs(x-a[1])+Math.abs(y-a[2]);
            int rest = a[0]-t-cost;
            if(rest < 0 || rest%2 > 0){
                flag = false;
                break;
            }
            t = a[0];
            x = a[1];
            y = a[2];
        }
        println(flag ? "Yes" : "No");
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        print(o+"\n");
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
    }
}


Measured memory_bytes: 41204
import kotlin.math.*
import java.util.*

fun main(args: Array<String>) {
  val x = readLine()!!.toLong()
  for (b in 0..119L) {
    val b5 = b * b * b * b * b
    for (a in (b + 1)..119L) {
      val a5 = a * a * a * a * a
      if (a5 - b5 == x) {
        println("${a} ${b}")
        return
      } else if (a5 + b5 == x) {
        println("${a} -${b}")
        return
      }
    }
  }
}


Measured memory_bytes: 34456
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
    ll n, *a;
    cin >> n;
    a = new ll[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];

    ll x = a[0];
    for (int i = 1; i < n; i++)
        x = x ^ a[i];

    for (int i = 0; i < n; i++)
        cout << (x ^ a[i]) << endl;

    return 0;
}

Measured memory_bytes: 5108
#include<stdio.h>
#define WORD_NUM 3
#define STR_MAX 35

int main(void)
{
    char text[STR_MAX];
    for(int i = 0; i < WORD_NUM; i++)
    {
        scanf("%s",text);
        printf("%c",text[0] + ('A' - 'a'));
    }

  return 0; 
}

Measured memory_bytes: 128
D=gets.split
gets
while gets
a,b=$_.split.map{|s|D.index s}
d=[*D]
f=->x{x.map{|i|d[i]}.rotate.map.with_index{|v,i|d[x[i]]=v}}
f[rand(2)>0?[0,2,5,3]:[0,4,5,1]]until[D[a],D[b]]==d[0..1]
puts d[2]
end

Measured memory_bytes: 6136
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n)cin >> a[i];
  map<int,int> mp;
  rep(i,n){
    if(mp[a[i]]==0)mp[a[i]]++;
    else mp.erase(a[i]);
  }
  cout << mp.size() << endl;
}

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

int main(){
    int n;
    cin >> n;
    if(n < 4) cout << "No" << endl;
    else if(n % 4 == 0 || n % 7 == 0){
        cout << "Yes" << endl;
    } else {
        while(true){
            if(n % 4 == 0 || n < 4) break;
            n -= 7;
        }
        if(n % 4 == 0) cout << "Yes" << endl;
        else if(n < 4) cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
 

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
	    ll n;
	    cin>>n;
	    ll a[n];
	    ll i,j;
	    rep(i,0,n){
	    	cin>>a[i];
	    }
	    ll f=0;
	    for(i=n-1;i>0;i--){
	    	if(a[i]-a[i-1]>=0)
	    	continue;
	    	if(abs(a[i]-a[i-1])==1)
	    	a[i-1]--;
	    	else
	    	{
	    		cout<<"No";
	    		return 0;
	    	}
	    }
	    cout<<"Yes"<<'\n';
	}
	return 0;
}


Measured memory_bytes: 1024
n=int(input())
arr=[]
arr.append(0)
arr+=list(map(int,input().split()))
arr.append(0)
total=0
for i in range(n+1):
  total+=abs(arr[i+1]-arr[i])
for i in range(1,n+1):
  diff=abs(arr[i+1]-arr[i])+abs(arr[i]-arr[i-1])-abs(arr[i+1]-arr[i-1])
  print(total-diff)

Measured memory_bytes: 14048
N = input()
L = len(N)

# dp[i][j]: 紙幣の最小枚数
# i: 決定した桁数
# j: 1枚多めに渡すフラグ
dp = [[float("inf")] * 2 for _ in range(L + 1)]

# 初期条件
dp[0][0] = 0
dp[0][1] = 1

# 貰うDP
for i in range(L):
    n = int(N[i])

    dp[i + 1][0] = min(dp[i][0] + n, dp[i][1] + (10 - n))
    dp[i + 1][1] = min(dp[i][0] + (n + 1), dp[i][1] + (10 - (n + 1)))

print(dp[L][0])

Measured memory_bytes: 190144
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	Ln := make([]int, N)
	for i := range Ln {
		Ln[i] = nextInt()
	}
	sort.Ints(Ln)
	var ans int
	for i := 0; i < N-2; i++ {
		for j := i + 1; j < N-1; j++ {
			for k := j + 1; k < N; k++ {
				a, b, c := Ln[i], Ln[j], Ln[k]
				if c-b < a {
					ans++
				}
				// if a+c > b && a+b > c {
				// 	fmt.Println(a, b, c)
				// 	ans++
				// }
				if a+b < c {
					break
				}
			}
		}
	}
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1860
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
  double a;
  double PI=asin(0.5)*6;
  cin>>a;
  printf("%.6lf %.6lf\n",a*a*PI,2*a*PI);
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1228
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

int main(int argc, const char * argv[]) {
    double x1,x2,y1,y2,d;
    cin >> x1 >> y1 >> x2 >> y2;
    d = sqrt(pow(x2-x1,2)+pow(y2-y1,2));
    cout << setprecision(10) <<d << endl;
    return 0;
}

Measured memory_bytes: 1280
// avvinci -  summers 18    
// #include"prettyprint.hpp"
#include<bits/stdc++.h>
using namespace std;

typedef pair<long long,long long > P;

#define mod 1000000007 
#define pb emplace_back
#define fs first
#define sc second
#define ll long long 
#define fr(it,st,en) for(it=st;it<en;it++)
#define all(container) container.begin(),container.end()
#define INP ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ws(x) cout << #x << " = " << x << endl;
#define N 1000004

const long long infl = 1e18+5;

ll n,m,k,q,x,y,f,val,t,i,j;
ll ind,cnt,sz,sm,ans,mx,mn;
ll a[N] ;

ll fn(ll x){
	ll re =0 ; 
	while(x > 0 ){
		re += x%10;
		x /= 10; 
	}
	return re;
}

int main(){
INP
if (fopen("inp.txt", "r")) {
    freopen("myfile.txt","w",stdout);
    freopen("inp.txt", "r", stdin);
}

cin>>n;
ans = infl; 
fr(i,1,n){
	x = i ; 
	y = n-i;
	ans = min(fn(x)+fn(y),ans) ;
	// ws(ans) ;
}
cout<<ans; 


return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <climits>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()
int main()
{
  string s, t;
  cin >> s >> t;
  int ls = s.length(), lt = t.length();
  int dp[lt+1][ls+1] = {0};
  for (int i = 0; i < lt+1; ++i) {
    dp[i][0] = 0;
  }
  for (int i = 0; i < ls+1; ++i) {
    dp[0][i] = 0;
  }


  for (int i = 1; i < lt+1; ++i) {
    for (int j = 1; j < ls+1; ++j) {
      if(t[i-1] == s[j-1]){
        dp[i][j] = dp[i-1][j-1] + 1;
      }else {
        dp[i][j] = max( dp[i-1][j], dp[i][j-1]);
      }
    }
  }
  int i = lt, j = ls;
  string ans = "";
  while (i > 0 && j > 0) {
    if (t[i-1] == s[j-1]) {
      ans = t[i-1] + ans;
      i--; j--;
    }else {
      if (dp[i-1][j] >= dp[i][j-1]) {
        i--;
      }else {
        j--;
      }
    }
    // cout << i << j << ans << "\n";
  }
  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 101, K = 1e5+10;
inline char get() {
	static char buf[10000], *S = buf, *T = buf;
	if (S == T) {
		T = (S = buf) + fread(buf, 1, 10000, stdin);
		if (S == T) return EOF;
	}
	return *S++;
}
inline void read(int &x) {
	static char c; x = 0; int sgn = 0;
	for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
	for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
	if (sgn) x = -x;
}

int n, k;
int a[N];
bitset<K> dp;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  read(n); read(k);
  for (int i = 0; i < n; i++) {
    read(a[i]);
  }
  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < n; j++) {
      if (a[j] > i) continue;
      if (!dp[i-a[j]]) {
        dp[i] = 1;
        break;
      }
    }
  }
  puts(dp[k] ? "First" : "Second");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H,W,K; cin >> H >> W >> K;
  vector<string> cake(H);
  rep(i,H) cin >> cake[i];
  vector<vector<int>> ans(H, vector<int>(W, 0));
  vector<int> x,y;
  int num = 1;
  rep(h,H) { rep(w, W) { if(cake[h][w] == '#') { ans[h][w] = num; ++num; x.push_back(w); y.push_back(h); } } }
  rep(i, x.size()) {
    int h = y[i];
    int w = x[i]-1;
    while(w >=0 && ans[h][w] == 0) {
      ans[h][w] = ans[y[i]][x[i]];
      --w;
    }
    w = x[i]+1;
    while(w < W && ans[h][w] == 0) {
      ans[h][w] = ans[y[i]][x[i]];
      ++w;
    }
  }
  rep(h,H) {
    rep(w,W) {
      if(ans[h][w] == 0) {
        int tmp = 0, cnt = 1;
        while(h-cnt >= 0 && tmp == 0) { tmp=ans[h-cnt][w]; cnt++;}
        cnt = 0;
        while(h+cnt < H && tmp == 0) { tmp=ans[h+cnt][w]; cnt++;}
        ans[h][w] = tmp;
      }
    }
  }
  rep(h,H) { rep(w, W) { cout << ans[h][w] << " "; } cout << endl; }
}

Measured memory_bytes: 2164
a, b = [int(v) for v in input().split()]

a_s = str(a)
for i in range(1, b):
    a_s += str(a)

b_s = str(b)
for i in range(1, a):
    b_s += str(b)

if a_s > b_s:
    print(b_s)
else:
    print(a_s)


Measured memory_bytes: 2940
def abc():
    import re
    re_yy = r'([0-9][0-9])'
    re_mm = r'(0[1-9]|1[0-2])'
    s = input().rstrip()

    f = ''
    if re.match(re_yy + re_mm, s):
        f += 'YYMM'
    if re.match(re_mm + re_yy, s):
        f += 'MMYY'
    if f == 'YYMMMMYY':
        f = 'AMBIGUOUS'
    if f == '':
        f = 'NA'
    print(f)


abc()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define inf 1145141919810893364
#define PI 3.141592653589
#define int long long
typedef pair<int,int> P;
#define REP(i,n) for(int i=0;i<(n);i++)

signed main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int sum = b-a+1;
  int e = c*d/__gcd(c,d);
  if(b/c*c >= a)sum -= b/c-(a-1)/c;
  if(b/d*d >= a)sum -= b/d-(a-1)/d;
  if(b/e*e >= a)sum += b/e-(a-1)/e;
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
string s;
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!='?')
			cout<<s[i];
		else
			cout<<'D';
	}
	return 0;
}

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

int lcm(int a,int b){
  return a/__gcd(a,b)*b;
}

double calc(double a,double b){
  return (a+a*b)*0.5*b;
}

int n,m;
int a[20];

int main(){
  while(1){
    cin>>n>>m;
    if(n==0&&m==0)break;
    for(int i=0;i<m;i++)cin>>a[i];
    double sum = calc(1,n);    
    double cnt = n;
    
    for(int S=1;S<(1<<m);S++){
      
      int k=1;
      for(int i=0;i<m;i++)
        if(S>>i&1)k=lcm(k,a[i]);
      
      if( __builtin_popcount(S)%2 ){
        sum-=calc(k,n/k);
        cnt-=n/k;
      }else{
        sum+=calc(k,n/k);
        cnt+=n/k;
      }
    }
    printf("%.8f\n",(cnt==0?0:sum/cnt));
  }
  return 0;
}

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

using namespace std;
using ll = long long;

int main() {
	ll N, L;
	cin >> N >> L;
	vector<ll> a(N + 1);
	for (int i = 1; i <= N; ++i) { cin >> a[i]; }

	int idx = 0;
	bool can = false;
	for (int i = 1; i < N; ++i) {
		if (a[i] + a[i + 1] >= L) {
			idx = i;
			can = true;
		}
	}

	if (!can) {
		cout << "Impossible" << endl;
	} else {
		cout << "Possible" << endl;
		for (int i = 1; i < idx; ++i) { cout << i << endl; }
		for (int i = N - 1; i > idx; --i) { cout << i << endl; }
		cout << idx << endl;
	}

	return 0;
}


Measured memory_bytes: 1664
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::io::{stdin, stdout, Read, Write};
use std::str::FromStr;

#[derive(Default)]
struct Scanner<R: Read> {
    reader: R,
}

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader }
    }

    fn scan<T: FromStr>(&mut self) -> Option<T> {
        let s = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        s.parse::<T>().ok()
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.scan() {
            s
        } else {
            std::process::exit(1);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let out = stdout();
    let mut out = out.lock();

    let n = sc.next();
    let mut a = vec![0; n];
    for i in 0..n {
        a[i] = sc.next();
    }

    let a_min = a.iter().min().unwrap();
    let mut b = vec![0; n];
    for i in 0..n {
        b[i] = a.iter().filter(|&&x| x < a[i]).count();
    }

    let mut seen = vec![false; n];
    let mut ans = 0;
    for i in 0..n {
        if seen[i] || b[i] == i {
            continue;
        }
        let mut v = Vec::<usize>::new();
        let mut i = i;
        while !seen[i] {
            seen[i] = true;
            v.push(a[i]);
            i = b[i];
        }
        v.sort();
        let sum = v[1..].iter().fold(0, |sum, x| sum + x);
        ans += min(
            v[0] * (v.len() - 1) + sum,
            a_min * (v.len() - 1) + sum + (v[0] + a_min) * 2,
        )
    }

    writeln!(out, "{}", ans).ok();
}



Measured memory_bytes: 5052
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

const int N = 3000;
ll dp[N][N];
int a[N];

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);

	for (int i = 0; i < n; i++) dp[i][i] = a[i];
	for (int x = 1; x < n; x++) {
		for (int i = 0; i + x < n; i++) {
			dp[i][i+x] = max(a[i] - dp[i+1][i+x], a[i+x] - dp[i][i+x-1]);
		}
	}
	printf("%lld\n", dp[0][n-1]);
}



Measured memory_bytes: 70016
#include <bits/stdc++.h>
using namespace std;
typedef bitset<13> B;

int solve(B a, B b, int l, int r, int k){
	if(a == 0)return 1;
	if(b == 0)return 0;
	int ans, t1 = 0, t2 = 0;
	if(k == 0){
		ans = 0;
		if(l-1 >= 0 && a[l-1]){
			t1 = 1;
			a.reset(l-1);
			ans = max(ans, solve(a, b, l-1, r, 1));
			a.set(l-1);
		}
		if(r+1 < 13 && a[r+1]){
			t2 = 1;
			a.reset(r+1);
			ans = max(ans, solve(a, b, l, r+1, 1));
			a.set(r+1);
		}
		if(t1 == 0 && t2 == 0)
		ans = max(ans, solve(a, b, l, r, 1));
	}else{
		ans = 1;
		if(l-1 >= 0 && b[l-1]){
			t1 = 1;
			b.reset(l-1);
			ans = min(ans, solve(a, b, l-1, r, 0));
			b.set(l-1);
		}
		if(r+1 < 13 && b[r+1]){
			t2 = 1;
			b.reset(r+1);
			ans = min(ans, solve(a, b, l, r+1, 0));
			b.set(r+1);
		}
		if(t1 == 0 && t2 == 0)
		ans = min(ans, solve(a, b, l, r, 0));
	}
	return ans;
}

int main(){
	int n, t, c[6];
	scanf("%d", &n);
	while(n--){
		bitset<13> a, b;
		b.set();b.reset(6);
		for(int i = 0;i < 6;i++)scanf("%d", &c[i]);
		for(int i = 0;i < 6;i++){
			a.set(c[i]-1);
			b.reset(c[i]-1);
		}
		int ans = solve(a, b, 6, 6, 0);
		printf("%s\n", ans ? "yes" : "no");
	}
	return 0;
}


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

#define forsn(i,s,n) for(tint i=(s);i<(tint)(n); i++)
#define forn(i,n) forsn(i,0,n)
#define dforn(i,n) for(tint i = tint(n)-1; i >= 0; i--)
#define debug(x) cout << #x << " = "  << x << endl

using namespace std;

typedef long long tint;

random_device rd;
mt19937 gen(rd());

uniform_int_distribution<tint> dis(1, 10000);

void imprimirVector (vector<tint> v)
{
	if (!v.empty())
	{ 
		tint p = tint(v.size());
		cout << "[";
		forn(i,p-1)
			cout << v[i] << ",";
		cout << v[p-1] << "]" << endl;
	}
	else
		cout << "[]" << endl;
}

int main()
{
	#ifdef ACMTUYO
		assert(freopen("entrada.in", "r", stdin));
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	tint k,n;
	while (cin >> k >> n)
	{
		vector<tint> a (n,0);
		forn(i,n)
			cin >> a[i];
		tint ans = a[n-1] - a[0]; // n >= 2
		forsn(i,1,n)
			ans = min(ans,k - a[i] + a[i-1]);
		
		cout << ans << "\n";
	}
	
	return 0;
}






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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

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

    set<int>st;
    st.insert(s);
    for(int i=2;;i++){
        if(s&1)s=3*s+1;
        else s/=2;
        if(st.find(s)!=st.end()){
            cout<<i<<endl;
            return 0;
        }
        st.insert(s);
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]

x = y = t = 0
for i in range(n):
    dx, dy, dt = l[i][1], l[i][2], l[i][0]
    dist = abs((dx - x) + (dy - y))

    if abs(dt - t) < dist:
        print("No")
        exit()
    if abs(dt - t) % 2:
        if dist % 2 == 0:
            print("No")
            exit()
    else:
        if dist % 2 == 1:
            print("No")
            exit()
    x, y, t = dx, dy, dt
print("Yes")

Measured memory_bytes: 27004
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define INF 100000000

int main(){
    int A,B;cin>>A>>B;
    if(B%A==0){
        cout<<A+B<<endl;
    }else{
        cout<<B-A<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*


*/

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

int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

#define endl '\n'
#define ld long double
#define ll long long
#define PI acos(-1.0)
#define OO 1e13
#define EPS 1e-12
#define MLOG 20
#define MAX 1* 100 * 1000+5
const int mod = 1e9 + 7;
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }


void fast(){
#ifndef ONLINE_JUDGE
	freopen("E:\\Competitve\\solving\\input.txt", "r", stdin);
	freopen("E:\\Competitve\\solving\\output.txt", "w", stdout);
#endif
}
int n, m;
char g[1005][1005];
ll dp[1005][1005];

int main(){
//	fast();

	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
	cin >> n >> m;

	for (int i = 1; i <= n;i++)
	for (int j = 1; j <= m; j++)
		cin >> g[i][j];

	dp[0][1] = 1;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			if (g[i][j] == '#')
				dp[i][j] = 0;
			else{
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1])%mod;
			}
		}
	}
	cout << dp[n][m] << endl;
	return 0;

}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
constexpr long long INF = 1e18;

struct UF{
	vector<int>par,sz;
	void init(int n){
		par.resize(n);
		sz.resize(n);
		for(int i=0;i<n;i++){
			par[i]=i;
			sz[i]=1;
		}
	}
	int find(int x){
		return x==par[x]?x:par[x]=find(par[x]);
	}
	void unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return;
		sz[x]+=sz[y];
		par[y]=x;
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	int size(int x){
		return sz[find(x)];
	}
};

signed main(){
	int N;
	cin >> N;
	vector<pair<int,int>>a(N),b(N);
	vector<pair<int,int>>v(N);
	REP(i,N){
		cin >> v[i].second;
	}
	REP(i,N){
		cin >> v[i].first;
	}
	REP(i,N){
		a[i] = {v[i].second,i};
		b[i] = {v[i].first,i};
	}
	sort(ALL(v));
	sort(ALL(a));
	sort(ALL(b));
	REP(i,N){
		if(a[i].first > b[i].first){
			cout << "No" << endl;
			return 0;
		}
	}
	REP(i,N-1){
		if(a[i+1].first <= b[i].first){
			cout << "Yes" << endl;
			return 0;
		}
	}
	UF uf;
	uf.init(N);
	REP(i,N){
		uf.unite(a[i].second,b[i].second);
	}
	if(uf.size(0)==N)cout << "No" << endl;
	else cout << "Yes" << endl;
}

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

int main(){
    int K, A, B;
    cin >> K >> A >> B;
    int fin = 0;
    int i=A;
    for(i=A; i<=B;i++){
        if(i%K==0){
            cout << "OK" << endl;
          	fin = 1;
            break;
        }
    }
  	if(fin==0){
      cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>

#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

int main(){
    llong N,M;
    llong P,Y;
    llong index=0;
    llong rank;
    cin >> N >> M;
    
    vector<priority_queue<llong> > PQ_TABLE(N);
    vector<pair<llong, llong> > ANS_TABLE(M);
    map<llong, pair<llong, llong> > dict;
    for(int i=0; i<M; i++){
        cin >> P >> Y;
        PQ_TABLE[P-1].push(Y);
        dict[Y].first = P;
        dict[Y].second = i;
    }
    for(int i=0; i<N; i++){
        while(!PQ_TABLE[i].empty()){
            rank = PQ_TABLE[i].size();
            Y = PQ_TABLE[i].top();
            PQ_TABLE[i].pop();
            P = dict[Y].first;
            ANS_TABLE[dict[Y].second].first = P;
            ANS_TABLE[dict[Y].second].second = rank;
        }
    }
    for(int i=0; i<M; i++){
        printf("%06lld%06lld\n", ANS_TABLE[i].first, ANS_TABLE[i].second);
    }
    return 0;
}


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

int main(void) {
    int n;
    vector<int> b;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (i % 2) b.insert(b.begin(), a);
        else b.push_back(a);
    }
    if (n % 2) reverse(b.begin(), b.end());
    for (int i = 0; i < n; i++) {
        cout << b[i];
        if (i != n - 1) cout << ' ';
        else cout << endl;
    }
}


Measured memory_bytes: 3188
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        ArrayList<int[]> works = new ArrayList<int[]>();
        int finished = 0;
        boolean[] finish = new boolean[n];
        for (int i = 0; i < n; i++) {
            int[] work = new int[2];
            work[0] = sc.nextInt();
            work[1] = sc.nextInt();
            works.add(work);
            finish[i] = false;
        }
        int currentTime = 0;

        Collections.sort(works, new Comparator<int[]>() {
            @Override
            public int compare(int[] a, int[] b) {
                return a[1] - b[1];
            }
        });

        for (int i = 0; i < n; i++) {
            int[] work = works.get(i);
            int time = currentTime + work[0];
            if (time > work[1]) {
                System.out.println("No");
                return;
            }
            currentTime = time;
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 98560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    vector<int> a(n);
    vector<vector<int>> g(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
        if (i) {
            g[a[i]].emplace_back(i);
        }
    }
    if (a[0]) {
        a[0] = 0;
        ans++;
    }
    vector<int> depth(n), mx(n);
    function<void(int)> dfs = [&](int v) {
        mx[v] = depth[v];
        for (int to : g[v]) {
            depth[to] = depth[v] + 1;
            dfs(to);
            mx[v] = max(mx[v], mx[to]);
        }
        if (mx[v] - depth[v] >= k - 1 && depth[v] > 1) {
            mx[v] = depth[v] - 1;
            ans++;
            debug(v);
        }
    };
    dfs(0);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

#define vl vector<ll>
#define vi vector<int>

#define ff first
#define ss second

#define pb push_back
#define MOD 1e9+7 
const int nax = 1e6+5;
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "

inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }


int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll ans = 0;
    ll h = 1;
    while(1){
        ans += h;
        if(n == 1){
            break;
        }
        n/=2;
        h*=2;
    }
    cout << ans;

    return 0;
 }

Measured memory_bytes: 256
import string

N = int(input())
d1, d2 = 0, 26
n = 1
while d2 < N:
    n += 1
    d1 = d2
    d2 += 26 ** n
m = N - d1 - 1
xs = [None] * n
for i in range(n):
    xs[-1 - i] = string.ascii_lowercase[m % 26]
    m //= 26
print(''.join(xs))

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

class compare
{
public:
bool operator() (pair<int, pair<int, int> > a, pair<int, pair<int, int> > b)
{
	if(a.second.first > b.second.first)
		return true;
	if(a.second.first < b.second.first)
		return false;
	if(a.second.second < b.second.second)
		return true;
	return false;
}
};

int distances[1001][1001];

int graph()
{
	int N, M, i, a, b, w, L, dist[1001], INF, start, end, Q, fuel[1001], cur_ver, vert, fuel_left;
	vector<pair<int, int> > adj[1001];
	bool visited[1001], done[1001];
	priority_queue< pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >, compare> unvisited;
	scanf("%d%d%d", &N, &M, &L);

	for(i = 1; i <= N; i++)
	{
		done[i] = false;
		adj[i].clear();
	}

	for(i = 1; i <= M; i++)
	{
		scanf("%d%d%d", &a, &b, &w);
		if(w > L)
		{
			M--;
			i--;
			continue;
		}
		adj[a].push_back(make_pair(b, w));
		adj[b].push_back(make_pair(a, w));
	}
	INF = N + 10;

	scanf("%d", &Q);

	while(Q--)
	{
		scanf("%d%d", &start, &end);
		if(done[start] == true)
		{
			if(distances[start][end] == INF)
				printf("-1\n");
			else
				printf("%d\n", distances[start][end]);
			continue;
		}
		for(i = 1; i <= N; i++)
		{
			if(i != start)
			{
				visited[i] = false;
				unvisited.push(make_pair(i, make_pair(INF, 0)));
			}
			else
			{
				visited[i] = false;
				unvisited.push(make_pair(i, make_pair(0, L)));
			}
			dist[i] = INF;
			fuel[i] = 0;
		}
		dist[start] = 0;
		fuel[start] = L;

		while(!unvisited.empty())
		{
			cur_ver = unvisited.top().first;
			fuel_left = unvisited.top().second.second;
				// printf("Check %d %d %d\n", cur_ver, fuel_left, dist[cur_ver]);
			unvisited.pop();
			if(visited[cur_ver])
				continue;
			visited[cur_ver] = true;
			for(i = 0; i < adj[cur_ver].size(); i++)
			{
				vert = adj[cur_ver][i].first;
				w = adj[cur_ver][i].second;
				// printf("Check1 %d %d %d\n", vert, w, fuel_left);
				if(dist[vert] > dist[cur_ver] + (w > fuel_left))
				{
					dist[vert] = dist[cur_ver] + (w > fuel_left);
					if(w > fuel_left)
					{
						fuel[vert] = L - w;
						unvisited.push(make_pair(vert, make_pair(dist[vert], L - w)));
					}
					else
					{
						fuel[vert] = fuel_left - w;
						unvisited.push(make_pair(vert, make_pair(dist[vert], fuel_left - w)));
					}
				}
				else if(dist[vert] == dist[cur_ver] + (w > fuel_left))
				{
					if(w > fuel_left && L - w > fuel[vert])
					{
						fuel[vert] = L - w;
						unvisited.push(make_pair(vert, make_pair(dist[vert], L - w)));
					}
					else if(w <= fuel_left && fuel_left - w > fuel[vert])
					{
						fuel[vert] = fuel_left - w;
						unvisited.push(make_pair(vert, make_pair(dist[vert], fuel_left - w)));
					}
				}
			}
		}
		done[start] = true;
		for(i = 1; i <= N; i++)
		{
			distances[start][i] = dist[i];
			// printf("Check distances[%d][%d] = %d\n", start, i, dist[i]);
		}
		if(dist[end] == INF)
			printf("-1\n");
		else
			printf("%d\n", dist[end]);
	}
	return 0;
}

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


Measured memory_bytes: 3328
#include <cstdio>
#include <map>
#include <queue>
#include <tuple>
#include <utility>

const int N = 100000 + 10;

int n;

int anc[N];

int find(int x) { return anc[x] == x ? x : (anc[x] = find(anc[x])); }

std::map<int, int> adj[N];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) anc[i] = i;
  std::queue<std::pair<int, int>> q;
  for (int i = 2 * n - 2; i--;) {
    int a, b;
    scanf("%d%d", &a, &b);
    q.emplace(a, b);
    ++adj[a][b];
    ++adj[b][a];
  }
  for (; !q.empty(); q.pop()) {
    int a, b;
    std::tie(a, b) = q.front();
    a = find(a), b = find(b);
    if (a == b || adj[a].find(b) == adj[a].end()) continue;
    if (adj[a][b] < 2) continue;
    if (adj[a][b] > 2) return puts("NO"), 0;
    adj[a].erase(b);
    adj[b].erase(a);
    if (adj[a].size() < adj[b].size()) std::swap(a, b);
    anc[b] = a;
    for (auto it : adj[b]) {
      int c = it.first, d = it.second;
      adj[a][c] += d;
      adj[c][a] += d;
      adj[c].erase(b);
      q.emplace(a, c);
    }
  }
  for (int i = 1; i <= n; ++i) if (find(i) != find(1)) return puts("NO"), 0;
  puts("YES");
  return 0;
}


Measured memory_bytes: 25984
#!/mnt/c/Users/moiki/bash/env/bin/python
# N,M = map(int, input().split())
S = input()

# for i in range(len(S)-1): #125 0
ans = 0
for i in range(1<<(len(S)-1)):
    bef = 0
    lst = []
    # if i == 0: continue
    for j in range(len(S)-1):

        if i & 1<<j:
            lst.append( int(S[bef:j+1]) ) 
            # print("S[bef:{bef}:j+1:{jp1}]:{S}".format(bef=bef, jp1=j+1, S=S[bef:j+1]))
            bef = j+1
    lst.append( int(S[bef:]) ) 
    # ans = max(ans, sum(lst))
    ans += sum(lst)
    # print(lst)
    # break
print(ans)
    
        
    


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

int main() {
  int D;
  cin >> D;
  if (D == 25) {
    cout << "Christmas" << endl;
  } else if (D == 24) {
    cout << "Christmas Eve" << endl;
  } else if (D == 23) {
    cout << "Christmas Eve Eve" << endl;
  } else {
    cout << "Christmas Eve Eve Eve" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		double h = (double)(a + b + c) / 2; // half

		String result = "No";

		if (a == h || b == h || c == h) {
			result = "Yes";
		}

		System.out.println(result);

		sc.close();

	}

}


Measured memory_bytes: 23636
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N, K = in.nextInt
  val Ps = Array.fill(N)(in.nextInt)
  val sums = (0 until N - K).scanLeft(Ps.take(K).sum)((z, i) => z - Ps(i) + Ps(K + i))
  println((sums.max.toDouble + K) / 2)
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int n,m;cin>>n>>m;
  ll a[n+10],b[n+10];rep(i,0,n)cin>>a[i]>>b[i];
  ll c[m+10],d[m+10];rep(i,0,m)cin>>c[i]>>d[i];

  rep(i,0,n){
    int num=1;ll mi=2e8+1;
    rep(j,0,m){
      ll dis=abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(mi>dis){
        mi=dis;
        num=j+1;
      }
    }
    out(num);
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

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

ll N;
vector<double> x;
vector<string> u;

int main()
{
    cin >> N;
    x = vector<double>(N);
    u = vector<string>(N);
    REP(i, N)
    {
        cin >> x[i] >> u[i];
    }

    double ans = 0.0;
    REP(i, N)
    {
        if (u[i] == "JPY")
        {
            ans += x[i];
        }
        else
        {
            ans += x[i] * 380000;
        }
    }

    cout << fixed << setprecision(15);
    OUT(ans);
}

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

int main(){
    int N, M;
    cin >> N >> M;
    int sum[400001] = {0};
    int64_t S = 0;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        sum[a]++;
        S += a;
    }
    for(int i=1; i<=400000; i++) sum[i] += sum[i-1];

    int B[200001] = {0};
    for(int i=0; i<M; i++){
        int b;
        cin >> b;
        B[b]++;
    }

    int64_t ans = S*M;
    for(int i=1; i<=200000; i++){
        int64_t q = 0;
        for(int c=0; c*i<=200000; c++){
            int64_t s = sum[c*i+i-1];
            if(c) s -= sum[c*i-1];
            q += s*c;
        }
        ans -= q*B[i]*i;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 5476
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define FASTIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 1e18
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mod 1000000007
#define pb push_back
#define all(s) s.begin(),s.end()
#define pie 3.14159265358979323846
#define fr(i,a,b)  for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=b-1;i>=a;i--)
#define gcd __gcd
#define con continue
#define pii pair<ll,ll>
const ll N=100;
signed main(){
    FASTIO;
    ll tt=1;
    //cin>>tt;
    while(tt--){
        ll x;cin>>x;
        if(x>=30)cout<<"Yes\n";
        else cout<<"No\n";
    }
}


Measured memory_bytes: 3656