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

public class Main {

    static int Y;
    static int X;
    static boolean CAN_PAINT = true;
    // @formatter:off
    static int[][] NEIGHBOR_GRID =
        {             {  0, -1 },
          { -1,  0 },              {  1,  0 },
                      {  0,  1 },};
    // @formatter:on
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String[] HW = sc.nextLine().split(" ");
        Y = Integer.parseInt(HW[0]);
        X = Integer.parseInt(HW[1]);

        String[][] grid = new String[Y][X];
        for (int i = 0; i < Y; i++) {
            char[] row = sc.nextLine().toCharArray();
            for (int j = 0; j < X; j++) {
                grid[i][j] = String.valueOf(row[j]);
            }
        }

        System.out.println(canPaint(grid) ? "Yes" : "No");
    }

    private static boolean canPaint(String[][] grid) {

        for (int i = 0; i < Y; i++) {
            for (int j = 0; j < X; j++) {
                String point = grid[i][j];
                if (!point.equals("#")) {
                    continue;
                }
                if (!isMatch(grid, j, i)) {
                    return false;
                }
            }
        }
        return true;
    }

    private static boolean isMatch(String[][] grid, int xi, int yi) {
        boolean isMatch = false;
        for (int[] row : NEIGHBOR_GRID) {
            int y = row[0] + yi;
            int x = row[1] + xi;

            // 枠外
            if (x < 0 || y < 0 || x >= X || y >= Y) {
                continue;
            }

            // 4方向を全探索して、1か所でも連続していれば条件に合う状態
            if (grid[y][x].equals("#")) {
                isMatch = true;
            }
        }
        return isMatch;
    }
}



Measured memory_bytes: 21844
//   PIGMEISTER™   //

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

#define ll long long
#define ld long double
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD (ll)1000000007
//#define MOD (ll)998244353
#define PI (ld)3.141592653589793238
#define MAX 100005

int main()
{
    jaldi;
    
    ll n, k;
    cin >> n >> k;
    ll a[n];
    sidha (i, 0, n) cin >> a[i];
    ll ans = 0;
    sort(a, a+n);
    sidha (i, 0, k) ans += a[i];
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 3664
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer a[] = new Integer[n];
        for (int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a, Comparator.reverseOrder());

        int Alice = 0;
        int Bob = 0;
        for (int i=0; i < n; i+=2) {
            Alice += a[i];
        }
        for (int i=1; i<n; i+=2) {
            Bob += a[i];
        }
        System.out.println(Alice-Bob);
        sc.close();
    }
}

Measured memory_bytes: 36112
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

void printVec1(std::vector<string> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

void printVec2(std::vector<Int> &vec) {
//    std::cout << "";
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        std::cout << *it << " ";
    }
    cout << '\n';
}

Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

int main() {
    IOS;
    int n;cin>>n;
    int sum=0;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        int t;
        cin>>t;t--;
        a[i]=t;
    }
    for(int i=0;i<n;i++){
        if(a[a[i]]==i)sum++;
    }
    cout<<sum/2;

    cout << endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
    int prime[1000000], i, j, n, num;
    
    for(i = 0;i < 1000000; i++)
        prime[i] = 1;
    for(i = 2;i < 1000; i++)
    {
        for(j = i * 2;j < 1000000;j += i)
            prime[j] = 0;
    }
    while(scanf("%d",&n) != EOF)
    {
        num = 0;
        for(i = 2; i <= n; i++)
            if(prime[i]) num++;
        printf("%d\n",num);
    }
    return 0;
}



Measured memory_bytes: 5624
/* ex3_2
    suuxxu */

#include <stdio.h>

int main(void){
    int n;
    
    // get inputs
    scanf("%d", &n);

    // output
    switch (n % 10){
    case 2: case 4: case 5: case 7: case 9:
        printf("hon\n");
        break;
    
    case 0: case 1: case 6: case 8:
        printf("pon\n");
        break;

    case 3:
        printf("bon\n");
        break;
    }
    return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
const ll INF = 1e10;
const ll MOD = 1e9 + 7;

int f(int x) {
    if (x%2 == 0) {
        return x/2;
    }
    else {
        return 3 * x + 1;
    }
}

int main() {
    int s; cin >> s;
    set<int> a;
    a.insert(s);
    int x = s;
    int i = 2;
    while (true) {
        int y = f(x);
        if (a.count(y)) break;
        a.insert(y);
        x = y;
        i ++;
    }

    cout << i << endl;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        m: usize,
        xs: [usize;n],
    }
    let total = xs.iter().sum::<usize>() as f32;
    let count = xs.iter().filter(|&&x| (x as f32) >= total / (4. * (m as f32))).count();
    println!("{}", if count >= m { "Yes" } else { "No" });
}

Measured memory_bytes: 2176
/*
ID: Trump
TASK: 
LANG: C++
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include <iostream>
#include <fstream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef long double lb;
//#define MARK
const ll losn=1e6+5;
const ll maxn=1e5+5;
const ll minn=1e3+5;
const ll tiny=1e2+5;
const ll inf=1e9;
const ll mod=1e9+7;
const ll hmod=4698571;

char c[maxn];
int main(){
//#ifdef MARK
//    freopen("input.in", "r", stdin);
//    freopen("ouput.out", "w", stdout);
//    freopen("input.in", "r", stdin);
//    freopen("ouput.out", "w", stdout);
//#endif
	scanf(" %s",c+1);
	ll len=strlen(c+1);
	for(ll i=1;i<=len;i++){
		cout<<c[i];
	}
	if(c[len]!='s'){
		cout<<"s"<<endl;
	}else{
		cout<<"es"<<endl;
	}
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 3684
a=list(map(int,input().split()))

ans=[0]*4
for i in range(4):
    if a[i]==1:
        ans[0]=1
    elif a[i]==9:
        ans[1]=1
    elif a[i]==7:
        ans[2]=1
    elif a[i]==4:
        ans[3]=1
if sum(ans)==4:
    print('YES')
else:
    print('NO')
     

Measured memory_bytes: 3060
N=int(input())
s=input()
l=len(s)
dp=[[0]*(N+1) for i in range(N)]
dp[0][1]=2
dp[0][0]=1
mod=10**9+7
for i in range(N-1):
    for j in range(N):
        if j==0:
            dp[i+1][j+1]+=2*dp[i][j]
            dp[i+1][j+1]%=mod
            dp[i+1][j]+=dp[i][j]
            dp[i+1][j]%=mod            
            continue
        if j!=N:
            dp[i+1][j+1]+=2*dp[i][j]
            dp[i+1][j+1]%=mod
        dp[i+1][j-1]+=dp[i][j]
        dp[i+1][j-1]%=mod  
t=pow(2,(mod-2),mod)
t=pow(t,l,mod)
print((dp[-1][l]*t)%mod)

Measured memory_bytes: 230024
<?php
 
$str = file_get_contents('php://stdin');
 
$alphabet = array_fill_keys(range('a', 'z'), 0);
foreach (str_split($str) as $c) {
    if (! ctype_alpha($c)) { continue; }
 
    $alphabet[strtolower($c)]++;
}
 
foreach ($alphabet as $char => $count) {
    printf('%s : %d%s', $char, $count, PHP_EOL);
}

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

int N;
vector<int> h;

// 高さx のときのプロック数を数える
int block ( int x ){
    int count = 0;
    for ( int i = 0; i < N-1; ++i){
        if ( h[i] - x >= 0 and h[i+1] - x < 0 ) ++count;
    }
    if ( h[N-1] - x >= 0 ) ++count;
    return count;
}



int main() {
    cin >> N;
    h.resize(N);
    for ( int i = 0; i < N; ++i){
        cin >> h[i];
    }
    
    int res = 0;
    for ( int x = 1; x <= 100; ++x){
        res = res + block(x);
        //cout << "x " << x << " res " << res << endl;
    }
    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

const int N=1e5+5;

ll dp[N],n,m,tree[6*N];

vector<pll> v[N];

 
ll query(int left,int right,int l,int r,int i)
{
	if(left>=l&&right<=r)
	return tree[i];
	int mid=(left+right)/2;
	if(r<=mid)
	return query(left,mid,l,r,2*i);
	if(l>mid)
	return query(mid+1,right,l,r,2*i+1);
	ll t2=query(mid+1,right,mid+1,r,2*i+1);
	ll t1=query(left,mid,l,mid,2*i);
	
	return min(t1,t2);
}
 
 
void update(int left,int right,int pos,int d,int i)
{
	if(left==right)
	{
		tree[i]=dp[pos];
	 	return;
	}
	
	int mid=(left+right)/2;
	if(pos<=mid)
	update(left,mid,pos,d,2*i);
	else
	update(mid+1,right,pos,d,2*i+1);
	tree[i]=min(tree[2*i],tree[2*i+1]);
	
}

int main()
{ios_base::sync_with_stdio(false);
cin>>n>>m;
rep(i,1,n)dp[i]=1e17+7;
rep(i,1,6*N-1)tree[i]=1e17+7;
while(m--)
{
	int l,r,c;
	cin>>l>>r>>c;
	v[r].pb(mp(l,c));
}

dp[1]=0;
update(1,n,1,0,1);

rep(i,2,n)
{
	tr(v[i],it)
	{
		int lo=it->ff;
		ll cst=it->ss;
		dp[i]=min(dp[i],query(1,n,lo,i-1,1)+cst);
	}
	update(1,n,i,0,1);
}
if(dp[n]>1e16)
{
	ol("-1");
}
else
{
	ol(dp[n]);
}
return 0;
}



Measured memory_bytes: 11136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int[] ia = readNums();
		int a = ia[0];
		int b = ia[1];
		int k = ia[2];
		int d = k;
		int e = k;
		for (int i = a; i <= b; i++) {
			if (d > 0) {
				pln(i);
				d--;
			} else {
				if (i < b - k + 1) {
					i = b - k + 1;
				}
				pln(i);
			}
		}
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 21332
import math
n = int(input())
sum_ij = 1000000000000
sq_n = int(math.sqrt(n))
for i in range(1, sq_n+1):
  if (n%i==0):
    j = int(n/i)
    if(i+j < sum_ij):
      sum_ij = i+j-2
print(int(sum_ij))

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

	ll H, W;
	cin >> H >> W;
	ll c[10][10];
	for(ll i = 0; i < 10; i++){
		for(ll j = 0; j < 10; j++){
			cin >> c[i][j];
		}
	}
	for(ll i = 0; i < 10; i++){
		for(ll j = 0; j < 10; j++){
			for(ll k = 0; k < 10; k++){
				c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
			}
		}
	}
	ll ans = 0;
	for(ll i = 0; i < H; i++){
		for(ll j = 0; j < W; j++){
			ll tmp = 0;
			cin >> tmp;
			if(tmp < 0)continue;
			ans += c[tmp][1];
		}
	}	
	cout << ans << endl;

	return 0;
}


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

using namespace std;


int main(void) {
    int N,M;
    long long ans=0;

    cin>>N>>M;

    if(N >=2){
        ans=ans+(N*(N-1))/2;
    }

    if(M>=2){
        ans = ans+(M*(M-1))/2;
    }

    cout<<ans<<endl;

 

    return 0;
}

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

void fnInput(vector<string>& rvsBoard)
{
  int nHigh, nWide;
  cin >> nHigh >> nWide;

  rvsBoard.resize(nHigh);
  for (int ny = 0; ny < nHigh; ny++)
    cin >> rvsBoard[ny];
}

int fnCountBomb(int ny, int nx, const vector<string>& cnrvsBoad)
{
  if (   ny >= 0  && ny < cnrvsBoad.size()
      && nx >= 0  && nx < cnrvsBoad[ny].size())
    if (cnrvsBoad[ny][nx] == '#')  return 1;
    else;

  return 0;
}

void fnMinesweeper(vector<string>& rvsBoard)
{
  const vector<int> cnvnDy = {-1, -1, -1,  0,  0,  1,  1,  1};
  const vector<int> cnvnDx = {-1,  0,  1, -1,  1, -1,  0,  1};
  for (int ny = 0; ny < rvsBoard.size(); ny++)
  {
    for (int nx = 0; nx < rvsBoard[ny].size(); nx++)
    {
      if (rvsBoard[ny][nx] == '.')
      {
        int nCount = 0;
        for (int i = 0; i < cnvnDx.size(); i++)
          nCount += fnCountBomb(ny + cnvnDy[i], nx + cnvnDx[i], rvsBoard);

        rvsBoard[ny][nx] = '0' + nCount;
      }
    }
  }
}

void fnResult(const vector<string>& cnrvsBoard)
{
  for (string sBoard : cnrvsBoard)
    cout << sBoard << endl;
}

int main()
{
  vector<string> vsBoard;

  fnInput(vsBoard);
  fnMinesweeper(vsBoard);
  fnResult(vsBoard);

  return 0;
}

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

int main(){
int a,b,c;
cin>>a>>b>>c;
int d[10];

d[a]++;
d[b]++;
d[c]++;
if(d[5]==2&&d[7]==1)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    if (n % 2 == 0){
        cout << n/2-1;
    }
    else{
        cout << n/2;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val Array(w, h, n) = sc.nextLine.split(" ").map(_.toInt)
    val black = List.fill(n)(sc.nextLine.split(" ").map(_.toInt))

    val xZeros = black.filter(_ (2) == 1)
    val xOnes = black.filter(_ (2) == 2)
    val yZeros = black.filter(_ (2) == 3)
    val yOnes = black.filter(_ (2) == 4)

    val xZero = if (xZeros.isEmpty) 0 else xZeros.map(_ (0)).max
    val xOne = if (xOnes.isEmpty) w else xOnes.map(_ (0)).min
    val yZero = if (yZeros.isEmpty) 0 else yZeros.map(_ (1)).max
    val yOne = if (yOnes.isEmpty) h else yOnes.map(_ (1)).min

    val xLength = if (xOne >= xZero) xOne - xZero else 0
    val yLength = if (yOne >= yZero) yOne - yZero else 0

    println(xLength * yLength)
  }
}


Measured memory_bytes: 25552
n = int(input())
ans_a = 0
ans_b = 0
ans_c = 0
for b in range(1, 3501):
    for c in range(1, 3501):
        sita = 4 * b * c - (n * (b + c))
        if sita <= 0:
            continue
        ue = n * b * c
        if ue % sita == 0:
            ans_a, ans_b, ans_c = ue // sita, b, c
            break
print(ans_a, ans_b, ans_c)

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

#define ll long long
int check_palindrome(string s)
{
    int j = 0;
    int l = s.size();
    for(int i=0; i<=l/2; i++)
    {
        if(s[i]!=s[l-i-1])
        {
            j=1;
        }
    }
    return j;
}

int main()
{
    int a,b;
    scanf("%d %d", &a, &b);
    int cnt = 0;
    for(int i = a; i <= b; i++)
    {
        string s = to_string(i);
        if(!check_palindrome(s))
            cnt++;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3744
from random import randrange
from heapq import heapify, heappush, heappop
from time import time
K = 60
rand = lambda: randrange(1 << K)
sTime = time()
N = int(input())
S, IS, C = [], [], []
for _ in range(N):
    s, c = input().split()
    S.append(s)
    IS.append(s[::-1])
    C.append(int(c))

D = {}
done = set()
r = rand()
D[r] = (0, "", 0)
H = [r]
ans = 1 << K
while H:
    r = heappop(H)
    if r in done: continue
    done.add(r)
    if time() - sTime > 1.7:
        break
    d, s, c = D[r]
    if d == 0:
        for ss, cc in zip(S, C):
            m = min(len(s), len(ss))
            if s[:m] == ss[:m]:
                if abs(len(s) - len(ss)) <= 1 or len(ss) > len(s) and ss[m:] == ss[m:][::-1]:
                    ans = min(ans, c + cc)
                else:
                    if len(s) < len(ss):
                        r = rand() + (c + cc << K)
                        D[r] = (1, ss[m:], c + cc)
                        heappush(H, r)
                    else:
                        r = rand() + (c + cc << K)
                        D[r] = (0, s[m:], c + cc)
                        heappush(H, r)
    else:
        for ss, cc in zip(IS, C):
            m = min(len(s), len(ss))
            if s[:m] == ss[:m]:
                if abs(len(s) - len(ss)) <= 1 or len(ss) > len(s) and ss[m:] == ss[m:][::-1]:
                    ans = min(ans, c + cc)
                else:
                    if len(s) < len(ss):
                        r = rand() + (c + cc << K)
                        D[r] = (0, ss[m:], c + cc)
                        heappush(H, r)
                    else:
                        r = rand() + (c + cc << K)
                        D[r] = (1, s[m:], c + cc)
                        heappush(H, r)

print(ans if ans < 1 << K - 2 else -1)


Measured memory_bytes: 258068
#include<bits/stdc++.h>
//*************** Constraints are always Imaginary,I'm real **************
using namespace std;
#define int long long 
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define fi first
#define se second
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<PII> VPII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
int32_t main()
{
          ios_base::sync_with_stdio(false);
          cin.tie(NULL);
          // #ifndef ONLINE_JUDGE
          // freopen("input.txt","r",stdin);
          // freopen("output.txt","w",stdout);
          // #endif
          int n;
          cin>>n;
          VI pal(n+1);
          for(int i=1;i<=n;i++)
                    cin>>pal[i];
          int mini=INT_MAX,curr,ans=0;
          for(int i=1;i<=n;i++)
          {
                    curr=pal[i];
                    mini=min(mini,curr);
                    if(mini>=curr)
                              ans++;
          }
          cout<<ans;
          return 0;
}

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

typedef long long ll;

using namespace std;

int main(){
  int A,B,Q;
  cin>>A>>B>>Q;
  
  vector<ll> S(A);
  vector<ll> T(B);
  for(int i=0;i<A;i++){ ll s; cin>>s; S[i] = s; }
  for(int i=0;i<B;i++){ ll t; cin>>t; T[i] = t; }
  for(int i=0;i<Q;i++){
    ll q; cin>>q;
    auto sq = lower_bound(S.begin(), S.end(), q);
    auto tq = lower_bound(T.begin(), T.end(), q);
    vector<ll> U, V;
    for(int j=-1;j<=1;j++){
      if(sq+j<S.begin()){ U.push_back(*sq); }
      else if(sq+j>=S.end()){ U.push_back(*sq); }
      else { U.push_back(*(sq+j)); }
      if(tq+j<T.begin()){ V.push_back(*tq); }
      else if(tq+j>=T.end()){ V.push_back(*tq); }
      else { V.push_back(*(tq+j)); }
    }
    ll ans=3e10;
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        ans = min(ans, abs(U[j]-q)+abs(V[k]-U[j]));
        ans = min(ans, abs(V[k]-q)+abs(U[j]-V[k]));
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<vector>
using namespace std;
int Q;
int A;
int t[1000005];
int ans[105];

void solve(int y){
  int cnt=0;
  while(A>=10){
    if(t[A]==y||ans[t[A]]==-1){
      ans[y]=-1;      break;    }
    t[A]=y;
    int x=-1;
    for(int i=10;i<A;i*=10){
      int a=A/i,b=A%i;
      x=max(x,a*b);
    }
    A=x;
    cnt++;
  }
  ans[y]=cnt;
}

int main(){
  cin>>Q;
  for(int i=1;i<=Q;i++){
    cin>>A;
    solve(i);
  }
  for(int i=1;i<=Q;i++)cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 2968
R, G, B, N = [int(c) for c in input().split()]

n=0
for r in range(N//R+1):
    N2 = N-R*r
    if N2==0:
        n+=1
        continue
    
    for g in range(N2//G+1):
        if (N2-G*g)%B==0:
            n+=1

print(n)
    


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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

int main() {
    lld N;
    long double D;
    cin >> N >> D;
    lld ans = 0;
    for (int i = 0; i < N; i++) {
        long double x,y;
        cin >> x >> y;
        if(sqrt(x*x+y*y) <= D){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=2e3+5;
const ll oo=1e18+5;
const ll mod=1e9+7;

int n;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	int k=n/2;
	vector<ll> a(n);
	for(ll& x:a) cin>>x;
	ll ans;
	if(n%2==0){
		vector<vector<ll>> dp(k+1,vector<ll>(2));
		for(int i=0;i<k+1;++i){
			for(int j=0;j<2;++j){
				dp[i][j]=0;
			}
		}
		for(int i=0;i<k;++i){
			dp[i+1][1]=max(dp[i][1]+a[i*2+1],dp[i][0]+a[2*i+1]);
			dp[i+1][0]=dp[i][0]+a[2*i];
		}
		ans=max(dp[k][1],dp[k][0]);
		return cout<<ans,0;
	}
	vector<vector<ll>> dp(k+1,vector<ll>(3));
	for(int i=0;i<k+1;++i){
		for(int j=0;j<3;++j){
			dp[i][j]=0;
		}
	}
	for(int i=0;i<k;++i){
		dp[i+1][2]=max(max(dp[i][1]+a[2*i+2],dp[i][0]+a[2*i+2]),dp[i][2]+a[2*i+2]);
        dp[i+1][1]=max(dp[i][1]+a[2*i+1],dp[i][0]+a[2*i+1]);
        dp[i+1][0]=dp[i][0]+a[2*i];
	}
	ans=max(max(dp[k][0],dp[k][1]),dp[k][2]);
	cout<<ans;
	return 0;
}


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

#define ll long long int

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

    ll dp[n+1][n+1];
    for(int i=0; i<=n; i++) dp[i][0] = 0;
    for(int l=1; l<=n; l++)
        for(int i=0; i+l<=n; i++)
            dp[i][l] = max(a[i] - dp[i+1][l-1], a[i+l-1] - dp[i][l-1]);
    cout<< dp[0][n] <<endl;
    return 0;
}

Measured memory_bytes: 70400
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		System.out.println(N >= 10 ? K : K+(100*(10-N)));
	}
}

Measured memory_bytes: 21972
#include <stdio.h>

using namespace std;

void outPut(int Array[],char mark){
	for(int i = 1; i <= 13; i++){
		if(Array[i] == 0) printf("%c %d\n",mark,i);
	}
}

int main(){
	char mark[2];
	int n,S[14],H[14],C[14],D[14],tmp;
	for(int i = 0; i < 14; i++) S[i] = H[i] = C[i] = D[i] = 0;
	scanf("%d",&n);

	for(int i = 0; i < n; i++){
		scanf("%s %d",mark,&tmp);
		switch(mark[0]){
		case 'S':
			S[tmp] = 1;
			break;
		case 'H':
			H[tmp] = 1;
			break;
		case 'C':
			C[tmp] = 1;
			break;
		case 'D':
			D[tmp] = 1;
			break;
		}
	}
	outPut(S,'S');
	outPut(H,'H');
	outPut(C,'C');
	outPut(D,'D');
}



Measured memory_bytes: 2720
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
buf = 0

for i in range(N) :
    buf += B[A[i]-1]

for i in range(N-1) :
    if A[i+1] - A[i] == 1 :
        buf += C[A[i]-1]

print(buf) 

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    var (a, b, c, d) = readLine()!!.map { it.toString().toInt() }
    for (op1 in arrayOf(-1, 1)) {
        for (op2 in arrayOf(-1, 1)) {
            for (op3 in arrayOf(-1, 1)) {
                if (a + op1 * b + op2 * c + op3 * d == 7) {
                    println("$a${if (op1 == 1) "+" else "-"}$b${if (op2 == 1) "+" else "-"}$c${if (op3 == 1) "+" else "-"}$d=7")
                    return
                }
            }
        }
    }
}

Measured memory_bytes: 33704
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)(j);i <= (int)(k);i ++)
#define debug(x) cerr<<#x<<":"<<(x)<<endl
#define fix cout<<fixed<<setprecision(20);
const int maxn=(int)1e6+5;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    if(n==2){cout<<1<<endl;return 0;}
    ll ans=0;
    for(ll  i=1;i*i<n;i++){
        if((n-1)%i==0){ans+=2;if((n-1)/i==i)ans--;}
    }
    ans--;
    debug(ans);
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            ll x=n;while(x%i==0)x/=i;
            if((x-1)%i==0)ans++;
            ll ii=i;i=n/i;if(ii==i)continue;
             x=n;while(x%i==0)x/=i;
            if((x-1)%i==0)ans++;
            i=ii;
        }
    }
    ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long answer = 0;

		for (long i = 1; i < (long) Math.sqrt(N) + 1; i++) {
			if (N % i == 0) {
				long m1 = i - 1;
				//System.out.println("m1:"+m1);
				if (m1 != 0) {
					if (N / m1 == N % m1) {
						answer += m1;
					}
				}
				if (i != N / i) {
					long m2 = N / i - 1;
					//System.out.println("m2:"+m2);
					if (N / m2 == N % m2) {
						answer += m2;
					}
				}
			}
		}
		sc.close();
		System.out.println(answer);
	}
}

Measured memory_bytes: 24916
N,M=map(int,input().split())
X=list(map(int,input().split()))
X.sort()
a=[0 for i in range(M-1)]
for i in range(M-1):
    a[i]=X[i+1]-X[i]
a.sort(reverse=True)
a=a[N-1:]
print(sum(a))



Measured memory_bytes: 14088
#include <stdio.h>

int main (){
	int n,AC=0,TLE=0,WA=0,RE=0;
	char s[n+1];
	
	scanf ("%d",&n);
	for (int i=0; i<n; i++){
		scanf ("%s",&s);
	
	if (s[0]=='A'){
		AC++;
		
	}
	else if (s[0]=='W'){
		WA++;
	}
	else if (s[0]=='T'){
		TLE++;
	}
	else {
		RE++;
	}
	}
	printf ("AC x %d\n",AC);
	printf ("WA x %d\n",WA);
	printf ("TLE x %d\n",TLE);
	printf ("RE x %d\n",RE);
	return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
using P = pair<int, pii>;
vector<P> ps, es;
int par[100010];

int root(int x) {
  return par[x] == x ? x : par[x] = root(par[x]);
}
void merge(int x, int y) {
  x = root(x); y = root(y);
  if (x == y) return;
  par[y] = x;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    ps.emplace_back(i, pii(x, y));
  }
  sort(ps.begin(), ps.end(), [&](P a, P b) {
    return a.second.first < b.second.first;
  });
  for (int i = 0; i < N-1; i++) {
    es.emplace_back(ps[i+1].second.first - ps[i].second.first, pii(ps[i].first, ps[i+1].first));
  }
  sort(ps.begin(), ps.end(), [&](P a, P b) {
    return a.second.second < b.second.second;
  });
  for (int i = 0; i < N-1; i++) {
    es.emplace_back(ps[i+1].second.second - ps[i].second.second, pii(ps[i].first, ps[i+1].first));
  }
  sort(es.begin(), es.end());
  iota(par, par+N, 0);
  ll ans = 0;
  for (P e : es) {
    if (root(e.second.first) == root(e.second.second)) continue;
    merge(e.second.first, e.second.second);
    ans += e.first;
  }
  cout << ans << endl;

  return 0;
}

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

int main(){
  string S;
  cin >> S;
  int max=0;
  int count=0;
  for (int i=0;i<S.length();i++){
    if (S[i]=='A' || S[i]=='T' || S[i]=='G' || S[i]=='C'){
      count++;
    }else {
      count = 0;
    }
    if (max<count) max=count;
  }
  cout << max;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double


int32_t main()
{
	IOS
	int n;cin>>n;
	vector<float>A(n+5);
	for(int i=1;i<=n;i++)cin>>A[i];
	vector<float>dp(n+5);
	//dp[i] probability of making i heads
	
	//base case using zero coins
	dp[0]=1;
	
	for(int i=1;i<=n;i++)
	{
		vector<float>dp2(n+5);
		for(int j=0;j<=n;j++)
		{
			dp2[j]+=dp[j]*(1-A[i]);
			dp2[j+1]+=dp[j]*A[i];
		}
		dp=dp2;
	}
	
	float ans=0;
	for(int i=0;i<=n;i++)
	{
		if( i > n-i )ans+=dp[i];
	}
	cout << fixed << setprecision(20) << ans <<endl;
	
	
				
		
}
			
	
	
	
	
	

	

	

	
		


Measured memory_bytes: 384
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#define PI 3.1415926535897932384626433
using namespace std;
int main(){
    int a[4],b[4];
    while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
        int hit=0,blow=0;
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(i==j&&b[i]==a[j])hit++;
                else if(b[i]==a[j])blow++;
            }
        }
        cout<<hit<<' '<<blow<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
<?php
  $n = trim(fgets(STDIN)) ;
$a = explode(' ',trim(fgets(STDIN))) ;
$b = explode(' ',trim(fgets(STDIN))) ;
$c = explode(' ',trim(fgets(STDIN))) ;
$sum=array_sum($b);
for($i=0;$i<$n;$i++){
  if(isset($a[$i+1])&&$a[$i]+1==$a[$i+1]){
  $sum+=$c[$a[$i]-1] ;
  }
}
echo $sum ;

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x;
    int y;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};
struct S
{
    //double a;
    int x;
    long long y;
};
vector<int> v[2300010];

int a,b,c,i,k,d,n,m,e;
//int dy[15]={0,0,-1,1},dx[15]={-1,1};
int dy[15]={-1,1,-1,1},dx[15]={-1,1,1,-1};
int l[100050];
int o[102020];
int dz[10]={0,0,0,0,1,-1};

long long x,y,z,mod=1000000007;
P u[100310];
long long j[40];
queue<int> q;
queue<int> q1;
stack<int> s,s1;

//deque<int> de;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,long long > p;
//string r,r1;
char r[100100];
//char r1[1000222];
bool as(P a,P b)
{
    return a.x<b.x;
}


long long f(long long x)
{
    if(x<10) return x;
    else return x%10+f(x/10);
}

int main()
{
    scanf("%lld",&x);
    z=f(x);
    for(long long t=10;t<=x;t*=10)
    //if(x%t)
    {
        long long y=x/(t);
        if(y%10)
        {
            y*=(t);
        y-=(t);
        y+=(t-1);
        z=max(z,f(y));
        }
        
    }
printf("%lld",z);

}


Measured memory_bytes: 54144
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int i,j;
  char c;
  string s,t;
  cin >> s >> t;
  for (i=0;i<s.size();i++){
    for (j=0;j<s.size();j++) if (s.at((i+j)%s.size())!=t.at(j)) break;
    if (j==s.size()) break;
  }
  if (i==s.size()) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int vx = x2 - x1;
  int vy = y2 - y1;

  cout << x2 - vy << " " << y2 + vx << " ";
  cout << x1 - vy << " " << y1 + vx;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

using ll = long long;

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

    ll x,k,d;cin>>x>>k>>d;

    ll ans=0;

    if(abs(x)/d>=k)
    {
        ans=abs(x)%d+(abs(x)/d-k)*d;
    }
    else 
    {
        if((k-abs(x)/d)%2==0)
            ans=abs(x)%d;
        else
            ans=abs(d-abs(x)%d);
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3648
class nCrMod():
    def __init__(self, mod):
        self.mod = mod
        self.fac = [1, 1]
        self.finv = [1, 1]
        self.inv = [0, 1]

    def prep(self, n):
        mod = self.mod
        f, fi = self.fac[-1], self.finv[-1]
        for i in range(len(self.fac), n + 1):
            fn = f * i % mod
            v = -self.inv[mod % i] * (mod // i) % mod
            fin = fi * v % mod
            f, fi = fn, fin
            self.fac.append(f)
            self.finv.append(fi)
            self.inv.append(v)

    def __call__(self, n, r):
        if len(self.fac) <= n:
            self.prep(n)
        return self.fac[n] * self.finv[r] * self.finv[n - r] % self.mod

def main():
    N = int(input())
    A = list(map(int, input().split()))
    d = {}
    f, s = 0, 0
    for i, a in enumerate(A):
        if a in d:
            break
        d[a] = i
    f, s = d[a], i
    mod = 10**9 + 7
    nCr = nCrMod(mod)
    for i in range(1, N + 2):
        if i > N + 1 - (s - f):
            print(nCr(N + 1, i))
        else:
            print((nCr(N + 1, i) - nCr(N - (s - f), i - 1)) % mod)
main()


Measured memory_bytes: 31068
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    string S;
    cin >> N >> S;
    
    int x = 0;
    int ans = 0;
    rep(i, N) {
        if (S[i] == 'I') ++x;
        if (S[i] == 'D') --x;
        ans = max(ans, x);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter

def main():
    N = int(input())
    V = list(map(int, input().split()))
    V1 = []
    V2 = []
    for i in range(0,len(V),2):
        V1.append(V[i])
    for i in range(1,len(V),2):
        V2.append(V[i])  
    VC1 = Counter(V1)
    VC2 = Counter(V2)
    count = 0

    VC1mosc = VC1.most_common()[0][0]
    VC1mosv = VC1.most_common()[0][1]
    VC2mosc = VC2.most_common()[0][0]
    VC2mosv = VC2.most_common()[0][1]

    count += len(V1) - VC1mosv
    count += len(V2) - VC2mosv

    if VC1mosc  == VC2mosc and len(VC1)==1:
        count += VC1mosv
    elif  VC1mosc  == VC2mosc:
        vc1sa = VC1mosv - VC1.most_common()[1][1]
        vc2sa = VC2mosv - VC2.most_common()[1][1]
        count += min([vc1sa,vc2sa])


    print(count)




if __name__ == '__main__':
    main()


Measured memory_bytes: 19040
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
static const int MOD = 1000000007;

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

    vector<int> C(61, 0);
    ll out = 0;
    for (int i = n - 2; i >= 0; i--) {
        int j = 0;
        for (ll a = A[i + 1]; a > 0; a /= 2) {
            C[j] += a % 2;
            j++;
        }

        int cmax = n - 1 - i;
        ll a = A[i];
        ll t = 1;
        for (int j = 0; j < 61; j++) {
            int d = a % 2 == 0 ? C[j] : (cmax - C[j]);
            out += (t * d) % MOD; out %= MOD;
            t *= 2; t %= MOD;
            a /= 2;
        }

    }

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#pragma region atcoder
/*#include <atcoder/all>
using namespace atcoder;
//These are for segment tree
/*int op(int a, int b){return max(a, b);}
int e(){return -1;}
int target;
bool f(int v){ return v < target;}
*/
#pragma endregion
#pragma region macros
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n - 1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
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; }
#pragma endregion
#pragma region debug for var, v, vv
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){cout << endl;int cnt = 0;for(const auto& v : vv){cout << cnt << "th : "; view(v); cnt++;} cout << endl;}
#pragma endregion
const ll mod = 1000000007;
const int inf = 1001001001;
const ll INF = 1001001001001001001;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MAX = 510000;

ll fact[MAX], finv[MAX], inv[MAX];

void pre_cal(){
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fact[i] = fact[i-1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod; 
    }
}

ll nCk(ll n, ll k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fact[n] * finv[k] % mod * finv[n - k] % mod;
}
/**
 * don't forget pre-calculation 
 * in main fuction !!!
 **/

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll n; cin >> n;
	pre_cal();
	if(n == 1 || n == 2) cout << 0 << endl;
	else{
		ll cnt = 0;
		ll ans = 0;
		while(n - 3 >= 0){
			n -= 3;
			ans += nCk(n + cnt, cnt);
			
			cnt++;
			ans %= mod;
		}
		cout << ans << endl;
	}
} 


Measured memory_bytes: 15636
#include <stdio.h>

int minimum_number(int a[], int M) {
	int min=a[0];
	int i=0;
	do {
        if(min >= a[i]) {
		    min = a[i];
		  
		}
		i++;
		
	}while(i<M);
	
	return(min);
}

int main(void) {
  int N;
  long int X, X2;
	int m[100]={0};
	scanf("%d", &N);
    scanf("%ld", &X);
	X2=X;
	int i=0;
	do {
		scanf("%d", &m[i]);	
		i++;
	}while(i!=N);
	i=0;
	int count=0;
	do {
	   X2 -= m[i];
		count++;
		i++;

	}while (i!=N);
	int diff = minimum_number(m, N);
	
	do {
		if(X2 >0&& X2>=diff) {count++;
		X2 -=diff;
		}
		else break;
	} while(X2>=0);
	printf("%d", count);
    return(0);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int H,W;
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			H=scan.nextInt();
			W=scan.nextInt();
			if(H == 0 && W== 0) {
				break;
			}
			for(int i = 0;i < H; i++) {

					for(int j=0;j<W-1&&(i==0||i+1==H)||j==0;j++) {
						System.out.printf("#");
					}
					for(int k=0;k<W-2&&i!=0&&i+1!=H;k++) {
						System.out.printf(".");
					}
					System.out.printf("#\n");

				}
				System.out.println("");
			}

	}
}

Measured memory_bytes: 57980
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n;
   cin>>n;
   map<string,long long int> str;
   string st;
   for(int i=0;i<n;i++){
       cin>>st;
       sort(st.begin(),st.end());
       if(!str.count(st)){
        str[st] = 1;
       }
       else{
        str[st]++;
       }
   }
   long long int sum = 0;
   for(auto const& x:str){
        //cout<<x.first<<endl;
    if(x.second>1){
        sum+=(x.second*(x.second-1))/2;
    }
   }
   cout<<sum<<endl;
   return 0;
}


Measured memory_bytes: 11136
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

mPrime = 10^9 + 7

lim = 2 * 10^5

solve :: Int -> [Int] -> Int
solve n cs = runST $ do
    vec <- VUM.replicate (lim+1) 0
    sub vec 1 (uniq cs)

    where
    sub vec xCur [] = return xCur
    sub vec xCur (c:cs) = do
      x <- VUM.read vec c
      let newX = x `mAdd` xCur
      VUM.write vec c newX
      sub vec newX cs


  
uniq [] = []
uniq [x] = [x]
uniq (y:x:xs) | y == x    = uniq (x:xs)
              | otherwise = y : (uniq (x:xs))

-- mAdd x y = (x + y) `mod` mPrime
mAdd :: Int -> Int -> Int
mAdd x y = let w = x + y in if w < mPrime then w else w - mPrime

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n]:remLines1 = remLines0
      n = readBInt bs_n
      cs = map (\[x] -> readBInt x) remLines1
  in solve n cs

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


-------------------------------------------------------------------------------

inp1 = "5\n1\n2\n1\n2\n2\n"
inp2 = "6\n4\n2\n5\n4\n2\n4\n"
inp3 = "7\n1\n3\n1\n2\n3\n3\n2\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
test1 = tv1 == 3
test2 = tv2 == 5
test3 = tv3 == 5
alltest = test1 && test2 && test3



Measured memory_bytes: 4348
from itertools import product

N = input()
l1 = ['3','5','7']

P = []
for i in range(len(N)):
  P += list(product(l1, repeat=i+1))

N = int(N)
ans = 0
for p in P:
  if ('7' not in p) or ('5' not in p) or ('3' not in p):
    continue
  else:
    p = int(''.join(p))
    ans += (p <= N)

print(ans)

Measured memory_bytes: 7028
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const int N=200010;
int d1[N],d2[N],n;
int main()
{
    IO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            int x,y;
            cin>>x>>y;
            d1[i]=x+y;
            d2[i]=x-y;
        }
        sort(d1+1,d1+1+n);
        sort(d2+1,d2+1+n);
        cout<<max(d1[n]-d1[1],d2[n]-d2[1])<<'\n';
        
    }
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<int> P(N); REP(i, N) cin >> P[i];
  int max_n = pow(10, 9);
  int ans = 0;
  REP(i, N) {
      if(max_n > P[i]) {
          ans++;
          max_n = P[i];
      }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4008
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<iomanip>
using namespace std;
int main(){
	char s[25],ans[25] = {'\0'};
	int len = 0;
	cin >> s;
	for(int i = 0;s[i] != '\0';i++){
		if(s[i] == '1'){
			ans[len] = '1';
			ans[len+1] = '\0';
			len++;
		}
		if(s[i] == '0'){
			ans[len] = '0';
			ans[len+1] = '\0';
			len++;
		}
		if(s[i] == 'B' && len != 0){
			ans[len-1] = '\0';
			len--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

string s;
string t;
vector<int> p[26], q[26];

int main() {
	int i;
	
	cin >> s >> t;
	rep(i, s.length()) p[s[i] - 'a'].push_back(i);
	rep(i, t.length()) q[t[i] - 'a'].push_back(i);
	sort(p, p + 26);
	sort(q, q + 26);
	rep(i, 26) {
		if (p[i] != q[i]) { cout << "No" << endl; return 0; }
	}
	cout << "Yes" << endl;
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

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

  // 200 ^ 5 は 32 * 10^10 なので、これくらいまで見ておけば良さそう。
  // A ^ 5 - B ^ 5 = X となる (A, B) が与えられることはないので、考えなくて良い。
  
  // A ^ 5 / B ^ 5 は 2^31 以上になる可能性があるので、long long
  for (long long A = -200; A <= 200; ++A) {
    for (long long B = -200; B <= 200; ++B) {
      if (A * A * A * A * A - B * B * B * B * B == X) {
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3672
n , k = map(int, input().split())
x=[]
j=0
c=0
for i in range(n):
    a , b = map(int, input().split())
    x.append([a,b])
x.sort(key = lambda x :x[0])
while True:
    c+=x[j][1]
    if c>=k:
        print(x[j][0])
        break
    j+=1


Measured memory_bytes: 21248