akhauriyash/Code-Regression huggingface dataset:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      for(int i = 1; i <= 9; i++){
        if((N / i < 10) && (N % i == 0)){
          myout("Yes");
          return;
        }
      }
      myout("No");
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32788
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll n;
  cin >> n;
  vl a(n+1,INF),b(n+1,INF),c(n+1,INF);
  rep(i,n){
    cin >> a[i];
  }
  rep(i,n){
    cin >> b[i];
  }
  rep(i,n){
    cin >> c[i];
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  ll ans=0;
  vl sum_ab(n,0);
  vl P_ab(n,0);
  ll l=0;
  rep(i,n){
    while(b[i]>a[l]){
      l++;
    }
    P_ab[i]=l;
  }
  sum_ab[0]=P_ab[0];
  FOR(i,1,n){
    sum_ab[i]=sum_ab[i-1]+P_ab[i];
  }
  l=0;
  rep(i,n){
    while(c[i]>b[l]){
      l++;
    }
    if(l!=0){
      ans+=sum_ab[l-1];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4224
A,B,C = map(int,input().split())
# A,B,C = 100,100,100

def foo(A,B,C):
	return((B+C)//2,(A+C)//2,(A+B)//2)

c = 0
for i in range(10**6):
	if A%2 == 0 and B%2 == 0 and C%2 == 0:
		A,B,C = foo(A,B,C)
		c+=1
	else:
		print(c)
		break
else:
	print("-1")


Measured memory_bytes: 3060
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	ll n, m, a, b;
	cin >> n >> m;
	vector< pair<ll, ll>> ed;
	REP(i, n){
		cin >> a >> b;
		//ed.push_back(make_pair(a, b));
		ed.emplace_back(a, b);
	}
	sort(ed.begin(), ed.end());
	ll rest = m;
	for(int i = 0; rest > 0; i++){
		ans += ed[i].first * min(ed[i].second, rest);
		rest -= ed[i].second;
	}
	cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for( int i = 0; i < N ; i++) {
    cin >> vec.at(i);
  }
  int inn = 0;
  int highest = vec.at(0);
  for( int i = 0; i < N ; i++) {
    if (vec.at(i) >= highest) {
      inn ++;
      highest = vec.at(i);
    }
  }
  cout << inn << endl;
}


Measured memory_bytes: 256
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

S = readline().decode().rstrip()

print("A") if S.isupper() else print('a')


Measured memory_bytes: 27112
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0;
  int N=s.size();
  int i=0;int a=2;
  while(i<N-1){
  if(a==2){ans++; a=1;i++;}
    else{
    if(s.at(i)==s.at(i-1)){ans++; a=2; i+=2;}
      else{ans++; i++;}
    }
  }if(i==N-1 &&(a==2 || s.at(N-1)!=s.at(N-2)))ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int main(){
  int A, B;
  cin >> A >> B;
  
  int res;
  int A_price_min, B_price_min;
  int A_price_max, B_price_max;
  
  B_price_min = 10*B;
  B_price_max = 10*B + 9;
  
  if(A%2 == 0){
    A_price_min = 25*A/2;
    A_price_max = 25*A/2 + 12;
  }else{
    A_price_min = (25*A+1)/2;
    A_price_max = (25*A+1)/2 + 11;
  }
  
  if(A_price_max < B_price_min || B_price_max < A_price_min) {
    res = -1;
  }else{
    res = max (A_price_min, B_price_min);
  }
  
  //cout << A_price_min << " " << A_price_max << endl;
  cout << res;
}

Measured memory_bytes: 256
// kartikay26
#include <bits/stdc++.h>
using namespace std;
#define debug(x...) 
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
typedef long long int ll; typedef double db; typedef vector<ll> vi; typedef pair<ll, ll> pii;
#define int ll
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define clr(x) memset(x, 0, sizeof(x))
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
void print(){cout << endl;} void prints(){}
template<typename T> void get(T* x, int n){for (int i = 0; i < n; ++i) { cin >> x[i]; }}
template<typename T> void get(T& x, int n){for (int i = 0; i < n; ++i) { cin >> x[i]; }}
template<typename T, typename... A> void print(T x,A... r){cout << x << " ";print(r...);}
template<typename T, typename... A> void prints(T x,A... r){cout << x << " ";prints(r...);}

const int mod = 1e9+7;
const int N = 21;

char grid[N][N];
int h, w; 
int d[N*N][N*N];

bool bounds(int i, int j) {
	return 0 <= i && i < h && j < w && 0 <= j;
}

void flw() {
	for (int k = 0; k < N*N; ++k) {
	    for (int i = 0; i < N*N; ++i) {
	        for (int j = 0; j < N*N; ++j) {
	            d[i][j] = min(d[i][j], d[i][k] + d[k][j]); 
	        }
	    }
	}
}

int32_t main(){
	fast_io();

	for (int i = 0; i < N*N; ++i) {
		for (int j = 0; j < N*N; ++j) {
			d[i][j] = 1e9;
		}
	}
	for (int i = 0; i < N*N; ++i) {
		d[i][i] = 0;
	}

	cin >> h >> w;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> grid[i][j];
		}
	}
	
	int ans = 0;

	for(int i = 0; i < h; i++) {
		for (int j = 0; j < w; ++j) {
			if(grid[i][j] == '.') {
				vector<pii> v = {{i,j+1},{i,j-1},{i+1,j},{i-1,j}};
				for(auto p: v){
					int x = p.first;
					int y = p.second;
					if(bounds(x,y) && grid[x][y] == '.'){
						int a = i*w+j;
						int b = x*w+y;
						d[a][b] = 1;
					}
				}
			}
		}
	}

	flw();

	for(int i = 0; i < h; i++) {
		for (int j = 0; j < w; ++j) {
			for(int x = 0; x < h; x++) {
				for (int y = 0; y < w; ++y) {
					if(grid[x][y] == '.' && grid[i][j] == '.'){
						int a = i*w+j;
						int b = x*w+y;
						ans = max(ans, d[a][b]);
					}
				}
			}
		}
	}

	print(ans);

	return 0;
}

Measured memory_bytes: 1920
#辺の重み(変化量)が0である場合は01DFSって特別なやつ
#0の場合はそこでBFSできる
import sys
from collections import deque
sys.setrecursionlimit(10**7)
input=sys.stdin.readline
h,w=map(int,input().split())
c=[int(i)-1 for i in input().split()]
d=[int(i)-1 for i in input().split()]
s=[input() for i in range(h)]
inf=100000000
dp=[[-1 if s[i][j]=="#" else inf for j in range(w)] for i in range(h)]
dp[c[0]][c[1]]=0
now=deque([[c[0],c[1]]])
def bfs():
    global h,w,s,dp,now
    while len(now):
        i,j=now.popleft()
        if i>0:
            if dp[i-1][j]!=-1:
                if dp[i-1][j]>dp[i][j]:
                    dp[i-1][j]=dp[i][j]
                    now.appendleft([i-1,j])
        if j>0:
            if dp[i][j-1]!=-1:
                if dp[i][j-1]>dp[i][j]:
                    dp[i][j-1]=dp[i][j]
                    now.appendleft([i,j-1])
        if i<h-1:
            if dp[i+1][j]!=-1:
                if dp[i+1][j]>dp[i][j]:
                    dp[i+1][j]=dp[i][j]
                    now.appendleft([i+1,j])
        if j<w-1:
            if dp[i][j+1]!=-1:
                if dp[i][j+1]>dp[i][j]:
                    dp[i][j+1]=dp[i][j]
                    now.appendleft([i,j+1])
        for k in range(-2,3):
            for l in range(-2,3):
                if 0<=i+k<h and 0<=j+l<w:
                    if dp[i+k][j+l]!=-1:
                        if dp[i+k][j+l]>dp[i][j]+1:
                            dp[i+k][j+l]=dp[i][j]+1
                            now.append([i+k,j+l])
bfs()
print(dp[d[0]][d[1]] if dp[d[0]][d[1]]!=inf else -1)

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

int main(){
int N, K; cin >> N >> K;
vector<int> x(N);
for (int i = 0; i < N; i++) {
    cin >> x[i];
}

int ans = 0;
for (int i = 0; i < N; i++) {
    ans += 2*min(x[i], K - x[i]);
}

cout << ans << endl;

}



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

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

	int fir = s/100;
	int sec = s%100;

	if(1 <= fir && fir <= 12){
		if(1 <= sec && sec <= 12) cout << "AMBIGUOUS" << endl;
		else cout << "MMYY" << endl;
	}else if(1 <= sec && sec <= 12){
		cout << "YYMM" << endl;
	}else cout << "NA" << endl;

	return 0;
}

Measured memory_bytes: 256
def abc079_b():
    n = int(input())
    if n == 1:
        print(1)
    else:
        l = [0] * (n + 1)
        l[0] = 2
        l[1] = 1
        for i in range(2, n + 1):
            l[i] = l[i - 1] + l[i - 2]
        print(l[n])


abc079_b()

Measured memory_bytes: 3060
#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long a = 0;a < b;++a)
#define ALL(x) (x).begin(),(x).end()
void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}

void solve() {
    int go[4] = {};
    REP(i, 2) {
        int a;
        cin >> a;
        go[a] = 1;
    }
    for (int i = 1;; i++) {
        if (go[i] == 0) {
            cout << i << endl;
            return;
        }
    }
}

int main() {
    init();
    solve();
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll N = 2005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll n, m;

ll arr[N], arr2[N];

ll dp[N][N];

ll recur(ll i, ll j) {

  if (i == 0 or j == 0) {
    return 1;
  }
  ll &ans = dp[i][j];
  if (ans != -1)
    return ans;
  ans = 0;
  if (arr[i] == arr2[j]) {
    ans += recur(i - 1, j - 1);
  }
  ans += recur(i - 1, j) + recur(i, j - 1) - recur(i - 1, j - 1);
  ans = (ans % mod + mod) % mod;
  return ans;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n >> m;

  for (ll i = 1; i <= n; i++) {
    cin >> arr[i];
  }

  for (ll j = 1; j <= m; j++)
    cin >> arr2[j];

  for (ll i = 0; i <= n; i++) {
    for (ll j = 0; j <= m; j++)
      dp[i][j] = -1;
  }

  cout << recur(n, m) % mod << en;
  return 0;
}

Measured memory_bytes: 31872
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int sum = 0;
		int count = 0;
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] l = new int[n];
		for(int i = 0;i < l.length;i++) {
			l[i] = sc.nextInt();
		}
		while(sum <= x) {
			if(count < l.length) {
				sum += l[count];
			}
			if(count <= l.length) {
				count++;
			}
			else break;
		}
		sc.close();
		System.out.println(count);
    }
}

Measured memory_bytes: 20692
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end(),greater<int>())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000003 //1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int x,y;
int ct1,ct2;
struct edge{ll to;}; //edgeパラメータ
struct graph{
  ll N; //ノードの個数
  vector<vector<edge> > G; //G[辺の元]((.to辺の先,.costコスト),...)
  vector<ll> parent;
  vector<ll> depth; // d[ノード] ノードの深さ

  graph(ll n){ //グラフ生成時
    N = n;
    G.resize(N); //Edge情報
    parent.resize(N); //Node情報,親
    depth.resize(N); //Node情報,深さ
    rep(i,N){depth[i]= -1; parent[i]= -1;}
  }
  void add_edge(ll s, ll t){
    G[s].emplace_back((edge){t});
  }

  void dfs(ll v=0, ll p=0, ll d=0){
    parent[v] = p;
    depth[v] = d;
    for(auto E : G[v]){ // E つなぐエッジ
      if(E.to != p) dfs(E.to , v , d+1); //まだ行ってないなら
    }
  }
  void dfs1(ll v=0, ll p=0, ll d=0){
    if(v==0) rep(i,N){parent[i] = -1;}
    parent[v] = p;
    depth[v] = d;
    //cout<< 1<< " "<<v<<"\n";
    ct1++;
    for(auto E : G[v]){ // E つなぐエッジ
      if(E.to != p and E.to !=x) dfs1(E.to , v , d+1); //まだ行ってないなら
    }
  }
  void dfs2(ll v, ll p, ll d=0){
    if(v==N-1) rep(i,N){parent[i] = -1;}
    parent[v] = p;
    depth[v] = d;
    //cout<< 2<< " "<<v<<"\n";
    ct2++;
    for(auto E : G[v]){ // E つなぐエッジ
      if(E.to != p and E.to !=y) dfs2(E.to , v , d+1); //まだ行ってないなら
    }
  }
};


void Main(){

  int N;
  cin>>N;

  graph g(N);
  //graph g2(N);

  rep(i,N-1){
    int a,b;
    cin>>a>>b;
    g.add_edge(a-1,b-1);
    g.add_edge(b-1,a-1);
    //g2.add_edge(a-1,b-1);
    //g2.add_edge(b-1,a-1);
  }

  g.dfs();
  //g2.dfs(N-1);
/*
  rep(i,N){
    if(g.depth[i]<=g2.depth[i])ct1++;
    else ct2++;
  }
*/


  int v=N-1;

  //cout<<g.depth[N-1] <<"\n";

  rep(i,(g.depth[N-1]-1)/2){
    v=g.parent[v];
  }
  x=v;
  y=g.parent[v];

  g.dfs1();
  g.dfs2(N-1,N-1);

  //cout<< x<<"\n";
  //cout<< y<<"\n";

  //cout<< ct1<<"\n";
  //cout<< ct2<<"\n";


  cout<< ( ct1>ct2 ? "Fennec" : "Snuke" )<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 11008
#include<stdio.h>
#include<string.h>

#define MOD % 1000000007
#define LEN 1000 + 1


int main( void )
{
	char str[LEN] ,spell[LEN] ;
	scanf( "%s %s" ,str ,spell ) ;

	int st_len = strlen( str ) ;
	int sp_len = strlen( spell ) ;

	int ans[LEN] = { 1 } ;
	int i ,j ;
	for( i = 0 ; i < st_len ; ++i )
	{
		for( j = sp_len - 1 ; j >= 0 ; --j )
		{
			if( str[ i ] == spell[ j ] )
			{
				ans[ j + 1 ] = (ans[ j ] + ans[ j + 1 ]) MOD ;
			}
		}
	}

	printf( "%d\n" ,ans[ sp_len ] ) ;

	return 0 ;
}


Measured memory_bytes: 2104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author saku
 */
public class Main {

    public static void main(String args[]) throws IOException {

        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        
        if (r <= x && x <= w-r && r <= y && y <= h-r) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  int m = N + 1;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int P;
    cin >> P;
    ans += (int)(P <= m);
    m = min(m, P);
  }
  cout << ans << endl;

  return 0;
}

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

Measured memory_bytes: 128
module WeightedDirectedGraph
  (Vertex : sig
    type t
    val compare : t -> t -> int
  end)
  (Weight : sig
    type t
    val zero : t
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  val dijkstra :
    (* 隣接リスト *)
    (Vertex.t -> (Vertex.t * Weight.t) list) ->
    (* 始点 *)
    Vertex.t ->
    (* 始点から辿り着けなければNoneを返す *)
    (Vertex.t -> Weight.t option)
end =
struct
  module WMap = Map.Make (Weight)
  module VMap = Map.Make (Vertex)

  (* ダイクストラ法のメインループ *)
  (* d に入っていない頂点への距離は無限大とみなす *)
  let rec dijkstra_aux e (d, q) =
    match WMap.min_binding q with
    | exception Not_found -> d
    | (w, us) ->
        dijkstra_aux e @@ List.fold_left (fun (d, q) u ->
          if Weight.compare (VMap.find u d) w < 0
          (* 既に頂点uを訪れていた *)
          then (d, q)
          (* w = d.(u) *)
          else List.fold_left (fun (d, q) (v, c) ->
            let open Weight in
            if
              (* d.(v) <= d.(u) + c *)
              try Weight.compare (VMap.find v d) (w + c) <= 0
              with Not_found -> false (* d.(v) は無限大 *)
            then (d, q)
            else
              VMap.add v (w + c) d,
              WMap.add (w + c) (v :: try WMap.find (w + c) q with Not_found -> []) q)
          (d, q) (e u)) (d, WMap.remove w q) us

  let dijkstra e s =
    let d =
      dijkstra_aux e
        (VMap.singleton s Weight.zero, WMap.singleton Weight.zero [s]) in
    fun t -> try Some (VMap.find t d) with Not_found -> None
end

module Int = struct
  type t = int
  let zero = 0
  let ( + ) = ( + )
  let compare = compare
end

module G = WeightedDirectedGraph (Int) (Int)

let () = Scanf.scanf "%d %d %d %d\n" @@ fun n m s t ->
  let uvab = Array.init m @@ fun _ -> Scanf.scanf "%d %d %d %d\n" @@ fun u v a b -> u, v, a, b in
  let es_yen = Array.make n [] in
  let es_snuke = Array.make n [] in
  Array.iter (fun (u, v, a, b) ->
    es_yen.(u - 1) <- (v - 1, a) :: es_yen.(u - 1);
    es_yen.(v - 1) <- (u - 1, a) :: es_yen.(v - 1);
    es_snuke.(u - 1) <- (v - 1, b) :: es_snuke.(u - 1);
    es_snuke.(v - 1) <- (u - 1, b) :: es_snuke.(v - 1)) uvab;
  let d_yen = G.dijkstra (fun u -> es_yen.(u)) (s - 1) in
  let d_snuke = G.dijkstra (fun u -> es_snuke.(u)) (t - 1) in
  let ans = Array.make (n + 1) max_int in
  for i = n - 1 downto 0 do
    ans.(i) <- min ans.(i + 1) @@
      match d_yen i, d_snuke i with
      | None, _ -> max_int
      | _, None -> max_int
      | Some d, Some d' -> d + d'
  done;
  for i = 0 to n - 1 do
    Printf.printf "%d\n" @@
      (( - ) 1000000000000000) ans.(i)
  done


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

int main(){
    int N, M; cin >> N >> M;
    vector<pair<int, int>> v(N);
    priority_queue<int> pq;
    for(int i = 0; i < N; i++){
        int A, B; cin >> A >> B;
        v[i] = make_pair(A, B);
    }
    int ans = 0;
    int j = 0;
    sort(v.begin(), v.end());
    for(int i = 1; i <= M; i++){
        if(j < N){
            while(v[j].first <= i){
                pq.push(v[j].second);
                j++;
                if(j >= N) break;
            }
        }
        if(!pq.empty()){
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;


int main() {
    int d,g; cin >> d >> g;
    vector<int> p(d), c(d);
    rep(i,d) cin >> p[i] >> c[i];
    int ans = 1001;
    int cnt = 0;
    int score = 0;
    rep(x,1<<d) { //全解きなら1，無解きなら0
        score = 0;
        cnt = 0;
        rep(i,d) {
            if (x & 1<<i) {
                score += 100*(i+1)*p[i]+c[i];
                cnt += p[i];
            }
        }
        //if (score > g) continue;
        int mx;
        rep(i,d) {
            if (!(x & 1<<(d-1-i))) {
                mx = d-1-i;
                break;
            }
        }
        int num = 0;
        while (score < g && num < p[mx]) {
            score += 100*(mx+1);
            num++;
            cnt++;
        }
        if (score >= g) {
            chmin(ans,cnt);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
import sys
def input():
    return sys.stdin.readline()[:-1]
MOD = 10**9+7
fac = [1 for k in range(2000010)]
inv = [1 for k in range(2000010)]
finv = [1 for k in range(2000010)]
P25 = [1 for k in range(2000010)]
P26 = [1 for k in range(2000010)]
P25[1] = 25
P26[1] = 26
for k in range(2,2000010):
    fac[k] = (fac[k-1]*k)%MOD
    inv[k] = (MOD - inv[MOD%k] * (MOD // k))%MOD
    finv[k] = (finv[k - 1] * inv[k]) % MOD;
    P26[k] = (P26[k-1]*26) % MOD
    P25[k] = (P25[k-1]*25) % MOD

def nCr(n,r):
    return (fac[n]*finv[r]*finv[n-r])%MOD
def main():
    K = int(input())
    S = input()
    ans = 0
    for k in range(K+1):
#        print(k,nCr(K-k+len(S)-1,len(S)-1))
        ans += nCr(K-k+len(S)-1,len(S)-1)*P25[K-k]*P26[k]
        ans %= MOD
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 273016
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let mut cur: u64 = 1;
    let mut ok = false;
    for _ in 0..10 {
        println!("? {}", cur);
        let ans: String = sc.read();
        if ans.as_str() == "N" {
            ok = true;
            break;
        }
        cur *= 10;
    }

    if ok {
        let mut ok = cur - 1;
        let mut ng = cur / 10;
        while ok - ng > 1 {
            let n = (ok + ng) / 2;
            println!("? {}", n * 10);
            if sc.read::<String>().as_str() == "Y" {
                ok = n;
            } else {
                ng = n;
            }
        }
        println!("! {}", ok);
    } else {
        let mut cur: usize = 10;
        for _ in 0.. {
            println!("? {}", cur - 1);
            if sc.read::<String>().as_str() == "Y" {
                println!("! {}", cur / 10);
                return;
            }
            cur *= 10;
        }
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}



Measured memory_bytes: 4816
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>

typedef long long ll;

using namespace std;

int main() {
  ll N, X;
  cin >> N >> X;
  ll m = X;
  for (int i = 1; i < 5; ++i) {
    cin >> X;
    m = min(m, X);
  }
  printf("%lld\n", (ll)ceil((double)N / m) + 4);
}

Measured memory_bytes: 3216
SQRT3 = 3**0.5

class Point
  attr_accessor :x, :y
  def initialize(x,y)
    @x,@y = x,y
  end
  def print
    printf("%f %f\n",@x,@y)
  end
end

def coch(n,l,r)
  if n>0
    p1 = Point.new((l.x*2/3 + r.x/3), (l.y*2/3 + r.y/3))
    p2 = Point.new((l.x/2 + r.x/2 + l.y*SQRT3/6 - r.y*SQRT3/6), (-l.x*SQRT3/6 + r.x*SQRT3/6 + l.y/2 + r.y/2))
    p3 = Point.new((l.x/3 + r.x*2/3),(l.y/3 + r.y*2/3))
    
    coch(n-1,l,p1)
    p1.print
    coch(n-1,p1,p2)
    p2.print
    coch(n-1,p2,p3)
    p3.print
    coch(n-1,p3,r)
  end
end

left  = Point.new(  0.0, 0.0)
right = Point.new(100.0, 0.0)
n = gets.to_i
left.print
coch(n,left,right)
right.print


Measured memory_bytes: 6944
def main():
    import sys
    from collections import deque
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    N, M = [int(x) for x in input().strip().split()]
    H = [int(x) for x in input().strip().split()]
    F = [False] * N
    G = [deque([]) for _ in range(N)]
    for m in range(M):
        a, b = [int(x) for x in input().strip().split()]
        G[a-1].append(b)
        G[b-1].append(a)

    ans = 0
    for n in range(N):
        t = 1
        for nm in G[n]:
            if H[nm-1] >= H[n]:
                t = 0
                break
        ans += t

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 84340
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);

using ll = int64_t;
using ull = uint64_t;

using namespace std;

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

    string s;
    cin >> s;
    cout << (s == "ABC" ? "ARC" : "ABC");

    return 0;
}


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

int main(){
  
  int64_t N, K;
  cin >> N >> K;
  
  int64_t check = N / K;
  int64_t ans = N - K*check;
  
  cout << min(ans, abs(ans-K)) << "\n";
  
}

Measured memory_bytes: 256
H,W = map(int,input().split())
mod = 10**9 + 7
grid_0 = [0] * (W+1)
grid_0[1] = 1

for n in range(1,H+1):
  grid_1 = [0] * (W+1)
  for i, j in enumerate(input(), 1):
    if j == ".":
      grid_1[i] = (grid_0[i] + grid_1[i-1]) % mod
  grid_0 = grid_1

print(grid_0[-1])

Measured memory_bytes: 9188
import sys

read = sys.stdin.buffer.read


def main():
    N, K, *AF = map(int, read().split())
    A = AF[:N]
    F = AF[N:]

    A.sort()
    F.sort(reverse=True)

    def is_ok(cost):
        k = 0
        for i in range(N):
            if A[i] * F[i] > cost:
                k += (A[i] * F[i] - cost + F[i] - 1) // F[i]
        return k <= K

    ok = pow(10, 12)
    ng = -1
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid

    print(ok)
    return


if __name__ == '__main__':
    main()


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, k, result = 0;
  cin >> n >> k;
  if(n % k == 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << 1 << endl;
	return 0;
}

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

int main(){
    ll n,ans=2;
    cin>>n;
    if(n==2) ans=1;
    for(ll k=2;k*k<=n;k++){
        ll m=n;
        while(m>=k) m%k?m%=k:m/=k;
        if(m==1) ans++;
        if((n-1)%k==0&&k*k!=(n-1) ) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
K, N = map(int, input().split())
A = list(map(int, input().split()))

distance = []

A.sort()

distance.append(A[0] + (K - A[N-1]))

for i in range(N-1) :
  distance.append(A[i+1] - A[i])
  
print(K - max(distance))

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    vector<bool> s(200100); //1とi
    vector<bool> t(200100); //iとn がつながってる
    bool ok=false;
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        if(a==1) s[b] = true;
        if(b==n) t[a] = true;
    }
    for(int i=1; i<=n; i++){
        if(s[i] == true && t[i] == true) ok=true;
    }
    if(ok) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	int y1_nokori = A - B;

	if (y1_nokori <= C) {
		cout << C - y1_nokori << endl;
	}
	else {
		cout << 0 << endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>

int compare_int(const void *a, const void *b) {
    return *(int *) a - *(int *) b;
}

int main() {
    int a[3];
    std::cin >> a[0] >> a[1] >> a[2];
    qsort(a, 3, sizeof(int), compare_int);
    if (a[2] == (a[0] + a[1])) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=100010;
int n,m,a[maxn];
int calc(int l,int r,int x)
{
	return max(l,min(r,x));
}
int main()
{
    int X;
    scanf("%d%d",&X,&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    int L,R=X;
    int t=0,k=0,s=-1,x=0;
    int time,A;
    scanf("%d",&m);
    for(int i=1;i<=m;i++)
	{
        scanf("%d%d",&time,&A);
        while(k<n&&a[k+1]<=time)
		{
            int dif=s*(a[k+1]-t);
            L=calc(0,X,L+dif);
            R=calc(0,X,R+dif);
            s*=-1;
            x+=dif;
            t=a[k+1];
            k++;
        }
        int T=time-t;
        A=calc(L,R,A+x);
        A=calc(0,X,A+s*T);
        printf("%d\n",A);
    }
    return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char A,B,C,D;
    char op1,op2,op3;
    int result;
    int record1,record2;
    scanf("%c%c%c%c",&A,&B,&C,&D);
    getchar();
    for (op1=43; op1<=45; op1+=2)
    {
        result=0;
        if (op1==43)
        {
            result+=A+B-96;
        }
        else
        {
            result+=A-B;
        }
        record1=result;
        for (op2=43; op2<=45; op2+=2)
        {
            result=record1;
            if (op2==43)
            {
                result+=C-48;
            }
            else
            {
                result-=C-48;
            }
            record2=result;
            for (op3=43; op3<=45; op3+=2)
            {
                result=record2;
                if (op3==43)
                {
                    result+=D-48;
                }
                else
                {
                    result-=D-48;
                }
                if (result==7)
                {
                    printf("%c%c%c%c%c%c%c=7",A,op1,B,op2,C,op3,D);
                    exit(0);
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 128
import numpy as np

N, K = [int(item) for item in input().split()]
h =np.array([int(item) for item in input().split()])
# print(h.shape)
dp = np.full(N+K, 10**10+1, dtype='int64')
dp[0] = 0

for i in range(1, N):
    max1 = min(N, i+K)
    cost = abs(h[i:max1] - h[i-1])
    # print(cost.shape, dp[i:max1].shape)
    dp[i:max1] = np.minimum(dp[i:max1], dp[i-1] + cost)

    # print(dp)
print(dp[N-1])

Measured memory_bytes: 23080
N = gets.to_i
A = gets.split(' ').map(&:to_i).freeze
b=[nil]*N

for i in 0...N/2
  b[i] = A[N-i*2-1]
  b[N-1-i] = A[N-i*2-2]
end

if N%2 == 1
  b[N/2] = A.first
end

puts b.join(' ')


Measured memory_bytes: 25476
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-10, pi = acos(-1.0);

bool eq(ld a,ld b) {
  return (abs(a - b) < eps);
}
 // 内積
 ld dot(Point a, Point b) {
 return real(conj(a) * b);
 }
 // 外積
 ld cross(Point a, Point b) {
 return imag(conj(a) * b);
 }

int ccw (Point a, Point b, Point c){
  b-=a; c-=a;
  if (cross(b, c) > eps) return 0; // a,b,cが反時計周り
  if (cross(b, c) < -eps) return 1; // a,b,cが時計周り
  if (dot(b, c) < 0) return 2; // c,a,b順でon line
  if (norm(b) < norm(c)) return 3; // a,b,c順にon line
  return 4; // a,c,b順にon line
}


int main(){
  Point a,b,c;
  ld tmp[4];
  REP(i,4) cin >> tmp[i];
  a = Point(tmp[0],tmp[1]);
  b = Point(tmp[2],tmp[3]);
  int q;
  cin >> q;
  string rs[5]={"COUNTER_CLOCKWISE","CLOCKWISE","ONLINE_BACK","ONLINE_FRONT","ON_SEGMENT"};
  REP(i,q){
    cin >> tmp[0] >> tmp[1];
    c = Point(tmp[0],tmp[1]);
    cout << rs[ccw(a,b,c)] << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

void shellSort(vector<int> v, int N);
vector<int> insertionSort(vector<int> v, int N, int g, int &c);

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

	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v.at(i);
	}

	shellSort(v, N);
}

void shellSort(vector<int> v, int N) {
	int cnt = 0;
	int m;
	vector<int> h;
	for (int i = 0; i < N; i=3*i+1) {
		h.push_back(i);
	}
	reverse(h.begin(), h.end());
	m = h.size();

	int& c = cnt;
	for (int i = 0; i < m; i++) {
		v = insertionSort(v, N, h.at(i), c);
	}

	cout << m << endl;

	for (int i = 0; i < h.size(); i++) {
		cout << h.at(i);
		if (i == h.size() - 1) {
			cout << endl;
		}
		else {
			cout << ' ';
		}
	}

	cout << cnt << endl;

	for (int i = 0; i < N; i++) {
		cout << v.at(i) << endl;
	}
}

vector<int> insertionSort(vector<int> v, int N, int g, int &c) {
	for (int i = g; i < N; i++) {
		int n = v.at(i);
		int j = i - g;
		while (j >= 0 && v.at(j) > n) {
			v.at(j+g) = v.at(j);
			j = j - g;
			c++;
		}
		v.at(j + g) = n;
	}

	return v;
}


Measured memory_bytes: 18516
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n,k,s=0;
    cin>>n>>k;
    long long int arr[n];
    for(long long int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(long long int i=0;i<n-k;i++){
        s=s+arr[i];
    }
    cout<<s;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int s;
        s = sc.nextInt();
        int h = s / 3600;
        int m = s % 3600 / 60;
        s = s % 60;
        System.out.println(h + ":" + m + ":" + s);
    
    }
}


Measured memory_bytes: 26228
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  set<int> p1;
  set<int> pn;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    if(a==1||b==1)
      p1.insert(max(a,b));
    if(a==n||b==n)
      pn.insert(min(a,b));
  }
  bool f=0;
  for(int x:p1)
    f=(pn.count(x)?1:f);
  cout<<(f?"POSSIBLE":"IMPOSSIBLE")<<endl;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int X,N;
bool check[102];

int main(){

	scanf("%d %d",&X,&N);

	for(int i = 0; i <= 101; i++){

		check[i] = false;
	}

	int tmp;
	for(int i = 0; i < N; i++){

		scanf("%d",&tmp);
		check[tmp] = true;
	}

	int minimum = BIG_NUM,ans;
	for(int i = 0; i <= 101; i++){
		if(check[i])continue;

		if(abs(X-i) < minimum){

			minimum = abs(X-i);
			ans = i;
		}
	}

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

	return 0;
}


Measured memory_bytes: 3836
/* It's a shot in the dark
 				But I will make it */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=1000000000;

bool cmp(pair<int,int> a, pair<int,int> b){
	return a.second<b.second;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
       map<string,ll>mp;
       mp["AC"]=0;
       mp["WA"]=0;
       mp["TLE"]=0;
       mp["RE"]=0;
       int n;
       cin >>n;
       for(int i=0;i<n;i++){
       	string s;
       	cin >>s;
       	mp[s]++;
	   }
	   cout <<"AC x "<<mp["AC"]<<"\n";
	   cout <<"WA x "<<mp["WA"]<<"\n";
	   cout <<"TLE x "<<mp["TLE"]<<"\n";
	   cout <<"RE x "<<mp["RE"]<<"\n";
	   
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL

int main(){
  ll N;
  cin >> N;
  vll a(N);
  bool flag = false;
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
    if(a.at(i) % 2 == 1) flag = true;
  }
  cout << (flag? "first": "second") << endl;

}

Measured memory_bytes: 1024
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics


# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===


data1 = getInputListInt()
n = data1[0]
k = data1[1]
data2 = getInputListInt()

tmp = n - 1
ans = math.ceil(tmp/(k-1))

print(ans)

Measured memory_bytes: 23292
n=int(input())
a=list(map(int,input().split()))
a=a[::-1]
b=list(map(int,input().split()))
b=b[::-1]

#print(a,b)

result=0

for i in range(n):
  if a[i]-b[i]>0:
    result+=b[i]
    b[i]=0
  else:
    result+=a[i]
    b[i]-=a[i]
  if b[i]>0:
    if a[i+1]-b[i]>0:
      result+=b[i]
      a[i+1]-=b[i]
    else:
      result+=a[i+1]
      a[i+1]=0

print(result)

Measured memory_bytes: 18468
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string.h>
#define pi acos(-1)
using namespace std;
int main()
{
    int n,m,a[107][107],b[107],c[107];
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            cin>>a[i][j];
    memset(c, 0, sizeof(c));
    for(int j=1;j<=m;j++)cin>>b[j];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            c[i]+=b[j]*a[i][j];
    for(int i=1;i<=n;i++)cout<<c[i]<<endl;
    return 0;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

ll power(ll a,ll b)
{
    ll r = 1;
    while(b>0)
    {
        if(b%2 == 1)
        {
             r = r*a;
        }
        a = a*a;
    }
    return r;
}


ll n;
vector < pair<ll,ll> > vec[100005];
ll flg[100005];

void solve(ll index,ll color)
{
    flg[index] = color;
    for(auto v:vec[index])
    {
        if(flg[v.first]!=-1)continue;
        if(v.second % 2 == 0)
        {
            solve(v.first,color);
        }
        else{
            solve(v.first,1-color);
        }
    }
}

int main()
{	
    std::ios_base::sync_with_stdio(0);
	  cin.tie(0);
	  cout.tie(0);
    
    cin>>n;
    for(ll i=1;i<n;i++)
    {
        ll a,b,c;
        cin>>a>>b>>c;

        vec[a].push_back({b,c});
        vec[b].push_back({a,c});
    }
    memset(flg,-1,sizeof(flg));
    
    solve(1,0);

    for(ll i=1;i<=n;i++)
    {
        cout<<flg[i]<<endl;
    }
}

Measured memory_bytes: 15488
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(1e17+100)
#define N 1000005

int lpf[N];

void least_prime_factor()
{
    for(int i=1;i<N;i++)
        lpf[i] = i;

    for(int i=2;i<N;i++)
        if(lpf[i]==i)
            for(int j=i*2;j<N;j+=i)
                if(lpf[j]==j)
                    lpf[j] = i;
}

int power(int a,int m1)
{
    if(m1==0)return 1;
    else if(m1==1)return a;
    else if(m1==2)return (1LL*a*a)%mod;
    else if(m1&1)return (1LL*a*power(power(a,m1/2),2))%mod;
    else return power(power(a,m1/2),2)%mod;
}


// Driver code to test above functions
int32_t main()
{
    
 
   
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;

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

    least_prime_factor();

    map<int, int> prime_factor;

    for(int i=0;i<n;i++)
    {
        int temp = a[i];
        map<int, int> single_number;
        while(temp>1)
        {
            int x = lpf[temp];
            single_number[x]++;
            temp /= x;
        }
        if(i==0)
            prime_factor = single_number;
        else
        {
            for(auto x:single_number)
                prime_factor[x.first] = max(x.second, prime_factor[x.first]);
        }
    }

    int ans = 0, lcm = 1;

    for(auto x:prime_factor)
        lcm = (lcm * power(x.first, x.second))%mod;

    for(int i=0;i<n;i++)
        ans = (ans + (lcm * power(a[i], mod-2))%mod)%mod;


    cout << ans;

    return 0;
    
} 






































































































 

Measured memory_bytes: 8832
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = Integer.parseInt(sc.next());
        sc.close();
        //嬉しさ1000の合計
        int happy500 = 1000 * (X / 500);
        //残高を計算
        X -= 500 * (X / 500);
        //嬉しさ5の合計
        int happy5 = 5 * (X / 5);
        //嬉しさの最大値を出力a
        System.out.println(happy500 + happy5);
    }
}

Measured memory_bytes: 23636
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
bef = -2
sum = 0
for i in range(N):
  #print(A[i]-1,B[A[i]-1])
  sum += B[A[i]-1]
  if bef+1 == A[i]:
    sum+=C[A[i]-2]
    #print("c",C[i-2])
  bef = A[i] 

print(sum)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;

int main()
{
	int n;
	cin >> n;
	vector<pair<int, int>> p(n);
	rep(i, n)
	{
		int a, b;
		cin >> a >> b;
		p[i] = make_pair(b, a);
	}
	sort(ALL(p));
	int t = 0;
	rep(i, n)
	{
		if (t + p[i].second <= p[i].first)
		{
			t += p[i].second;
		}
		else
		{
			co("No");
			return 0;
		}
	}
	co("Yes");
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a,b,c;
  cin >> a>>b>>c;
  
  if (a*b*c==175 && a+b+c==17 && a*a+b*b+c*c==99) {
  cout << "YES" << endl; 
  return 0;
  }
  
  cout << "NO" << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 10000000
int arr[MAX];
int ans[MAX];

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

    int n;
    cin>>n;
  //  int arr[n];

    for(int i=1;i<=n-1;i++)
    {
        cin>>arr[i];
    }
    for(int i=1;i<=n-1;i++)
    {
        //if(arr[i]==)
        ans[arr[i]]++;
    }
     for(int i=1;i<=n;i++)
    {
        cout<<ans[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 5140
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if (i)*500+(j)*100+(k)*50 == X:
        count += 1
      else:
        pass
print(count)

Measured memory_bytes: 3060
#include <cstdio>

int g[120000];
int i,n;
long long l,r;

int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
		scanf("%d",&g[i]);
	l=r=2;
	for (i=n;i>0;i--)
	{
		if (r/g[i]==(l-1)/g[i])
		{
			printf("-1");
			return 0;
		}
		l=((l-1)/g[i]+1)*g[i];
		r=r/g[i]*g[i]+g[i]-1;
	}
	printf("%lld %lld",l,r);
	return 0;
}

Measured memory_bytes: 512