akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

typedef pair<int, int> P;

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

ll a[100100], x[510];
int main() {
	a[0] = 0;
	int N, Q;
	cin >> N >> Q;
	REP(i, N) {
		ll c; cin >> c;
		a[i + 1] = a[i] + c;
	}
	REP(i, Q)cin >> x[i];
	REP(k, Q) {
		ll ans = 0;
		ll sum = 0;
		int right = 1;
		FOR(left, 0, N) {
			while (right < N + 1 && (a[right] - a[left]) <= x[k]) {
				right++;
			}
			ans += (right - left-1);
			if (right == (left + 1))right++;
		}
		cout << ans << endl;
	}
}



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

using namespace std;

int main() {
  double N, X, T;
  cin >> N >> X >> T;

  cout << int(ceil(N/ X) * T) << endl;

  return 0;
}


Measured memory_bytes: 3220
a,b,c=gets.chomp.split.map(&:to_i)
def mm(number1,number2)
    if number1%2 != 0 then
        number1 = number1-1
    end
    number2 = number2 +(number1/2)
    number1 = number1/2
    return number1,number2
end

c.times{
    b,a = mm(a,b)
}
if c%2==0 then
    puts [a,b].join(" ")
else
    puts [b,a].join(" ")
end

Measured memory_bytes: 1788
n = int(input())
ans = []
for i in range(1,n+1):
    count = 0
    num = i
    while True:
        if num % 2 == 0:
            count += 1
        else:
            break
        num /= 2
    ans.append(count)
print(ans.index(max(ans))+1)

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

vector<pair<int,int> > edge[100001];

int dist[100001];

void dfs(int x){
	for(auto i:edge[x])
		if(dist[i.first]==-1){
			dist[i.first]=(dist[x]+i.second)%2;
			dfs(i.first);
		}
}


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1,u,v,w;i<n;i++){
		cin>>u>>v>>w;
		w%=2;
		edge[u].emplace_back(make_pair(v,w));
		edge[v].emplace_back(make_pair(u,w));
	}
	memset(dist,-1,sizeof dist);
	dist[1]=0;
	dfs(1);
	for(int i=1;i<=n;i++)
		cout<<dist[i]<<'\n';
	

}


Measured memory_bytes: 7680
using System;

namespace AGC041
{
    class Program
    {
        private static int Solve(int n, int m, int v, int p, int[] a)
        {
            if (Validate(0, n, m, v, p, a)) return n;
            int mn = 0;
            int mx = n - p + 1;
            while (mn < mx - 1)
            {
                int i = (mn + mx) / 2;
                if (Validate(i, n, m, v, p, a)) mx = i;
                else mn = i;
            }
            return n - mx;
        }

        private static bool Validate(int i, int n, int m, int v, int p, int[] a)
        {
            if (a[i] + m < a[n - p]) return false;
            long sum = i > 0 ? (long)i * (long)m : 0;
            for (int j = i; j <= n - p; ++j)
            {
                sum += a[i] + m - a[j];
            }
            sum += (long)(p - 1) * m;
            return sum >= (long)m * (long)v;
        }

        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ');
            var n = Convert.ToInt32(line[0]);
            var m = Convert.ToInt32(line[1]);
            var v = Convert.ToInt32(line[2]);
            var p = Convert.ToInt32(line[3]);
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), Convert.ToInt32);
            Array.Sort(a);
            Console.WriteLine(Solve(n, m, v, p, a));
        }
    }
}


Measured memory_bytes: 20576
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){
    int N;
    double x, tot = 0;
    char u[5];
    cin>>N;
    for(int i=0; i<N; i++){
        cin>>x>>u;
        if(u[0] == 'B')
            tot += x * 380000.0;
        else
            tot += x;
    }
    printf("%lf", tot); 
}

Measured memory_bytes: 256
def gcd(a,b):
    while b != 0:
        a, b = b, a % b
    return a

def solve():
    A,B,K = map(int, input().split())
    n = gcd(A,B)
    for i in range(n,0,-1):
        if n % i == 0:
            K -= 1
            if K == 0:
                return i

ans = solve()
print(ans)


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

int main(){
  int N,M;
  cin >> N >> M;
  map<int,int> m;
  for(int i = 0; i < N; i++){
    int num;
    cin >> num;
    for(int j = 0; j < num; j++){
      int tmp;
      cin >> tmp;
      if(m.count(tmp) == 0){
        m[tmp] = 1;
      } else { 
        m[tmp] += 1;
      }
    }
  }
  int ans = 0;
  for(auto x:m){
    if(x.second == N){
      ans++;
    }
  }
  cout << ans << endl;


}

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

int main(void)
{
	int i;
	int n;
	
	cin >> n;
	
	int a[n];
	
	for(i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	
	for(i = 0; i < n; i++)
	{
		cout << a[n - i - 1];
		if(i < n - 1)
		{
			cout << " ";
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>
int main(){
	int n,m,l[10000],i,x,p,a;
	while(1){
		scanf("%d%d",&n,&m);
		p=0;
		a=0;
		if(n==0&&m==0){
			break;
		}

		for(i=0;i<1024;i++){
			l[i]=0;
		}


		for(i=0;i<n;i++){
			scanf("%d",&l[i]);
		}
		for(i=0;i<m;i++){
			scanf("%d",&x);
			p+=x+l[p+x];
			if(p>=n-1&&a==0){
				a=i+1;
			}
		}
		printf("%d\n",a);
	}
    return 0;
}

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


int main(void){
	int n, p;
  cin >> n >> p;
  vector<int> odd, even;
  rep(i, n) {
    int x;
    cin >> x;
    if(x%2==0) even.push_back(x);
    else odd.push_back(x);
  }
  int n1 = odd.size(), n2 = even.size(); //奇数の数、偶数の数
  
  ll ans, select_odd = pow(2, n1)/2, select_even = pow(2, n2);
  
  
  if(p==0){
    ans = pow(2, n) - select_even * select_odd;
  }
  else{
    ans = select_even * select_odd;
  }
  cout << ans;
}


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

int main(){
 long long A,B,C,D;
 cin>>A>>B;
 C=min(A,B);
 D=max(A,B);
int r=D;
 
 while(1){
  
   if(D%C==0){
    cout<<D<<endl;
    return 0;
    
   }
   else{
   D+=r;
   }
 }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
//LIFE IS NOT A PROBLEM TO BE SOLVED
 
#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
#define debug(a) cout << #a << " = " << a << endl;
#define debug2(a,b) cout << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugP(a) cout << a.F << " " << a.S << endl;
#define debugV(v, n) { rep( i, 0, n ) { if(i) printf(" "); printf("%d", v[i]); } printf("\n"); }
#define debugM(mat,n,m) rep( i, 0, n ){ rep( j, 0, m ) { if(j) printf(" "); printf("%d", mat[i][j]); } printf("\n"); }
 
using namespace std;
 
typedef long long int ll;
typedef pair <int, int> ii;

const int MAXN = 1010;

int pset[MAXN];
int findset(int x){ if(x!=pset[x]) pset[x] = findset(pset[x]); return pset[x]; }
void unionset(int x, int y){ x = findset(x), y = findset(y); pset[x] = y; }
bool sameset(int x, int y){ return findset(x) == findset(y); }


int main(){
	
	int k, x; cin >> k >> x;
	if(k*500>=x) puts("Yes");
	else puts("No");
	
	return 0;
}

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



int main(){
     int n, k, c; cin >> n >> k >> c;
     string s; cin >> s;
     vector <int> loc1, loc2;
     int pardon = 0;
     for(int i = 0; i < n; i++){
          if(loc1.size() > k) break;
          if(s[i] == 'o'){
               if(pardon == 0){
                    loc1.push_back(i);
                    pardon = c;
               }
               else pardon--;
          }
          else{
               if(pardon > 0) pardon--;
          }
     }
     if(loc1.size() > k) loc1.pop_back();
     pardon = 0;
     for(int i = n-1; i >= 0; i--){
          if(loc2.size() > k) break;
          if(s[i] == 'o'){
               if(pardon == 0){
                    loc2.push_back(i);
                    pardon = c;
               }
               else pardon--;
          }
          else{
               if(pardon > 0) pardon--;
          }
     }
     if(loc2.size() > k) loc2.pop_back();
     reverse(loc2.begin(), loc2.end());
     for(int i = 0; i < k; i++)
          if(loc1[i] == loc2[i]) printf("%d\n", loc1[i]+1);
     return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



string s;
void solve(){
	cin >> s;
	
	cout << s.substr(0,4) << " " << s.substr(4) << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        List<int> ab = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToList();
        int a = ab[0], b = ab[1];

        Console.WriteLine(a % 2 == 0 || b % 2 == 0 ? "Even" : "Odd");
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

using namespace std;

int main()
{
	int n; cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++) { cin >> d[i]; }
	sort(d.begin(), d.end());
	
	int ans = 0, index = d[0],pool = 0;
	
	for (int i = 0; i < n; i++)
	{
		pool = i;
		for (int j = i+1; j < n-1; j++)
		{
			if (d[i] != d[j])
			{
				i = j-1;
				break;
			}
		}

		if (pool == d.size() - pool)
		{
			ans += d[i] - index;
		}
		index = d[i];
	}
	
	cout << ans << endl;

	return 0;
}

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

int main(){
  int n=0;
  cin >> n;
  if(n%2){
    n=n/2+1;
    cout << n << endl;
  }
  else{
    n=n/2;
    cout << n << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
const int NMAX=1<<17;
int n,a;
int main(){
  scan(n);scan(a);
  prin(n*n-a);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0){
      break;
    }
    for(i=0; i<H; i++){
      for(j=0; j<W; j++){
        if((i%2==0&&j%2==0)||(i%2==1&&j%2==1))
        printf("#");
        else printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2140
#include"bits/stdc++.h"
#include<valarray>

using namespace std;

#define MAX 10000002

#define MOD 998244353


int n;

long long int k[MAX];
long long int r[MAX];

long long int ppow(long long int i,long long int j){
	long long int ret=1;
	while(j){
		if(j&1LL){
			ret*=i;
			if(ret>=MOD)ret%=MOD;
		}
		i*=i;
		if(i>=MOD)i%=MOD;
		j>>=1LL;
	}
	//cout<<"ret "<<ret<<endl;
	return ret;
}
long long int p2[MAX];
inline long long int C(int a,int b){
	long long int u=r[b]*r[a-b];
	if(u>=MOD)u%=MOD;
	u*=k[a];
	//cout<<r[b]<<" "<<r[a-b]<<" "<<k[a]<<endl;
	if(u>=MOD)u%=MOD;
	return u;
}
int main(){
	cin>>n;
	k[0]=1;
	p2[0]=1;
	for(int i=1;i<=n;i++){
		p2[i]=p2[i-1]*2LL;
		if(p2[i]>=MOD)p2[i]%=MOD;
	}
	for(int i=1;i<=n;i++){
		k[i]=k[i-1]*i;
		if(k[i]>=MOD)k[i]%=MOD;
	}
	r[n]=ppow(k[n],MOD-2);
	for(int i=n-1;i>=0;i--){
		r[i]=r[i+1]*(i+1);
		if(r[i]>=MOD)r[i]%=MOD;
	}
	int ng=n/2+1;
	long long int ans=0;
	for(int i=ng;i<=n;i++){
		//cout<<n<<" "<<i<<" "<<C(n,i)<<endl;
		long long int w=C(n,i)*p2[n-i];
		ans+=w;
		if(ans>=MOD)ans%=MOD;
	}
	ans*=2LL;
	ans%=MOD;
	long long int f=ppow(3,n);
	f+=MOD-ans;
	f%=MOD;
	ans=f;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 234624
package main

import "fmt"

func main() {
	var n, y int
	fmt.Scan(&n, &y)

	for i := 0; i <= n; i++ {
		for j := 0; i+j <= n; j++ {
			k := n - i - j
			if 10000*i+5000*j+1000*k == y {
				fmt.Println(i, j, k)
				return
			}
		}
	}
	fmt.Println("-1 -1 -1")
}


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

int main() {
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;++i) cin>>a[i];
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;
    return 0;
}


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

int n, k, f, ind;
std::vector<int> vec, vec2;

int main() {
    std::cin >> n >> k;
    vec.assign(n, 0);
    for (int i = 0; i < n; i++) {
        std::cin >> vec[i];
    }
    for (int i = 0; i+k-1 < n; i++) {
        int f = vec[i];
        int l = vec[i+k-1];
        if (f <= 0 && l <= 0) {
            vec2.push_back(std::abs(f));
        }
        else if (f >= 0 && l >= 0) {
            vec2.push_back(std::abs(l));
        }
        else {
            int abs_f = std::abs(f);
            int abs_l = std::abs(l);
            if (abs_f <= abs_l) {
                vec2.push_back(abs_f * 2 + abs_l);
            }
            else if (abs_l < abs_f) {
                vec2.push_back(abs_l * 2 + abs_f);
            }
        }
    }
    std::cout << *std::min_element(vec2.begin(), vec2.end()) << std::endl;
}


Measured memory_bytes: 1024
#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>
#include <fstream>
#include <iomanip>
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-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;

int main() {
	int a, b;
	cin >> a >> b;

	int d = b - a;
	cout << d*(d - 1) / 2 - a << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a=sc.nextLong(),b=sc.nextLong(),c=sc.nextLong(),d=sc.nextLong();
		long lc=0,rc=0,sumc=0,ld=0,rd=0,sumd=0,lcd=0,rcd=0,sumcd=0,res=0;
		long lcm=0;
		if(c<d)lcm=LCM(c,d);
		else lcm=LCM(d,c);

		lc=(a-1)/c;
		rc=b/c;
		sumc=rc-lc;

		ld=(a-1)/d;
		rd=b/d;
		sumd=rd-ld;

		lcd=(a-1)/lcm;
		rcd=b/lcm;
		sumcd=rcd-lcd;

		res=sumc+sumd-sumcd;
		System.out.println((b-a+1)-res);
	//	System.out.println(sumc+" "+sumd+" "+sumcd+" "+res);
	//	System.out.println(lc+" "+rc+" "+ld+" "+rd+" "+lcd+" "+rcd);
	}
	/*min,maxの最大公約数を求める。引数の大小は気を付ける*/
	public static long GCD(long min,long max) {
		if(max%min==0)return min;
		else return GCD(max%min,min);
	}
	/*min,maxの最小公倍数を求める。GCDとセットで使うように。引数の大小は気を付ける*/
	public static long LCM(long min,long max) {
		return (min*max)/GCD(min,max);
	}
}



Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c;cin>>a>>b>>c;
  cout<<min(c,b/a)<<endl;
  return 0;
}

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


def solve(N: int, A: "List[int]", B: "List[int]"):

    count = 0
    flag = True
    while flag:
        flag = False
        for i in range(N):
            a, b, c = B[i-1], B[i], B[(i+1) % N]
            if b > A[i] and b > a+c:
                d, m = divmod(b-A[i], a+c)
                if m == 0:
                    B[i] = A[i]
                    count += d
                else:
                    d, m = divmod(b, a+c)
                    count += d
                    B[i] = m
                flag = True
    # print(*A)
    # print(*B)
    if A != B:
        count = -1

    print(count)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 106872
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <map>
# include <stack>
using namespace std;
//# define M_PI 3.141592
# define INF ((int)(1<<30))
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 

class Point
{
public:
	double x, y;

	Point(double x = 0, double y = 0) :x(x), y(y) {}


	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
	Point operator * (double k) { return Point(x * k, y * k); }
	Point operator / (double k) { return Point(x / k, y / k); }
	bool operator < (const Point &p)const { return x != p.x ? x < p.x : y < p.y; }
	bool operator ==(const Point &p)const { return fabs(x - p.x) < EPS&&fabs(y - p.y) < EPS; }

	double abs() { return sqrt(norm()); }
	double norm() { return x*x + y*y; }
};
typedef Point Vector;
struct Segment
{
	Point p1, p2;
};
typedef Segment Line;
class Circle
{
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0.0) :c(c), r(r) {}
};

double dot(Vector a, Vector b) { return a.x*b.x + a.y*b.y; }//??????
double cross(Vector a, Vector b) { return a.x*b.y - a.y*b.x; }//??????
bool isOrthogonal(Vector a, Vector b) { return fabs(dot(a, b)) < EPS; }//??´??????
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) { return isOrthogonal(a1 - a2, b1 - b2); }
bool isOrthogonal(Line l1, Line l2) { return fabs(dot(l1.p2 - l1.p1, l2.p2 - l2.p1)) < EPS; }
bool isParallel(Vector a, Vector b) { return fabs(cross(a, b)) < EPS; }//?????????
bool isParallel(Point a1, Point a2, Point b1, Point b2) { return isParallel(a1 - a2, b1 - b2); }
bool isParallel(Line l1, Line l2) { return fabs(cross(l1.p2 - l1.p1, l2.p2 - l2.p1)) < EPS; }
Point project(Line s, Point p)
{
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / base.norm();
	return s.p1 + base*r;
}


int main()
{
	int n;
	cin >> n;
	long long ans = 0;
	for (int i = 0; i < n; i++)
	{
		long long x; cin >> x;
		ans += x;
	}
	cout << ans / n << endl;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define db double
#define ll long long
#define reg register
#define pb(x) push_back(x)
#define fup(i,x,y) for(reg int i=x;i<=y;++i)
#define fdw(i,x,y) for(reg int i=x;i>=y;--i)
using namespace std;
int a; 
inline int read()
{
	int x=0,ff=1;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*ff;
}
int main()
{
	//freopen("1.in","r",stdin);
	cin>>a;
	while(a) {if(a%10==7) {puts("Yes");return 0;}a/=10;}
	puts("No");
	return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0; i<(int)(n); ++i)
#define repi(i,m,n) for(ll i=(ll)(m); i<(ll)(n); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
const double PI=acos(-1);
//fixed<<setprecision(11)<<

int main(){
  string SSS,SSR,SRS,RSS,SRR,RSR,RRS,RRR;
  string a;
  cin >> a;
  
  if(a == "SSS") cout << 0 << endl;
  if(a == "SSR") cout << 1 << endl;
  if(a == "SRS") cout << 1 << endl;
  if(a == "RSS") cout << 1 << endl;
  if(a == "SRR") cout << 2 << endl;
  if(a == "RSR") cout << 1 << endl;
  if(a == "RRS") cout << 2 << endl;
  if(a == "RRR") cout << 3 << endl;
return 0;
}

Measured memory_bytes: 3628
def main():
    n = int(input())
    for i in range(1, n+1):
        x = i
        if x % 3 == 0:
            print(f" {i}", end="")
        else:
            while (x):
                if x % 10 == 3:
                    print(f" {i}", end="")
                    break
                x = x // 10
    print()


if __name__ == "__main__":
    main()



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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<40;
const ll MOD = 1000000007;

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];

  sort(ALL(a));
  ll prev = 0;
  ll g = 0;
  REP(i, n) {
    if((a[i] - prev) % 2) {
      g ^= n-i;
    }
  }
  if(g == 0) cout << "second" << endl;
  else cout << "first" << endl;

  return 0;
}


Measured memory_bytes: 1152
N = int(input())
D = {}

def gcd(x,y):
    if x>y: x,y=y,x
    while x:
        x,y=y%x,x
    return y

for _ in range(N):
    A, B = map(int, input().split())
    if   A==0 and B==0: key=(0,0)
    elif A==0: key=(0,1)
    elif B==0: key=(1,0)
    else:
        if A<0:
            A=-A
            B=-B
        g = gcd(A,abs(B))
        key = (A//g, B//g)

    if key not in D: D[key]=0
    D[key]+=1

mod = 10**9+7

ans = 1
n00 = 0
for k1, v1 in D.items():
    if k1==(0,0):
        n00+=v1
        continue
    if v1==0: continue
        
    k2 = (k1[1], -k1[0]) if k1[1]>0 else (-k1[1], k1[0])
    if k2 not in D:
        ans = ans * pow(2, v1, mod) % mod
    else:
        v2 = D[k2]
        m = (pow(2, v1, mod) + pow(2, v2, mod) - 1) % mod
        ans = ans * m % mod
        D[k2]=0
        
print((ans+n00-1)%mod)


Measured memory_bytes: 46244
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int H, N;
    cin >> H >> N;

    vector<int> A(N), B(N);
    rep(i,N) cin >> A[i] >> B[i];

    vector<long long> minimum(H + 1, LINF);
    minimum[0] = 0;
    rep(i,N) {
        for (int j = 1; j <= H; j++) {
            int k = j - A[i] > 0 ? j - A[i] : 0;
            minimum[j] = min(minimum[j], minimum[k] + B[i]);
        }
    }

    cout << minimum[H] << endl;

    return 0;
}

Measured memory_bytes: 384
import collections
n = int(input())
arr = []
ans = []
for i in range(n):
    s = input()
    arr.append(s)
c = collections.Counter(arr)
max_s = c.most_common()[0][1]
for j, k in c.items():
    if k == max_s:
        ans.append(j)
s_ans = sorted(ans)
for l in s_ans:
    print(l)

Measured memory_bytes: 45040
#input
N, M = map(int, input().split())
A = list(map(int, input().split()))

#output
import numpy as np
A = np.array(A)
B = np.sum(A)
C = A[A >= B/(4*M)]

if len(C) >= M:
    print("Yes")
else:
    print("No")

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

int main(){
	int m,f,r;
	

	while(1){
		cin >> m >> f >>r;
		if( m==-1 && f==-1 && r==-1) break;
		
		if( m== -1 || f== -1 ){ // ||???or
			cout << 'F' << "\n";
		}else if( m+f>=80 ){
			cout << 'A' << "\n";
		}else if( m+f<80 && m+f>= 65){
			cout << 'B' << "\n";
		}else if( m+f<65 && m+f>= 50){
			cout << 'C' << "\n";
		}else if( m+f<50 && m+f>= 30 && r>=50){
			cout << 'C' << "\n";
		}else if( m+f<50 && m+f>= 30 && r<50){
			cout << 'D' << "\n";
		}else{
			cout << 'F' << "\n";
		}
	}

	return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    x %= b;
    cout << x;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;


public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    HashSet<Integer> hs = new HashSet();
    hs.add(sc.nextInt());
    hs.add(sc.nextInt());
    int ans = 0;
    if(!hs.contains(1)) ans = 1;
    else if(!hs.contains(2)) ans = 2;
    else ans = 3;
    System.out.println(ans);
  }

}


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

int main(){
  int n;
  cin >> n;
  int t = n, c = 0;
  while(t > 0) c+= t % 10, t /= 10;
  if(n % c == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<unistd.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<stdint.h>
#include<time.h>
#include<tgmath.h>
inline int max(int a, int b){return a>b?a:b;}
inline int min(int a, int b){return a>b?b:a;}
long gcd(long a, long b){return b?gcd(b, a%b):a;}

//fast(?) Input
#define buf_sz 1<<24
char buf[buf_sz];
unsigned int nextint(){
	static int idx = 0;
	if(idx == 0)read(0, buf, buf_sz);
	unsigned int res = 0;
	while(idx<buf_sz && buf[idx]<'0' || '9'<buf[idx])idx++;
	while(idx<buf_sz && '0'<=buf[idx] && buf[idx]<='9'){
		res *= 10;
		res += buf[idx++] - '0';
	}if(idx>=buf_sz)exit(1);
	return res;
}

const long mod = 1e9 + 7;
long modpow(long x, long y, long m){
    long res = 1, tmp = x;
    while(y){
        if(y&1) res = res * tmp % m;
        tmp = tmp * tmp % m;
        y >>= 1;
    }
    return res;
}
long pom(long x, long y){return modpow(x, y, mod);}
long COM(long x, long y){
    if(x < y) return 0;
    if(x < 0 || y < 0) return 0;
    long res = 1;
    for(int i=0; i<y; i++){
        res = res * (x-i) % mod * pom(y-i, mod-2) % mod;
    }
    return res;
}

int main(){
	long S = nextint();
	long ans = 0;
	for(long i=1; i<=S/3; i++){
		long t = S - i*3;
		ans += COM(t+i-1, t);
		ans %= mod;
	}
	printf("%ld\n", ans);
	return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    priority_queue<long long> qu;
    for (auto i = 0; i < n; i++)
    {
        long long a;
        cin >> a;
        qu.push(a);
    }

    for (auto i = 0; i < m; i++)
    {
        long long tmp = qu.top();
        qu.pop();
        tmp /= 2;
        qu.push(tmp);
    }

    long long ans = 0;
    while (!qu.empty())
    {
        ans += qu.top();
        qu.pop();
    }

    cout << ans << endl;
}

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

int main(){
    string str;
    cin>>str;
    int n=str.size();
    int s=0,t=0;
    int ans=n;
    for(int i=0;i<n;i++){
        if(str[i]=='S') s++;
        if(str[i]=='T'){
            if(s){
                ans-=2;
                s--;
            }
        }
    }
    cout<<ans;

}

Measured memory_bytes: 640
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

fn solve(xs: &Vec<u64>, m: usize, z: u64) -> Option<u64> {
    let mut n = m;
    let mut ys = vec![];
    for &x in xs.iter() {
        let mut y = x;
        while y > z && n > 0 {
            y /= 2;
            n -= 1;
        }
        if y <= z {
            ys.push(y);
        } else {
            return None
        }
    }
    ys.sort();
    ys.reverse();
    for i in 0..n {
        ys[i % xs.len()] /= 2;
    }
    Some(ys.iter().sum())
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: usize = sc.cin();
    let xs: Vec<u64> = (0..n).map(|_| sc.cin()).collect();

    let mut ans: u64 = xs.iter().sum();
    {
        let mut left = 0;
        let mut right = 1000000003;
        for _ in 0..100 {
            let mid = (left + right) / 2;
            if let Some(sm) = solve(&xs, m, mid) {
                ans = min!(ans, sm);
                right = mid;
            } else {
                left = mid;
            }
        }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 12404
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;
int main(){
    string s;
    cin >> s;
    char a,b,x;
    a=s[0];
    int acounter=1;
    int bcounter=0;
    for(int i=1;i<4;i++){
    x=s[i];
    if(x==a){
        acounter++;
    }
    else if(bcounter==0){
        b=x;
        bcounter++;
    }
    else if(bcounter==1 && x==b){
        bcounter++;
    }
    else{
        break;
    }

    }

    if(acounter==2 && bcounter==2){
        cout << "Yes"<<endl;
    }
    else{
        cout <<"No"<<endl;
    }

 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  char s[1001], t[1001];
  scanf("%s %s", s, t);

  int sl = strlen(s);
  int tl = strlen(t);

  int max = 0;
  for (int si = 0; si <= sl - tl; si++) {
    int tmp = si;
    int count = 0;
    for (int ti = 0; ti < tl; ti++) {
      if (s[tmp] == t[ti]) count++;
      tmp++;
    }
    max = max(max, count);
  }
  printf("%d\n", tl - max);
  return 0;
}


Measured memory_bytes: 1732
n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))

dis=[]

if m==1 or n>=m:
    print(0)
    exit()

for i in range(m-1):
    dis.append(x[i+1]-x[i])
# x_i+1 と x_iの距離の最小値を取っていく
# distanceをソートして、小さいものからm-n-1個得る
dis.sort()

print(sum(dis[:m-n]))

Measured memory_bytes: 13960
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

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

    int a[n];
    REP(0, i, n) {
        cin >> a[i];
    }

    vector<int> b;
    REP(0, i, n) {
        if (i % 2 == 0) {
            b.push_back(a[i]);
        } else {
            b.insert(b.begin(), a[i]);
        }
    }

    if (b.size() % 2 != 0) {
        reverse(b.begin(), b.end());
    }

    REP(0, i, n) {
        if (i == 0) {
            cout << b[i];
        } else {
            cout << ' ' << b[i];
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3828
n, k = map(int, input().split())
s = list(input())
lr = 0
rl = 0
ans = 0
for i in range(n-1):
    if s[i]=='L' and s[i+1]=='R':
        lr += 1
    elif s[i]=='R' and s[i+1]=='L':
        rl += 1
    else:
        ans += 1

if lr >= k and rl >= k:
    ans += 2*k
elif lr == rl:
    ans += 2*lr
else:
    num = max(lr, rl)
    ans += 2*num-1

print(ans)

Measured memory_bytes: 9796
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
ll fac[110000];
ll finv[110000];
ll inv[110000];
int main() {
	int n;
	cin >> n;
	VL a(n + 1);
	VL sum(n + 1, 0);
	rep1(i, n) {
		cin >> a[i];
		sum[i] = sum[i - 1] + a[i];
	}
	VL diff(n + 1, 0);
	diff[0] = UPPER;
	rep1(i, n) {
		ll l = sum[i];
		ll r = sum[n] - l;
		diff[i] = abs(l - r);
	}
	cout << *min_element(all(diff)) << endl;
	return 0;
}

Measured memory_bytes: 4992
require 'prime'
require 'set'
require 'tsort'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

l = array(8,0)
n = gif
a = gi
tmp = 0
a.each do |aa|
  if aa < 400
    l[0] += 1
  elsif aa < 800
    l[1] += 1
  elsif aa < 1200
    l[2] += 1
  elsif aa < 1600
    l[3]+=1
  elsif aa < 2000
    l[4]+=1
  elsif aa < 2400
    l[5] += 1
  elsif aa < 2800
    l[6] += 1
  elsif aa < 3200
    l[7] += 1
  else
    tmp += 1
  end
end

l.sort!
num = 0
rep 8 do |i|
num += 1 if l[i] != 0
end
max = num + tmp
min = num
if min == 0 && tmp > 0
  min = 1
end

puts min.to_s + " " + max.to_s



Measured memory_bytes: 2428
#include <stdio.h>

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

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

  ans = 0;
  while (1) {
    if (c > 0) {
      ans++;
      c--;
      if (b > 0) {
        ans++;
        b--;
      }
      else if (a > 0) {
        a--;
      }
      else {
        break;
      }
    }
    else if (c == 0) {
      break;
    }
  }

  while (1) {
    if (b > 0) {
      ans++;
      b--;
    }
    else {
      break;
    }
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

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

	if n == 1 {
		fmt.Println(1)
	}else if n >= 2 && n < 4{
		fmt.Println(2)
	}else if n >= 4 && n < 8{
		fmt.Println(4)
	}else if n >= 8 && n < 16{
		fmt.Println(8)
	}else if n >= 16 && n < 32{
		fmt.Println(16)
	}else if n >= 32 && n < 64{
		fmt.Println(32)
	}else if n >= 64 && n <= 100{
		fmt.Println(64)
	}
}

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

#define ll long long
#define ull unsigned long long int
#define INF 0x3f3f3f3f
#define pb push_back
#define pii pair<int, int>

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    const int t = 100005;
    int n, v[t];
    int ans[t];
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    memset(ans, INF, sizeof ans);
    ans[0] = 0;
    for (int i = 1; i < n; i++) {
        if (i - 1 >= 0)
            ans[i] = min(ans[i], ans[i - 1] + abs(v[i] - v[i - 1]));
        if (i - 2 >= 0) {
            ans[i] = min(ans[i], ans[i - 2] + abs(v[i] - v[i - 2]));
        }
    }
    cout << ans[n - 1] << "\n";
    
    //cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
		int input[] = new int[n];
		for(int i = 0; i < n; i++){
			input[i] = sc.nextInt();
		}

		int dp[] = new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		for(int i = 1; i < n; i++){
			for(int j = 1; j <= k && i - j >= 0; j++){
				dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(input[i] - input[i - j]));
			}
		}

		System.out.println(dp[n - 1]);
	}

}



Measured memory_bytes: 49464
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    int N;
    double[][][] memo;
    double calc(int p, int q, int r)
    {
        if (p < 0 || q < 0 || r < 0)
        {
            return 0;
        }
        if (memo[p][q][r] >= 0)
        {
            return memo[p][q][r];
        }

        int M = p + q + r;
        var ret = (double)N / M;
        ret += calc(p - 1, q, r) * p / M;
        ret += calc(p + 1, q - 1, r) * q / M;
        ret += calc(p, q + 1, r - 1) * r / M;

        return memo[p][q][r] = ret;
    }

    void solve()
    {
        N = cin.nextint;
        var A = cin.scanint;
        var P = A.Count(i => i == 1);
        var Q = A.Count(i => i == 2);
        var R = A.Count(i => i == 3);

        memo = new double[N + 1][][];
        for (int i = 0; i < N + 1; i++)
        {
            memo[i] = new double[N + 1][];
            for (int j = 0; j < N + 1; j++)
            {
                memo[i][j] = new double[N + 1];
                for (int k = 0; k < N + 1; k++)
                {
                    memo[i][j][k] = int.MinValue;
                }
            }
        }
        memo[0][0][0] = 0;
        WriteLine(calc(P, Q, R).ToString("F10"));
    }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

Measured memory_bytes: 261376
#include<stdio.h>
 
static const int N = 1000;
 
void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}
 
int main(){
  int n, i, j,v;
  int A[N+1];
  scanf("%d", &n);
 
  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
   
  
  for(i=1; i<=n; i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
    }
    trace(A, n);
  }
  return 0;
}


Measured memory_bytes: 2068
def main():
    n, m = map(int, input().split())
    p = 2**n
    inf = 10**7
    dp = [inf]*p
    dp[0] = 0
    for _ in range(m):
        a, _ = map(int, input().split())
        c = sum([1<<(int(i)-1) for i in input().split()])
        for s in range(p):
                if dp[s|c] > dp[s] + a:
                    dp[s|c] = dp[s] + a
    ans = dp[-1]
    if ans == inf:
        ans = -1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
import os, sys, re, math


(H, W) = [int(n) for n in input().split()]


def set_moves(x, y, moves):
    if S[y + 1][x + 1] != '.':
        return
    if 0 <= grid[y][x] < moves:
        return

    grid[y][x] = moves
    set_moves(x, y - 1, moves + 1)
    set_moves(x, y + 1, moves + 1)
    set_moves(x - 1, y, moves + 1)
    set_moves(x + 1, y, moves + 1)


S = []
S.append('#' * (W + 2))
has_wall = False
for i in range(H):
    s = input()
    has_wall |= '#' in s
    S.append('#' + s + '#')
S.append('#' * (W + 2))

if not has_wall:
    result = W + H - 2
else:
    result = 0
    for gy in range(H):
        for gx in range(W):
            if S[gy + 1][gx + 1] != '.':
                continue
            grid = []
            for i in range(H):
                grid.append([-1] * W)
            set_moves(gx, gy, 0)

            result = max(result, max([max(row) for row in grid]))

print(result)


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

typedef long long ll;

const int MAX_N = 300;
const int INF = 2147483647;

ll DISTS[MAX_N][MAX_N];
ll DISTS2[MAX_N][MAX_N];


int main() {
    int N, M, L;
    cin >> N >> M >> L;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i == j) {
                DISTS[i][j] = 0;
                DISTS2[i][j] = 0;
            } else {
                DISTS[i][j] = INF;
                DISTS2[i][j] = INF;
            }
        }
    }
    for (int i = 0; i < M; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        DISTS[a][b] = c;
        DISTS[b][a] = c;
    }
    for (int k = 0; k < N; ++k) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                DISTS[i][j] = min(DISTS[i][j], DISTS[i][k] + DISTS[k][j]);
            }
        }
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            ll d = DISTS[i][j];
            if (d <= L && i != j) {
                DISTS2[i][j] = 1;
            }
        }
    }
    for (int k = 0; k < N; ++k) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                DISTS2[i][j] = min(DISTS2[i][j], DISTS2[i][k] + DISTS2[k][j]);
            }
        }
    }
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; ++i) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        ll d = DISTS2[s][t];
        ll ans = 0;
        if (d >= INF) {
            ans = -1;
        } else {
            ans = d - 1;
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 1920