akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[][] sm=new int[N][2];
		int sum=0;
		for(int i=0; i<N; i++) {
			sm[i][0]=sc.nextInt();
			sum+=sm[i][0];
			sm[i][0]*=N;
			sm[i][1]=i;
		}
		quick_sort(sm,0,N-1);
		int dif_min=Integer.MAX_VALUE;
		int banme=0;
		for(int i=0; i<N; i++) {
			if(dif_min==Math.abs(sm[i][0]-sum)) {
				if(banme>sm[i][1]) {
					banme=sm[i][1];
				}
			}
			else if(dif_min>Math.abs(sm[i][0]-sum)) {
				dif_min=Math.abs(sm[i][0]-sum);
				banme=sm[i][1];
			}
		}
		System.out.println(banme);
	}
	static void quick_sort(int[][] d, int left, int right) {
        if (left>=right) {
            return;
        }
        int p = d[(left+right)/2][0];
        int l = left, r = right, tmp,tmp1,tmp2;
        while(l<=r) {
            while(d[l][0] < p) { l++; }
            while(d[r][0] > p) { r--; }
            if (l<=r) {
                tmp = d[l][0]; d[l][0] = d[r][0]; d[r][0] = tmp;
                tmp1=d[l][1]; tmp2=d[r][1]; d[l][1]=tmp2; d[r][1]=tmp1;
                l++; r--;
            }
        }
        quick_sort(d, left, r);
        quick_sort(d, l, right);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 200010, INF = 0x3f3f3f3f;
int val[N], n, dp[N][2], tp[N], num, ans[N];
struct segt {
  int mx[N << 2];
  void setval(int p,int v,int x=1,int lp=1,int rp=n) {
    if (lp == rp) {
      mx[x] = v;
      return;
    }
    int mid = (lp + rp) >> 1;
    if (p <= mid) setval(p, v, x<<1, lp, mid);
    else setval(p, v, x<<1|1, mid+1, rp);
    mx[x] = max(mx[x<<1], mx[x<<1|1]);
  }
  int query(int l,int r,int x=1,int lp=1,int rp=n) {
    if (l > rp || lp > r) return -INF;
    if (lp >= l && rp <= r) return mx[x];
    int mid = (lp + rp) >> 1;
    return max(query(l, r, x<<1, lp, mid), query(l, r, x<<1|1, mid+1, rp));
  }
} t[2];
bool check(int v,int l) {
  if (v < 0) return false;
  if (v == 0) return true;
  if (v % 2 == 0)
    return t[0].query(l, n) >= v;
  else
    return t[1].query(l, n) >= v;
}
int main() {
  read(n);
  rep (i, 1, n) read(val[i]);
  for (int i = 1, j = 0; i <= n; ++ i) {
    if (val[i] > j) tp[i] = 2, j = val[i], ++ num;
    else tp[i] = 1;
  }
  rep (i, 1, n) t[0].setval(i, -INF), t[1].setval(i, -INF);
  rrp (i, n, 1) {
    dp[i][0] = max(0, t[0].query(val[i]+1, n)) + tp[i];
    dp[i][1] = t[1].query(val[i]+1, n) + tp[i];
    if (tp[i] == 1) dp[i][1] = max(dp[i][1], dp[i][0]);
    t[0].setval(val[i], dp[i][0]);
    t[1].setval(val[i], dp[i][1]);
  }
  if (!check(num, 1)) {
    puts("-1");
    return 0;
  }
  // v0 - v1 + num = 2k1 + m1
  int mx0 = 0, mx1 = 0, v0 = 0, v1 = 0;
  rep (i, 1, n) {
    t[0].setval(val[i], -INF);
    t[1].setval(val[i], -INF);
    num -= (tp[i] - 1);
    int c0 = v0, c1 = v1;
    if (val[i] > mx0) ++ c0;
    if (!check(c1 - c0 + num, max(mx0, val[i])+1) && !check(c0 - c1 + num, mx1+1)) {
      ans[i] = 1;
      v1 += (val[i] > mx1);
      mx1 = max(mx1, val[i]);
    } else {
      ans[i] = 0;
      v0 += (val[i] > mx0);
      mx0 = max(mx0, val[i]);
    }
  }
  rep (i, 1, n) printf("%d", ans[i]);
  puts("");
  return 0;
}


Measured memory_bytes: 10624
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n, ans = 0;
long long x, y, d;

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> n >> d;
	d *= d;
	for( int i = 1; i <= n; ++i )
	{
		cin >> x >> y;
		x = x * x + y * y;
		if( x <= d )
		{
			++ans;
		}		
	}
	cout << ans << "\n";	
	return 0;
}

Measured memory_bytes: 3644
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    a,b=map(int,input().split())
    if a<=b:
        print(a)
    else:
        print(a-1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  int h,w,n;
  cin>>h>>w>>n;
  vector<pair<int,int> > xy(n);
  for(int i=0;i<n;i++){
    cin>>xy[i].first>>xy[i].second;
  }
  sort(xy.begin(),xy.end());

  int cn=0;
  int f=-1;
  for(int i=0;i<n;i++){
    int x=xy[i].first;
    int y=xy[i].second;
    if(f<x&&x==y+cn){
      cn++;
      f=x;
    }else if(x>y+cn){
      cout<<x-1<<endl;
      return 0;
    }
  }
  cout<<h<<endl;
}


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

using namespace std;

using i64 = long long int;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()

int main(){
    i64 n;
    cin >> n;
    vector<i64> a(n), w(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> w[i];
    vector<i64> pat(n);
    rep(i, n) pat[i] = i;
    i64 ans = numeric_limits<i64>::max();
    do{
        i64 cost = 0;
        rep(i, n){
            if(i == 0){
                if(a[pat[i]] == 1 && a[pat[i + 1]] == 0) cost += w[pat[i]];
                if(a[pat[i]] == 0 && a[pat[n - 1]] == 1) cost += w[pat[i]];
            }else if(i == n - 1){
                if(a[pat[i]] == 1 && a[pat[0]] == 0) cost += w[pat[i]];
                if(a[pat[i]] == 0 && a[pat[i - 1]] == 1) cost += w[pat[i]];
            }else{
                if(a[pat[i]] == 1 && a[pat[i + 1]] == 0) cost += w[pat[i]];
                if(a[pat[i]] == 0 && a[pat[i - 1]] == 1) cost += w[pat[i]];
            }
        }
        ans = min(ans, cost);
    }while(next_permutation(all(pat)));
    cout << ans << endl;
}


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

int main(){
	int k;
	cin>>k;
	string s;
	cin>>s;
	if(s.size()<=k){
		cout<<s<<endl;
	}
	else{
		string a;
		for(int i=0;i<k;i++){
			a+=s.at(i);
		}
		cout<<a<<"..."<<endl;
	}
}

Measured memory_bytes: 3612
n,k=map(int,input().split())
h=[]
for i in range(n):
    h.append(int(input()))
h.sort()
mm=h[k-1]
m=h[0]
ans=mm-m
for i in range(1,n-k+1):
    mm=h[k+i-1]
    m=h[i]
    ans=min(ans,mm-m)
print(ans)






Measured memory_bytes: 7384
use std::io;

fn main() {let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("");
    let mut iter = buf.trim().split_whitespace();
    let a:u128 = iter.next().unwrap().parse().ok().unwrap();
    let b = iter.next().unwrap();
    let mut iter = b.split(".");
    let mut b:u128 = iter.next().unwrap().parse().ok().unwrap();
    b = b*100;
    let c:u128 = iter.next().unwrap().parse().ok().unwrap();
    b = b + c;
    //println!("{}", b);
    println!("{}", (a*b)/100);
}

Measured memory_bytes: 2120
#include <iostream>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    float m = 0;
    int ans_w = 0;
    int ans_s = 0;

    for(int a=0; a<=30; a++){
        for(int b=0; b<=30; b++){
            int ww = 100*A*a + 100*B*b;
            if(ww > F) continue;
            if(a==0 && b == 0) continue;

            for(int c=0; c<=1000; c++){
                for(int d=0; d<=1000; d++){
                    int ss = C*c + D*d;
                    if(ss + ww > F) continue;
                    float st = (float)ss/(float)ww;
                    if(st > (float)E/100) continue;
                    
                    st = (float)(ss)/(float)(ss+ww)*100;
                    m = max(m , st);
                    if(m == st){
                        ans_w = ww+ss;
                        ans_s = ss;
                    }
                }
            }
        }
    }

    cout << ans_w << " " << ans_s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 101

int main(){
        int n, i, j, u, k, v[N][N], num=1;

        scanf("%d", &n);
        for(i=1; i<=n; i++) {
                scanf("%d%d", &u, &k);

                for(j=1; j<=k; j++) {
                        scanf("%d", &v[i][j]);
                }
        }
        for(i=1; i<=n; i++) {
                num = 1;
                for(j=1; j<=n; j++) {
                        if(j==v[i][num]) {
                                printf("1");
                                num++;
                        }
                        else{
                                printf("0");
                        }
                        if(j+1>n) break;
                        printf(" ");
                }
                printf("\n");
        }
        return 0;
}

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

int main() {
  int N;
  cin >> N;
  int64_t sum =0;

  for(int i =1;i<N+1;i++){

    if(i%3==0 || i%5==0){
      //cout << i << endl;
      continue;
    }
    sum +=i;
  }

  cout << sum << endl;
}

Measured memory_bytes: 3616
#pragma warning disable

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
// Do not use: System.Numerics;

public class Test
{
    public static void Main()
    {
        int n = Int32.Parse(Console.ReadLine());

        KeyValuePair<char, int>[] dictmax = null;

        for (int i = 0; i < n; i++)
        {
            var line1 = Console.ReadLine();

            var dict = new Dictionary<char, int>();

            foreach (var c in line1)
            {
                if (!dict.ContainsKey(c))
                {
                    dict[c] = 0;
                }

                dict[c]++;
            }

            if (dictmax == null)
            {
                dictmax = dict.OrderBy(x => x.Key).ToArray();
            }
            else
            {
                for (int j = 0; j < dictmax.Length; j++)
                {
                    var kvpair = dictmax[j];

                    if (dict.ContainsKey(kvpair.Key))
                    {
                        dictmax[j] = new KeyValuePair<char, int>(kvpair.Key, Math.Min(kvpair.Value, dict[kvpair.Key]));
                    }
                    else
                    {
                        dictmax[j] = new KeyValuePair<char, int>(kvpair.Key, 0);
                    }
                }
            }

        }

        for (int j = 0; j < dictmax.Length; j++)
        {
            var kvpair = dictmax[j];

            for (int k = 0; k < kvpair.Value; k++)
            {
                Console.Write(kvpair.Key);
            }
        }

        Console.WriteLine();
    }
}


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

int main (){
	int N;cin>>N;
	double n=(double)N;
	double ans;
	if(N%2==1){
		ans= (n/2+0.5)/n;
	}else{
		ans= n/n/2;
	}
	if(N==1)ans=1.0000000000;
	cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main() {
	int n; int sum = 0;
	cin >> n;
	vector<int>num(n);
	for (int i = 0; i < n; i++) {
		cin >> num[i];


	}
	vector<int>nm(n);
	for (int i = 0; i < n; i++) {
		cin >> nm[i];


	}
	for (int i = 0; i < n; i++) {
		if (num[i] > nm[i]) {
			sum = sum + num[i] - nm[i];
		}


	}
	cout << sum;

}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	int a, b;
	vi cross(100+1);
	while(cin >> a >> b) {
		if(a|b) {
			cross[a]++;
			cross[b]++;
		} else {
			int count = 0;
			bool ok = true;
			if(cross[1] != 1 || cross[2] != 1) {
				ok = false;
			}
			FOR(i, 3, 100) {
				if(cross[i]%2) {
					ok = false;
					break;
				}
			}

			cout << (ok ? "OK" : "NG") << endl;

			REP(i, 100+1) {
				cross[i] = 0;
			}
		}
	}
}

Measured memory_bytes: 1188
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        char[] s = sc.next().toCharArray();
        int k = sc.nextInt();
        int n = s.length;
        int[] t = new int[n];
        for (int i = 0; i < n; i++) {
            t[i] = s[i] - 'a';
        }
        for (int i = 0; i < n; i++) {
            if (i == n - 1) {
                t[i] = (t[i] + k) % 26;
            } else if (t[i] != 0 && t[i] + k >= 26) {
                k -= 26 - t[i];
                t[i] = 0;
            }
        }
        for (int i = 0; i < n; i++) {
            s[i] = ((char) (t[i] + 'a'));
        }
        System.out.println(String.valueOf(s));
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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

int main() {
  int L, R, d;
  cin >> L >> R >> d;
  int ans = 0;

  for (int i = L; i < R+1 ; i++) {
    if (i%d == 0) {
      ans ++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3672
#include<stdio.h>
int main()
{
	int n,a[100],c=0,x=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]%2==0){
			c++;
			if(a[i]%3==0||a[i]%5==0) x++;
		}
	}
	if(c==x) printf("APPROVED\n");
	else printf("DENIED\n");
	return 0;
}


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

#define print2(a, b) cerr << "(" << a << "," << b << ")" << endl
#define print3(a, b, c) cerr << "(" << a << "," << b << "," << c << ")" << endl


void solve(long long A, long long B){
    cout << (A-1) * (B-1) << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MN 100000
#define ll long long
using namespace std;
inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	return x;
}
ll f[MN+5],g[MN+5];
int n,m,a[MN+5],b[MN+5],c[MN+5],s[MN+5],rk[MN+5],used[MN+5],head[MN+5],cnt;
struct edge{int to,next;}e[MN*2+5];
inline void ins(int f,int t)
{
	e[++cnt]=(edge){t,head[f]};head[f]=cnt;
	e[++cnt]=(edge){f,head[t]};head[t]=cnt;	
}
inline int getfa(int x){return s[x]?s[x]=getfa(s[x]):x;}
bool cmp(int x,int y){return c[x]<c[y];}
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;++i) a[i]=read(),b[i]=read(),c[i]=max(a[i]-b[i],0),rk[i]=i;
	sort(rk+1,rk+n+1,cmp);
	for(int i=1;i<=m;++i) ins(read(),read());
	for(int i=1;i<=n;++i)
	{
		int x=rk[i];used[x]=1;ll mn=c[x];g[x]=b[x];
		for(int j=head[x];j;j=e[j].next) if(used[e[j].to])
		{
			int y=getfa(e[j].to);
			if(y==x) continue;
			s[y]=x;g[x]+=g[y];
			mn=min(mn,max((ll)c[x],f[y])-g[y]);
		}
		f[x]=g[x]+mn;
	}
	printf("%lld",f[rk[n]]);
	return 0;
}



Measured memory_bytes: 6144
#include<iostream>
#include<numeric>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  while(n--){
    cin>>v[n];
  }
  sort(v.rbegin(),v.rend());
  long long a=1;
  auto it=begin(v)+min<int>(4,v.size());
  a+=accumulate(begin(v),it,0LL);
  v.erase(begin(v),it);
  while(!v.empty()){
    vector<int> nv;
    int n2=0;
    for(auto e:v){
      n2+=e>=2;
      if(e-2>0){
	nv.push_back(e-2);
      }
    }
    a+=min(4,n2);
    auto it=begin(nv)+min<int>(8,nv.size());
    a+=accumulate(begin(nv),it,0LL);
    nv.erase(begin(nv),it);
    v=nv;
  }
  cout<<a<<endl;
}

    

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(){
  int q;
  list<int>L;
  list<int>::iterator it=L.begin();
  cin>>q;
  while(q--){
    int a,b;
    cin>>a;
    if(a<2)cin>>b;
    if(!a)it=L.insert(it,b);
    else if(a==1){
      r(i,abs(b)){
        if(b<0)it--;
        else it++;
      }
    }
    else it=L.erase(it);
  }
  it=L.begin();
  for(;it!=L.end();it++){
    cout<<*it<<endl;
  }
}


Measured memory_bytes: 18616
import java.util.*;

public class Main {
		public static void main(String[] args) {
			
			Scanner sc = new Scanner(System.in);
			
			int N = sc.nextInt();
			int M = sc.nextInt();
			
			if(N == M) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}
}
		

Measured memory_bytes: 24020
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    int n,k;
    cin>>k>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    vi sum;
    rep(i,n-1)sum.pb(v[i+1]-v[i]);
    sum.pb(v[0]+(k-v[n-1]));
    Sort(sum);
    fin(k-sum[sum.size()-1]);

    
}


Measured memory_bytes: 2168
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#include "boost/multiprecision/cpp_int.hpp"
typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////




int main(){fastio
    LL n;cin>>n;
    cout<<(n+1)/2<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=2000003;
int bit1[maxn];
ll a[maxn];
ll b[maxn],c[maxn];
int main(){
  int n;
  ll k;
  cin>>n>>k;
  fill(a,a+maxn,0LL);
  fill(b,b+maxn,0LL);
  fill(c,c+maxn,0LL);
  for(int i=0;i<n;i++){
    int ta;
    ll tb;
    cin>>ta>>tb;
    a[ta]+=tb;
  }
  int now=1;
  for(int i=0;i<maxn;i++){
    if(a[i]!=0LL){
      b[now]=a[i];
      b[now]+=(ll)b[now-1];
      c[now]=(ll)i;
      now++; 
    }
  }
  
  int l=-1,r=now-1,mid;
  while(r-l>1){
    mid=(l+r)/2;
    //cout<<l<<" "<<r<<" "<<mid<<" "<<b[mid]<<endl;
    if(b[mid]>=k)r=mid;
    else l=mid;
  }
  cout<<c[r]<<endl;


  return 0;
}


Measured memory_bytes: 47360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll d;   cin >> d;
    vector<ll> c(26), days(26, 1);
    REP(i, 26) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26, 0));
    REP(i, d) REP(j, 26) cin >> s[i][j];

    ll res=0;
    REP(q, d){
        ll x;   cin >> x;
        x--;
        REP(i, 26){
            if(i==x){
                res += s[q][x];
                days[x] = 1;
            }else{
                res -= days[i]*c[i];
                days[i] += 1;
            }
        }
        cout << res << endl;
    }
}


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

#define endl "\n"
#define INF 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    int n, m;
    cin >> n >> m;
    int poss = true;
    vector<int> num(n);
    vector<int> marked(n);
    while (m--) {
        int a, b;
        cin >> a >> b;
        if (n > 1 and a == 1 and b == 0) {
            poss = false;
            break;
        }
        if (marked[a - 1] and num[a - 1] != b) {
            poss = false;
            break;
        }
        num[a - 1] = b;
        marked[a - 1] = true;
    }

    if (poss) {
        for (int i = 0; i < n; i++) {
            if (i == 0 and num[i] == 0 and n != 1) {
                cout << 1;
            } else {
                cout << num[i];
            }
        }
        cout << endl;
    } else {
        cout << -1 << endl;
    }

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能

int main(){
    ll n,a,b; cin >> n >> a >> b;
    ll ans;
    if((b-a)%2==0){
        ans=(b-a)/2;
    }else{
        ans=min(b-1,n-a);
        ans=min(ans,(b+a-1)/2);
        ans=min(ans,(2*n-a-b+1)/2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

int main(){
    int h, w;
    cin >> h >> w;

    char m[105][105];
    int a[105][105];
    memset(a,-1,sizeof(a));

    rep(i,h) cin >> m[i];
    rep(i,h){
        rep(j,w){
            if(m[i][j] == 'c'){
                for(int k = j; k < w; k++){
                    a[i][k] = k - j;
                }
            }
        }
    }
    rep(i,h){
        rep(j,w){
            if(j) cout << ' ';
            cout << a[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3156
using System;
using System.Linq;

namespace AtCoder
{
    static class Solver
    {
        static IO io = new IO();

        public static void Solve()
        {
            io.Read();
            int N = io.Int();

            int[] S = new int[N];
            for (int i = 0; i < N; ++i)
            {
                io.Read();
                S[i] = io.Int();
            }

            io.WriteLine(Ans(S).ToString());

        }

        public static int Ans(int[] S)
        {
            Array.Sort(S);

            int sum = S.Sum();
            if (sum % 10 != 0)
            {
                return sum;
            }
            else
            {
                for (int i = 0; i < S.Length ; ++i)
                {
                    if (S[i] % 10 != 0)
                    {
                        return sum - S[i];
                    }
                }
            }
            return 0;

        }

    }
}
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Solver.Solve();
        }
    }
    class IO
    {
        private string[] _Inputs;
        private int _Index;
        public void Read()
        {
            _Inputs = new string[1];
            _Inputs[0] = Console.ReadLine();
            _Index = 0;
        }
        public void ReadSplit()
        {
            _Inputs = Console.ReadLine().Split(' ');
            _Index = 0;
        }
        public string String()
        {
            return _Inputs[_Index++];
        }
        public string[] String(int xCount)
        {
            string[] rv = new string[xCount];
            Array.Copy(_Inputs, _Index, rv, 0, xCount);
            _Index += xCount;
            return rv;
        }
        public int Int()
        {
            return int.Parse(_Inputs[_Index++]);
        }
        public int[] Int(int xCount)
        {
            int[] rv = new int[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = int.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public long Long()
        {
            return long.Parse(_Inputs[_Index++]);
        }
        public long[] Long(int xCount)
        {
            long[] rv = new long[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = long.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public void Write(string xStr)
        {
            Console.Write(xStr);
        }
        public void WriteLine(string xStr)
        {
            Console.WriteLine(xStr);
        }
    }
}

Measured memory_bytes: 13268
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2020-01-10 20:59:44
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int k, x;
    cin >> k >> x;

    if (k*500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func setupIO() {
	sc.Split(bufio.ScanWords)
}

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

func main() {
	setupIO()
	a, b, c := nextInt(), nextInt(), nextInt()

	if a%2 == 1 || b%2 == 1 || c%2 == 1 {
		fmt.Println(0)
		return
	}

	if a == b && b == c {
		fmt.Println(-1)
		return
	}

	var ans int
	for a%2 == 0 && b%2 == 0 && c%2 == 0 {
		a, b, c = b/2+c/2, a/2+c/2, a/2+b/2
		ans++
	}
	fmt.Println(ans)

}


Measured memory_bytes: 1772
#include <iostream>
#include <list>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plll;
list<plll> li;

ll distplll(plll a){
	return a.F.S-a.F.F+1;
}

void w_list(ll a,ll b){
	list<plll>::iterator it=li.begin();
	while(1){
		if(b==0) break;
		if(it==li.end()){
			if(it==li.begin()){
				li.PB(mkp(mkp(0,b-1),a));
			}
			else{
				--it;
				li.PB(mkp(mkp((*it).F.S+1,(*it).F.S+b),a));
				++it;
			}
			return;
		}
		else{
			if((*it).S==-1){
				if(distplll(*it)<=b){
					(*it).S=a;
					b-=distplll(*it);
				}
				else{
					plll tmp;
					tmp.S=a;
					tmp.F.S=(*it).F.F+b-1;
					tmp.F.F=(*it).F.F;
					(*it).F.F=tmp.F.S+1;
					it=li.insert(it,tmp);
					++it;
					return;
				}
			}
		}
		++it;
	}
}


void d_list(ll a){
	list<plll>::iterator it=li.begin();
	while(it!=li.end()){
		if((*it).S==a){
			(*it).S=-1;
		}
		++it;
	}
}

void r_list(ll a){
	list<plll>::iterator it=li.begin();
	while(it!=li.end()){
		if(a<=(*it).F.S){
			cout<<(*it).S<<endl;
			return;
		}
		++it;
	}
	cout<<"-1"<<endl;
}


int main(){
	int n;
	while(cin>>n,n){
		list<plll> ttt;
		li=ttt;
		rep(i,n){
			char c;
			cin>>c;
			if(c=='W'){
				ll a,b;
				cin>>a>>b;
				w_list(a,b);	
	
			}
			else if(c=='D'){
				ll a;
				cin>>a;
				d_list(a);
			}
			else{
				ll a;
				cin>>a;
				r_list(a);
			}
			list<plll>::iterator it=li.begin();
			
			// for(;it!=li.end();++it){
				// cout<<(*it).F.F<<" "<<(*it).F.S<<" "<<(*it).S<<endl;
			// }
			// cout<<endl;
		}
		cout<<endl;
	}
	return 0;
} 

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

int main() {
  int64_t a;
  cin >> a;
  
  int64_t sum, b, c, d;
  sum = a*(a+1)/2;
  b = a/3;
  b = 3*b*(b+1)/2;
  c = a/5;
  c = 5*c*(c+1)/2;
  d = a/15;
  d = 15*d*(d+1)/2;
  
  sum = sum - b - c + d;
  cout << sum;
}








Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
double PI=acos(-1);
int n,k,arr[105];
ll dp[105][100005];
int const mod=1e9 +7;

int main(){
    IO
    cin>>n>>k;
    for(int i=0;i<105;i++) dp[i][0]=1;
    for(int i=1;i<n+1;i++) cin>>arr[i];
    sort(arr,arr+n+1);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=100000;j++){
            if(arr[i]>=j) dp[i][j]=dp[i][j-1]+dp[i-1][j];
            else dp[i][j]=dp[i][j-1]+dp[i-1][j]-dp[i-1][j-arr[i]-1];
            dp[i][j]=(dp[i][j]+mod)%mod;
        }
    }
    cout<<dp[n][k]<<'\n';


    return 0;
}


Measured memory_bytes: 81784
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int p[][]=new int[3][2];
		List<Integer>[]acts=new ArrayList[4];
		for(int i=0;i<4;i++)acts[i]=new ArrayList<Integer>();
		for(int i=0;i<3;i++) {
			int a=sc.nextInt()-1;
			int b=sc.nextInt()-1;
			acts[a].add(b);
			acts[b].add(a);
		}
		boolean a=true;
		for(int i=0;i<4;i++) {
			int sum=acts[i].size();
			if(sum==3)a=false;
			
		}

		
		System.out.println(a?"YES":"NO");

	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define maxs 220202
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
int dis1[maxs],disn[maxs];
vector<int>vc[maxs];

void dfs(int u,int pa,int dis[ ],int len){
    dis[u] = len;
    int sz = vc[u].size(),id;
    for(int i=0;i<sz;i++){
        id = vc[u][i];
        if(id == pa) continue;
        dfs(id,u,dis,len+1);
    }
}


int main(){
    int n;
    while(~scanf("%d",&n)){
        for(int i=1;i<=n;i++) vc[i].clear();
        mme(dis1,0);
        mme(disn,0);
        int u,v;
        for(int i=2;i<=n;i++){
            scanf("%d%d",&u,&v);
            vc[u].push_back(v);
            vc[v].push_back(u);
        }
        dfs(1,0,dis1,0);
        dfs(n,0,disn,0);
        int ans = 0;
        for(int i=1;i<=n;i++){
            if(dis1[i]<=disn[i]) ans++;
            else if(dis1[i]>disn[i]) ans--;
        }

        if(ans>0)
            puts("Fennec");
        else puts("Snuke");
    }

    return 0;
}

Measured memory_bytes: 18048
import collections
n = int(input())
ls = []
for i in range(n):
    s = input()
    ls.append(s)
m = int(input())
lt = []
for i in range(m):
    t = input()
    lt.append(t)

ans = 0
for i in set(ls):
    sum = ls.count(i) - lt.count(i)
    if sum > ans:
        ans = sum
print(ans)

Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			String[] line = br.readLine().split(" ");
			double x1 = Double.parseDouble(line[0]);
			double y1 = Double.parseDouble(line[1]);
			double x2 = Double.parseDouble(line[2]);
			double y2 = Double.parseDouble(line[3]);

			double diffX = Math.abs(x1 - x2);
			double diffY = Math.abs(y1 - y2);
			double z = diffX * diffX + diffY * diffY;
			System.out.println(String.format("%.5f", Math.sqrt(z)));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 17088
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte(){
        if(ptr < buflen){
            return true;
        }else{
            ptr = 0;
            try{
                buflen = in.read(buffer);
            }catch(IOException e){
                e.printStackTrace();
            }
            if(buflen <=0){
                return false;
            }
        }
        return true;
    }

    private int readByte(){
        if(hasNextByte())return buffer[ptr++];
        else return -1;
    }

    private static boolean isPrintableChar(int c){
        return 33<=c && c<=126;
    }
    public boolean hasNext(){
        while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;
        return hasNextByte();
    }

    public String next(){
        if(!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)){
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong(){
        if(!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if(b == '-'){
            minus = true;
            b = readByte();
        }
        if(b < '0' || '9' < b){
            throw new NumberFormatException();
        }
        while(true){
            if('0' <= b && b<='9'){
                n*=10;
                n+=b-'0';
            }else if(b==-1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt(){
        long nl = nextLong();
        if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDoutble(){return Double.parseDouble(next());}
}
public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int[] h = new int[n];
        for(int i=0;i<n;i++)h[i] = fs.nextInt();

        for(int i=n-2;i>=0;i--){
            if(h[i] - h[i+1]>=2){
                System.out.println("No");
                return;
            }else if(h[i]-h[i+1]==1){
                h[i]--;
            }
        }

        System.out.println("Yes");
        

    }
}

Measured memory_bytes: 22392
a,b = map(int, input().split())

#from math import gcd
from fractions import gcd

g = gcd(a,b)

pf = {}

for i in range(2,int(g**0.5)+1):
    while g % i == 0:
        pf[i] = pf.get(i,0) + 1
        g //= i
if g > 1: pf[g] = 1

ans = 1 + len(pf.keys()) # 1は素数ではないが答えには入る

print(ans)

Measured memory_bytes: 71276
N,X = map(int,input().split())

def f(N,X):
  if N==0:
    return 0 if X<=0 else 1
  elif X<=1+2**(N+1)-3:
    return f(N-1,X-1)
  else:
    return 2**(N)+f(N-1,X-2**(N+1)+3-2)
        
print(f(N,X))

Measured memory_bytes: 9140
#include<iostream>

using namespace std;

int main(){

    long long x;
    cin >> x;
    long long ans = 0;
    long long y = 0;

    ans += (x/11)*2;
    x %= 11;
    while(y<x){
        y += 6;
        ans++;
        if(y<x){
            y += 5;
            ans++;
        }
    }
    cout << ans << 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 N=sc.nextInt();

		int K=sc.nextInt()-1;

		String s=sc.next();

		String[] str=s.split("");

		for(int i=0;i<N;i++){
			if(i==K){
				str[i]=str[i].toLowerCase();
			}
			System.out.print(str[i]);
		}

		System.out.println();

		sc.close();

	}

}


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


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

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


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






























int main(){
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll c = min(k, x / d);
    k -= c;
    x -= c * d;
    cout << ((k % 2 == 0)? x : d - x) << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a=0;
    char text[10];
    scanf("%d,.",&a);
    scanf("%s,.",text);
    if(a>=3200){
        printf("%s\n",text);
    }else if(a<3200){
        printf(" red\n");
    }
    
    return 0;
}


Measured memory_bytes: 128
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if(i*500 + j*100 + k*50 == x):
                count += 1
print(count)


Measured memory_bytes: 3060
#include <iostream>

#define _USE_MATH_DEFINES

#include <cmath>
#include <cstdio>

using namespace std;

double radian = 60 * M_PI / 180.0;

struct co {
	double x;
	double y;
};

void kock(int n, co p1, co p2) {
	if (n == 0) {
		return;
	}
	co s, t, u;
	s.x = (2 * p1.x + 1 * p2.x) / 3;
	s.y = (2 * p1.y + 1 * p2.y) / 3;
	t.x = (1 * p1.x + 2 * p2.x) / 3;
	t.y = (1 * p1.y + 2 * p2.y) / 3;

	u.x = (t.x - s.x) * cos(radian) - (t.y - s.y) * sin(radian) + s.x;
	u.y = (t.x - s.x) * sin(radian) + (t.y - s.y) * cos(radian) + s.y;

	kock(n - 1, p1, s);
	printf("%.8f %.8f\n", s.x, s.y);
	kock(n - 1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	kock(n - 1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	kock(n - 1, t, p2);

}

int main() {
	int n;
	scanf("%d", &n);
	co p1 { 0, 0 };
	co p2 { 100, 0 };

	printf("%.8f %.8f\n", p1.x, p1.y);
	kock(n, p1, p2);
	printf("%.8f %.8f\n", p2.x, p2.y);

	return 0;
}

Measured memory_bytes: 3412
package main

import (
        "fmt"
)

func solution(n int) int {
        var L [87]int
        L[0] = 2
        L[1] = 1
        for i := 2; i <= n; i++ {
                L[i] = L[i-1] + L[i-2]
        }
        return L[n]
}

func main() {
        var n int
        fmt.Scan(&n)
        fmt.Println(solution(n))
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
    int h,w,k;

bool kblack(vector<vector<int>> vvi,int n)
{
    rep(i,h){
        if(n&(1<<i)){
            rep(j,w){
                vvi[i][j] = 2;
            }
        }
    }
    rep(i,w){
        if(n&(1<<(h+i))){
            rep(j,h){
                vvi[j][i] = 2;
            }
        }
    }
    int cnt=0;
    rep(i,h){
        rep(j,w){
            if(vvi[i][j]==1){
                cnt++;
            }
        }
    }
    return cnt == k;
}

signed main()
{
    cin>>h>>w>>k;
    vector<vector<int>> vvi(h,vector<int>(w));
    rep(i,h){
        string s;
        cin>>s;
        rep(j,w){
            if(s[j]=='.'){
                vvi[i][j] = 0;
            }
            else {
                vvi[i][j] = 1;
            }
        }
    }
    int cnt = 0;
    rep(i, 1 << (h+w))
    {
        if(kblack(vvi,i)){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636