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

class Main{

    int INF = Integer.MAX_VALUE;
    int n, m, s, g;
    int[][] dist, seigen;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            n = sc.nextInt(); m = sc.nextInt();
            if(n==0 && m==0) break;
            s = sc.nextInt()-1; g = sc.nextInt()-1;
            dist = new int[n][n];
            seigen = new int[n][n];
            for(int i=0; i<n; i++) Arrays.fill(dist[i], INF);
            for(int i=0; i<m; i++){
                int x = sc.nextInt()-1, y = sc.nextInt()-1;
                int d = sc.nextInt(), c = sc.nextInt();
                dist[x][y] = d; dist[y][x] = d;
                seigen[x][y] = c; seigen[y][x] = c;
            }
            System.out.println(dijkstra());
        }
    }

    class P{
        int pos, bpos, speed;
        double cost;
        P(int pos, int bpos, int speed, double cost){
            this.pos = pos;
            this.bpos = bpos;
            this.speed = speed;
            this.cost = cost;
        }
    }

    String dijkstra(){
        PriorityQueue<P> q = new PriorityQueue<P>(10, new Comparator<P>(){
                public int compare(P p1, P p2){
                    if(p1.cost<p2.cost) return -1;
                    else if(p1.cost>p2.cost) return 1;
                    return 0;
                }
            });
        q.add(new P(s, -1, 1, 0));
        boolean[][][] v = new boolean[n][n][10000];

        while(q.size()>0){
            P pp = q.poll();
            int pos = pp.pos, bpos = pp.bpos, speed = pp.speed;
            double cost = pp.cost;

            if(pos==g && speed==1) return String.valueOf(cost);
            if(bpos==-1){
                for(int i=0; i<n; i++) v[pos][i][speed] = true;
            }else{
                if(v[pos][bpos][speed]) continue;
                v[pos][bpos][speed] = true;
            }

            for(int i=0; i<n; i++){
                if(i==pos || i==bpos || dist[pos][i]==INF) continue;
                for(int j=-1; j<=1; j++){
                    int nspeed = speed + j;
                    if(nspeed<=0 || seigen[pos][i]<nspeed) continue;
                    if(bpos==-1 && nspeed!=1) continue;
                    q.add(new P(i, pos, nspeed, cost+(double)dist[pos][i]/nspeed));
                }
            }

        }

        return "unreachable";
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 195380
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  int t[100001],x[100001],y[100001];
  t[0] = x[0] = y[0] = 0;
  for(int i=0;i<N;++i)
    {
      cin>>t[i+1]>>x[i+1]>>y[i+1];

    }
  bool can=true;
  for(int i=0;i<N;i++){
    int dt=t[i+1]-t[i];
    int dxy=abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
    if(dt<dxy){can=false;}
  if(dt%2 != dxy%2){can=false;}

  }
  if(can)  cout<<"Yes"<<endl;

  else cout<<"No"<<endl;
}



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


#define SIZE 11

int POW[SIZE];
int N,K;
ll dp[205][SIZE][SIZE][1024]; //dp[最後に処理した数][最後に処理した数-左下の数][左下の数-その上の数][上の行の状態] = 場合の数
ll M;

int calc_state(int base_number,int work[2][SIZE]){

	int base_col = 0;
	if(work[1][1] != 0){

		base_col = 1;
	}

	int ret = 0;

	for(int col = base_col+1; col <= K; col++){
		if(work[0][col] == 0)break;

		ret += POW[base_number-work[0][col]];
	}

	return ret;
}

ll recursive(int last_number,int left_under_diff,int left_vertical_diff,int top_state){

	if(dp[last_number][left_under_diff][left_vertical_diff][top_state] != -1){

		return dp[last_number][left_under_diff][left_vertical_diff][top_state];
	}

	int work[2][SIZE];

	for(int row = 0; row < 2; row++){
		for(int col = 0; col < SIZE; col++){
			work[row][col] = 0;
		}
	}

	//左下の数
	int left_under = last_number-left_under_diff;
	work[1][0] = left_under;
	//その上の数
	work[0][0] = left_under-left_vertical_diff;

	//状態の復元
	int top_index = 0;
	for(int diff = (K-1); diff >= 0; diff--){

		if(top_state & (1 << (diff))){

			work[0][1+top_index++] = last_number-diff;
		}
	}

	if(last_number == 2*N){

		if(left_under == 2*N && top_index == 0){

			return 1;
		}else{

			return 0;
		}
	}

	ll ret = 0;

	bool FLG = true;

	//左下更新
	if(top_index == 0){ //上段の列数==下段の列数

		if(work[0][0] != 0 && last_number+1-work[0][0] > K){

			FLG = false;
		}

	}else{
		if(left_under == 0){

			work[1][1] = last_number+1;
			int next_state = calc_state(last_number+1,work);
			if(next_state >= POW[K]){

				//BUG

			}else{
				ret = recursive(last_number+1,0,work[1][1]-work[0][1],next_state);
				work[1][1] = 0;
			}

		}else{

			int tmp = min(work[1][0],work[0][1]);
			if((last_number+1)-tmp > K){

				FLG = false; //差がKより大きくなるので不可
			}else{

				work[1][1] = last_number+1;
				int next_state = calc_state(last_number+1,work);
				if(next_state >= POW[K]){

					//BUG

				}else{
					ret = recursive(last_number+1,0,work[1][1]-work[0][1],next_state);
					work[1][1] = 0;
				}
			}
		}
	}

	//上の行の右端更新
	if(FLG == true && top_index <= K-1 && (last_number+1-work[0][top_index] <= K)){

		work[0][1+top_index] = last_number+1;

		int next_state = calc_state(last_number+1,work);
		if(next_state >= POW[K]){

			//BUG

		}else{

			ret += recursive(last_number+1,last_number+1-left_under,left_vertical_diff,next_state);
			ret %= M;
		}
	}

	return dp[last_number][left_under_diff][left_vertical_diff][top_state] = ret;
}

int main(){

	POW[0] = 1;
	for(int i = 1; i < SIZE; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%d %d %lld",&N,&K,&M);

	for(int num = 0; num <= 2*N; num++){
		for(int diff = 0; diff <= K; diff++){
			for(int diff_2 = 0; diff_2 <= K; diff_2++){
				for(int state = 0; state < POW[K]; state++){

					dp[num][diff][diff_2][state] = -1;
				}
			}
		}
	}

	printf("%lld\n",recursive(0,0,0,0)%M);

	return 0;
}



Measured memory_bytes: 197784
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++){
            A[i] = sc.nextInt();
        }
        String status = "APPROVED";
        for (int i = 0; i < N; i++) {
            if (A[i] % 2 == 1) continue;

            if (A[i] % 3 != 0 && A[i] % 5 != 0) {
                status = "DENIED";
                break;
            }
        }
        System.out.println(status);
    }
}


Measured memory_bytes: 21588
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=rdsp;foreach(ref j;v.tupleof)pick(r,j);}}

void main()
{
  int n, m; readV(n, m);
  struct R { int a, b; }
  R[] r; readS(m, r);

  r.sort!"a.b<b.b";

  auto x = 0, s = 0;
  foreach (ri; r)
    if (ri.a > x) {
      ++s;
      x = ri.b-1;
    }

  writeln(s);
}


Measured memory_bytes: 4092
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <string.h>
#include <string>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <typeinfo>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<double, double> pd;
typedef pair<ll, ll> pl;

int dp[10001];
int damage[1001];
int cost[1001];

int main()
{
  int h, n;
  scanf("%d %d", &h, &n);
  
  for(int i = 0; i < n; i++)
    scanf("%d %d", &damage[i], &cost[i]);
  
  for(int i = 1; i <= h; i++)
    dp[i] = INT_MAX;
  
  for(int i = 0; i < h; i++)
  {
    if(dp[i] == INT_MAX)
      continue;
    for(int j = 0; j < n; j++)
    {
      if(i+damage[j] < h)
        dp[i+damage[j]] = min(dp[i+damage[j]], dp[i] + cost[j]);
      else
        dp[h] = min(dp[h], dp[i] + cost[j]);
    }
  }
  
  printf("%d\n", dp[h]);
  
  return 0;
}


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

using namespace std;
typedef long long ll;

ll b[2010][2010], ans = 1e18;

int main(void) {
  ll n, x;
  cin >> n >> x;

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

  for (int i = 0; i < n; i++) {
    ll sum = i * x;
    for (int j = 0; j < n; j++) {
      if (i) {
        b[i][j] = min(b[i - 1][j], a[(j - i + n) % n]);
      } else {
        b[i][j] = a[j];
      }
      sum += b[i][j];
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;

  return 0;
}


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

int power(int x, int p){
    return (x-p) * (x-p);
}

int compar(const int *val1, const int *val2) {
    if ( *val1 < *val2 ) {
        return -1;
    } else if ( *val1 == * val2 ) {
        return 0;
    } else {
        return 1;
    }
}

int main(){
    int i, p;
    int N, X[100] = {}, S[101] = {};
    scanf("%d", &N);
    for(i=0; i<N; i++){
        scanf("%d", &X[i]);
    }
    S[0] = 999999;
    for(p=1; p<=100; p++){
        for(i=0; i<N; i++){
            S[p] += power(X[i], p);
        }
    }

    qsort(S, 100, sizeof(int), (int (*)(const void *, const void *))compar);
    printf("%d\n", S[0]);
    

    return 0;
}

Measured memory_bytes: 128
parseInt(x) = parse(BigInt, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function eval(a::Tuple{Int,Int},b::Tuple{Int,Int})
	if a[2]<b[2]
		1
	elseif a[2]==b[2]
		0
	else
		-1
	end
end

function hpush(h::Array{Tuple{Int,Int},1},x::Tuple{Int,Int})
	push!(h,x)
	if length(h) > 1
		l = length(h)
		k = l>>1
		while eval(x,h[k])==1&&k>=1
			tmp = h[k]
			h[k] = x
			h[l] = tmp
			k = max(k>>1,1)
			l = l>>1
		end
	end
end

function hpop(h::Array{Tuple{Int,Int},1})
	x = h[1]
	z = pop!(h)
	if !isempty(h)
		h[1] = z
		k = 1
		l = length(h)
		while k <= l
			if 2*k>l
				break
			elseif 2*k+1>l
				if eval(h[2*k],z)>=0
					break
				else
					tmp = h[2*k]
					h[2*k] = z
					h[k] = tmp
					k = 2*k
				end
			else
				if eval(z,h[2*k])>=0&&eval(z,h[2*k+1])>=0
					break
				else
					t = eval(h[2*k],h[2*k+1])>=0?2*k:2*k+1
					tmp = h[t]
					h[t] = z
					h[k] = tmp
					k = t
				end
			end
		end
	end
	x
end

function main()
	k = readline() |> parseInt
	e = [Tuple{Int,Int}[] for i in 1:k]
	for i in 0:k-1
		push!(e[i+1],((i+1)%k+1,1))
		push!(e[i+1],((10*i)%k+1,0))
	end
	dis = -ones(Int, length(e))
	h = Array{Tuple{Int,Int},1}()
	push!(h,(2,0))
	while !isempty(h)
		v,w = hpop(h)
		dis[v] = dis[v]<0?w:min(dis[v],w)
		for i in 1:length(e[v])
			if dis[e[v][i][1]]<0　|| dis[e[v][i][1]]>w+e[v][i][2]
				dis[e[v][i][1]] = w+e[v][i][2]
				hpush(h,(e[v][i][1],w+e[v][i][2]))
			end
		end
	end
	println(dis[1]+1)
end

main()

Measured memory_bytes: 175044
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    tree = [[] for _ in range(n)]
    for _ in range(m):
        l, r, d = map(int, input().split())
        tree[l - 1].append([r - 1, d])
        tree[r - 1].append([l - 1, -d])

    def dfs(v, p):
        for u, d in tree[v]:
            if u == p:
                continue
            else:
                if dist[u] == f_inf:
                    dist[u] = dist[v] + d
                    dfs(u, v)
                else:
                    if dist[u] != dist[v] + d:
                        print("No")
                        exit()

    dist = [f_inf] * n
    for i in range(n):
        if dist[i] == f_inf:
            dist[i] = 0
            dfs(i, -1)

    print("Yes")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 153236
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (long long r = (aa)-1; r >= (bb); r--)
 
using namespace std;
 
 int main(){
    int h, w;
    cin >> h >> w;
    char ta[h][w];
    rep(i,0,h){
        rep(j,0,w){
            cin >> ta[i][j];
        }
    }
    int ma = 0;
    rep(i,0,h){
        rep(j,0,w){
            if(ta[i][j]=='.'){
                vector <vector<bool> >v(h, vector<bool>(w,0));
                queue <pair<pair <int, int>, int> > q;
                q.push({{i,j},0});
                while(!q.empty()){
                    auto num = q.front();
                    auto ch = num.first;
                    q.pop();
                    
                    if(v[ch.first][ch.second]){
                        continue;
                    }
                    ma = max(ma, num.second);
                    v[ch.first][ch.second]=1;
                    if(ch.first+1<h && ta[ch.first+1][ch.second]=='.'){
                        q.push({{ch.first+1, ch.second}, num.second+1});
                    }
                    if(ch.second+1<w && ta[ch.first][ch.second+1]=='.'){
                        q.push({{ch.first, ch.second+1}, num.second+1});
                    }
                    if(ch.first-1>-1 && ta[ch.first-1][ch.second]=='.'){
                        q.push({{ch.first-1, ch.second}, num.second+1});
                    }
                    if(ch.second-1>-1&& ta[ch.first][ch.second-1]=='.'){
                        q.push({{ch.first, ch.second-1}, num.second+1});
                    }
                }

            }
        }
    }
    cout << ma << endl;
 }

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main(){
    int H, A;
    cin >> H >> A;
    cout << (H + A - 1) / A << endl;
}


Measured memory_bytes: 3636
import java.io.*;
import java.util.*;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Printer pr = new Printer(System.out);

		int n = sc.nextInt();
		int k = sc.nextInt();

		boolean[] ng = new boolean[10];
		for (int i = 0; i < k; i++) {
			ng[sc.nextInt()] = true;
		}

		out:
		for (int i = n; true; i++) {
			int tmp = i;
			while (tmp > 0) {
				if (ng[tmp % 10]) {
					continue out;
				}
				tmp /= 10;
			}

			pr.println(i);
			break;
		}

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 9556
#include<bits/stdc++.h>
#include<climits>
 
using namespace std;
 
#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()
 
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<int,int>> vpi;
 
const long long OO = 2e18;
const double pi=2*acos(0.0);
 
bool isprime(long long int a){
    if(a==1){
        return false;
    }
    for(int i=2;i*i<=a;i++){
        if(a%i==0){
            return false;
        }
    }
    return true;
} 

bool iscoprime(int a,int b){
    int i;
    for(i=2;i<=min(a,b);i++){
        if(a%i==0 && b%i==0){
            return false;
        }
    }
    return true;
}

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

int maxA(vi a){
    int m=0;
    for(int i=0;i<a.size();i++){
        m=max(m,a[i]);
    }
    return m;
}

int minA(vi a){
    int m=100000;
    for(int i=0;i<a.size();i++){
        m=min(m,a[i]);
    }
    return m;
}

vi freqN(vi a, int n){
    vi f(n);
    f={0};
    for(int i=0;i<a.size();i++){
        f[a[i]]++;
    }
    return f;
}

vi freqA(vi a){
    vi f(26);
    f={0};
    for(int i=0;i<a.size();i++){
        f[a[i]-'0']++;
    }
    return f;
}

bool mycomp(const pair<long int,long int>&p1 , const pair<long int,long int>&p2){
    if(p1.second < p2.second) return true;
    else if(p1.second==p2.second) return p1.first<p2.first;
    else return false;
}

unsigned int rightmostsetbit(unsigned int n){
    return n & -n;
}

bool cmp(pair<string,int>&p1 , pair<string,int>&p2){
    if(p1.second==p2.second) return p1.first<p2.first;
    return p1.second>p2.second;
}

int main(){
fast;
cin.tie(0);
lld a,b;
cin>>a>>b;
lld g=__gcd(a,b);
lld lcm=(a*b)/g;
cout<<lcm<<endl;

}

Measured memory_bytes: 256
#!/usr/bin/env python3
# coding: utf-8
"""
about module
"""


def main():
    _, m = map(int, input().split())
    a = list(map(int, input().split()))
    counter = 0
    border = sum(a)/(4*m)
    for v in a:
        if v >= border:
            counter += 1
    if counter >= m:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int maxn = 1e8;
int a, b, c, cnt;
int main()
{
	scanf("%d%d%d", &a, &b, &c);
		int x, y, z;
		while(cnt <= maxn){
			if(a & 1 || b & 1 || c & 1)break;
			x = a, y = b, z = c;
			a = (y + z) / 2;
			b = (x + z) / 2;
			c = (x + y) / 2;
			cnt++;
		}
		if(cnt <= maxn)printf("%d\n", cnt);
		else printf("-1\n");
}

Measured memory_bytes: 128
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << std::endl;
#else
#define DEBUG(message)
#endif

void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<char>> a(n, vector<char>(m, '.'));
  auto b = a;
  auto c = a;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    b[i][0] = '#';
    c[i][m - 1] = '#';
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '#') {
        b[i][j] = c[i][j] = '#';
      }
      if (i % 2 == 0 && j + 1 < m) {
        b[i][j] = '#';
      }
      if (i % 2 == 1 && j > 0) {
        c[i][j] = '#';
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << b[i][j];
    }
    cout << "\n";
  }
  cout << "\n";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << c[i][j];
    }
    cout << "\n";
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}


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

using namespace std;
typedef long long int ll;
bool check(ll fromtime,ll totime,ll fromx,ll fromy,ll tox,ll toy){
	ll dist,difftime;
	dist=abs(tox-fromx)+abs(toy-fromy);
	difftime=totime-fromtime;

	if(dist < difftime){

		if(dist%2==0 && difftime%2==0){
			return true;
		}else if(dist%2==1 && difftime%2==1){
			return true;
		}else{
			return false;
		}

	}else if(dist==difftime){
		return true;
	}else{
		return false;
	}



}



int main(){
	
	ll N;
	bool res;
	cin>>N;
	ll fromx=0;
	ll fromy=0;
	ll tox;
	ll toy;
	ll totime;
	ll fromtime=0;
	for(ll i=0;i<N;i++){
		cin>>totime>>tox>>toy;
		if(check(fromtime,totime,fromx,fromy,tox,toy)){
			res=true;
		}else{
			res=false;
			break;
		}
		fromx=tox;
		fromy=toy;
		fromtime=totime;
	}

	if(res==true){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
  long long int  n,i,l,r,haba;
  long long int a[200001],sum=0;
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
    a[i]-=i+1;
  }
  sort(a,a+n);
/*for(i=0;i<n;i++)
printf("%lld ",a[i]);*/
  l=0;
  haba=0;
  a[n]=a[n-1]+1;
  if(n%2==1)
    r=a[n/2];
  else
    r=(a[n/2]+a[n/2-1])/2;
  /*for(i=0;i<n;i++){
    if(a[l]!=a[i+1]){
      if(haba<i+1-l){
        haba=i+1-l;
        r=a[l];
        l=i+1;
      }
    }
  }*/
  for(i=0;i<n;i++){
    sum+=labs(a[i]-r);
  }
  printf("%lld\n",sum);
}

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

namespace ABC068A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            Console.WriteLine("ABC" + str);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
//#pragma comment(linker, "/STACK:1024000000,1024000000")
/* vim: set fdm=marker */
//{{{
#define __ return
int ATTENTION() {
	/* pls IGNORE this function and go down and HACK me
	 * read this AFTER contest
	 * this function is empty and it will not be called !
	 */

	http://codeforces.com/group/Pmz2A2x7ES
	/* I created a group there.
	 * I hope with the group, people can finish
	 * past contests, which is important for 
	 * increasing rating.
	 * I am still getting familiar with this function.
	 */
	 __ 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < 0) return gcd(-a, b);
	if(b < 0) return gcd( a,-b);
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}

ll qpow(ll a, ll n, ll mod) {
	a %= mod;
	ll ans = 1LL;
	while(n) {
		if(n & 1) ans = (ans*a % mod);
		a = (a*a % mod);
		n >>= 1;
	}
	return ans;
}

inline ll rev(ll a, ll p) {
	return qpow(a, p - 2, p);
}

#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define rep(x, st, en) for(int x = st; x < en; x++)
#define rer(x, st, en) for(int x = st; x >= en; x--)
#define pb push_back
#define mp make_pair
#define dbgm(msg, var) cerr<<#msg<<" "<<#var<<" = "<<var<<endl; 
#define dbg(var) cerr<<#var<<" = "<<var<<endl;
#define X first
#define Y second
// build prefix sum
template<typename T>
inline void BPS(T* DST, T* SRC, int N, int s = 0) {
	DST[s] = SRC[s];
	rep(i, 1, N) DST[s + i] = DST[s + i - 1] + SRC[s + i];
}
inline int in() { int x; cin>>x; return x; }
#ifdef ALNDBG
namespace alndbg {
	clock_t s, e;
}
#endif

inline void tic() {
#ifdef ALNDBG
	alndbg::s = clock();
#endif
}

inline void toc() {
#ifdef ALNDBG
	alndbg::e = clock();
	cerr<<1000.0 * (alndbg::e - alndbg::s) / CLOCKS_PER_SEC<<" ms"<<endl;
#endif
}



//}}}

// -------------------- Spliters ------------------------
// BFS求最短路小心vis可能访问过
const int maxn = 111;

int d[maxn];

int lis[maxn];

int main() {
	ios::sync_with_stdio(0);
  int n; cin>>n;
  rep(i,0,n) {
    cin>>d[i];
  }
  sort(d, d+n);
  int ans = n;
  rep(i,1,n) {
    if(d[i] == d[i - 1]) ans--;
  }
  cout<<ans<<endl;
	return 0;
}
// --USE C++11
// *-USE O2


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

int main(){
  int r,g,b,n;
  cin >>r >> g >> b >> n ;
  int ans=0;
  for(int i=0;i<=3000;i++){
    for(int q=0;q<=3000;q++){
      int as =n-r*i-q*g;
     if(as>=0 && as%b == 0){ans++;}
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int calc_a(int A, int B, int x, int y)
{
    return 100 * A * x + 100 * B * y;
}

int calc_b(int C, int D, int z, int w)
{
    return C * z + D * w;
}

int main()
{
    int A, B, C, D, E, F;
    int a, b;
    long double maxv = 0;
    int maxa, maxb;

    cin >> A >> B >> C >> D >> E >> F;

    for (int x = 0; x <= 1.0 * F / (100 * A) + 1; x++)
    {
        for (int y = 0; y <= 1.0 * F / (100 * B) + 1; y++)
        {
            for (int z = 0; z <= 1.0 * F / C + 1; z++)
            {
                for (int w = 0; w <= 1.0 * F / D + 1; w++)
                {
                    a = 100 * A * x + 100 * B * y;
                    b = C * z + D * w;
                    if (a == 0)
                    {
                        continue;
                    }
                    // if (a + b == 2634)
                    // {
                        // cout << a + b << " " <<  b << endl;
                    // }
                    if (a + b <= F && 100 * b <= a * E && 100.0L * b / (a + b) >= maxv)
                    {
                        maxv = 100.0L * b / (a + b);
                        maxa = a;
                        maxb = b;
                        // cout << x << " " << y << " " << z << " " << w << endl;
                    }
                }
            }
        }
    }

    cout << maxa + maxb << " " << maxb << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    string str;
    int sum = 0;
    cin >>  str;
    for(int i = 0; i < (int)str.size(); i++) 
    {
        if(str[i] == '+') {
            sum++;
        } else {
            sum--;
        }
    }

    cout << sum << endl;
    return 0;
}

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

int main() {
	int N, T;
	int min = 10000;
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		int c, t;
		cin >> c >> t;
		if (t <= T) {
			min = std::min(min, c);
		}
	}
	if (min == 10000) {
		cout << "TLE\n";
	} else {
		cout << min << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}




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

    
    ll N;
    cin >> N ;
    
    string ans="";
    
    while(N!=0){
        if(N%2 == 0){
            ans += '0';
            N /= (-2);
            cerr << "first " <<  N << endl;

        }
        else{
            ans += '1';
            if(N > 0) N/=(-2);
            else N = (N - 1)/(-2);
            cerr << "second" << N << endl;

        }
    }
    
    reverse(all(ans));
    if(ans=="") cout << 0 << endl;
    else cout << ans << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

int main(){
  int x;
  cin >> x;
  vector<int> kyu={400,600,800,1000,1200,1400,1600,1800,2000};
  int ans = 0;
  rep(i,9){
    for(int j=kyu[i];j<kyu[i+1];j++){
      //cout << j << ",";
      if(j <= x) ans = i;
    }
  }
  cout << 8-ans << endl;
}

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

#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol Mod=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r,q;
int a[55],b[55],c[55],d[55];
lol dfs(int hu,int i[15]){
  if(hu==n+1){
    int ans=0;
    for(int j=0;j<q;j++){
      if(c[j]==i[b[j]]-i[a[j]]) ans+=d[j];
    }
    //for(int j=1;j<=n;j++) cout <<' '<<i[j];
    //cout <<'\n'<<ans<<'\n';
    return ans;
  }
  int ans=0;
  hu++;
  for(int j=i[hu-1];j<=m;j++){
    i[hu]=j;
    chmax(ans,dfs(hu,i));
  }
  return ans;
}
  
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n>>m>>q;
  
  for(int i=0;i<q;i++){
    cin >>a[i]>>b[i]>>c[i]>>d[i];
  }
  int p[15];
  p[0]=1;
  cout <<dfs(0,p)<<'\n';
  return (0);
}


Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
using namespace std;
void read(int &x){
    char ch;bool ok;
    for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
    for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
#define rg register
const int maxn=1<<16;
int n,m,v[20][20], ans,in[maxn],f[maxn][20];
vector<int>d[20];
int main(){
    read(n),read(m);
    for(rg int i=1,x,y,z;i<=m;i++){
        read(x),read(y),read(z),v[x][y]=v[y][x]=z;
        ans+=z;
        d[x].push_back(y),d[y].push_back(x);
    }
    int tot=1<<n;
    for(rg int i=0;i<tot;i++){
        for(rg int j=1;j<=n;j++)
            if(!(i&(1<<(j-1)))&&!in[i|(1<<(j-1))]){
                int w=d[j].size(),sum=in[i];
                for(rg int k=0;k<w;k++)
                    if(i&(1<<(d[j][k]-1)))sum+=v[j][d[j][k]];
                in[i|(1<<(j-1))]=sum;
        }
    }
    memset(f,-1,sizeof f);
    f[1][1]=0;
    for(rg int i=0;i<tot;i++)
        for(rg int k=1;k<=n;k++){
            if(f[i][k]==-1)continue;
            if(i&(1<<(k-1))){
                for(rg int j=1;j<=n;j++)
                    if(!(i&(1<<(j-1)))&&v[k][j])
                        f[i|(1<<(j-1))][j]=max(f[i][k]+v[k][j],f[i|(1<<(j-1))][j]);
                int now=((tot-1)^i)|(1<<(k-1));
                for(rg int j=now;j;j=(j-1)&now)
                    if(j&(1<<(k-1)))f[i|j][k]=max(f[i][k]+in[j],f[i|j][k]);
            }
        }
    printf("%d\n",ans-f[tot-1][n]);
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define rd read()
char s[1001];
int a,b,c,d;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	return x*f;
}
int main() {
	int n=rd;
    gets(s);
    for(int i=0;i<strlen(s);i++)
    {   if(s[i]=='G')a=1;
		if(s[i]=='W')b=1;
		if(s[i]=='P')c=1;
		if(s[i]=='Y')d=1;
	}
int ans=a+b+c+d;
if(ans==4)cout<<"Four"<<endl;
else cout<<"Three"<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	K := nextInt()
	X := nextInt()

	left := max(-1000000, X-K+1)
	right := min(1000000, X+K-1)

	for i := left; i <= right; i++ {
		if i != left {
			fmt.Print(" ")
		}
		fmt.Print(i)
	}

	fmt.Println()
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


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

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



Measured memory_bytes: 3596
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

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



int main(){
  int a,b;cin>>a>>b;
  cout << a*b/2 << endl;
}


Measured memory_bytes: 256
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-26 20:59:51
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    if (w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;

    return 0;
}


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

void Main()
{
  ll N; string S;
  cin >> N; cin >> S;
  ll sum = 0;
  
  vector<int> rnum(N);
  vector<int> gnum(N);
  vector<int> bnum(N);
  rep(i,N) { rnum[i] = 0; gnum[i] = 0; bnum[i] = 0;
  }
  if (S[0] == 'R') rnum[0] = 1;
  else if (S[0] == 'G') gnum[0] = 1;
  else bnum[0] = 1;
  for (int i = 1; i < N; i++) {
    if ( S[i] == 'R') {
      rnum[i] = rnum[i-1] + 1;
      gnum[i] = gnum[i-1];
      bnum[i] = bnum[i-1];
    } else if (S[i] == 'G') {
      bnum[i] = bnum[i-1];
      gnum[i] = gnum[i-1] + 1;
      rnum[i] = rnum[i-1];
    } else {
      bnum[i] = bnum[i-1] + 1;
      gnum[i] = gnum[i-1];
      rnum[i] = rnum[i-1];
    }
  }
  
  for (int i = 0; i < N-2; i++) {
    char si = S[i];
    for (int j = i+1; j < N-1; j++) {
      char sj = S[j];
      if (sj != si) {
        if ((si == 'R' && sj == 'G') || (si == 'G' && sj == 'R')) {
          sum += bnum[N-1] - bnum[j];
          if (2*j-i < N) {
            if (S[2*j-i] == 'B') sum--;
          }
        } else if ((si == 'G' && sj == 'B') || (si == 'B' && sj == 'G')) {
          sum += rnum[N-1] - rnum[j];
          if (2*j-i < N) {
            if (S[2*j-i] == 'R') sum--;
          }
        } else if ((si == 'R' && sj == 'B') || (si == 'B' && sj == 'R')) {
          sum += gnum[N-1] - gnum[j];
          if (2*j-i < N) {
            if (S[2*j-i] == 'G') sum--;
          }
        }
        /*
        for (int k = j+1; k < N; k++) {
          char sk = S[k];
          if (sk != sj && sk != si && j-i != k-j) sum++;
        }
        */
      }
    }
  }
  cout << sum << endl;
}

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


Measured memory_bytes: 3700
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
  let n = read::<i64>();
  let mut x = vec![];
  let mut x2 = vec![];
  for _ in 0..n {
    let x_i = read::<i64>();
    x.push(x_i);
    x2.push(x_i);
  }

  x.sort();
  let center_s = x[(n / 2) as usize - 1];
  let center_l = x[(n / 2) as usize];

  for i in x2 {
    if i <= center_s {
      println!("{}", center_l);
    } else {
      println!("{}", center_s);
    }
  }
}



Measured memory_bytes: 11780
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
// #define mod  1000000007
#define N 100005
// #define MAX 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
const int inf = (int)1e18 + 10;
int a[N] , b[N];
signed main(){
  fast;
  int n  , ans = 0;
  cin >> n;
  for(int i = 0 ; i <=n ; i++)
    cin >> a[i];

  for(int j = 0 ; j< n ; j++)
     cin >> b[j];



   for(int i = 0 ; i < n ; i++){
        if(a[i] < b[i]){
          ans += a[i];
          b[i] -= a[i];
          a[i] = 0;
          if(a[i+1] < b[i] )
            ans += a[i+1] , a[i+1] = 0;
          else
            a[i+1] -= b[i] , ans += b[i];
        }
        else{
          ans += b[i];
        }
   }

   cout << ans << endl;

}	

Measured memory_bytes: 1792
using System;
using System.Linq;

class program
{
  static void Main(){
    var input=Console.ReadLine().Split(' ').Select(s=>int.Parse(s)).ToArray();
    var hoge=input[0]*input[1];
    var fuga=input[2]*input[3];
    Console.WriteLine(hoge > fuga ? hoge : fuga);
  }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
template<typename T>
struct Edge {
    int from, to;
    T cost;
    Edge(int from, int to, T cost) {
        this->from = from;
        this->to = to;
        this->cost = cost;
    }
};
bool operator == (Edge<int> e1, Edge<int> e2) {
    return e1.from == e2.from &&
            e1.to == e2.to &&
            e1.cost == e2.cost;
}
template<typename T>
using Edges = std::vector<Edge<T>>;
template<typename T>
using Graph = std::vector<Edges<T>>;
template<typename T>
std::vector<int> topological_sort(const Graph<T> &graph) {
    Graph<T> g = graph;
    int n = g.size();
    std::vector<int> res;
    std::queue<int> que;
    std::vector<int> in(n);
    std::vector<bool> used(n, false);
    for(int i=0;i<n;++i) {
        for(int j=0;j<(int)(g[i].size());++j) {
            in[g[i][j].to]++;
        }
    }
    for(int i=0;i<n;++i) {
        if(in[i] == 0) que.push(i);
    }
    if((int)(que.size()) == 0) res.push_back(-1);
    while(!que.empty()) {
        int now = que.front(); que.pop();
        if(used[now]) {
            res.clear();
            res.push_back(-1);
            break;
        }
        used[now] = true;
        res.push_back(now);
        for(int i=0;i<(int)(g[now].size());++i) {
            int next = g[now][i].to;
            if(in[next] == 1) {
                que.push(next);
        }
            in[next]--;
        }
    }
    return res;
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n, m; cin >> n >> m;
  Graph<int> g(n);
  for(int i=0;i<m;++i) {
    int u, v; cin >> u >> v;
    g[u].push_back(Edge<int>(u, v, 1));
  }
  auto ans = topological_sort(g);
  for(int i=0;i<n;++i) {
    cout << ans[i] << endl;
  }
}



Measured memory_bytes: 4772
#include <cstdio>
using namespace std;
int main(void){
  int i,n,m,x,count;
  char str[1000001];
 
  for( ; ; ){
    fgets(str,sizeof(str),stdin);
    sscanf(str,"%d %d",&m,&n);
    if(m == 0) break;
    count = 0;
    for(i=m; i<=n; i++){
      x = i; 
      for( ; ; ){
        if(x == 1){
          count++;
          break;}
        else if(x%2 == 0){
          x /= 2;}
        else if(x%3 == 0){
          x /= 3;}
        else if(x%5 == 0){
          x /= 5;}
        else
          break;
      }
    }
    printf("%d\n", count);
  }
  return 0;
}

Measured memory_bytes: 2576
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;


int main(){
	vector<ll> a,b,c;
	ll n;
	cin >> n;
	
	ll input;
	for(int i=0;i<n;i++){
		cin >> input;
		a.push_back(input);
	}
	for(int i=0;i<n;i++){
		cin >> input;
		b.push_back(input);
	}
	for(int i=0;i<n;i++){
		cin >> input;
		c.push_back(input);
	}
	
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	ll answer=0;
	for(int i=0;i<n;i++){
		vector<ll>::iterator A = lower_bound(a.begin(),a.end(),b[i]);
		vector<ll>::iterator C = upper_bound(c.begin(),c.end(),b[i]);
		ll low = A-a.begin();
		ll up = C-c.begin();
		answer += (low * (n - up));
	}
	
	cout << answer << endl;
	
	return 0;
}


Measured memory_bytes: 3316
hash = Hash.new
hash.store("a",gets.chomp)
hash.store("b",gets.chomp)
hash.store("c",gets.chomp)
trashCard = hash["a"][0]
hash["a"].slice!(0)
loop do
  break if hash[trashCard].length == 0
  tempTrashCard = hash[trashCard][0]
  hash[trashCard].slice!(0)
  trashCard = tempTrashCard
end
puts trashCard.upcase

Measured memory_bytes: 1788
N=int(input(""))

ar=[]
total=1
big=False
lion = False
A=N-1
ar = list(map(int, input().strip().split(' ')))

if 0 in ar:
      print("0")
      big=True
      lion=False
      
while big == False and lion == False:
      for i in range (0,N):
            total=ar[i]*total
            if i == A:
                  lion = True
            if total>(1000000000000000000):
                  big=True
                  lion=True
                  break

if big == False and lion == True:
      print(total)

if big == True and lion == True:
      print("-1")

Measured memory_bytes: 21648
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
long long n, a[100000], b;
int main() {
	cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; b += a[i]; }
	if (b % (n*(n + 1) / 2) != 0) { cout << "NO" << endl; return 0; }
	long long c = (b / (n*(n + 1) / 2));
	for (int i = 0; i < n; i++) {
		long long s = a[(i + 1) % n] - a[i];
		s *= -1; s += c;
		if (s < 0 || (s%n) != 0) { cout << "NO" << endl; return 0; }
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int A,B,X,nA,nB;
	
	scanf("%d %d %d",&X,&A,&B);
	
	nA = A-X;
	if(nA < 0){
		nA = -nA;
	}
	
	nB = B-X;
	if(nB < 0){
		nB = -nB;
	}
	
	if(nB < nA){
		printf("B\n");
	}
	else{
		printf("A\n");
	}
	
	return 0;
}



Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
try:
    from math import gcd
except Exception:
    from fractions import gcd
from collections import Counter

def solve(N: int, A: "List[int]"):
    tmp = [(i,c) for i, c in Counter(A).items() if 2 <= c]
    tmp = sorted(tmp, reverse=True)
    if 2 <= len(tmp):
        return (tmp[0][0] ** 2) if 4 <= tmp[0][1] else (tmp[0][0] * tmp[1][0])
    else:
        return 0


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, A)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26648