akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1e9
#define endl '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define FORE(i, a, b) for (int i = (a), e = (b); i < e; ++i)
#define RFORE(i, a, b) for (int i = (b)-1, e = (a); i >= e; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    if (S.at(S.length() - 1) == 's') {
        cout << S << "es" << endl;
    } else {
        cout << S << "s" << endl;
    }
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
typedef long long int ll;
int main() {
	// your code goes here
	int a,b;
	cin>>a>>b;
	int socket=1;
	int num=0;
	while(socket<b){
	    socket--;
	    socket+=a;
	    num++;
	}
	cout<<num;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()

    var ans = n - 1
    var i = 2L

    while (i * i <= n) {
        if (n % i == 0L) {
            ans = Math.min(ans, i + n / i - 2)
        }
        i++
    }

    println(ans)
}


Measured memory_bytes: 33580
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
MOD = 998244353

n, s = map(int, input().split())
a = [int(item) for item in input().split()]

dp = [[0] * (s + 1) for _ in range(n+1)]
dp[0][0] = 1

for i, item in enumerate(a):
    for j in range(s, -1, -1):
        if dp[i][j] == 0:
            continue
        if j + item <= s:
            dp[i+1][j+item] += dp[i][j] 
        dp[i+1][j] += dp[i][j] * 2
        dp[i+1][j] %= MOD

print(dp[-1][-1] % MOD)

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

int main(){
  
  int n;
  int ans;
  // 無限ループさせる
  while(true){
    cin >> n;
    // n == 0
    if(n == 0){
      break;
    }

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

    // サーチする数
    int snum;
    cin >> snum;

    // search
    int top, last, center;
    top = 0;
    last = n - 1;
    ans = 0;
    while(top <= last){
      center = (top + last) / 2;
      ans++;
      // 一致？
      if(snum == num[center]){
	break;
      }
      
      if(snum > num[center]){
	top = center + 1;
      }
      else{
	last = center - 1;
      }
    }

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

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
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 main(){
    ll n,k;
    cin>>n>>k;
    ll a[2000];
    rep(i,0,n) cin>>a[i];

    ll inside=0;
    rep(i,0,n-1)
    rep(j,i+1,n){
      if(a[i]>a[j]) inside++;
    }

    ll outside=0;
    rep(i,0,n)
    rep(j,0,n){
      if(a[i]>a[j]) outside++;
    }

    //ll ans=(inside*k)%inf;

    //ans+=((k*(k-1)/2)%inf)*(outside);

    ll ans=inside*k;
    ans%=inf;

    ans+=outside*((k*(k-1)/2)%inf);
    ans%=inf;
    cout<<ans<<endl;

    return 0;
    //cout<<ans%inf<<endl;
    //cout<<inside<<' '<<outside;
}


Measured memory_bytes: 256
S=input()
n=len(S)
 
for i in range(n-1):
  if S[i] == S[i+1]:
    print(i+1, i+2)
    exit()
for i in range(n-2):
  if S[i] == S[i+2]:
    print(i+1, i+3)
    exit()

print(-1, -1)

Measured memory_bytes: 9016
//15:36:00 start

//16:53:00

#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace  std;
using ll=long long;
using pii=pair<int,int>;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	if(n==25) cout<<"Christmas\n";
	else if(n==24) cout<<"Christmas Eve\n";
	else if(n==23) cout<<"Christmas Eve Eve\n";
	else cout<<"Christmas Eve Eve Eve\n";
	return 0;
}

















Measured memory_bytes: 256
Option Strict On

Module Module1
    Sub Main()
        'let'
        Dim tmp() As Long =
            Array.ConvertAll(Of String, Long) _
            (Console.ReadLine().Split(), AddressOf Long.Parse)
        Dim a As Long = tmp(0)
        Dim b As Long = tmp(1)

        'var'
        Dim ans As Long = a

        If b < a Then ans -= 1

        Console.WriteLine(ans)

    End Sub
End Module

Measured memory_bytes: 11092
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = llabs(a*b*(c/2) - a*b*(c-c/2));
    chmin(ans, llabs(a*(b/2)*c - a*(b-b/2)*c));
    chmin(ans, llabs((a/2)*b*c - (a-a/2)*b*c));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll = long;
const ll N = 200010;
ll a[N], n, k, pos;
int main()
{
	scanf("%lld%lld", &n, &k);
	for (ll i = 1; i <= n; i++)
		scanf("%lld", a + i);
	for (ll i = 1; i < n; i++)
		if (a[i] + a[i + 1] >= k)
		{
			pos = i;
			break;
		}
	if (pos == 0)
		return puts("Impossible"), 0;
	puts("Possible");
	for (ll i = 1; i < pos; i++)
		printf("%lld\n", i);
	for (ll i = n -1; i > pos ; i--)
		printf("%lld\n", i);
	printf("%lld", pos);
}

Measured memory_bytes: 1536
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val a, b = in.nextLong
  def gcd(l: Long, r: Long): Long = if (r == 0) l else if (l % r == 0) r else gcd(r, l % r)
  println(a * b / gcd(a, b))
}

Measured memory_bytes: 27212
N,M = map(int, input().split())  #複数の数字
A = list(map(int, input().split()))  #リスト

cou = 0
for i in range(N):
    if A[i] >= sum(A) / (4 * M):
        cou += 1

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

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

int main(){
  int n, a;
  cin >> n >> a;
  while(n >= 0) {
    n -= 500;
  }
  n += 500;
  if (n<=a) cout << "Yes"  << endl;
  else cout << "No" << endl;
}


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

int main() {
  int D;
  int N;
  cin >> D >> N;
    if (N != 100){
    cout << pow(100,D)*N << endl;
    }
    if (N == 100){
      long ans = pow(100,D)*101;
      cout << ans << endl;
    }
}



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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}

int main(){
    int x = read();
    if (x >= 30) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;

int n;
map < int , int > m;

int main()
{
    scanf("%d", &n);
    for(int i = 1 ; i <= n ; i++)
    {
        int x;
        scanf("%d", &x);
        m[x]++;
    }
    vector < int > v;
    long long int ans = 0;
    for(auto it : m)
    {
        if(it.second > 1)
        v.push_back(it.first);
        if(it.second >= 4)
        ans = max(ans, (long long)it.first*it.first);
    }
    int sz = (int)v.size();
    if((int)sz > 1)
    ans = max(ans, (long long)v[sz - 2]*v[sz - 1]);
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int G[20][20];
int dp[1<<15][15];
int cost[15][1<<15];
int cc[1<<15];
int main()
{
    memset(dp,0x3f,sizeof(dp));
    dp[1][0]=0;
    int n,m;
    cin>>n>>m;
    for(int i=0,u,v,w;i<m;i++)
    {
        cin>>u>>v>>w;
        u--,v--;
        G[u][v]=G[v][u]=w;
    }
    for(int i=0;i<n;i++)
    {
        for(int S=0;S<(1<<n);S++)
        {
            for(int j=0;j<n;j++)
            {
                if(S>>j&1)
                    cost[i][S]+=G[i][j];
            }
        }
    }
    for(int S=1;S<(1<<n);S++)
    {
        int SS=((1<<n)-1)^S;
        for(int T=SS;T;T=(T-1)&SS)
            cc[T]=0;
        for(int T=SS;T;T=(T-1)&SS)
            for(int j=0;j<n;j++)
                if(S>>j&1) cc[T]+=cost[j][T];
        for(int i=0;i<n;i++)
        {
            if(S>>i&1)
            {
                for(int j=0;j<n;j++)
                {
                    if(G[i][j])
                        dp[S|(1<<j)][j]=min(dp[S|(1<<j)][j],dp[S][i]+cost[j][S]-G[i][j]);
                }
            }
            for(int T=SS;T;T=(T-1)&SS)
                dp[S|T][i]=min(dp[S|T][i],dp[S][i]+cc[T]-cost[i][T]);
        }
        //for(int j=0;j<n;j++) dbg(S,j,dp[S][j]);
    }
    cout<<dp[(1<<n)-1][n-1]<<'\n';
}

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

int a1,a2,a3;
int cnt=0;

int main()
{    
    string s;
    cin >> s;
    int a = 0;
    for(char c : s){
        if(c == '+') ++a;
        else --a;
    }
    cout << a << endl;
}

/*
Ctrl+@ でコンソールを開け、以下で実行。
g++ code.cpp
./a.out

file-prefer-snipet
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int M = 1000000007;
ll mod(ll x){
        return ((x%M + M)%M);
    }
ll add(ll a, ll b){
        return mod(mod(a)+mod(b));
    }
ll mul(ll a, ll b){
        return mod(mod(a)*mod(b));
    }
ll minu(ll a, ll b){
        return mod(mod(a)-mod(b));
    }
ll power(ll a, ll b){
    ll res=1;
    while(b>0){
        if(b&1) res=mul(res,a);
        b = b>>1;
        a=mul(a,a);
    }
    return res;
}
int main(){
    ll n;
    cin>>n;
    ll a[n];
    ll s=0;
    for(ll i=0;i<n;++i){
        cin>>a[i];
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        s=max(s,a[i]);
        ans+=s-a[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5100
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int M;
	cin >> M;
	int ans = 0;
	int sum = 0;
	REP(i, M) {
		int d, c;
		cin >> d >> c;
		ans += c;
		sum += d * c;
	}
	cout << ans - 1 +(sum-1)/9<< endl;
	return 0;
}



Measured memory_bytes: 256
//by shubham_bitsg

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector <string> vs;

//#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    n = n%10;
    if(n == 2 || n == 4 || n ==5 || n == 7 || n == 9) {
        cout<<"hon";
    }
    else if(n == 0 || n == 1 || n ==8 || n == 6) {
        cout<<"pon";
    }
    else
        cout<<"bon";
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(){

  int r[200000];
  int n, i, j, max, min;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
    scanf("%d", &r[i]);

  max = r[1] - r[0];
  min = r[0];

  for(j = 1; j < n; j++){
    if(r[j]-min > max)
      max = r[j] - min;
    if(r[j] < min)
      min = r[j];
  }


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

  return 0;
}

Measured memory_bytes: 2576
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int M;

int main()
{
	in>>M;
	out<<48-M<<std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
long long int h;
long long int qurt = 1;
long long int sum;
int main()
{
	scanf("%lld", &h);
	while(h > 0)
	{
		sum += qurt;
		h /= 2;
		qurt *= 2;
	}
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
from numba import njit
import numpy


def read():
    N = int(input().strip())
    line = input().strip()
    P = numpy.fromstring(line, dtype=numpy.int32, sep=" ")
    return N, P


@njit
def dfs(N, Q, stay, p, q):
    y, x = divmod(p, N)
    for dy, dx in ((0, 1), (1, 0), (-1, 0), (0, -1)):
        ny, nx = y + dy, x + dx
        if 0 <= ny < N and 0 <= nx < N:
            np = ny * N + nx
            if Q[np] > q:
                Q[np] = q
                dfs(N, Q, stay, np, q + stay[np])


@njit
def np_solve(N, P, INF=10**9):
    P -= 1
    Q = numpy.empty(N*N, dtype=numpy.int32)
    stay = numpy.ones(N*N, dtype=numpy.bool_)
    
    for i in range(N):
        for j in range(N):
            Q[i*N+j] = min([i, j, N-i-1, N-j-1])

    ans = 0
    for p in P:
        stay[p] = 0
        q = Q[p]
        ans += q
        dfs(N, Q, stay, p, q)
    return ans


if __name__ == '__main__':
    outputs = np_solve(*read())
    if outputs is not None:
        print("{}".format(outputs))


Measured memory_bytes: 166020
C = [[] for _ in range(3)]
for i in range(3):
    C[i] = list(map(int,input().split()))

dy1,dy2 = C[1][0]-C[0][0], C[2][0]-C[1][0]
dx1,dx2 = C[0][1]-C[0][0], C[0][2]-C[0][1]

Ans = "Yes"
for i in range(1,3):
    if C[1][i]-C[0][i] != dy1 or C[2][i]-C[1][i] != dy2:
        Ans = "No"
        break
    if C[i][1]-C[i][0] != dx1 or C[i][2]-C[i][1] != dx2:
        Ans = "No"
        break

print(Ans)


Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int n;
	int[] pow;
	String[] names;
	HashSet<String>[] sets;

	@SuppressWarnings("unchecked")
	void run(){
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			names=new String[n];
			pow=new int[n];
			sets=new HashSet[n];
			for(int j=0; j<n; j++){
				names[j]=sc.next();
				pow[j]=sc.nextInt();
				sets[j]=new HashSet<String>();
				int m=sc.nextInt();
				for(int i=0; i<m; i++){
					sets[j].add(sc.next());
				}
			}
			solve();
		}
	}

	long[] g;
	int ans;

	void solve(){
		HashMap<String, Integer> map=new HashMap<String, Integer>();
		for(int i=0; i<n; i++){
			map.put(names[i], i);
		}
		g=new long[n];
		for(int i=0; i<n; i++){
			for(String s : sets[i]){
				int j=map.get(s);
				g[i]|=1L<<j;
			}
		}
		ans=0;
		mis(1, 1, pow[0]);
		println(ans+"");
	}

	void mis(int k, long choosed, int sum){
		if(k==n){
			// TODO
			ans=max(ans, sum);
			return;
		}
		if((choosed&g[k])==0){
			mis(k+1, choosed|(1L<<k), sum+pow[k]);
			long rem=0;
			for(int i=k+1; i<n; i++)
				if((choosed&g[i])==0)
					rem|=g[i];
			if((rem>>>k&1)==0)
				return;
		}
		mis(k+1, choosed, sum);
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 13000
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string s; readV(s);
  string t; readV(t);

  auto vs = conv(s), vt = conv(t);
  if (!equal(vs, vt)) {
    writeln("No");
    return;
  }

  writeln("Yes");
}

auto conv(string s)
{
  auto c = new int[](s.length);
  int[int] h;
  foreach (i, si; s) {
    auto j = cast(int)(si-'a');
    if (j !in h) h[j] = h.length.to!int;
    c[i] = h[j];
  }
  return c;
}


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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a % b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    long long i, j, k, n, m, t, x, y, s=0, c=0, l;
    string a;
    cin >> a;
    char z=a[a.size()-1];
    if(z=='2' || z=='4' || z=='5' || z=='7' || z=='9')
        cout << "hon\n";
    else if(z=='0' || z=='1' || z=='6' || z=='8')
        cout << "pon\n";
    else
    {
        cout << "bon\n";
    }
    
}


Measured memory_bytes: 3572
n = gets.chomp.to_i
s = gets.chomp
sum = Array.new(s.length + 1, 0)

s.length.times do |i|
  if s[i] == 'E'
    sum[i + 1] = sum[i] + 1
  else
    sum[i + 1] = sum[i]
  end
end

m = s.length
s.length.times do |i|
  ci = i + 1
  l = sum[ci - 1] - sum[0]
  r = sum[-1] - sum[ci]
  total = (ci - 1 - l) + r
  if total < m
    m = total
  end
end

puts m



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

#define mp make_pair
#define s second 
#define f first
#define pb push_back


typedef long long ll;
typedef double db;


using namespace std;

const int inf=2e9+312;
const int N=2e5+4578;


int xx[4]={0, 0, 1, -1};
int yy[4]={1, -1, 0 ,0};

int a[N], b[N];

int main(){
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k;
	cin >> n >> k;
	for(int i=1; i<=n; i++){
		cin >> a[i];
	}
	b[2]=abs(a[2]-a[1]);
	for(int i=3; i<=n; i++){
		int j=2;
		b[i]=b[i-1]+abs(a[i-1]-a[i]);
		while(j<=k && i-j>0){
			b[i]=min(b[i], b[i-j]+abs(a[i-j]-a[i]));
			j++;
		}
	}
	cout << b[n];
	return 0;
}

Measured memory_bytes: 1024
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef unsigned long long ull;

const int nax = 105;
vector<int> w[nax];
int n;

ull mul(ull a, ull b) {
	if((__int128) a * b > LONG_LONG_MAX) return LONG_LONG_MAX;
	return a * b;
}

pair<int, ull> would(vector<int> start) {
	vector<bool> vis(n);
	for(int x : start) vis[x] = true;
	ull answer = start.size();
	int times = 0;
	while(!start.empty()) {
		++times;
		vector<int> nowy;
		int biii = 0;
		for(int a : start) {
			int cnt = 0;
			for(int b : w[a]) if(!vis[b]) {
				++cnt;
				nowy.push_back(b);
				vis[b] = true;
			}
			biii = max(biii, cnt);
		}
		debug() << imie(start) imie(nowy) imie(biii);
		if(biii) answer = mul(answer, biii);
		start = nowy;
	}
	debug() << imie(times) imie(answer);
	return {times, answer};
}

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n - 1; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		--a;
		--b;
		w[a].push_back(b);
		w[b].push_back(a);
	}
	//~ would({1, 2}); return 0;
	pair<int, ull> best = would({0});
	for(int i = 1; i < n; ++i) best = min(best, would({i}));
	for(int a = 0; a < n; ++a)
		for(int b : w[a]) if(a < b) best = min(best, would({a, b}));
	cout << best.first << " " << best.second << endl;
}


Measured memory_bytes: 256
from sys import stdin

n = int(stdin.readline().rstrip())
b = [int(x) for x in stdin.readline().rstrip().split()]

a = [b[0]]

for i in range(n - 1):
    if i == (n - 2):
        a.append(b[-1])
    else:
        a.append(min(b[i], b[i + 1]))

print(sum(a))

Measured memory_bytes: 3060
import java.util.Scanner;

class Main{

	static char[][] map;
	static int H;
	static int W;

	public static void main(String[] args) {



		Scanner sc = new Scanner(System.in);			//文字の入力
		int N = sc.nextInt();
		int[] data = new int [10000001];
		
		int c = 0;
		
		for(int i = 10;i <= 55555;i++){
			for(int j = 2;j <= (i+1)/2;j++){
				if(i % j == 0){
					break;
				}
				if(j == (i + 1)/2 && i % 5 == 1) {
					data[c] = i;
					c++;
					if(c == N){
						for(int k = 0;k < N;k++){
							System.out.println(data[k]);
						}
						return;

					}
				}
				
			}
		}

	}
}




class Pair implements Comparable{
	String from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}





Measured memory_bytes: 62676
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
const int INF = 1e9;
typedef pair<int, int> P;
 
int N;
int A;
set<int> S;
 
signed main()
{
    cin >> N;
    REP(i,N) {
        cin >> A;
        if (S.find(A) == S.end()) {
            S.insert(A);
        } else {
            S.erase(A);
        }
    }
 
    cout << S.size() << endl;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,x,y,kai=1;
    ll tmp[]={0,1,2,3,4,5,6,7};
    double ans=0.0;
    cin >> n;
    vector<pair<ll,ll>> xy(n);
    rep(i,n){
        cin >> x >> y;
        xy[i]=m_p(x,y);
    }
    for(int i=1;i<=n;i++) kai*=i;
    do{
        rep(i,n-1){
            ans+=sqrt(pow(xy[tmp[i]].first-xy[tmp[i+1]].first,2)+pow(xy[tmp[i]].second-xy[tmp[i+1]].second,2));
        }
    }while(next_permutation(tmp,tmp+n));
    cout << DOUBLE << ans/kai << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

using namespace std;

int map_N[1500];
int map_M[1500];
int NN[1500001];
int MM[1500001];

int main(){
    while(1){
        int N,M;
        cin >> N >> M;
        if(N+M == 0)break;
        for(int i = 0;i < N;i++)cin >> map_N[i];
        for(int i = 0;i < M;i++)cin >> map_M[i];
        int Max = 0;
        for(int i = 0;i <= 1500000;i++){
            NN[i] = 0;
            MM[i] = 0;
        }
        for(int i = 0;i < N;i++){
            int sum = 0;
            for(int j = i;j >= 0;j--){
                sum = sum + map_N[j];
                NN[sum]++;
            }
            Max = max(Max, sum);
        }
        for(int i = 0;i < M;i++){
            int sum = 0;
            for(int j = i;j >= 0;j--){
                sum = sum + map_M[j];
                MM[sum]++;
            }
            Max = max(Max, sum);
        }
        int ans = 0;
        for(int i = 0;i <= Max;i++){
            ans = ans + NN[i]*MM[i];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 12888
import numpy as np
from numba import njit, b1, i4, i8, f8
from heapq import heappop as hpp, heappush as hp

@njit((b1[:, :],i8,i8,i8,i8), cache=True)
def main(ss,ch,cw,dh,dw):
    inf = 1<<30
    h,w = ss.shape
    start = ch*w+cw
    goal = dh*w+dw
    n = h*w
    seen = np.full(n, inf, np.int64)
    seen[start] = 0
    q = [(0, start)] # ワープ回数, 現在位置, 最後の道の位置
    while q:
        pnum,pu = hpp(q)
        ux,uy = divmod(pu,w)
        if pu==goal:
            break
        for xx in range(-2, 3):
            for yy in range(-2, 3):
                if xx==yy==0:
                    continue
                if abs(xx)+abs(yy)<=1:
                    vv = 0
                else:
                    vv = 1
                x,y = ux+xx, uy+yy
                u = x*w + y
                num = pnum+vv
                if x<0 or y<0 or x>=h or y>=w or ss[x][y]:
                    continue
        #         print(x,y)
                if seen[u]>num:
                    seen[u] = num
                    hp(q,(num, u))
                
    val = seen[goal]
    if val==inf:
        return -1
    else:
        return val
      
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

h,w = map(int, input().split())
ch,cw = map(int, input().split())
dh,dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1
rows,cols = h,w

OK = "."
NG = "#"

ss = np.array([[c=="#" for c in input()] for _ in range(h)])

print(main(ss,ch,cw,dh,dw))

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

string s;
int n;
vector<int> et[100000];

signed main() {
	int i, j;
	
	cin >> s;
	n = s.length();
	
	if (s[n - 1] == '1') { cout << -1 << endl; return 0; }
	if (s[0] == '0') { cout << -1 << endl; return 0; }
	
	int l = 0, r = n - 2;
	while (l < r) {
		if (s[l] != s[r]) { cout << -1 << endl; return 0; }
		l++;
		r--;
	}
	
	vector<int> cnts;
	for (i = 0; i < n / 2; i++) {
		if (s[i] == '1') { cnts.push_back(i); }
	}
	cnts.push_back(n - 1);
	
	for (i = 1; i < cnts.size(); i++) {
		for (j = cnts[i - 1]; j < cnts[i]; j++) {
			int u = cnts[i];
			int v = j;
			cout << u + 1 << " " << v + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4220
package main

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

// input に使うやつ
var rdr = bufio.NewReaderSize(os.Stdin, 10000)

func readLine() string {
	buf := make([]byte, 0, 10000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

// string から int へ
func atoi(s string) int {
	i, _ := strconv.Atoi(s)
	return i
}

// 一つの文字を int として読み込み
func readInt() int {
	return atoi(readLine())
}

// 複数の文字を int のスライスとして読み込み
func readInts() []int {
	in := readLine()
	ins := strings.Split(in, " ")
	out := make([]int, len(ins))
	for i, v := range ins {
		out[i] = atoi(v)
	}
	return out
}

// sortしたスライスを返す
func sorted(a []int) []int {
	b := make([]int, len(a))
	copy(b, a)
	sort.Ints(b)
	return b
}

// 逆順のsort
func reverse(a []int) []int {
	b := make([]int, len(a))
	copy(b, a)
	sort.Sort(sort.Reverse(sort.IntSlice(b)))
	return b
}

func main() {
	n := readInts()
	k := n[0]
	x := n[1]

	ans := make([]int, 0)

	s := x - (k - 1)
	if s < -1000000 {
		s = -100000
	}
	for i := 0; i < k*2-1; i++ {
		ans = append(ans, s)
		s++
	}

	for i, v := range ans {
		if i == len(ans)-1 {
			fmt.Println(v)
		} else {
			fmt.Print(fmt.Sprint(v) + " ")
		}
	}

}


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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	ld D,T,S; cin >> D >> T >> S;
	ld res = D/S;
	if(res <= T){
		cout << "Yes\n";
		return 0;
	}
	cout << "No\n";
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 3760
cross_section = input()
visited = {0: -1}
height = 0
pools = []
for i, c in enumerate(cross_section):
    if c == '\\':
        height -= 1
    elif c == '/':
        height += 1
        if height in visited:
            width = i - visited[height]
            sm = 0
            while pools and pools[-1][0] > visited[height]:
                _, volume = pools.pop()
                sm += volume
            pools.append((i, sm + width - 1))
    visited[height] = i

print(sum(v for _, v in pools))
print(len(pools), *(v for _, v in pools))

Measured memory_bytes: 8824
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

const int LEFT = 0;
const int DOWN = 1;
const int RIGHT = 2;
const int UP = 3;

const array<int, 4> dx = { -1, 0, 1, 0 };
const array<int, 4> dy = { 0, 1, 0, -1 };

int main() {
  while( true ) {
	int n;
	cin >> n;
	if ( n == 0 ) break;
	vector<tuple<int, int, int>> vs( n );
	for ( int i = 0; i < n - 1; i++ ) {
	  int a1, a2;
	  cin >> a1 >> a2;
	  vs[ i ] = make_tuple( a1, a2, i + 1 );
	}
	sort( vs.begin(), vs.end() );
	
	vector<tuple<int, int>> rects( n );
	rects[ 0 ] = make_tuple( 0, 0 );
	int min_x = 10000, min_y = 10000, max_x = -10000, max_y = -10000;
	for ( auto elem : vs ) {
	  const auto r = rects[ get<0>( elem ) ];
	  const int d = get<1>( elem );
	  const int i = get<2>( elem );
	  rects[ i ] = make_tuple( get<0>( r ) + dy[ d ], get<1>( r ) + dx[ d ] );
	  min_x = min( min_x, get<1>( rects[ i ] ) );
	  max_x = max( max_x, get<1>( rects[ i ] ) + 1 );
	  min_y = min( min_y, get<0>( rects[ i ] ) );
	  max_y = max( max_y, get<0>( rects[ i ] ) + 1 );
	}
	cout << ( max_x - min_x ) << " " << ( max_y - min_y ) << endl;
  }
}

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

bool contains(std::vector<int> const& xs, int x) {
  return std::any_of(xs.begin(), xs.end(), [x](auto const& y) { return x == y; });
}

void unite(std::vector<std::vector<int>>& ss, int x, int y) {
  std::vector<int> united{};
  auto it = std::remove_if(ss.begin(), ss.end(), [&united, x, y](auto const& s) {
    bool hasxy = contains(s, x) || contains(s, y);
    if (hasxy)
      united.insert(united.end(), s.begin(), s.end());
    return hasxy;
  });
  ss.erase(it, ss.end());
  ss.push_back(std::move(united));
}

bool same(std::vector<std::vector<int>> const& ss, int x, int y) {
  return std::any_of(ss.begin(), ss.end(), [x, y](auto const& s) { return contains(s, x) && contains(s, y); });
}

int main() {
  int n, q;
  std::cin >> n >> q;

  std::vector<std::vector<int>> ss{};
  for (int i = 0; i < n; ++i) {
    ss.push_back({i});
  }

  for (int i = 0; i < q; ++i) {
    int com, x, y;
    std::cin >> com >> x >> y;
    switch (com) {
    case 0:
      unite(ss, x, y);
      break;
    case 1:
      if (same(ss, x, y)) std::cout << 1 << '\n';
      else                std::cout << 0 << '\n';
      break;
    }
  }
}



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

#define int long long

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

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

signed main(){
    int N;cin>>N;
    if(N&1)N<<=1;
    cout<<N<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll L,R,d;
    cin>>L>>R>>d;
    ll ans=0;
    Loop(i,L,R+1){
        if(i%d==0)ans++;
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 3640
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
ll res=0;
void dfs(ll n,ll x){
  //  cout<<n<<" "<<x<<endl;
    if(x==0){
        return;
    }
    if(n==1){
        res++;
    }
    else if(x==pow(2,n+1)-3){
        res+=pow(2,n)-1;
    }
    else if(x>=pow(2,n)-1){
        res+=pow(2,n-1);
        dfs(n-1,x-(pow(2,n)-1));
    }else{
        dfs(n-1,x-1);
    }
    return;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n,x;
    cin>>n>>x;
    dfs(n+1,x);
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



int main()
{
  string s1,s2,s3;
  cin>>s1>>s2>>s3;
  cout<<s1[0]<<s2[1]<<s3[2]<<endl;
  return 0;
}


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

int memo[105][10005];
int used[105][10005];
int N, W;
int v[105], w[105];

int dfs(int x, int sum){
  
  if( x == N ) return 0;
  
  if( used[x][sum] ) return memo[x][sum];
  
  used[x][sum] = 1;
  
  int res = dfs( x + 1, sum );
  
  if( sum + w[x] <= W ){
    res = max( res, dfs( x + 1, sum + w[x] ) + v[x] );
  }
  
  return memo[x][sum] = res;
}

signed main(){
  
  cin >> N >> W;
  
  for(int i=0;i<N;i++) cin >> v[i] >> w[i];
  
  cout << dfs( 0, 0 ) << endl;
  
  return 0;
}



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

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String readStr;
    int[] numPatternCount = new int[19];
    int i, j, k, l;
    int size = 9;
    int sum;
    for (i = 0; i <= size; i++) {
      for (j = 0; j <= size; j++) {
        for (k = 0; k <= size; k++) {
          if (i == 9 && j == 9 && k > 0)
            break;
          for (l = 0; l <= size; l++) {
            sum = i + j + k + l;
            if (sum > 18)
              break;
            numPatternCount[sum]++;
          }
        }
      }
    }

    while ((readStr = reader.readLine()) != null) {
      int n = Integer.parseInt(readStr);
      System.out.println(
              n > 36 ? 0
              : numPatternCount[n > 18 ? numPatternCount.length - (n - numPatternCount.length) - 2 : n]
      );
    }
  }

}

Measured memory_bytes: 16872
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
//prototype declaration

//gloval variable
double pi = 3.1415926535897932384626433;

int main(void){
    double a, b;
    double h, m;
    scanf("%lf %lf %lf %lf", &a, &b, &h, &m);
    double ans = 0;
    double arg = fabs((11*m-60*h)*pi/360);
    ans = sqrt(b*b+a*a-2*a*b*cos(arg));
    printf("%.16lf\n", ans);
    return 0;
}


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

#define int long long

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

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

string S;

const int mod=1000000007;

int dp[2][4][3];

inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}

signed main(){
    cin>>S;
    dp[0][0][0]=1;

    rep(i,S.size()){
        if(S[i]!='0'){
            add(dp[(i+1)&1][3][0],dp[i&1][3][0]);
            rep(j,3)rep(k,3){
                if(k)add(dp[(i+1)&1][j][k-1],dp[i&1][j][k]);
                else if(j<2)add(dp[(i+1)&1][j+1][k],dp[i&1][j][k]);
                else add(dp[(i+1)&1][3][0],dp[i&1][j][k]);
            }
        }

        if(S[i]!='1'){
            add(dp[(i+1)&1][3][0],dp[i&1][3][0]);
            rep(j,3)rep(k,3){
                if(k<2)add(dp[(i+1)&1][j][k+1],dp[i&1][j][k]);
                else add(dp[(i+1)&1][j][1],dp[i&1][j][k]);
            }
        }
        rep(j,4)rep(k,3)dp[i&1][j][k]=0;
    }


    int ans=0;
    add(ans,dp[S.size()&1][1][0]);
    add(ans,dp[S.size()&1][2][1]);
    add(ans,dp[S.size()&1][3][0]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 900
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long ans = 0;
    if((n > 0) && ((n % 2) == 0)) {
      long t = n / 2;
      for(int i = 1; i < 50; i++) {
        long t1 = (long)Math.pow(5, i);
        ans += (t / t1);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
from sys import setrecursionlimit

setrecursionlimit(100000)

N = int(input())

adj = [list() for _ in range(N)]

for i in range(N-1):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    adj[a].append((b,i))
    adj[b].append((a,i))


res = [None]*(N-1)

C = max(len(l) for l in adj)

def rec(v, used):
    global res
    c = 0
    for u,i in adj[v]:
        if c == used:
            c += 1
        if res[i] is None:
            res[i] = c
            rec(u, c)
            c += 1
rec(0, -1)
print(C)
for c in res:
    print(c+1)


Measured memory_bytes: 74684
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
//ios::sync_with_stdio(false);
//<< setprecision(5)
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int i,n;cin>>n;
	int ev=0,od=0;
	int ans=1;
	for(i=0;i<n;i++){
		int a;cin>>a;
		if(a%2==0){ev++;}
		else{od++;}
		ans*=3;
	}
	cout<<ans-(1<<ev)<<endl;
	return 0;
	
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    int tmp;
    int counter = 0;
    for(int i = 0; i < n; i++) {
        cin >> tmp;
        if(i % 2 == 0 && tmp % 2 == 1) counter++;
    }

    cout << counter << endl;
}

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

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

int main(){
   int h,w,k;cin >>h>>w>>k;
   vector<string>s(h);
   for (int i = 0; i < h; ++i)cin >>s[i];
   vector<vector<int>>ans(h,vector<int>(w,-1));
   int num=0;int cnt=0;
    for (int i = 0; i < h; ++i) {
        bool flg=false;
        num=cnt;
        for (int j = 0; j < w; ++j) {
            if(s[i][j]=='#')flg=true;
            if(s[i][j]=='#')cnt++;
        }
        if(flg) {
            num++;
            for (int j = 0; j < w; ++j) {
                ans[i][j]=num;
                if(s[i][j]=='#'&&num<cnt)num++;
            }
        }
        else {
            if(i!=0){
                for (int j = 0; j < w; ++j) {
                    ans[i][j]=ans[i-1][j];
                }
            }
        }
    }

    for (int i = h-1; i>=0; --i) {
        for (int j = 0; j < w; ++j) {
            if(ans[i][j]==-1)ans[i][j]=ans[i+1][j];
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cout <<ans[i][j]<<" ";
        }
         cout <<endl;
    }
}


Measured memory_bytes: 4088
using System;

class FindDvisors{
        static void Main(string[] args){
	  string[] str = Console.ReadLine().Split(' ');
	  int a = int.Parse(str[0]);
	  int b = int.Parse(str[1]);
	  int c = int.Parse(str[2]);
	  int count = 0;
	  for(int i = a;i <= b;i++){
	    if(c%i == 0) count++;
	  }
	  Console.WriteLine("{0}",count);
	}
}

Measured memory_bytes: 9160