akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Scanner;
class Main{


	static final int MOD = 1000000007;


	static int ans = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		
		//方針
		//数字とindexをpairとかで持っておき、数字ソート
		//loop
		//大きい順に、自分より大きい数字を一つ含む時の左と右の候補を計算
		//Treesetに自分のindexを入れる
		//loop
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 1;
		int num = a;
		while(num < b){
			ans++;
			num += a-1;
		}
		if(b == 1){
			ans = 0;
		}
		System.out.println(ans);


	}


	static void sieve(ArrayList<Long> list){
		int n = 50000000;
		boolean[] is_prime = new boolean[n+1];
		int[] prime = new int[n];
		for(int i= 0;i <=n;i++){
			is_prime[i] = true;
		}
		list.add((long) 1);
		for(int i = 2;i <= n;i++){
			if(is_prime[i]){
				list.add((long)i);
				for(int j = 2*i;j <= n;j+=i){
					is_prime[j] = false;
				}
			}
		}



	}




	static int upperbond(int k,int min,int[] data){		//kより小さい最大の値をdataの中から探し、返す二分探索
		int max = data.length;
		//		if(min == data.length-1){
		//			if(data[min] > k){
		//				return min;
		//			}
		//		}

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}

		return max;
	}

	static int lowerbond(int k,int min,int[] data){		//kより大きい最小の値をdataの中から探し、返す二分探索
		int max = data.length;

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}
		return min;
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}

class Town{
	int index;
	int x ;
	int y;
	public Town(int index,int x,int y) {
		this.index = index;
		this.x = x;
		this.y = y;
		// TODO 自動生成されたコンストラクター・スタブ
	}


}


class Edge extends ArrayList<P>{

}

class P{
	int to;
	long cost;
	P(int to,long cost){
		this.to = to;
		this.cost = cost;
	}
}

class Pair implements Comparable{
	int from;
	int end;
	public Pair(int from,int end) {
		this.from = from;
		this.end = end;
		// TODO 自動生成されたコンストラクター・スタブ
	}

	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   otherpair.from - from;
	}








}






Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <limits.h>

using namespace std;

int main(){
    long long int spending[5];
    long long int n;
    cin >> n;
    for(int i=0; i<5; ++i){
        cin >> spending[i];
    }

    long long int city[6] = {0};
    city[0] = n;

    // calculate
    int far_city = 0;
    long long int time_count = 0;
    while(city[5] == 0){
        for(int cur_city = far_city; cur_city >= 0; --cur_city){
            if(cur_city != 5){
                if(city[cur_city] > spending[cur_city]){
                    city[cur_city+1] += spending[cur_city];
                    city[cur_city] -= spending[cur_city];
                    if(cur_city+1 > far_city) far_city = cur_city+1;
                }else if(city[cur_city] != 0){
                    city[cur_city+1] += city[cur_city];
                    city[cur_city] = 0;
                    if(cur_city+1 > far_city) far_city = cur_city+1;
                }
            }
            
        }
        /*
        // check p in every city
        for(int i=0; i<6; ++i){
            cout << city[i] << " ";
        }
        cout << endl;
        */
        time_count += 1;
    }

    long long int last_p = 0;
    if ( (n - city[5])%city[5] != 0){
        last_p = (n - city[5])/city[5];
        last_p += 1;
    }else{
        last_p = (n - city[5])/city[5];
    }

    cout << time_count+last_p << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  double x[3],y[3],s=0,z,a[3];
  char cc;
  cin>>x[0]>>cc>>y[0]>>x[1]>>cc>>y[1];
  for(int i=1;cin>>x[i%2+1]>>cc>>y[i%2+1];i++){
    z=0;
    for(int i=0;i<3;i++)a[i]= sqrt((x[i%3]-x[(i+1)%3])*(x[i%3]-x[(i+1)%3])+(y[i%3]-y[(i+1)%3])*(y[i%3]-y[(i+1)%3])),z+=a[i];
    z/=2;s += sqrt(z*(z-a[0])*(z-a[1])*(z-a[2]));
  }
  printf("%.7f\n",s);
}

Measured memory_bytes: 0
n = gets.to_i
dic = Hash.new(0)
order = Array.new(n)
for i in 0..(n-1)
  order[i] = gets.split(" ")
end
for i in 0..(n-1)
  if order[i][0] == "insert"
    dic[order[i][1]] = 1
  else
    if dic[order[i][1]] == 1
      puts "yes"
    else
      puts "no"
    end
  end
end

Measured memory_bytes: 244748
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for ( auto blockTime = make_pair(chrono::high_resolution_clock::now(), true);blockTime.second;\
debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
#define li long long int
#define ld long double
#define eb push_back
#define pb pop_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define size(a) a.size()
#define rev(a) reverse(a.begin(),a.end())
#define len(a) a.length()
#define f first
#define s second
#define sort(a) sort(a.begin(),a.end())
#define vli vector<li>
#define vvli vector<vli >
#define pli pair<li,li>
#define vpli vector<pli>
#define inp(t) li t;cin>>t; while(t--)
using namespace std;
const li mod = 1e9+7;
#define MAXN 1000005 

li power(li a, li b) { a%=mod; li ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}

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

li lcm(li a,li b)
{
    return ((a*b)/__gcd(a,b));
}

bool check(li n,li k)
{
  if(!((n-k)%2))
    return true;
  else
    return false;
}
void solve()
{
    li n;
    cin>>n;

    vli v(n);
    rep(i,0,n)
    cin>>v[i];

    li max = v[0];

    li ans = 0;
    for(li i=1;i<n;i++)
    {
      if(v[i]<=max)
      {
        ans+=(max-v[i]);
      }
      else
      {
        max = v[i];
      }
    }

    cout<<ans<<endl;

} 

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

    solve();

    return 0;
}

Measured memory_bytes: 4748
#include <iostream>

using namespace std;

int main()
{
  int n,x,y;
  cin >> n >> x >> y;
  int ans=0;
  for(int i=0; i<n; ++i)
  {
    int u,v;
    cin >> u >> v;
    if (u>=x && v>=y) ans++; 
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd, floor
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from decimal import *
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

t = input().split()
a, b = int(t[0]), Decimal(t[1])
ans = int(a * b)
print(ans)

Measured memory_bytes: 72880
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];

  set<int> s;
  rep(i, n) s.insert(p[i]);
  int ans = -inf;
  FOR(i, -300, 300) {
    if (s.find(i) != s.end()) continue;
    if (abs(ans - x) > abs(i - x)) {
      ans = i;
    }
  }
  cout << ans << '\n';

  




  
  return 0;
}


Measured memory_bytes: 3664
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::VecDeque;

fn main() {
    input!{
        n: usize,
        es: [(usize1, usize1)],
        qs: [(usize1, usize, usize)]
    }
    let mut g = vec![vec![]; n];
    for &(a, b) in &es {
        g[a].push(b);
        g[b].push(a);
    }
    let mut ds = vec![0; n];
    let mut col = vec![0; n];
    for &(v, d, c) in qs.iter().rev() {
        bfs(v, d, c, &g, &mut ds, &mut col);
    }
    for &c in &col {
        println!("{}", c);
    }
}

fn bfs(r: usize, d: usize, c: usize, g: &Vec<Vec<usize>>, ds: &mut Vec<usize>, col: &mut Vec<usize>) {
    let mut q = VecDeque::new();
    q.push_back((r, d));
    while let Some(s) = q.pop_front() {
        if ds[s.0] > s.1 {
            continue;
        }
        ds[s.0] = s.1 + 1;
        if col[s.0] == 0 {
            col[s.0] = c;
        }
        if s.1 == 0 {
            continue;
        }
        for &v in &g[s.0] {
            q.push_back((v, s.1 - 1));
        }
    }
}


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

int main()
{
    string i;
    cin >> i;
    if((i[0] == i[1] && i[1] == i[2]) || (i[1] == i[2] && i[2] == i[3]))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

typedef long long ll;

int main(){
  ll X; cin >> X;
  vector<bool> p(2 * X + 1, false);
  for(ll i = 2; i <= 2 * X; i++){
    if(p[i]) continue;
    for(ll j = i + i; j <= 2 * X; j += i){
      p[j] = true;
    }
  }
  ll cnt = X;
  while(p[cnt]) cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
int main()
{
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    if(S==U){
        A--;
    }else{
        B--;
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
main(){
  string d="IVXLCDM",s;
  int k[]={1,5,10,50,100,500,1000},a,b;
  while(cin>>s){
    int ans=0;
    for(int i=0;i<s.size();i++){      
      a=b=0;
      for(int j=0;j<7;j++){
	if(s[i]==d[j])a=k[j];
	if(s[i+1]==d[j])b=k[j];
      }
      if(a<b){
	ans+=b-a;
	i++;
      }
      else ans+=a;
    }  
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1188
x, y=map(int, input().split())

res=2019

x_q=x//2019
#x_mod=x%2019
#y_q=y//2019
#y_mod=y%2019

#if x_mod>0 or y_mod>0:
#	res=0
#else:

y_mod=min(y,2019*(x_q+1))

for i in range(x, y_mod):
	for j in range(i+1,y_mod+1):
		res=min(res,(i*j)%2019)

print(res)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
 
using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;
ll G[1919][1919];
ll tmp[1919][1919];
ll op[1919][1919];
ll H, W;
int main(){

    ll H, W;
    cin >> H >> W;
    //入力
    for(ll i = 0; i < H; i++){
        for(ll j = 0; j < W; j++){
            char S; cin >> S;
            if(S == '#') G[i+2][j+2] = 1;
            else G[i+2][j+2] = 0;
        }
    }

    //最短経路
    for(ll i = 2; i < H+2; i++){
        for(ll j = 2; j < W+2; j++){
            //cout << G[i][j] ;
            if(i == 2 && j == 2){
                if(G[i][j] == 1) op[i][j] = 1;
                continue;
            }else if(i == 2 && j != 2){
                //G[i][j] += G[i][j-1];
                if(G[i][j] !=  G[i][j-1] && G[i][j] == 1) op[i][j] = op[i][j-1]+1;
                else op[i][j] = op[i][j-1];
            }else if(i != 2 && j == 2){
                if(G[i][j] !=  G[i-1][j] && G[i][j] == 1) op[i][j] = op[i-1][j]+1;
                else op[i][j] = op[i-1][j];
            }else{
                ll t1 = op[i][j-1];
                if(!(G[i][j] == 0 && G[i][j-1] == 1)){
                    t1 += G[i][j]^G[i][j-1];
                }
                ll t2 = op[i-1][j];
                if(!(G[i][j] == 0 && G[i-1][j] == 1)){
                    t2 += G[i][j]^G[i-1][j];
                }
                op[i][j] = min(t1, t2);
                //if(G[i-1][j] !=G[i][j-1])
                //G[i][j] += min(G[i-1][j],G[i][j-1]);
            }               
        }
        //cout << endl;
    }

    cout << op[H+1][W+1] << endl;

}

Measured memory_bytes: 2816
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const ll MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;




int main(void){

    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)fin("bust");
    else fin("win");

}

Measured memory_bytes: 256
#include <iostream>

int main(void) {
  int N;
  float num;
  std::cin >> N;
  if (N % 2 == 0) {
    num = N / 2;
  }
  else {
    num = N / 2 + 1;
  }
  float den = N;
  std::cout << num/den;
  return 0;
}

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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define scan(n)         scanf("%d",&n)
#define mod             1000000007
#define maxsz           200001
#define int             ll

using namespace std;

vector<int> ans;

void solve(vector<int> vec[],int ind,vector<int> skills,int n,int m,int x,int sum){
    bool done=true;
    for(int i=0;i<m;i++){
        if(skills[i]<x){
            done=false;
            break;
        }
    }
    if(done){
        ans.push_back(sum);
        return;
    }

    if(ind>=n)return;

    solve(vec,ind+1,skills,n,m,x,sum);
    for(int i=1;i<=m;i++){
        skills[i-1]+=vec[ind][i];
    }
    solve(vec,ind+1,skills,n,m,x,sum+vec[ind][0]);
}

signed main(){
    int n,m,x;cin>>n>>m>>x;
    vector<int> vec[n];
    for(int i=0;i<n;i++){
        int c;cin>>c;
        vec[i].push_back(c);
        for(int j=0;j<m;j++){
            int aj;cin>>aj;
            vec[i].push_back(aj);
        }
    }
    vector<int> skills(m,0);
    solve(vec,0,skills,n,m,x,0);
    if(ans.empty()){
        cout<<-1<<endl;
    } else {
        sort(ans.begin(),ans.end());
        cout<<ans[0]<<endl;
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int64_t int

using namespace std;

vector <int> paths[100001];
bool hav_visit[100001];
int dp[100001];

void initialise(){
    memset(dp, -1, sizeof(dp));

}

int dfs(int s){
    if(dp[s]!=-1) return dp[s];
    for(int i=0;i<paths[s].size();i++){
        dp[s]=max(dp[s],1+dfs(paths[s][i]));
    }
    return dp[s];
}

int main(){
    int n, m;
    cin >> n >> m;
    int x, y;
    for(int i=0;i<m;i++){
        cin >> x >> y;
        paths[x].push_back(y);
    }
    initialise();
    int maxi=0;
    for(int i=0;i<=n;i++){
        maxi=max(maxi, dfs(i));
    }
    if(m!=0 && n!=0) cout << maxi+1;
    else cout << maxi;
}


Measured memory_bytes: 8192
#!/usr/bin/env python3
import sys
import functools
from math import factorial
from operator import mul

MOD = 10**9 + 7  # type: int

def solve(N: int, K: int):
    facts = [1] * (N+1)
    for i in range(2, N+1):
        facts[i] = facts[i-1] * (i)

    def C(n: int, r: int):
        upper = facts[n]
        lower = facts[r] * facts[n-r]
        return (upper // lower) % MOD

    for i in range(1, K+1):
        a = C(N-K+1, i)
        b = C(K-1, i-1)
        print((a*b) % MOD)
    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
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 6244
package main

import (
	"bufio"
	"fmt"
	"os"
)

type Edge struct {
	Source, Target, Cost int
}

const Inf = 1 << 60

func main() {
	N, M, P := ReadInt(), ReadInt(), ReadInt()
	edges := make([]*Edge, M)
	for i := 0; i < M; i++ {
		edges[i] = &Edge{
			Source: ReadInt() - 1,
			Target: ReadInt() - 1,
			Cost:   P - ReadInt(),
		}
	}
	d := make([]int, N)
	for i := 0; i < N; i++ {
		d[i] = Inf
	}
	d[0] = 0
	// ベルマンフォード ゴールまでの経路に負閉路があればd[N-1]が-Infになる
	for i := 0; i < 2*N; i++ {
		for _, edge := range edges {
			if d[edge.Source] == Inf {
				continue
			}
			newD := d[edge.Source] + edge.Cost
			if newD < d[edge.Target] {
				d[edge.Target] = newD
				if i >= N-1 {
					d[edge.Target] = -Inf
				}
			}
		}
	}
	if d[N-1] == -Inf {
		fmt.Println(-1)
	} else {
		fmt.Println(Max(0, -d[N-1]))
	}
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 2336
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
 
int main(){
  LL x,y;
  cin >> x >> y;
  LL ans=1LL<<60;
  LL tmp=0;
  LL res=0;
  LL act=x;
  LL react=-x;
  if(x<=y) ans=min(ans,y-x);
  if(-x<=y) ans=min(ans,y+x+1);
  if(x <=-y) ans=min(ans,-y-x+1);
  if(-x <= -y) ans=min(ans,-y+x+2);
  cout << ans;
  }

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

using namespace std;

#define PB push_back
#define MP make_pair
#define FOR( i , n ) for( int i = 0; i < (n); i++ )
#define FORR( i , n ) for( int i = ( n - 1 ); i >= 0 ; i-- )
#define DB( x ) cout << #x << " = " << x << endl;
#define OUT( a , n ) for( int J = 0; J < (n); J++ )cout<< (a)[J] << " \n"[J == (n) - 1 ]
#define WAIT cout << flush , system("PAUSE");
#define CONTAINS(a, x) ((a).find(x) != (a).end())
#define endl '\n'

typedef pair<int, int> pii;
typedef long long ll;

#define y1 _skjbgerge

const int N = 1e5 + 100;
vector<pii> g[N];
int n;
ll dist[N];

void dfs(int u , ll d , int p = -1){
	dist[u] = d;

	for(auto pp : g[u]){
		ll w = pp.second;
		int v = pp.first;
		if(v != p){
			dfs(v , d + w, u);
		}
	}
}
int main()
{
	ios::sync_with_stdio( 0 );
	cin.tie( 0 );

	cin >> n;
	for(int i = 0; i < n - 1; i++ ){
		int u , v ,w;
		cin >> u >> v >> w;
		g[u].push_back({v , w});
		g[v].push_back({u , w});
	}

	int q , k;
	cin >> q >> k;
	dfs(k, 0);

	while(q--){
		int u , v;
		cin >> u >> v;
		cout << dist[u] + dist[v] << endl;
	}

	return 0;
}


Measured memory_bytes: 12800
Num = int(input())
S = list(str(Num))
power = len(S)-1
ans = 0
for i in range(2**power):
    if i == 0:
        sum = Num
    else:
        P = list(format(i, "b").zfill(power))
        sum, temp = 0, int(S[0])
        for j in range(len(P)):
            if P[j] == "0":
                temp = temp*10 + int(S[j+1])
            else:
                sum += temp
                temp = int(S[j+1])
        sum += temp
    ans += sum
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Deque;
import java.util.LinkedList;
  
class Main {
    public static void main(String[] args) throws IOException {
        Deque<Integer> lnk=new LinkedList<Integer>();
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        for(int i=0;i<n;i++){
            String s=br.readLine();
                          
            if(s.equals("deleteFirst"))lnk.remove();
            else if(s.equals("deleteLast"))lnk.removeLast();
            else{ 
            	if(s.startsWith("insert"))lnk.addFirst(Integer.parseInt(s.substring(7)));
            else if(s.startsWith("delete")) lnk.remove(Integer.parseInt(s.substring(7)));
            }  
        }StringBuilder stb=new StringBuilder(Integer.toString(lnk.poll()));
        for(Integer i:lnk)stb.append(" "+i);
        System.out.println(stb);}
    
    }

Measured memory_bytes: 140916
#include <iostream>
#include <string>

void DisableIOSync() {
	std::cin.tie(0);
	std::cout.tie(0);
	std::ios::sync_with_stdio(false);
}
int main() {
	DisableIOSync();

	std::string str;
	std::getline(std::cin, str);
	std::cout << str[0] << str.length()-2 << *(str.end()-1) << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
using namespace std;
/// khodaya komak kon
/// ya navid navid
const int N=2e5+100;
vector <int> g[N];
ll ans[N];
ll dfs(ll v,ll p){
    ll cnt=0;
    for (int i=0;i<g[v].size();i++){
        ll u=g[v][i];
        if (u==p){
            continue;
        }
        dfs(u,v);
        cnt^=ans[u]+1;
    }
    ans[v]=cnt;
}
int32_t main(){
    ll n;
    cin >> n;
    for (int i=0;i<n-1;i++){
        ll u,v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(1,1);
    if (ans[1]){
        cout << "Alice" << endl;
    }
    else{
        cout << "Bob" << endl;
    }
}


Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  i64 ans = 0;
  auto solve = [&](auto rec, int l, int r, i64 acc) -> void {
    i64 x = 0;
    for (int i = l; i < r; ++i) {
      x = 10 * x + i64(s[i] - '0');
    }

    if (r == int(s.size())) {
      ans += acc + x;
      return;
    }

    rec(rec, l, r + 1, acc);

    rec(rec, r, r + 1, acc + x);
  };
  solve(solve, 0, 1, 0LL);
  cout << ans << '\n';
}


Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


signed main() {
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	cout << (a + b + 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


class RSQ(object):
    INT_MAX = 2**31 - 1

    def __init__(self, nn, init_val=0):
        self.val = [init_val] * (nn+1)
        self.n = 1
        while self.n < nn:
            self.n *= 2
        self.dat = [init_val] * ((2 * self.n)-1)

    def update(self, k, a):
        # A[k]???a?????´??°?????????????????°???????????¨?????´??°
        self.val[k] = a
        k += (self.n - 1)
        self.dat[k] = a

        while k > 0:
            k = (k - 1) // 2        #  ??????index??????
            self.dat[k] = self.dat[k * 2 + 1] + self.dat[k * 2 + 2]

    def add(self, k, a):
        self.val[k] += a
        self.update(k, self.val[k])

    def query(self, a, b, k, l, r):
        # [a, b)???????°????????±??????? (0????????§b???????????????)
        # ??????????????¨?????????query(a, b, 0, 0, n)?????¢??§??????????????????k, l, r???????????????????????´??°?????????
        if r <= a or b <= l:        #  ?????????????????§??¨??????????????????
            return RSQ.INT_MAX
        if a ==l and r == b:
            return self.dat[k]           #  ???????????°???????????????????????§????????°????????¨??????????????????????°?????????????????????????
        else:
            mid = (l+r) // 2
            if b <= mid:
                return self.query(a, b, k*2+1, l, (l+r)//2) #  ????????°????????????????°????
            elif a >= mid:
                return self.query(a, b, k*2+2, (l+r)//2, r) #  ????????°????????????????°????
            else:
                vl = self.query(a, mid, k*2+1, l, mid)
                vr = self.query(mid, b, k*2+2, mid, r)
                return vl + vr


    def find(self, s, t):
        return self.query(s, t+1, 0, 0, self.n)


def main(args):
    n, q = map(int, input().split(' '))

    rq = RSQ(n+1)
    for _ in range(q):
        com, x, y = map(int, input().split(' '))
        if com == 0:
            rq.add(x, y)
        elif com == 1:
            res = rq.find(x, y)
            print(res)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 13916
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;


int main(){
    int N;
    string S;
    cin >>N>>S;
    vi ST(N);
    rep(i,N){
        if(S[i]=='(') {
            if(i==0){
                ST[0] =-1;
            }
            ST[i]=ST[i-1]-1; 
        }
        else {
            if(i==0){
                ST[0] =1;
            }
            ST[i]=ST[i-1]+1;
        }
    }
    int end =ST[N-1];
    sort(all(ST));
    int M = max(ST[N-1],0);
    rep(i,M){
        S = "("+S;
    } 
    rep(i,M-end){
        S = S+")";
    }
    cout <<S<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff { ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;

typedef long long int ll;
 ll  p=1e9+7; 

 int  main() {
        ff;
       
       string s;
       cin>>s;
       
       if(s=="ABC"){
           cout<<"ARC"<<endl;
       }else{
           cout<<"ABC"<<endl;
       }
       
    
       
      
    return 0;
}


Measured memory_bytes: 3656
def f(n, s):
    md = 10 ** 9 + 7
    dp = [1] * n
    for i in range(n - 1):
        if s[i] == "<":
            L = dp[0]
            for dpi in range(1, n - i - 1):
                dp[dpi] = L = (dp[dpi] + L) % md
            dp = dp[:-1]
        else:
            R = dp[-1]
            for dpi in range(n - i - 2, 0, -1):
                dp[dpi] = R = (dp[dpi] + R) % md
            dp = dp[1:]
    print(dp[0])


n = int(input())
s = input()
f(n, s)


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

ll c = 0;
ll n;

string itos(ll val){
  char b[100];
  sprintf(b, "%lld", val);
  return string(b);
}

int dfs(ll k) {
  if(k > n) return 0;
  string s = itos(k);
  ll is753 = 0;
  bool has3 = false, has5 = false, has7 = false;
  REP(i, s.length()) {
    if (s[i] == '3') {
      has3 = true;
    }
    if (s[i] == '5') {
      has5 = true;
    }
    if (s[i] == '7') {
      has7 = true;
    }
  }
  if(has3 && has5 && has7) {
    is753 = 1;
  }

  return dfs(k*10 + 3) + dfs(k*10 + 5) + dfs(k*10 + 7) + is753;
}

int main()
{
  cin >> n;
  cout << dfs(0) << endl;

}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,b,c,m;
    scanf("%d %d %d",&a,&b,&c);
    if(1<=a && a<=9 && 1<=b && b<=9 && 1<=c && c<=9)
    {
       m=100*a+10*b+c;
       if(m%4==0) printf("\nYES");
        else printf("\nNO");
    }

    return 0;
}

Measured memory_bytes: 1700
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
B = [list(map(int, input().split())) for _ in range(N)]

A_sorted = sorted(A, key=lambda x: x[1], reverse=True)
B_sorted = sorted(B, key=lambda x: x[0])


def func():
    global A_sorted, B_sorted
    count = 0
    for b in B_sorted:
        a = None
        A_sorted_cp = A_sorted[:]
        while True:
            if len(A_sorted_cp) == 0:
                break
            a = A_sorted_cp.pop(0)
            if a[0] < b[0] and a[1]<b[1]:
                count += 1
                A_sorted.pop(A_sorted.index(a))
                break
    return count
            
    

print(func())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define MAX 1000000
#define INF ((ll)1 << 60)
using namespace std;
using ll = long long;

//int A,B,C,D,N,M;
ll A,B,C,D,N,M,K;
ll cost[MAX][3];
ll dp[MAX][3];

void solve() {
  for(int i = 1; i< N; i++) {
    for(int j = 0; j <= 2; j++) {
      for(int k = 0; k <= 2; k++) { //kは前
        if(j == k) continue;
        dp[i][j] = max(dp[i][j], dp[i-1][k] + cost[i][j]);
      }
    }
  }
}



int main() {
  ios::sync_with_stdio(false);
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> cost[i][0] >> cost[i][1] >> cost[i][2];
    dp[i][0] = dp[i][1] = dp[i][2] = 0;
  }

  dp[0][0] = cost[0][0];
  dp[0][1] = cost[0][1];
  dp[0][2] = cost[0][2];

  solve();
  ll m = max(dp[N-1][0], dp[N-1][1]);
  m = max(m, dp[N-1][2]);
  cout << m;


  
  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n;
	cin >> n;

	rep(i,n){
		int t,x,y;
		cin >> t >> x >> y;

		if(x+y > t || (x+y)%2 != t%2) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int H,W = 0;
		while(true) {
			H = sc.nextInt();
			W = sc.nextInt();			
			if (H == 0 && W == 0) {
				return;
			}
			
			for (int i = 0; i < H; i ++) {
				for (int j = 0; j < W; j++) {
					if (	(i == 0) || (i == H-1) || (j == 0) || (j == W-1))  {
						System.out.printf("#");
					} else {
						System.out.printf(".");
					}
				}
				System.out.printf("%n");
			}
			System.out.printf("%n");
		}
	}

}


Measured memory_bytes: 61108
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define tisic 47
#define soclose 1e-8
#define patkan 9
#define ff first
#define ss second
using uint = unsigned int;
using cat = long long;
using dbl = long double;
constexpr dbl pi = 3.14159265358979323846;
using namespace std;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

template <typename T>
T abs(T x) {return (x < 0) ? -x : x;}

cat pw(cat a, cat e, cat mod) {
	if(e <= 0) return 1;
	cat x = pw(a, e/2, mod);
	x = x * x % mod;
	return (e&1) ? x * a % mod : x;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(10);
	cat mod = 1000000007;
	int N, A, B;
	cin >> N >> A >> B;
	if(A > B) swap(A, B);
	if(A == 1) {
		cat ans = 1;
		for(int i = 0; i < N; i++) ans = 2 * ans % mod;
		cout << ans << "\n";
		return 0;
	}
	vector<cat> cnt_segB(B, 0);
	cnt_segB[1] = 1;
	for(int i = 2; i < B; i++) {
		cnt_segB[i] = cnt_segB[i-1];
		for(int j = A; j <= i-2; j++) cnt_segB[i] += cnt_segB[i-1-j];
		cnt_segB[i] %= mod;
	}
	vector<cat> cnt_segB_bor(B, 0);
	cnt_segB_bor[0] = 1;
	for(int i = 1; i < B; i++) {
		cnt_segB_bor[i] = cnt_segB_bor[i-1];
		for(int j = A; j <= i-1; j++) cnt_segB_bor[i] += cnt_segB_bor[i-1-j];
		cnt_segB_bor[i] %= mod;
	}
	vector<cat> dp_segA(N+1, 0), dp_segB(N+1, 0);
	dp_segB[0] = dp_segA[0] = 1;
	for(int i = 1; i <= N; i++) {
		for(int j = 1; j <= min(i, A-1); j++) dp_segA[i] += dp_segB[i-j];
		dp_segA[i] %= mod;
		cat mod2 = mod * mod * 4;
		for(int j = 1; j <= min(i-1, B-1); j++) {
			dp_segB[i] += dp_segA[i-j] * cnt_segB[j];
			if(dp_segB[i] >= mod2) dp_segB[i] -= mod2;
		}
		if(i < B) dp_segB[i] += cnt_segB_bor[i];
		dp_segB[i] %= mod;
	}
	cat ans = 1;
	for(int i = 0; i < N; i++) ans = 2 * ans % mod;
	ans -= dp_segA[N] + dp_segB[N];
	for(int i = 1; i < B; i++) ans -= dp_segA[N-i] * (cnt_segB_bor[i] - cnt_segB[i]) % mod;
	ans %= mod;
	if(ans < 0) ans += mod;
	cout << ans << "\n";
}

// look at my code
// my code is amazing


Measured memory_bytes: 3732
<?php
$n = trim(fgets(STDIN));
$result = "";
for($i = 0; $i < strlen(strval($n)); $i++){
	if(strcmp("1", substr(strval($n), $i, 1)) == 0){
		$result = $result . "9";
	}elseif(strcmp("9", substr(strval($n), $i, 1)) == 0){
		$result = $result . "1";
	}
}

printf("%s", $result);
?>

Measured memory_bytes: 3576
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define pii pair<int,int>
#define pip pair<int,pii>
#define ppi pair<pii,int> 
#define ppp pair<pii,pii>
#define pb push_back
#define N 200003
#define inf (ll)1e9+11
#define warmup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7;
deque<char> dq;

signed main()
{
    warmup
    
    string s;
    cin>>s;
    int q,f,t,i,n=s.size();
    for(i=0;i<n;++i)
        dq.pb(s[i]);
    
    char c;
    cin>>q;
    bool fl=0;
    while(q--)
    {
        cin>>t;
        if(t==1)
            fl^=1;
        else
        {
            ++n;
            cin>>f>>c;
            if(f-fl==1)
                dq.push_front(c);
            else
                dq.pb(c);
        }   
    }   
    while(n--)
    {
        if(fl)
            cout<<dq.back(), dq.pop_back();
        else
            cout<<dq.front(), dq.pop_front();
    }   
    
    return 0;
}


Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    sort(all(h));
    reverse(all(h));
    if (n <= k){
        cout << 0 << endl;
        return 0;
    }
    long long int ans = 0;
    repr(i, k, n) ans += h[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e16;
const double EPS=1e-8;
const ll mod = 1000000007;
int64_t powm(int64_t a,int64_t b){//a^bを求める
	if(b==0){
		return 1;
	}else{
		int64_t temp = powm(a,b/2);
		temp = temp * temp;
		if(b%2==1){
			temp = temp * a;
		}
		return temp%13;
	}
}

int main(){
	string s;
	cin>>s;
	reverse(s.begin(),s.end());
	ll **d = new ll*[s.size()];
	for(ll i1=0;i1<s.size();i1++){
		d[i1] = new ll[13];
		for(ll i2=0;i2<13;i2++){
			d[i1][i2]=0;
		}
	}
	if(s[0]=='?'){
		for(ll i1=0;i1<=9;i1++){
			d[0][i1]=1;
		}
	}else{
		d[0][s[0]-'0']=1;
	}
	for(ll i1=1;i1<s.size();i1++){
		ll mod = powm(10,i1);
		if(s[i1]=='?'){
			for(ll i2=0;i2<=9;i2++){
				for(ll i3=0;i3<13;i3++){
					d[i1][(i2*mod+i3)%13]=(d[i1][(i2*mod+i3)%13]+d[i1-1][i3])%1000000007;
				}
			}
		}else{
			for(ll i2=0;i2<13;i2++){
				d[i1][((s[i1]-'0')*mod+i2)%13]=(d[i1][((s[i1]-'0')*mod+i2)%13]+d[i1-1][i2])%1000000007;
			}
		}
	}
	cout<<d[s.size()-1][5]<<endl;


}


Measured memory_bytes: 12032
#include <stdio.h>
#define NIL -1
#define MAX 100
#define INF 100000

void prime(void);

int n;
int d[MAX], w[MAX][MAX], pi[MAX];

int main()
{
  int i, j, sum=0;

  scanf("%d", &n);

  for(i=0; i<n; i++){
	for(j=0; j<n; j++){
	  scanf("%d", &w[i][j]);
	}
  }

  prime();
  for(i=0; i<n; i++) sum+=d[i];

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

  return 0;
}


void prime()
{
  int u, v, min;
  int color[MAX];
  int i, j;

  for(u=0; u<n; u++){
	d[u] = INF;
	pi[u] = NIL;
	color[u] = 0;
  }

  d[0] = 0;

  for(i=0; i<n; i++){
	min = INF;
	for(j=0; j<n; j++){
	  if(color[j] == 1) continue;
	  if(d[j] <= min){
		u=j;
		min = d[j];
	  }
	}

	for(v=0; v<n; v++){
	  if(w[u][v] == -1) continue;
	  if(color[v] == 1) continue;
	  if(w[u][v] < d[v]){
		pi[v] = u;
		d[v] = w[u][v];
	  }
	}
	color[u] = 1;
  }
}

Measured memory_bytes: 640
let s = read_line ()
let n, fs, i = Array.(String.length s, make 26 false, ref 0)
let f s n = Printf.printf "%s%c\n" s (Char.chr (n + 97)); exit 0
let _ = String.(Char.(iter (fun c -> fs.(code c - 97) <- true; incr i) s; if n < 26 then (i := 0; while fs.(!i) do incr i done; f s !i);
  for j = n - 1 downto 0 do i := code s.[j] - 96; while !i < 26 && fs.(!i) do incr i done; if !i < 26 then f (sub s 0 j) !i; fs.(code s.[j] - 97) <- false done; print_endline "-1"))

Measured memory_bytes: 384
#include <stdio.h>

long long gcd(long long a, long long b){
	if(!(a % b)) return b;
	return gcd(b,a % b);
}

int main(int argc, char const *argv[]){
	int n;
	long long ans,t;

	scanf("%d %lld", &n, &ans);
	for(int i = 0;i < n - 1; ++i){
		scanf("%lld", &t);
		ans = ans / gcd(ans,t) * t;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
	char c = getchar(); int w = 1; int x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
	x *= w;
	return x;
}
inline ll readll() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
	x *= w;
	return x;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
ll n,W;
const int MAXN=110;
ll w[MAXN],v[MAXN],dp[100100];
int main(){
	cin>>n>>W;
	for(int i=1;i<=n;i++){
		cin>>w[i]>>v[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=W;j>=w[i];j--){
			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	cout<<dp[W]<<endl;
	return 0;
}
/* stuff to remember
	* int overflow, array bounds
	* special cases (n=1? n=0?)
	* do something instead of nothing and stay organized
	* USE STATIC ARRAYS
	* DEFINING ARRAYS BEFORE main()
	* DO NOT DEFINE ARRAYS IN main()
	* USE INT INSTEAD OF LL,NOTICE THE MLE
*/

Measured memory_bytes: 1024
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

int main() {
  int h, w;
  cin >> h >> w;
  string a[101];

  rep(i, h) {
    cin >> a[i];
  }

  rep(i, w+2) {
    cout << '#';
  }
  cout << endl;

  rep(i, h) {
    cout << '#';
    rep(j, w) {
      cout << a[i][j];
    }
    cout << '#' << endl;
  }

  rep(i, w+2) {
    cout << '#';
  }
  cout << endl;

  return 0;
}

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

int main()
{
	int member{}, point{}, quiz_cout{};
	cin >> member >> point >> quiz_cout;

	vector<int>ans_cnt(member,0);
	int ans_mem{};

	for (size_t i = 0;i < quiz_cout;++i) {
		cin >> ans_mem;
		ans_cnt.at(ans_mem-1)++;
	}

	for (size_t i = 0;i < member;++i) {
		if (point-quiz_cout+ans_cnt.at(i)>0) {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}
	}





}

Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
	int a, b, c, max = 0;
	scanf("%d%d%d", &a, &b, &c);
	max = (a>=b) ? a : b;
	max = (c>=max) ? c : max;
	printf("%d\n", max * 10 + a + b + c - max);
	
	return 0;
}

Measured memory_bytes: 128