akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

N = input_int()
a_list = LII_split()

ans = 0
# pre_idx = 0  # 前の数字のindex
current_idx = 0
continuous_cnt = 0

for i in range(1, N + 2):

    while current_idx < N:
        if a_list[current_idx] == i:
            continuous_cnt += 1
            break
        else:
            current_idx += 1
    if i == 1 and continuous_cnt == 0:
        break

print(N - continuous_cnt if continuous_cnt > 0 else -1)

Measured memory_bytes: 26140
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力
		int n = sc.nextInt();

		boolean allClose = true;
		Kakko[] list = new Kakko[n];
		int leftPos = -1;
		int rightPos = n;
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			while (s.contains("()")) {
				s = s.replace("()", "");
			}
			if (!s.equals("")) {
				allClose = false;
				Kakko k = new Kakko(i, s);
				if (k.putLeft()) {
					leftPos++;
					list[leftPos] = k;
				} else {
					rightPos--;
					list[rightPos] = k;
				}
			}
		}
		boolean correct = true;
		int leftRemainder = 0;
		int rightRemainder = 0;
		if (!allClose) {
			//ソート
			if (leftPos >= 0) {
				Arrays.sort(list, 0, leftPos, new KakkoComp());
			}
			if (rightPos <= list.length - 1) {
				Arrays.sort(list, rightPos, list.length - 1, new KakkoComp());
			}
			//カウント
			for (int i = 0; i <= leftPos; i++) {
				if (leftRemainder < list[i].getRightCloseCount())  {
					correct = false;
					break;
				}
				leftRemainder += list[i].getLeftCloseCount() - list[i].getRightCloseCount();
			}
			if (correct) {
				for (int i = rightPos; i < n; i++) {
					if (rightRemainder < list[i].getLeftCloseCount())  {
						correct = false;
						break;
					}
					rightRemainder += list[i].getRightCloseCount() - list[i].getLeftCloseCount();
				}
			}
		}

		// 出力
		System.out.println(correct && leftRemainder == rightRemainder || allClose ? "Yes" : "No");
		sc.close();
	}

	static class Kakko {
		private int id;
		private int leftCloseCount;
		private int rightCloseCount;
		Kakko (int id, String s) {
			this.id = id;
			if (s.indexOf("(") < 0) {
				rightCloseCount = s.length();
				leftCloseCount = 0;
			} else if (s.indexOf(")") < 0) {
				rightCloseCount = 0;
				leftCloseCount = s.length();
			} else {
				rightCloseCount = s.indexOf("(");
				leftCloseCount = s.length() - rightCloseCount;
			}
		}
		public int getId() {
			return id;
		}
		public int getLeftCloseCount() {
			return leftCloseCount;
		}
		public int getRightCloseCount() {
			return rightCloseCount;
		}
		public boolean putLeft() {
			return leftCloseCount > rightCloseCount ? true : false;
		}
	}

	static class KakkoComp implements Comparator<Kakko> {

	    @Override
	    public int compare(Kakko o1, Kakko o2) {
	        // o1の方が昇順で上なら負の数を返す。
	    	int result = 0;
	    	if (o1.putLeft()) {
	    		result = o1.getRightCloseCount() - o2.getRightCloseCount();
	    	} else {
	    		result = o1.getLeftCloseCount() - o2.getLeftCloseCount();
	    	}
	        return result;
	    }
	}
}


Measured memory_bytes: 85220
#include <stdio.h>

int main(){
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);
  if(A == 7 && B == 5 && C == 5){
    printf("YES\n");
  }else if(A == 5 && B == 7 && C == 5){
    printf("YES\n");
  }else if(A == 5 && B == 5 && C == 7){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 128
package main

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

func main() {
	sc = initScanner(os.Stdin)
	n := scanInt(sc)
	b := scanIntSlice(sc, n-1)
	fmt.Println(resolve(n-1, b))
}

func resolve(n int, b []int) int {
	if n == 1 {
		return b[0]*2
	}

	prev, sum := b[0], b[0] + b[n-1]
	for i:=1;i<n;i++ {
		if prev > b[i] {
			sum += b[i]
		} else {
			sum += prev
		}
		prev = b[i]
	}

	return sum
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStringSlice(sc *bufio.Scanner, n int) []string {
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		ss[i] = sc.Text()
	}

	return ss
}


Measured memory_bytes: 1788
#include<bits/stdc++.h>
    using namespace std ;
    int main()
    {
      int a , b , c , k , ans = 0 ;
      cin >> a >> b >> c >> k ;
      if(a > k )
      {
        cout << k << endl ;
      }
      else
      {
        k -= a ;
        ans = a ;
        if(k < b)
        {
          cout << ans << endl ;
        }
        else
        {
          k -= b ;
          ans = a - k ;
          cout << ans << endl ;
        }
    }
 }

Measured memory_bytes: 3636
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;

    int n = s.length();
    bool bad = false;
    for (int i = 1; i < n; ++i) {
        if (s[i] == s[i - 1]) {
            bad = true;
            break;
        }
    }

    if (bad) {
        cout << "Bad\n";
    } else {
        cout << "Good\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int i;
	long long int k,nana;
	scanf("%lld",&k);
	if(k%2==0 || k%5==0){
		printf("-1\n");
		return 0;
	}
	nana=7;
	for(i=1;;i++){
		if((nana%=k)==0){
			break;
		}
		nana = 10*nana+7;
	}
	printf("%d\n",i);

}


Measured memory_bytes: 1732
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define MANX MAXN


const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    int x;
    cin>>x;
    int n;
    cin>>n;
    vector <int> good(101,1);
    while (n--)
    {
        int y;
        cin>>y;
        good[y]=0;
    }
    pii mx={x,0};
    for (int i=1;i<=100;i++)
    {
        if (good[i])
            mx=min(mx,mp(abs(x-i),i));
    }
    mx=min(mx,mp(101-x,101));
    cout<<mx.se;


    //n=1 ?
    //recursion - matrix exponential
    //linear algebra - just a joke
    //check ios_base, MAXN, mod1 before submit
    //if debug more than 15 minutes - write stress
    //compression
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int N;

void dfs(string s,char mx){
    if(s.length()==N){
        cout<<s<<endl;
    }
    else{
        for(char c='a';c<=mx;c++){
            dfs(s+c,((c==mx) ? (char)(mx+1) : mx) );
        }
    }
}

int main(){
    cin>>N;
    dfs("",'a');
}

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

using namespace std;
#define ll long long

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

int col[9];

signed main()
{
	int n;
	int a[1000];
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n) {
		a[i] = min(3200, a[i]);
		col[a[i]/400]++;
	}
	int res = 0;
	rep(i, 8) {
		res += min(1, col[i]);
	}
	int ma = res + col[8];
	int mi;
	if (res) mi = res;
	else mi = 1;
	cout << mi << " " << ma << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M 			200011
#define LN             14
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
}


vii g[M];
ll a[M];

ll go(ll u,ll p){
	a[u]+=a[p];
	for(auto v:g[u]){
		if(v==p)continue;
		go(v,u);
	}
}
int main(){
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    cin>>n>>q;
    lp(1,n-1){
    	cin>>x>>y;
    	g[x].pb(y);g[y].pb(x);
    }
    lp(1,q){
    	cin>>x>>y;
    	a[x]+=y;
    }
    go(1,0);
    lp(1,n)cout<<a[i]<<" ";cout<<"\n";

    





    	






    

}



Measured memory_bytes: 24320
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    cin >> n;

    vector<ll> h(n);
    for(auto &x:h)cin >> x;

    int maxrange=0,range=0;
    for(int i=1;i<n;i++){
        if(h[i]<=h[i-1]){
            range++;
        }else{
            range=0;
        }
        maxrange=max(maxrange,range);
    }

    cout << maxrange << endl;

    return 0;
}


Measured memory_bytes: 4004
#include<cstdio>
#include<map>
#include<queue>
using namespace std;

typedef pair<int,int> P;
int n,q,a,v,f[1000001]={0};

int main(){
  scanf("%d%d",&n,&q);
  priority_queue<P> p; p.push(P(0,-1));
  for(int i=0;i<q;++i){
    scanf("%d%d",&a,&v);
    f[a]+=v; p.push(P(f[a],-a));
    for(;;){
      a=-p.top().second; v=p.top().first;
      if(v==f[a]){ printf("%d %d\n",a,v); break; }
      p.pop();
    }
  }
}

Measured memory_bytes: 5840
#include<iostream>
using namespace std;
long long x[101],y[101],X[4],Y[4],n,ans;
main()
{
	while(cin>>n,n)
	{
		for(int i=0;i<n;i++)cin>>x[i]>>y[i];
		for(int i=0;i<4;i++)cin>>X[i]>>Y[i];
		while(!(X[0]>X[1]&&Y[0]>Y[3]))
		{
			int a=X[0],b=Y[0];
			for(int i=0;i<3;i++)X[i]=X[i+1],Y[i]=Y[i+1];
			X[3]=a,Y[3]=b;
		}
		x[n]=x[0],y[n]=y[0];
		ans=0;
		for(int i=1;i<=n;i++)
		{
			if(x[i]==x[i-1])
			{
				if(X[3]<x[i])
				{
					if(y[i]>Y[3])
					{
						long long L=x[i]-X[3],nowy=y[i-1];
						if(nowy<Y[3])nowy=Y[3];
						ans+=(y[i]-nowy)*L;
					}
					else if(y[i-1]>Y[3])
					{
						long long L=x[i]-X[3],nowy=y[i];
						if(nowy<Y[3])nowy=Y[3];
						ans+=(nowy-y[i-1])*L;
					}
				}
				else if(x[i]<X[1])
				{
					if(y[i]<Y[1])
					{
						long long L=x[i]-X[1],nowy=y[i-1];
						if(nowy>Y[1])nowy=Y[1];
						ans+=(y[i]-nowy)*L;
					}
					else if(y[i-1]<Y[1])
					{
						long long L=x[i]-X[1],nowy=y[i];
						if(nowy>Y[1])nowy=Y[1];
						ans+=(nowy-y[i-1])*L;
					}
				}
			}
			else
			{
				if(Y[0]<y[i])
				{
					if(x[i]<X[0])
					{
						long long L=y[i]-Y[0],nowx=x[i-1];
						if(nowx>X[0])nowx=X[0];
						ans+=(nowx-x[i])*L;
					}
					else if(x[i-1]<X[0])
					{
						long long L=y[i]-Y[0],nowx=x[i];
						if(nowx>X[0])nowx=X[0];
						ans+=(x[i-1]-nowx)*L;
					}
				}
				else if(y[i]<Y[2])
				{
					if(x[i]>X[2])
					{
						long long L=y[i]-Y[2],nowx=x[i-1];
						if(nowx<X[2])nowx=X[2];
						ans+=(nowx-x[i])*L;
					}
					else if(x[i-1]>X[2])
					{
						long long L=y[i]-Y[2],nowx=x[i];
						if(nowx<X[2])nowx=X[2];
						ans+=(x[i-1]-nowx)*L;
					}
				}
			}
		}
		cout<<ans<<endl;
	}
}



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

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

long long gcd(long long a, long long b) {
    if (a%b == 0) {
        return b;
    } else {
        return gcd(b, a%b);
    }
    // while (b != 0) {
    //     a = b;
    //     b = a % b;
    // }
    // return a;
}

long long lcm(long long a, long long b) {

    return (a  / gcd(a, b)) * b;
}


int main() {
    int N;
    cin >> N;
    vector<long long> T(N);

    rep(i, N) {
        cin >> T.at(i);
    }

    long long ans = T[0];
    for (int i = 1; i < N; ++i) {
        ans = lcm(ans, T[i]);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3640
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        X: i64,
    }

    for a in -500i64..501i64 {
        for b in -500i64..501i64 {
            if a.pow(5) - b.pow(5) == X {
                println!("{} {}", a, b);
                return;
            }
        }
    }

}


Measured memory_bytes: 2064
N, M = map(int, input().split())

foods = dict(zip([i+1 for i in range(M)], [0 for i in range(M)]))

for i in range(N):
    A = list(map(int, input().split()))[1::]
    for f in A:
        foods[f]+=1
ans = 0
for count in foods.values():
    if(count == N):
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <iterator>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long LL;
const int maxn = 55555;
const LL mod = 1e9 + 7;
const LL INF = 100000000000000LL;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define FOR(c,a,b) for(int c=a;c<=b;++c)
const double PI = acos(-1.0);

char mp[55][55];
int vis[maxn];
int ans[maxn], cnt;

void getans() {
	cnt = 0;
	memset(vis, 0, sizeof(vis));
	for(int i = 2;i <= maxn;i++) {
		if(vis[i]) continue;
		if(i%5 == 2) ans[cnt++] = i;
		for(int j = i;j <= maxn;j += i) {
			vis[j] = 1;
		}
	}
}

int solve() {
	getans();
	int n;
	cin >> n;
	for(int i = 0;i < n - 1;i++) {
		printf("%d ", ans[i]);
	}
	printf("%d\n", ans[n - 1]);
	return 0;
}

int main() {
	LL t = 1e18;
	//cin >> t;
	while(t--) {
		if(!solve())break;
	}
	int mark_EOF;
	if(scanf("%d", &mark_EOF) == EOF) return 0;
    return 0;
}

Measured memory_bytes: 512
h,w,k=map(int,input().split())

A=[[0 for i in range(w)] for j in range(w)]

for i in range(w):
        A[i][i]=1

mod=1000000007

Wlist=[[[-1]],[[-1],[0]],[[-1],[0],[1]]]
for i in range(3,w):
    W=[]
    for j in range(len(Wlist[i-1])):

        if Wlist[i-1][j][-1]!=i-2 : #hasiOK
            ww=Wlist[i-1][j][:]
            W.append(ww[:])
            ww.append(i-1)
            W.append(ww[:])
        else : #hasiNG
            ww=Wlist[i-1][j][:]
            W.append(ww[:])
    Wlist.append(W)


Ire=[]
for i in range(len(Wlist[w-1])):
    AA=[j for j in range(w)]
    for j in range(len(Wlist[w-1][i])):
        if Wlist[w-1][i][j]!=-1 :
            t=Wlist[w-1][i][j]
            AA[t]=t+1
            AA[t+1]=t
    Ire.append(AA)

#print(Ire)

for i in range(h):
    B=[[0 for i in range(w)] for j in range(w)]
    for j in range(len(Ire)):
        for kk in range(w):
            t=Ire[j][kk]
            #print(t)
            for mm in range(w):
                B[kk][mm]=(B[kk][mm]+A[t][mm])%mod


    #print(A)
    A=B[:]

#print(A)
print(A[0][k-1])


Measured memory_bytes: 3188
s=input().rstrip()
x=list(s)
i=0;
l=[]
s="";
while(i<len(x)):
    if i==0:
        l.append(x[i])
        i+=1;
    else:
        s+=x[i];
        if s==l[len(l)-1]:
            i+=1;
        else:
            l.append(s);
            s="";
            i+=1;
print(len(l))

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

int main() {
	string a;
	cin >> a;
	int b = 0;
	for (char c : a) {
		if (c == 'C'&&b == 0)b++;
		if (c == 'F'&&b == 1)b++;
	}
	cout<<((b == 2) ? ("Yes") : ("No"))<<endl;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var a = int.Parse(Console.ReadLine());
        var b = int.Parse(Console.ReadLine());
        var c = int.Parse(Console.ReadLine());
        var d = int.Parse(Console.ReadLine());
        var e = int.Parse(Console.ReadLine());

        var max = 0;
        var mod = 0;
        var mods = 0;

        mod = (10 - (a % 10)) % 10;
        mods += mod;
        max = Math.Max(max, mod);

        mod = (10 - (b % 10)) % 10;
        mods += mod;
        max = Math.Max(max, mod);

        mod = (10 - (c % 10)) % 10;
        mods += mod;
        max = Math.Max(max, mod);

        mod = (10 - (d % 10)) % 10;
        mods += mod;
        max = Math.Max(max, mod);

        mod = (10 - (e % 10)) % 10;
        mods += mod;
        max = Math.Max(max, mod);


        Console.WriteLine(mods + a + b + c + d + e - max);
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <vector>
using namespace std;
struct tree{
    int p;
    int pos;
    vector<int> sons;
    bool root;
    bool leaf;
};
tree map[100000];
void build(int now){
    for(int i=0;i<map[now].sons.size();i++){
        map[map[now].sons[i]].pos=map[now].pos+1;
        map[map[now].sons[i]].p=now;
        build(map[now].sons[i]);
    }
}
int main(){
    int n,l,k,r;
    scanf("%d",&n);
    for(int i=0;i<n;i++)map[i].root=true;
    for(int i=0;i<n;i++){
        scanf("%d%d",&l,&k);
        if(k==0)map[l].leaf=true;
        else map[l].leaf=false;
        for(int j=0;j<k;j++){
            scanf("%d",&r);
            map[l].sons.push_back(r);
            map[r].root=false;
        }
    }
    for(int i=0;i<n;i++)if(map[i].root){
        map[i].p=-1;
        map[i].pos=0;
        build(i);
    }
    for(int i=0;i<n;i++){
        printf("node %d: parent = %d, depth = %d, ",i,map[i].p,map[i].pos);
        if(map[i].root)printf("root, [");
        else if(map[i].leaf)printf("leaf, [");
        else printf("internal node, [");
        if(!map[i].leaf){
            printf("%d",map[i].sons[0]);
            for(int j=1;j<map[i].sons.size();j++)printf(", %d",map[i].sons[j]);
        }
        printf("]\n");
    }
}

Measured memory_bytes: 7308
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	while(true) {
		int N;
		cin>>N;
		if(N == 0) break;
		int size = 0;
		ll res = 0;
		vector<string> s(N);
		map<char, ll> omomil;
		map<char, ll> omomir;
		int perm[10];
		vector<int> out;
		REP(i, 10) {
			perm[i] = (int)i;
		}
		REP(i, N) cin>>s[i];
		REP(i, N) {
			REP(j, s[i].size()) {
				if(omomil.count(s[i][s[i].size() - 1 - j]) == 0) {
					omomil[s[i][s[i].size() - 1 - j]] = 0;
					omomir[s[i][s[i].size() - 1 - j]] = 0;
					++size;
				}
				if(i != N - 1) omomil[s[i][s[i].size() - 1 - j]] += pow(10, j);
				else omomir[s[i][s[i].size() - 1 - j]] += pow(10, j);
			}
		}
		map<char, ll>::iterator ite3 = omomil.begin();
		int foo = 0;
		while(ite3 != omomil.end()) {
			REP(i, N) {
				if(s[i].size() > 1 && s[i][0] == (*ite3).first) {
					out.pb(foo);
					//cout<<(*ite3).first<<":"<<foo<<endl;
					break;
				}
			}
			++ite3;
			++foo;
		}

		ll sugoil[10];
		ll sugoir[10];
		ite3 = omomil.begin();
		REP(i, size) {
			sugoil[i] = (*ite3).second;
			++ite3;
		}
		ite3 = omomir.begin();
		REP(i, size) {
			sugoir[i] = (*ite3).second;
			++ite3;
		}
		do {
			ll l = 0;
			ll r = 0;
			bool cont = false;
			REP(i, out.size()) {
				if(perm[out[i]] == 0) {
					cont = true;
					break;
				}
			}
			if(cont) continue;
			REP(i, size) {
				l += perm[i] * sugoil[i];
				r += perm[i] * sugoir[i];
			}
			if(l == r) ++res;
		} while(next_permutation(perm, perm + 10));

		ll hoge = 1;
		REP(i, 10 - size) {
			hoge *= 10 - size - i;
		}
		cout<<res / hoge<<endl;
	}
}

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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/

/**************************************/

/********** Main()  function **********/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  char c; cin >> c;
  if(c>='A' && c<='Z') cout << 'A' << endl;
  else cout << 'a' << endl;

  return 0;
}
/********  Main() Ends Here *************/


Measured memory_bytes: 3648
def main():
    N = int(input())
    S = input()

    ans = ''
    for word in S:
        tmp = ord(word) # 文字列 → ASCIIコード
        tmp += N
        if tmp > 90: tmp -= 26
        ans += chr(tmp) # ASCIIコード → 文字列

    print('{}'.format(ans))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; scanf("%lf",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
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 () {
  double a, b, x;
  cin >> a >> b >> x;
  double ans;
  if (a*a*b/2 <= x) ans = atan2(2*(a*a*b-x),a*a*a);
  else ans = atan2(a*b*b,2*x);
  ans *= 180/M_PI;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
	int tot[2][100010];
	int n,ans,mi=100010,ma=0;
int main()
{
	int x;
	scanf("%d",&n);
	ans=n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		tot[i&1][x]++;
		mi=min(mi,x);
		ma=max(ma,x);
	}
	int ma0=0,ma1=0,t0=0,t1=0;
	for(int i=mi;i<=ma;i++)
	{
		if(ma0<tot[0][i]) ma0=tot[0][i],t0=i;
		if(ma1<tot[1][i]) ma1=tot[1][i],t1=i;
	}
	if(t0==t1)
	{
		int ma2=0;
		for(int i=mi;i<=ma;i++)
			if(t0!=i) ma2=max(ma2,max(tot[0][i],tot[1][i]));
		ma0=ma2;
	}
	printf("%d",n-ma0-ma1);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  double n, m;
  cin >> n >> m;
  vector<double> a(n);
  rep(i,n) cin >> a.at(i);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  double sum = 0;
  rep(i,n) sum += a[i];
  double b = sum/(4*m);
  if(a[m-1]>=b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }

int main()
{
  int l, r, ans = 2018;

  cin >> l >> r;
  if (r - l >= 2019)
    ans = 0;
  l %= 2019;
  r %= 2019;
  if (r <= l)
    ans = 0;
  for (int i = l; i < r; i++)
  {
    for (int j = i + 1; j <= r; j++)
      ans = min(ans, (i * j) % 2019);
  }
  cout << ans << endl;
}


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

using namespace std;

#define ll long long

bool isprime(int n)
{
    if (n <= 1)
        return false;
    for (int i = 2; i*i<=n; i++)
        if (n % i == 0)
            return false;

    return true;
}
int binarySearch(int arr[], int l, int r, int x)
{
    if (r >= l) {
        int mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
long long lcm(long long a,long long b)
{
    long long p,r;
    p = a*b;
    r = __gcd(a, b);
    return p/r;
}
bool ispalindrome(string s)
{
    int n = s.length();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
            return false;
    }
    return true;
}

void solve()
{
    int a,b,c,k;
   cin>>a>>b>>c>>k;
   while(a>=b)
   {
       b = 2*b;
        k--;
   }
   while(b>=c)
   {
       c = c*2;
       k--;
   }
   //cout<<a<<" "<<b<<" "<<c<<" "<<k<<endl;
   if(a<b && b<c && k>=0)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3556
#include <iostream>
#include <vector>

using namespace std;

int N,M;
vector<int> s[15];
int p[15];
int ans;

inline bool judge(int state)
{
	int cnt=0;
	for (int i=1; i<=M; i++)
	{
		int tmp=0;
		for (int j=0; j<s[i].size(); j++) if (state>>(N-s[i][j])&1) tmp++;
		if (tmp%2==p[i]) cnt++;
	}
	return cnt==M;
}

int main()
{
	cin >> N >> M;
	for (int i=1; i<=M; i++)
	{
		int k;
		for (cin >> k; k--; )
		{
			int tmp;
			cin >> tmp;
			s[i].push_back(tmp);
		}
	}
	for (int i=1; i<=M; i++) cin >> p[i];
	for (int i=0; i<(1<<N); i++) if (judge(i)) ans++;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin>>N;
     vector<int> p(N);
   for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
       int ans =0;
for (int i = 1; i < N -1; i++) {
if((p[i - 1] < p[i]) && (p[i] < p[i + 1])) ans++;
else if((p[i - 1] > p[i]) && (p[i] > p[i + 1])) ans++;
} 
  
cout << ans << endl;
  
 
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, k;
  cin >> n >> k;

  vi a(n);
  trav(i, a) cin >> i;

  vi dp(k + 1); // 0 -> lose, 1 -> win
  rep(i, 1, k + 1) {
    trav(j, a) {
      if (j > i) continue;
      dp[i] |= (1 - dp[i - j]);
    }
  }
  cout << (dp[k] ? "First" : "Second") << '\n';
}


Measured memory_bytes: 640
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

Int dp[105][10];

int main(){
    cin.tie(0);
    
    Int H, W, K; cin >> H >> W >> K;
    K--;

    dp[0][0] = 1;
    for(int i = 0; i < H; i++){
        int lim = (1 << (W-1));
        for (int j = 0; j < lim; j++){
            int flag = 1;
            for (int k = 0; k < (W-2); k++){
                if ((1 << k) & j && (1 << (k+1)) & j){
                    flag = 0;
                }
            }
            if (!flag) continue;

            int amida[10];
            for (int k = 0; k < W; k++){
                amida[k] = k;
            }

            for (int k = 0; k < (W-1); k++){
                if ((1 << k) & j){
                    swap(amida[k], amida[k+1]);
                }
            }

            for (int k = 0; k < W; k++){
                dp[i+1][k] += dp[i][amida[k]];
                dp[i+1][k] %= MOD;
            }
        }
    }

    cout << dp[H][K] << endl;
    return 0;
}


Measured memory_bytes: 380
<?php
fscanf(STDIN, "%d %d", $N, $D);
$ans = 0;
for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d %d", $X, $Y);
    if ($D * $D >= $X * $X + $Y * $Y) {
        $ans++;
    }
}
printf("%d", $ans);


Measured memory_bytes: 16120
from heapq import heappop,heappush
import sys
sys.setrecursionlimit(10**6)
n=int(input())
pair=[i for i in range(n)]
que=[]
e=[None]*n
for i in range(n):
  x,y=map(int,input().split())
  e[i]=(i,x,y)
ex=sorted(e,key=lambda x:x[1])
ey=sorted(e,key=lambda x:x[2])
for i in range(n-1):
  w=ex[i+1][1]-ex[i][1]
  heappush(que,(w,ex[i][0],ex[i+1][0]))
for i in range(n-1):
  w=ey[i+1][2]-ey[i][2]
  heappush(que,(w,ey[i][0],ey[i+1][0]))
def find(x):
  if x==pair[x]:return x
  else:
    tmp=find(pair[x])
    pair[x]=tmp
    return tmp
q=[]
ans=0
while que:
  w,s,t=heappop(que)
  root_s=find(s)
  root_t=find(t)
  if root_s!=root_t:
    pair[root_s]=root_t
    ans+=w
print(ans)

Measured memory_bytes: 75096
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/


signed main(){
	int n;
	cin>>n;
	vi a(n);
	rep(i,n)cin>>a[i];

	rep(i,n-1){
		if(a[i]<0){
			a[i]*=-1;
			a[i+1]*=-1;
		}
	}
	int neg=0;
	rep(i,n){
		if(a[i]<0)neg++;
	}
	if(neg==0){
		int ans=0;
		rep(i,n)ans+=a[i];
		cout<<ans<<endl;
	}else{
		int mn=INF;
		rep(i,n)chmin(mn,abs(a[i]));
		int ans=0;
		rep(i,n)ans+=abs(a[i]);
		ans-=2*mn;
		cout<<ans<<endl;
	}


	return 0;
}



Measured memory_bytes: 4060
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
using P = pair<int, int>;

constexpr int INF = 1e9;

int main() {
    int N;
    while(cin >> N, N) {
        vector<int> hp(N);
        int max_hp = 0;
        for(int i=0; i<N; ++i) {
            cin >> hp[i];
            max_hp = max(max_hp, hp[i]);
        }
        int M;
        cin >> M;
        vector<vector<P>> s(2);
        for(int i=0; i<M; ++i) {
            string name, target;
            int mp, dam;
            cin >> name >> mp >> target >> dam;
            if(dam == 0) {
                continue;
            }
            s[target == "All"].emplace_back(mp, dam);
        }
        vector<vector<int>> cost(2, vector<int>(max_hp+1, INF));
        cost[0][0] = cost[1][0] = 0;
        for(int k=0; k<2; ++k) {
            for(int i=0; i<s[k].size(); ++i) {
                for(int j=0; j<=max_hp; ++j) {
                    int t = min(max_hp, j+s[k][i].second);
                    cost[k][t] = min(cost[k][t], cost[k][j] + s[k][i].first);
                }
            }
        }
        for(int j=max_hp; j>=1; --j) {
            cost[0][j-1] = min(cost[0][j-1], cost[0][j]);
        }
        if(s[0].size() == 0) {
            cout << cost[1][max_hp] << endl;
        } else {
            int res = INF;
            for(int i=0; i<=max_hp; ++i) {
                if(cost[1][i] == INF) {
                    continue;
                }
                int t = cost[1][i];
                for(int j=0; j<N; ++j) {
                    int rest_hp = hp[j] - i;
                    if(rest_hp <= 0 || cost[0][rest_hp] == INF) {
                        continue;
                    }
                    t += cost[0][rest_hp];
                }
                res = min(res, t);
            }
            cout << res << endl;
        }
    }
}


Measured memory_bytes: 3932
<?php
$s = trim(fgets(STDIN));
$v = "aeiou";
$c = 0;
$i = 0;
while($i < 5){
if($s == $v[$i]){
++$c;
break;
}else{
++$i;
}
}
echo $c > 0?"vowel":"consonant";

Measured memory_bytes: 3700
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var count = Console.ReadLine()
                .ToCharArray()
                .Count(x => x == 'o');

            Console.WriteLine(700 + count * 100);
        }
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;

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

        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());

        if (Math.min(A,B) <= C && Math.max(A,B) >= C) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23764
N = int(input())
A = [tuple(map(int, input().split())) for _ in range(N)]
B = A[:]
A.sort(key=lambda x: x[0])
B.sort(key=lambda x: x[1])

if N%2:
    print(B[N//2][1] - A[N//2][0] + 1)
else:
    print((B[N//2][1] + B[N//2-1][1]) - (A[N//2][0] + A[N//2-1][0])+1)

Measured memory_bytes: 40600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>B(N-1);
  vector<int>A(N,100000);
  for(int i=0;i<N-1;i++){
    cin>>B.at(i);
  }
  for(int i=0;i<N-1;i++){
    A.at(i)=min(A.at(i),B.at(i));
    A.at(i+1)=min(A.at(i+1),B.at(i));
  }
  long long sum=0;
  for(int i=0;i<N;i++){
    sum=sum+A.at(i);
  }
  cout<<sum<<endl;
}
  

Measured memory_bytes: 256
class segTree:
  inf = 10 ** 9
  def __init__(s, num):
    s.N = 1
    while s.N < num:
      s.N *= 2
    s.T = [s.inf] * (2 * s.N - 1)
    s.D = [0] * (2 * s.N - 1)
  def do(s, l, r):
    #最小値
    return min(l, r)
  def set(s, L):
    for i in range(len(L)):
      s.update(i, L[i])
  def update(s, x, v):
    k = x + s.N - 1
    s.T[k] = v
    while k > 0:
      k = (k - 1) // 2
      s.T[k] = s.do(s.T[2*k+1], s.T[2*k+2])
  def get(s, l, r):
    s.down(l)
    if l != r: s.down(r)
    ans = s.inf
    k, kl, kr = 0, 0, s.N - 1
    S = [[k, kl, kr]]
    while S:
      k, kl, kr = S.pop()
      if l <= kl and r >= kr: ans = s.do(ans, s.T[k])
      else:
        t = (kl + kr) // 2
        if l > t: S.append([2 * k + 2, t + 1,kr])
        elif r < t + 1: S.append([2 * k + 1, kl, t])
        else: 
          S.append([2 * k + 2, t + 1,kr])
          S.append([2 * k + 1, kl, t])
    return ans
  def add(s, l, r, v):
    k, kl, kr = 0, 0, s.N - 1
    S = [[k, kl, kr]]
    while S:
      k, kl, kr = S.pop()
      if l <= kl and kr <= r:
        s.D[k] += v
        continue
      if k >= s.N: continue
      if kl <= r and l <= kr:
        t = (kl + kr) // 2
        S.append([2 * k + 1, kl, t])
        S.append([2 * k + 2, t + 1, kr])

  def down(s, x):
    k, kl, kr = 0, 0, s.N - 1
    while True:
      v = s.D[k]
      s.T[k] += v
      s.D[k] = 0
      t = (kl + kr) // 2
      if 2 * k + 1 >= 2 * s.N - 1: return
      s.D[2 * k + 1] += v
      s.D[2 * k + 2] += v
      if x <= t:
        k = 2 * k + 1
        kr = t
      else:
        k = 2 * k + 2
        kl = t + 1

import sys
input = sys.stdin.readline
N, D, A = list(map(int, input().split()))
XH = [list(map(int, input().split())) for _ in range(N)]

XH.sort()
H = [XH[i][1] for i in range(N)]

T = segTree(N)
T.set(H)

p = 0
ans = 0
for i in range(N):
  for j in range(p + 1, N):
    if XH[j][0] > XH[i][0] + D * 2:
      p = j - 1
      break
    else:
      p = N - 1
  t = (T.get(i, i) - 1) // A + 1
  if t <= 0: continue
  ans += t
  T.add(i, p, -t * A)

print(ans)


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

static const int ds = 6;

void dsort( int a[], int i0, int i1, int i2, int i3 ) {
	int ta[] = { a[i0], a[i1], a[i2], a[i3] };
	int min = ta[0];
	for( int i = 0; i < 4; i++ ) {
		if( min > ta[i] ) {
			min = ta[i];
		}
	}

	int t = 0;
	while( true ) {
		if( a[i0] == min ) {
			break;
		}
		t = a[i0];a[i0]=a[i1];a[i1]=a[i2];a[i2]=a[i3];a[i3]=t;
	}

	return;
}

bool dcomp( int a[], int b[] )
{
	for( int i = 0; i < ds; i++ ) {
		if( a[i] != b[i] ) {
			return false;
		}
	}

	return true;
}

bool dcheck( int a[], int b[100][ds], int last ) {
	bool ret = false;
	for( int i = 0; i < last; i++ ) {
		ret = dcomp( a, b[i] );
		if( ret == true ) {
			break;
		}
	}
	return ret;
}

int main()
{
	int n, dx[ds], dbuff[100][ds];
	bool ret = false;

	cin >> n;

	for( int i = 0; i < n; i++ ) {
		for( int j = 0; j < ds; j++ ) {
			cin >> dx[j];
		}
		dsort( dx, 0, 1, 5, 4 );
		dsort( dx, 0, 3, 5, 2 );
		dsort( dx, 1, 2, 4, 3 );

		ret = dcheck( dx, dbuff, i );
		if( ret == true ) {
			break;
		}

		for( int j = 0; j < ds; j++ ) {
			dbuff[i][j] = dx[j];
		}
	}

	cout << (ret?"No":"Yes") << endl;

	return 0;
}


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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n=n>>1;
    }
    return result;
}



int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int n;
    cin >> n;
    int t;
    t = n % 10;
    if(t == 2 || t == 4 || t == 5 || t == 7 || t == 9)
        cout << "hon" << "\n";
    if(t == 0 || t == 1 || t == 6 || t == 8)
        cout << "pon" << "\n";
    if(t == 3)
        cout << "bon" << "\n";
}

Measured memory_bytes: 3636
def main():
    len_s = 0
    ans = -1
    dic = {}
    N, K = map(int, input().split())
    for _ in range(N):
        a, b = map(int, input().split())
        if a not in dic:
            dic[a] = b
        else:
            dic[a] += b
    dic = sorted(dic.items())
    for key, value in dic:
        len_s += value
        if len_s >= K and ans == -1:
            ans = key
    print(ans)
if __name__ == '__main__':
    main()

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

main(){
  int N;
  string S,T,U;
  cin >> N;
  cin >> S >> T;
  U=S+T;
  for (int i=0;i<N;i++){
    U.at(i*2)=S.at(i);
    U.at(i*2+1)=T.at(i);
  }
  cout <<U<<endl;

  return 0;
}

  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
const int MOD=1e9+7;
using pii=std::pair<int,int>;
using namespace std;

string s, t;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> s >> t;
    int good = 1;
    for(int i = 0; i < s.length(); i++)
        if(s[i] != t[i])
            good = 0;
    if(t.length() != s.length() + 1 || !good)
        cout << "No\n";
    else
        cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
 int main(void)
 {
     char A,B,C,D;
     int i,j;

     scanf("%c%c%c%c",&A,&B,&C,&D);

     if((A==B)&&(B==C)) { printf("Yes\n"); return 0; }
     else if((B==C)&&(C==D)) { printf("Yes\n"); return 0; }
     else printf("No\n");

     return 0;
 }



Measured memory_bytes: 128