akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;


int main(){
  int n, m;
  long long int INF = 1e14;
  while(cin >> n >> m, n){
    vector< vector<long long int> > L(n, vector<long long int>(n, INF)), S = L;
    int x, y, t;
    char s;
    for(int i = 0; i < m; ++i){
      cin >> x >> y >> t >> s;
      --x;--y;
      if(s == 'L'){
        L[x][y] = t;
        L[y][x] = t;
      }else{
        S[x][y] = t;
        S[y][x] = t;
      }
    }
    for(int i = 0; i < n; ++i){
      S[i][i] = 0;
      L[i][i] = 0;
    }
    for(int k = 0; k < n; ++k){
      for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
          L[i][j] = min(L[i][j], L[i][k] + L[k][j]);
          S[i][j] = min(S[i][j], S[i][k] + S[k][j]);
        }
      }
    }
    /*
    cout << "-------------------------------------" << endl;
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
        printf("%09d ", L[i][j]);
      }cout << endl;
    }
    cout << "-------------------------------------" << endl;
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
        printf("%09d ", S[i][j]);
      }cout << endl;
    }
    cout << "-------------------------------------" << endl;
    */
    int r;
    cin >> r;
    vector<int> Z(r);
    for(int i = 0; i < r; ++i){
      cin >> Z[i];
      --Z[i];
    }
    vector< vector<long long int> > DP(r, vector<long long int>(n,INF));
    DP[0][Z[0]] = 0;
    for(int i = 1; i < r; ++i){
      for(int j = 0; j < n; ++j){
        for(int k = 0; k < n; ++k){
          DP[i][k] = min(DP[i][k], DP[i-1][j] + L[Z[i-1]][j] + S[j][k] + L[k][Z[i]]);
          DP[i][k] = min(DP[i][k], DP[i-1][k] + L[Z[i-1]][Z[i]]);
        }
      }
    }
    /*
    for(int i = 0; i < r; ++i){
      for(int j = 0; j < n; ++j){
        printf("%09d ", DP[i][j]);
      }cout << endl;
    }
    cout << "-------------------------------------" << endl;
    */

    long long int ans = INF;
    for(int i = 0; i < n; ++i) ans = min(ans, DP[r-1][i]);
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 5164
#include<bits/stdc++.h>
using namespace std;
string s;
int ans; 
int main(){
	cin>>s;
	for(int i=0;i<4;i++) ans=ans*10+s[i]-48;
	if(ans>2019) {cout<<"TBD";return 0;}
	ans=0;
	for(int i=5;i<7;i++) ans=ans*10+s[i]-48;
	if(ans>4) cout<<"TBD";
	else cout<<"Heisei";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 3011
#define mod 1000000007

int n, m, i, j, l, r, maxi;
char s[maxN];
int sum[maxN];
vector< pair<int, int> > ord, aux;

ll comb[maxN][maxN];
ll ans;
ll dp[maxN][maxN];


void pre() {
    int i, j;

    for (i = 0; i <= n; i++) {
        comb[i][0] = 1;
        for (j = 1; j <= i; j++) {
            comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
            if (comb[i][j] >= mod) comb[i][j] -= mod;
        }
    }
}

ll sumi(ll x, ll y) {
    return sum[y] - sum[x - 1];
}

ll solve(int bg, int en) {
    int i, j, k, l, r, new_l, new_r, intr_dim, dim;
    int nr0, nr1, posl, posr, to;

    aux.clear();
    for (i = bg; i < en; i++)
        aux.pb(ord[i]);

    for (i = 0; i <= aux.size(); i++)
        memset(dp[i], 0, sizeof(dp[i]));

    dp[0][sumi(aux[0].first, aux[0].second)] = 1;
    for (i = 0; i + 1 < aux.size(); i++) {
        l = aux[i].first;
        r = aux[i].second;
        dim = r - l + 1;

        new_l = aux[i + 1].first;
        new_r = aux[i + 1].second;
        intr_dim = new_l - l;

        for (j = 0; j <= dim; j++) {
            if (dp[i][j] == 0) continue;

            nr1 = j;
            nr0 = dim - nr1;

            posl = max(0, intr_dim - nr0);
            posr = min(intr_dim, nr1);

            for (k = posl; k <= posr; k++) {
                to = j - k + sumi(r + 1, new_r);
                dp[i + 1][to] += (dp[i][j] * comb[intr_dim][k]) % mod;
                if (dp[i + 1][to] >= mod) dp[i + 1][to] -= mod;
            }
        }
    }

    l = aux.back().first;
    r = aux.back().second;
    dim = r - l + 1;

    ll ans = 0;
    for (i = 0; i <= dim; i++)
        ans += ( dp[aux.size() - 1][i] * comb[dim][i] ) % mod;

    return ans % mod;
}

int main()
{
 //   freopen("test.in","r",stdin);

    scanf("%d%d\n%s", &n, &m, s + 1);
    for (i = 1; i <= m; i++) {
        scanf("%d%d", &l, &r);
        ord.pb(mp(l, r));
    }

    sort(ord.begin(), ord.end(), [](const pair<int, int>& a, const pair<int, int>& b)->bool const {
        return mp(a.first, -a.second) < mp(b.first, -b.second);
    });

    aux = ord;
    ord.clear();

    maxi = 0;
    for (auto e : aux)
        if (e.second > maxi)
            maxi = e.second, ord.pb(e);

    pre();
    for (i = 1; i <= n; i++) sum[i] = sum[i - 1] + s[i] - '0';
    ans = 1;

    for (i = 0; i < ord.size(); i = j) {
        for (j = i + 1; j < ord.size(); j++)
            if (ord[j - 1].second < ord[j].first)
                break;

        ans = (ans * solve(i, j)) % mod;
    }

    printf("%lld", ans);


    return 0;
}


Measured memory_bytes: 65920
player_dict = {
    'a': input(),
    'b': input(),
    'c': input()
}

cur_player = 'a'

while True:
    card = player_dict[cur_player]
    if len(card) == 0:
        print(cur_player.upper())
        break
    else:
        player_dict[cur_player] = card[1:]
        cur_player = card[0]


Measured memory_bytes: 2940
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


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


def MF(): return map(float,input().split())


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


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))

# rstrip().decode('utf-8')
def main():
	
	n=II()
	A=LI()
	m=10**9+7
	
	x=sum(A)-n*(n+1)//2
	#print(x)
	l=A.index(x)
	r=A.index(x,l+1)
	#print(l,r)
	lr=l+n-r
	
	C=[1]
	D=[1]
	
	for i in range(1,n+2):
		C.append((C[-1]*(n+2-i)*pow(i,m-2,m))%m)
	
	for i in range(1,n+2):
		if i>lr:
			D.append(0)
		else:
			D.append((D[-1]*(lr+1-i)*pow(i,m-2,m))%m)
	
	#print(C,D)
	
	
	
	for i in range(1,n+2):
		print((C[i]-D[i-1])%m)
	
	
	
	

if __name__=="__main__":
	main()


Measured memory_bytes: 99424
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1000000000000000000;

ll H, N, A[1001], B[1001], dp[10001];

int main() {
    cin >> H >> N;
    for(int i=0; i<N; i++){
        cin >> A[i] >> B[i];
    }
    for(int i=0; i<H; i++){
        dp[i] = INF;
    }
    dp[H] = 0;

    for(int i=H; i>=0; i--){
        for(int j=0; j<N; j++){
            int idx = max((ll)0, i-A[j]);
            dp[idx] = min(dp[idx], dp[i]+B[j]);
        }
    }

    cout << dp[0] << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using pii = pair<int,int>;
#define all(x) begin(x), end(x)

const int MAXN = 200004;
char a[MAXN];

void init(){
    cin >>a;
}

void solve(){
    int n = strlen(a);
    int cnt = 0;
    LL ans = 0;
    for (int i=0; i<n; i++){
        if (a[i] == 'W'){
            ans += i - cnt;
            cnt ++;
        }
    }
    cout <<ans <<'\n';
}

int main (){
    cin.tie(0); cin.sync_with_stdio(0);
    int T = 1;
    //cin >>T;
    for (int i=1; i<=T; i++){
        init();
        solve();
    }
}


Measured memory_bytes: 512
n = int(input())
k = [int(i) for i in input().split()]
pair = {}

for i in range(n):
    pair.setdefault(k[i], []).append(i)

sum = 0
for value in pair.values():
    l = len(value)
    sum += l*(l-1)//2

for i in range(n):
    len_pair = len(pair[k[i]])
    if len_pair != 1:
        ans = sum - ((len_pair*(len_pair-1)//2)-((len_pair-1)*(len_pair-2)//2))
        print(ans)
    else:
        print(sum)

Measured memory_bytes: 39688
#include <iostream>
#include <bitset>
using namespace std;
typedef bitset<32> b8;
int main(){
	unsigned int n,m;
	cin>>n>>m;
	b8 b(n),c(m);
	cout<<(b&c)<<endl;
	cout<<(b|c)<<endl;
	cout<<(b^c)<<endl;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long double PI = (acos(-1));
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int n, m;
vector<vector<int> > G;
vector<int> h;

bool solve(int x){
    bool check = true;
    for (const auto &i : G[x]){
        if (h[i] >= h[x]) check = false;
    }
    return check;
}

int main(){
    int a, b, ans = 0;
    sc(n), sc(m);
    G.resize(n), h.resize(n);
    rep(i, 0, n) sc(h[i]);
    rep(i, 0, m){
        sc(a), sc(b);
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i, 0, n){
        if (solve(i)) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<ll> a(n);
  vector<ll> su(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
    if(i == 0) su[i] = a[i];
    else su[i] = su[i-1] + a[i];
  }
  ll ans = LINF;
  for(int i=0;i<n-1;++i) {
    ans = min(ans, abs(su[i] - (su[n-1]-su[i])));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3456
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> N >> M;
	int bef = -MOD;
	for (int i = 1 + M; i <= N; i += M * 2 + 1) {
		bef = i;
		K++;
	}
	if (bef + M < N)K++;
	cout << K << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_bakc
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	string a,b;
	cin>>a>>b;
	int ans=1e9;
	for(int i=0;i+sz(b)-1<sz(a);++i) {
		int cans=0;
		for(int j=0;j<sz(b);++j) {
			cans+=a[i+j]!=b[j];
		}
		ans=min(ans, cans);
	}
	
	cout<<ans<<"\n";

	return 0;
}


Measured memory_bytes: 3648
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scanf("%d %d", &N, &M)

	H := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &H[i])
	}

	var A, B int
	J := make([][]int, N)
	for i := 0; i < M; i++ {
		fmt.Scanf("%d %d", &A, &B)
		J[A-1] = append(J[A-1], B)
		J[B-1] = append(J[B-1], A)
	}

	var count, flag int
	for i := 0; i < N; i++ {
		flag = 0
		for k := 0; k < len(J[i]); k++ {
			if H[i] <= H[(J[i][k]-1)] {
				flag = 1
				break
			}
		}
		if flag == 0 {
			count++
		}
	}

	fmt.Println(count)
}


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

int main()
{
  char c;
  while(1)
    {
      cin.get(c);
      if(c=='\n') break;
      if(isalpha(c))     //??±???????????????????????\?????????????????????                     
        {
          if(islower(c))   cout << (char)toupper(c);
          //?°????????????§??????????????????islower(c)??§???c????°????????????¨???????????????         
          else   cout << (char)tolower(c);
          //??§??????????°???????????????????isupper(c)??§???c?????§???????????¨???????????????         
        }
      //else if(c==' ') cout << " ";                                            
      else  cout << c;
    }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3092
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
A = LIST()
if sorted(A) == [5, 5, 7]:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	int ans=-1;
	for(int i=1;i<=15000;i++)
	{
		int j=i*0.08;
		int k=i*0.1;
		if(j==a && k==b)
		{
			ans=i;
			break;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
S = input()
T = input()

l = []
if len(S) != len(T):
  for i in range(len(S) - len(T)):
    cnt = 0
    for j in range(len(T)):
      if T[j] != S[i+j]:
        cnt += 1
    l.append(cnt)
  print(min(l))
else:
  cnt = 0
  for i in range(len(S)):
    if T[i] != S[i]:
      cnt += 1
  print(cnt)


Measured memory_bytes: 9100
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);

		int M=1000000;
		boolean a[]=new boolean[M+1];
		Arrays.fill(a, true);
		a[0]=a[1]=false;
		for(int i=0;i*i<=M;i++)
		{
			if(!a[i])
				continue;
			for(int j=i*2;j<=M;j+=i)
				a[j]=false;
		}

		for(;;)
		{
			int N=in.nextInt(),P=in.nextInt();
			if(N==-1&&P==-1)
				return;

			ArrayList<Integer> al1=new ArrayList<Integer>();	
			ArrayList<Integer> al2=new ArrayList<Integer>();	
			for(int i=N+1;i<=N+1000;i++)
				if(a[i])
					al1.add(i);
			for(int i=0;i<al1.size();i++)
				for(int j=i;j<al1.size();j++)
					al2.add(al1.get(i)+al1.get(j));
			Collections.sort(al2);
			System.out.println(al2.get(P-1));
		}
	}
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define pq          priority_queue
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         INT_MAX-100
#define vl          vector<ll>
#define vvl         vector<vector<ll>>
#define F           first
#define S           second
#define db          double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
//const int N;

void solve()
{
   string s,t; cin>>s>>t;
   ll ns=sz(s),nt=sz(t);
   ll dp[ns+1][nt+1];
   rep(i,0,ns+1){
       rep(j,0,nt+1){
           if(i==0||j==0) dp[i][j]=0;
           else if(s[i-1]==t[j-1]) dp[i][j]=1+dp[i-1][j-1];
           else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
       }
   }
   string ans="";
   ll i=ns,j=nt;
   while(i>0 && j>0)
   {
       if(s[i-1]==t[j-1])
       {
           ans+=s[i-1];
           i--,j--;
       }
       else if(dp[i-1][j]>dp[i][j-1]) i--;
       else j--;
   }
   reverse(ans.begin(),ans.end());
   cout<<ans;
}
int main()
{
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  int check = 0;
  int size = (int)s.size();
  if(size % 2 == 0) size /= 2;
  else check++;
  rep(i,size) {
    string a = s.substr(i,2);
    if(a != "hi") {
      check++;
      break;
    }
    i++;
  }
  if(check == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using namespace std;

typedef complex<double> Point;
const double eps = 1e-7;

bool cmp(Point a,Point b)
{
    if(a.real()==b.real())
    {
        return a.imag()<b.imag();
    }else
    {
        return a.real()<b.real();
    }
}

double cosineTheorem(double a,double b,double c)
{
    double cosTheta = (a*a+b*b-c*c)/(2*a*b);
    return acos(cosTheta);
}

Point rotation(Point r,double theta)
{
    double x = r.real(), y = r.imag();
    double c = cos(theta), s = sin(theta);
    return Point(x*c-y*s,x*s+y*c);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(10);

    double x1,y1,r1,x2,y2,r2;
    cin>>x1>>y1>>r1;
    cin>>x2>>y2>>r2;
    Point c1(x1,y1),c2(x2,y2);
    Point r = c2 - c1;

    double theta = cosineTheorem(r1,abs(r),r2);

    Point s1 = rotation(r,theta);
    s1 = s1*r1/abs(s1);
    Point p1 = s1 + c1;

    Point s2 = rotation(r,-theta);
    s2 = s2*r1/abs(s2);
    Point p2 = s2 + c1;

    if(cmp(p2,p1)) swap(p1,p2);

    cout<<p1.real()<<" "<<p1.imag()<<" "<<p2.real()<<" "<<p2.imag()<<endl;

    return 0;
}



Measured memory_bytes: 3540
import sys
import itertools
import math
#input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

pattern = list(itertools.permutations(list(range(N))))

pall = 0
for pat in pattern:
    for i in range(N-1):
        currp = xy[pat[i]]
        nextp = xy[pat[i+1]]
        dist = math.sqrt(
            (currp[0] - nextp[0])**2
          + (currp[1] - nextp[1])**2
            )
        pall += dist

print(pall/(len(pattern)))
    


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

long long gcd(long x, long y)
{    if (y == 0)
        return x;
    return gcd(y, x % y);}
long long lcm(long x, long y){ return x * y / gcd(x, y);}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}


int main()
{
    int N,A[100010]={},ans=0;
    map<int,int> mp;

    cin>>N;

    for(int i=0;i<N;i++){
        cin>>A[i];
        mp[A[i]]++;

    }

    for( auto i = mp.begin(); i != mp.end() ; i++ ) {
      if(i->second%2==1)ans++;
  }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 5376
//Night's template
//orzakyrt
#include <bits/stdc++.h>
#define R register
#define LL long long
#ifdef __DEBUG__
	#define Debug (fprintf(stderr,"orzyrt\n"),fflush(stderr))
	#define debug(__a...) (fprintf(stderr,__a),fflush(stderr))
	#define setfile(__a) ('orzyrt')
	#define Compile(__a) system("g++ "__a".cpp -lm -o "__a)
#else
	#define Debug ('orzyrt')
	#define debug(__a...) ('orzyrt')
	#define setfile(__a) freopen(__a".in","r",stdin);freopen(__a".out","w",stdout)
	#define Compile(__a) ('orzyrt')
#endif
template<class TT>inline TT Max(R TT a,R TT b){return a<b?b:a;}
template<class TT>inline TT Min(R TT a,R TT b){return a<b?a:b;}
template<class TT>inline TT Abs(R TT a){return a<0?-a:a;}
template<class TT>inline TT cmin(R TT &a,R TT b){(b<a)&&(a=b);}
template<class TT>inline TT cmax(R TT &a,R TT b){(a<b)&&(a=b);}
using namespace std;
template<class TT>inline void read(R TT &x){
	x=0;R bool f=false;R char c=getchar();
	for(;c<48||c>57;c=getchar())f|=(c=='-');
	for(;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	(f)&&(x=-x);
}
//end template

namespace Night{
	const int mod = 1e9+7;
	int h,w,k;
	LL f[111][11],g[111];
	inline LL G(R int x){
		if(x<0 || x>w)return 0;
		return g[x];
	}
	int main(){
		read(h);read(w);read(k);
		g[0]=g[1]=1;g[2]=2;
		for(R int i=3;i<=10;++i)g[i]=(g[i-1]+g[i-2])%mod;
		f[0][1]=1;
		for(R int i=1;i<=h;++i){
			for(R int j=1;j<=w;++j){
				(f[i][j]+=f[i-1][j]*G(j-1)%mod*G(w-j)%mod)%=mod;
				(f[i][j]+=f[i-1][j-1]*G(j-2)%mod*G(w-j)%mod)%=mod;
				(f[i][j]+=f[i-1][j+1]*G(j-1)%mod*G(w-j-1)%mod)%=mod;
			}
		}
		cout<<f[h][k];
		return 0;
	}
}
int main(){
	return Night::main();
}


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

using namespace std;

int main()
{
    int n, m, d, I, Ip;
    string s;
    vector <int> V;
    cin >> n >> m >> s;
    I = n;
    Ip = n;
    while (I != 0)
    {
        for (int i = max(I-m,0); i < I; i++)
        {
            if (s[i] == '0')
            {
                V.push_back(I-i);
                I = i;
                break;
            }
        }
        if (I == Ip)
        {
            cout << -1;
            return 0;
        }
        Ip = I;
    }
    for (int i = V.size()-1; i >= 0; i--)
    {
        cout << V[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 1144
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;
class Main{
 
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        long[] a = new long[(1<<N)];
        for(int i=0;i<(1<<N);++i)a[i]=scan.nextLong();
        PrintWriter out = new PrintWriter(System.out);
        long bef=0;
        for(int K=1;K<(1<<N);++K){
            long max1=-1;
            long max2=-1;
            for(int j=K;j>=0;--j){
                j&=K;
                if(a[j]>max1){
                    max2=max1;
                    max1=a[j];
                }else if(a[j]>max2){
                    max2=a[j];
                }
            }
            bef=Math.max(bef, max1+max2);
            out.println(bef);
        }
        out.flush();out.close();
    }
}

Measured memory_bytes: 97748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e3+2;
char res[N];
ll dp[N][N];
 
int main()
{
     string s,t;   
    cin>>s>>t;
    ll ns=s.length();
    ll nt=t.length();
    for(int i=1;i<=ns;i++){
     for(int j=1;j<=nt;j++){
      if(s[i-1]==t[j-1])dp[i][j]=dp[i-1][j-1]+1;
      else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
     }
    }
  
    ll i=ns;
    ll j=nt;
      ll rc = 0;
  
    while(i!=0 && j!=0)
    {
     if(s[i-1]==t[j-1])
     {
      rc++;
      res[rc]=s[i-1];
      i--;
      j--;
     }
     else
     {
      if(dp[i-1][j]>=dp[i][j-1])
        i--;
      else 
        j--;
     }
    }
  
    for(int i=rc;i>=1;i--)
      cout<<res[i];
    cout<<endl;
    return 0;
}


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

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b&&a!=c)
        cout << "Yes" << endl;
    else if(a==c&&a!=b)
        cout << "Yes" << endl;
    else if(b==c&&a!=b)
        cout << "Yes" << endl;
    else
        cout << "No";

    //system("pause");
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif


void Main() {
    ll N; cin >> N;
    rep2(i, 1, 10){
        if (N % i == 0 && 1 <= N / i && N / i <= 9){
            cout << "Yes" << endl;
            exit(0);
        }
    }
    cout << "No" << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
      	long nam = 0;
      
      for(int i =1;i <= n ;i++){
        if(n>=i*i){nam=i*i;}
        else{break;}
      }
      System.out.print(nam);
	}
}

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

int main() {
    int n;
    cin >> n;
    if(n==10 || n==100 || n==1000 || n==10000 || n==100000) {
        cout << "10" << endl;
    } else {
        int ans=0;
        while(n>0) {
            ans += n%10;
            n /= 10;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxN 200005
#define inf (int) 1e9 + 50
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define REP(i, a, b) for(int i = a; i >= b; i--)

using namespace std;

int n, k;
int a[maxN];

void enter() {
    cin >> n >> k;
    FOR(i, 1, n)
       cin >> a[i];
    sort(a + 1, a + n + 1);
}

bool ok(int x) {
    int ans = 0;
    FOR(i, 1, n) {
        int y = a[i], u = y / x;
        while(1ll * x * u < y) u++;
        ans += u - 1;
    }
    return ans <= k;
}

void solve() {
    int lo = 0, hi = inf;
    while(hi - lo > 1) {
        int m = (hi + lo)/2;
        if(ok(m)) hi = m;
        else lo = m;
    }
    cout << hi;
}

int main() {
    //freopen("main.inp", "r", stdin);
    enter();
    solve();
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)

typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#ifdef Rahul
# define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
# define error(...) 42;
#endif
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/
const int N = 5e5 + 42;
int fen[30][N];

void upd(int k, int i, int v) {
  for (; i < N; i += i & -i) fen[k][i] += v;
}
int get(int k, int i) {
  int res = 0;
  for (; i > 0; i -= i & -i) {
    res += fen[k][i];
  }
  return res;
}
int32_t main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  vector<pair<int,char>> a(m);
  for (auto &e : a) {
    cin >> e.first >> e.second;
    --e.first;
  }
  for (int i = 0; i < 1000; ++i) {
    string s = to_string(i);
    if (SZ(s) != n) continue;
    int ok = 1;
    for (auto &e : a) {
      ok &= s[e.first] == e.second;
    }
    if (ok) kek(i);
  }
  kek(-1);
}


Measured memory_bytes: 256
#include <stdio.h>

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

    if(a == 1 && b == 2)
    printf("3\n");

    if(a == 1 && b == 3)
    printf("2\n");
    
    if(a == 2 && b == 3)
    printf("1\n");

    if(a == 2 && b == 1)
    printf("3\n");

    if(a == 3 && b == 1)
    printf("2\n");

    if(a == 3 && b == 2)
    printf("1\n");




    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
#include <iomanip>
int main(void){
    int a,b;
    cin >> a;
    cin >> b;
    int d=a/b;
    int r=a%b;
    double f=double(a)/double(b);
    cout << d;
    cout << " ";
    cout <<r;
    cout <<" ";
    cout <<fixed << setprecision(5) <<f;
    cout <<endl;
    
    
}



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

using namespace std;

long long n, v[100005], s[100005], d[100005];

inline int dist(long long  x, long long  y)
{
    return abs(x-y);
}

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

        s[i]=s[i-1]+dist(v[i-1], v[i]);
    }
    for (int i=n; i>=1; i--)
    {
        d[i]=d[i+1]+dist(v[i+1], v[i]);
    }
    for (int i=1; i<=n; i++)
    {
        cout<<s[i-1]+dist(v[i-1], v[i+1])+d[i+1]<<'\n';
    }
    return 0;
}


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

cnt = {}
for i in range(n):
    if a[i] not in cnt:
        cnt[a[i]] = 1
    else:
        cnt[a[i]] += 1

ans = 0
for i in cnt:
    ans += (cnt[i] - 1)
if ans % 2 == 0:
    print(n - ans)
else:
    print(n - ans - 1)

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


int main()
{
	int A,B,C;
	cin>>A>>B>>C;
	int ans=A;
	for(int i=1;i<=B;i++)
	{
		if((ans*i)%B==C)
		{
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=1e5+5,mod=1e9+7;
int n,i,j,sz,cir;
int a[N],vis[N],dgr[N],foot[N],cnt[N],dis[N],nc[N];
long long ans,g[N];
void dfs(int x) {
	vis[x]=1; sz++; if (dgr[a[x]]!=1 || nc[a[x]]) cir=0;
	if (vis[a[x]]) return ;
	dfs(a[x]);
}
void dfs2(int x,int step) {
	if (dgr[a[x]]>1) {foot[a[x]]=step; return ;}
	dfs2(a[x],step+1);
}
void dfs3(int x,int step) {
	if (dgr[a[x]]==2) {dis[a[x]]=step; return;}
	dfs3(a[x],step+1);
}
void dp(int n,int k)
{
	int i;
	g[0]=1;
	rep(i,1,n)
	{
		if ((k%2) && (k>1)) g[i]=g[i-1]*2%mod;
		else g[i]=g[i-1];
		if (i>1) g[i]=(g[i]+g[i-2]*(i-1)%mod *k%mod)%mod;
	}
	ans=ans*g[n]%mod;
}
void calc(int x)
{
	if (foot[x]<dis[x]) ans=ans*2%mod;
	else if (foot[x]>dis[x]) ans=0;
}
int main()
{
	//freopen("cycle.in","r",stdin);
	//freopen("cycle.out","w",stdout);
	scanf("%d",&n); ans=1;
	rep(i,1,n) scanf("%d",&a[i]),dgr[a[i]]++;
	rep(i,1,n) if (dgr[i]>2) { printf("0\n"); return 0; }
	rep(i,1,n)
	if (!vis[i])
	{
		sz=0; cir=1;
		dfs(i);
		if (cir) cnt[sz]++;
		else nc[i]=1;
	}
	rep(i,1,n) if (!dgr[i]) dfs2(i,1);
	rep(i,1,n) if (dgr[i]==2) dfs3(i,1);
	rep(i,1,n) if (cnt[i]) dp(cnt[i],i);
	rep(i,1,n) if (dgr[i]==2) calc(i);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
a, b, c = input()

if a == 'S' and b == 'S' and c == 'S':
  print(0)
  
elif a == 'R' and b == 'R' and c == 'R':
  print(3)
  
elif b == 'S' and a == 'R':
  print(1)
  
elif b == 'S' and c == 'R':
  print(1)
  
elif a == 'S' and b == 'R' and c == 'S':
  print(1)
  
else:
  print(2)

Measured memory_bytes: 9112
n = int(input())
s = input()

ans = 0

for i in range(1000):
    # 確認するpinの数字の組み合わせと桁の初期化
    current_digit = 0
    pin = f'{i:0>3}'
    # pin = list(str(i).zfill(3))
    k = pin[current_digit]

    for num in s:
        # 見つけると桁を右に一つずらす
        if num == k:
            current_digit += 1
            # indexが3(桁が3→2→1→0)になったときはそのPINは作れる
            if current_digit <= 2:
                k = pin[current_digit]

            elif current_digit == 3:
                ans += 1
                break

print(ans)

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

public class Program
{

	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

		var result = input.All(x => x == input.First()) ? "Yes" : "No";
		Console.WriteLine(result);
	}

}


Measured memory_bytes: 11348
#include <iostream>
#include <vector> 
#include <cmath>

int main(){
  int N, M;
  std::cin >> N  >> M;
  std::vector<int> k(M);
  std::vector<int> p(M);
  std::vector<std::vector<int> > s(M);
  for(int i = 0 ; i < M ; i++){
    std::cin >> k[i];
    for(int j = 0 ; j < k[i] ; j++){
      int s_ij;
      std::cin >> s_ij;
      s[i].push_back(s_ij);
    }
  }
  for(int i = 0 ; i < M ; i++){
    std::cin >> p[i];
  }

  int count = 0 ;
  for(int bit = 0 ; bit < (1 << N) ; bit++){
    int check = 0;
    for(int i = 0 ; i < M ; i++){
      int n_on = 0;
      for(int j = 0 ; j < k[i] ;j++){
	int a = (bit >> (s[i][j] - 1) ) & 1;
	if(a == 1){
	  n_on++;
	}	
      }
      if(n_on % 2 == p[i]){
	check++;
      }
    }
    if(check == M){
      count++;
    }
  }

  std::cout << count << std::endl;
  return 0;
}


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

using namespace std;


int main()
{
  int a,b,k;
  int i;

  cin >> a >> b >> k;

  for ( int i = a; i < a+k; ++i ) {
    if ( i > b ) break;
    cout << i << endl;
  }

  for ( int i = b-k+1; i <= b; ++i ) {
    if ( i < a+k ) continue;
    cout << i << endl;
  }

}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
inline int in(){int x;scanf("%lld",&x);return x;}
const int N=1e7+3;
int d[N];

int32_t main()
{
	int n=in();
	d[0]=0;d[1]=0;
	for(int i=2;i<=n;i++)
	{
		if(d[i]!=0)continue;
		d[i]=i;
		for(int j=i*i;j<=n;j+=i)
		{
			d[j]=i;
		}
	}
	int x,cur;
	int ans=1;int tp,dd;
	for(int i=2;i<=n;i++)
	{
		x=i;tp=1;
		while(x>1)
		{
			dd=d[x];
			cur=0;
			while(x%dd==0){cur++;x/=dd;}
			tp*=(cur+1);
		}
		ans+=tp*i;
	}
	cout<<ans;
	
}

Measured memory_bytes: 81776
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];} 
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";} cout<<endl;
#define S second
#define F first
#define SZ(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const int MOD = 1e9 + 7;
const int N = 1e6 + 7;
ll c[N];

long long power(long long x, unsigned int y) { 
    ll res = 1;
    while (y > 0) { 
        if (y & 1) res = res * x % MOD; 
        y = y >> 1; 
        x = x * x % MOD;
    }
    return res; 
} 

void solve(){
    int n , k; 
    cin>>n>>k;
    c[k - 1] = 1;
    // cout<<c[k - 1]<<" ";
    for(int i = k; i <= n ; i++){
        c[i] = c[i - 1] * i % MOD * power(i - (k - 1) , MOD - 2) % MOD;
        // cout<<c[i]<<" ";
    }
    // cout<<endl;
    vector<int> v(n);
    for(int i = 0 ; i < n ; i++){
        cin>>v[i];
    }
    sort(v.begin() , v.end());
    
    ll sum = 0;
    for(int i = 0 ; i + k - 1 < n ; i++){
        sum -= v[i] * c[n - i - 1];
        sum %= MOD;
        // cout<<v[i]<<" "<<c[n - i - 1]<<endl;
    }
    // cout<<"op"<<endl;

    for(int i = k - 1; i < n ; i++){
        sum += v[i] * c[i];
        sum %= MOD;
        // cout<<v[i]<<" "<<c[i]<<endl;
    }
    sum %= MOD;
    sum += MOD;
    sum %= MOD;
    cout<<sum<<endl;
}

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

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);





int main() 
{
  int N; cin>>N;
  map<int,int> D;
  rep(i,N)
  {
    int d; cin>>d;
    if(D.count(d)) {D.at(d)++; continue;}
    D[d]=1;
  }
  int M; cin>>M;
  rep(i,M)
  {
    int T; cin>>T;
    if(!(D.count(T))) {cout<<"NO"<<endl; return 0;}
    if(D.at(T)==0) {cout<<"NO"<<endl; return 0;}
    D.at(T)--;
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 9600
x,y = gets.split.map(&:to_i)
b = (y-2*x).to_f/2
a = x.to_f - b
if a >= 0 && b >= 0 && a - a.to_i == 0 && b - b.to_i == 0
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14372
import java.util.Scanner;

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

        if (s>w) {
            System.out.println("safe");
        } else {
            System.out.println("unsafe");
        }
    }
}


Measured memory_bytes: 35824
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cctype>
#include <string>
#include <cmath>

using namespace std;

typedef long long ll;

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

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

const int mod = 1000000007;
const int INF = 1001001001;

int main() {
    int n;
    int ans = 0;
    cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(all(l));
    rep(b, n) rep(a, b) {
        int ab = l[a] + l[b];
        int r = lower_bound(l.begin(), l.end(), ab) - l.begin();
        int l = b+1;
        ans += max(0, r-l);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll n; cin >> n;
    ll a[500010]; INITA(a, 0, 500000, -1);
    ll base = 250000;
    if (n % 2 == 0) {
        REP(i, n) {
            // 2: 2 1
            // 4: 4 2 1 3
            if (i % 2 == 0) {
                cin >> a[base+i/2];
            } else {
                cin >> a[base-(i+1)/2];
            }
        }
    } else {
        REP(i, n) {
            // 1: 1
            // 3: 3 1 2
            // 5: 5 3 1 2 4
            if (i % 2 == 0) {
                cin >> a[base-(i+2)/2];
            } else {
                cin >> a[base+(i-1)/2];
            }
        }
    }
    ll res = 0;
    REP(i, 500000) {
        if (a[i] != -1) {
            if (res != 0) {
                cout << " ";
            }
            cout << a[i];
            res++;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 7516
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,tc=0;
	cin>>n>>k;
	int r,s,p;
	cin>>r>>s>>p;
	char str[n];
	cin>>str;
	char ch[n];
	int t =0;
	while(t<k){
	if(str[t]=='r')
	 {
	   ch[t++]='p';
	   tc+=p;
	 }
	 else if(str[t]=='p')
	 {
	   ch[t++]='s';
	   tc+=s;	
	 }
	 else 
	 {
	 	ch[t++]='r';
	 	tc+=r;
	 }
    }
    for(int i=k;i<n;i++)
    {
       if(str[i]==str[i-k]&&str[i]!=ch[i-k])
       {
       	tc+=0;
       	ch[i]=str[i];
	   }
	   else
	   {
	   	if(str[i]=='r')
	   	{
	   		tc+=p;
	   		ch[i]='p';
		}
		else if(str[i]=='s')
		{
			tc+=r;
			ch[i]='r';
		}
		else
		{
			tc+=s;
			ch[i]='s';
		}
	   }
	}
	cout<<tc;
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(){
	int num[6];
	double ans[2];
	
	while(scanf("%d %d %d %d %d %d", num, num+1, num+2, num+3, num+4, num+5) != EOF)
	{
		if(((num[1]*num[3])-(num[0]*num[4])) == 0)
		{
			//一意に解が求まらない
		}
		else
		{
			ans[0] = (((double)((num[1]*num[5])-(num[4]*num[2]))) / ((double)((num[1]*num[3])-(num[0]*num[4]))));
			//b == 0
			if(num[1] == 0)
			{
				ans[1] = ((double)(num[5]-num[3]*ans[0]))/((double)num[4]);
			}
			else
			{
				ans[1] = ((double)(num[2]-num[0]*ans[0]))/((double)num[1]);
			}
		}
		
		if(ans[0] == 0)
		{
			ans[0] = 0.000;
		}
		if(ans[1] == 0)
		{
			ans[1] = 0.000;
		}
				
		printf("%.3lf %.3lf\n", ans[0], ans[1]);
	}
	
	return 0;
}

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


Measured memory_bytes: 128
#include<bits/stdc++.h>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
//251103FD
using namespace std;
#define PB pop_back
#define PF pop_front
#define np next_permutation
#define eb emplace_back
#define pb push_back
#define bf push_front
#define mp make_pair
#define s second
#define f first
#define mt make_tuple
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define forn(i, a) for(int i=0; i<a; i++)
#define Forn(i, a) for(int i=1; i<=a; i++)
#define read(x) ((scanf("%s", &_), (x) = _))
#define INF 1e9
#define memINF 127
#define inf 1e18
#define all(x) x.begin(), x.end()
#define MOD 1e9+7 
#define HASH 1543 

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;

using namespace std;

inline int in() 
{
    int x=0, c;
    for(; (uint)((c=getchar())-'0')>=10;) 
	{ 
		if(c=='-') 
			return -in(); 
		if(!~c)
			throw ~0; 
	}
    do 
	{ 
		x=(x<<3)+(x<<1)+(c^48); 
	} 
	while((uint)((c=getchar())^48)<10);
    return x;
}
inline int gcd(int a, int b){if(a>b) swap(a, b); return a==0?b:gcd(b%a, a);}
inline int lcm(int a, int b){return a*b/gcd(a, b);}

bool dp[5005][5005];
int N, K, a[5005], cnt, l, r, mid;

inline bool check(int base)
{
	memset(dp, false, sizeof(dp));
	dp[0][0]=true;
	Forn(i, N)
	{
		forn(j, K+1)
		{
			dp[i][j]=dp[i-1][j];
			if(i!=base&&j>=a[i])
				dp[i][j] |=dp[i-1][j-a[i]];
			if(dp[i][j]&&j>=K-a[base]&&j>=0&&j<K)
				return true;
		}
	}
	return false;
}

int main()
{
	N=in(), K=in();
	Forn(i, N)
		a[i]=in();
	sort(a+1, a+1+N);
	l=0, r=N+1;
	while(l+1<r)
	{
		mid=(l+r>>1);
		if(check(mid))
			r=mid;
		else
			l=mid;		
	}
	printf("%d\n", l);
	return 0;
}


Measured memory_bytes: 24704
def judge_prime(num):
    FLAG = True
    
    for i in range(2, int(num**0.5)+1):

        if (num%i == 0):
            FLAG = False
    
    if (num == 2):
        FLAG = True
    
    return(FLAG)

X = int(input())

while (True):
    flag = judge_prime(X)
    
    if (flag):
        break
    
    X += 1

print(X)


Measured memory_bytes: 3060
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(color[v]==WHITE){
      dfs_visit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}

void dfs(){
  int u;
  for(u=0;u<n;u++) color[u]=WHITE;
  tt=0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE) dfs_visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) M[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();

  return 0; 
}

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


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

    res = sorted([(a,i) for i,a in enumerate(A,1)])
    print(" ".join(map(lambda x: str(x[1]),res)))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 31188
import java.io.*
import java.util.*
import kotlin.math.*

fun main(){
	val f = BufferedReader(InputStreamReader(System.`in`))

	val n = f.readLine().toInt()

	val adj = Array(n+1){mutableListOf<Int>()}
	for(k in 2..n){
		val (a,b) = f.readLine().split(" ").map{it.toInt()}
		adj[a].add(b)
		adj[b].add(a)
	}

	for(k in 1..n) adj[k].sort()

	val a = LongArray(n+1){0L}
	//calc a[1]

	a[1] = 1L
	var prev = 1L
	for(k in 2..n){
		var i = 0L
		for(nei in adj[k]){
			if(nei < k) i++
			else break
		}

		prev = prev-(i-1)
		a[1] += prev
	}

	for(k in 1 until n){
		val neis = mutableListOf<Int>()

		for(nei in adj[k]){
			if(nei > k){
				//("nei $k $nei")
				neis.add(nei)
			}
		}

		if(neis.size == 0){
			a[k+1] = a[k] - (n-k+1)
		} else {
			//println("neis[0] = ${neis[0]}")
			a[k+1] = a[k] - (neis[0]-k)
			for(j in 1 until neis.size){
				a[k+1] = a[k+1] + (n-neis[j]+1).toLong()
			}
		}
	}

	var answer = 0L
	for(k in 1..n){
		//println(a[k])
		answer += a[k]
	}
	println(answer)
}


Measured memory_bytes: 86880