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

public class Main{ 
	
	static class FastReader{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

		int nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} 

		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 

		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	}

	public static void main(String[] args) 
	{ 
        FastReader sc = new FastReader(); 
        //PrintWriter out = new PrintWriter(System.out); 

        int n = sc.nextInt();
        int m = sc.nextInt();
        long mod = 1000000007L;
        char[][] arr = new char[n][m];
        long[][] dp = new long[n][m];

        for(int i=0;i<n;i++){
        	String line = sc.nextLine();
        	arr[i] = line.toCharArray();
		}
        
        for(int j=0;j<m;j++){
        	if(arr[0][j]=='#')
        		break;
        	dp[0][j] = 1;
        }

        for(int i=0;i<n;i++){
        	if(arr[i][0]=='#')
        		break;
        	dp[i][0] = 1;
        }


        for(int i=1;i<n;i++)
        	for(int j=1;j<m;j++){
        		if(arr[i][j]=='#')
        			continue;
        		dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
        	}

        System.out.println(dp[n-1][m-1]);
        
	}
}


Measured memory_bytes: 37892
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
float PHI = 1.6180339;
//const float  PI_F=3.14159265358979f;
#define MAX 100000 
#define endl "\n"    
//typedef long long float;
#define int long long
//#define float unsigned long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(9);

    int a,b,k;
    cin>>a>>b>>k;
    if(a>=k)
    {
        a=a-k;
        cout<<a<<" "<<b<<endl;
    }
    else if(a<k)
    {
        k=k-a;
        a=0;
        if(b>=k)
        {
            b=b-k;
            cout<<a<<" "<<b<<endl;
        }
        else
        {
            b=0;
            cout<<a<<" "<<b<<endl;
        }
    }

}

    
    

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    boolean isReverse = false;//反転中フラグ
    String s = sc.next();
    StringBuilder sb = new StringBuilder(s);//初期状態
    //最後頭にくっつけるグループとお尻にくっつけるグループを用意する
    StringBuilder sb1 = new StringBuilder("");
    StringBuilder sb2= new StringBuilder("");
    int Q = sc.nextInt();
    int tmp = 0;
    String tmpS;
    for(int i = 0;i<Q;i++){
      if(sc.nextInt()==1){
        isReverse = !isReverse;
      }else{
        tmp=sc.nextInt();
        tmpS=sc.next();
        if(isReverse&&tmp==1){//反転中∧頭につける⇔1番のお尻につける
          sb1.append(tmpS);
        }else if(isReverse&&tmp==2){//反転中∧お尻につける⇔2番のお尻につける
          sb2.append(tmpS);
        }else if(!isReverse&&tmp==1){//正常位∧頭につける⇔2番のお尻につける
          sb2.append(tmpS);
        }else{//正常位∧お尻につける⇔1番のお尻につける
          sb1.append(tmpS);
        }
      }
    }
    //反転回数が偶数ならば、2番をひっくり返したやつ+元の文字列+1番の順につける
    if(!isReverse){
      sb.append(sb1);//元の文字列+1番
      sb2.reverse();//2番反転
      sb2.append(sb);
    System.out.println(sb2);
    }else{
      //反転回数が奇数ならば、1番をひっくり返したやつ+元の文字列をひっくり返したやつ+2番の順につける
      sb.reverse();
      sb1.reverse();
      sb1.append(sb);
      sb1.append(sb2);
     System.out.println(sb1);
    }
  } 
}


Measured memory_bytes: 117840
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
from _collections import defaultdict
from functools import lru_cache

class Scanner():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def map_int():
        return [int(x) for x in Scanner.string().split()]
    def string_list(n):
        return [input() for i in range(n)]
    def int_list_list(n):
        return [Scanner.mapInt() for i in range(n)]
    def int_cols_list(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True

MOD = int(1e09) + 7

def main():
    A,B,C,D,E,F = Scanner.map_int()
    n,m = 0,0
    M = 0
    for a in range(41):
        for b in range(41):
            w = A * a * 100 + B * b * 100
            for c in range(41):
                for d in range(41):
                    s = c * C + d * D
                    mass = w + s
                    if mass > F:
                        continue
                    if s * 100 > E * w:
                        continue
                    if s * n >= m * mass:
                        n,m = mass,s

    print(n,m)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 40304
n,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(n - 1):
	if a[i] + a[i + 1] > x:
		d = min(a[i + 1],a[i] + a[i + 1] - x)
		a[i + 1] -= d
		ans += d
	if a[i] > x:
		ans += a[i] - x
print(ans)

Measured memory_bytes: 63984
import Control.Monad
main = do
    str <- getLine
    if str == "0 0" then return ()
                    else do
                        let [len,sumNum] = map read.words $ str
                        print $ length.filter(\x -> sum x == sumNum && length x == len).filterM (\x -> [True,False]) $ [0..9] 
                        main

Measured memory_bytes: 4588
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        int D;
        int T;
        int S;

        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            D = in.Int();
            T = in.Int();
            S = in.Int();
            out.println(D <= T * S ? "Yes" : "No");

        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 32888
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int H, W, D;
int Q;
int L, R;
PII VtoP[90010];
int ans[90010];


int calcMP(PII p, PII n){
	return abs(n.first-p.first)+abs(n.second-p.second);
}


void makeAns(){
	repe(i, D+1, H*W) ans[i] = ans[i-D]+calcMP(VtoP[i-D], VtoP[i]);
}


signed main(){
	cin >> H >> W >> D;
	repe(i, 1, H){
		repe(j, 1, W){
			int A;
			cin >> A;
			VtoP[A] = { i, j };
		}
	}

	makeAns();

	cin >> Q;
	rep(i, 0, Q) cin >> L >> R, cout << ans[R]-ans[L] << endl;

	return 0;
}

Measured memory_bytes: 2176
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.nextInt();

            out.println(x == 7 || x == 5 || x == 3 ? "YES" : "NO");
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



Measured memory_bytes: 21588
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl

int n,m,a[1005],b[1005],r[1000005],c[1000005];
ll rows,cols,cells;

int main()
{
	SPEED;	
	cin>>n>>m;
	bool z=1;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(r[a[i]]!=0)
			z=0;
		r[a[i]]=i;
	}
	for(int i=1;i<=m;i++)
	{
		cin>>b[i];
		if(c[b[i]]!=0)
			z=0;
		c[b[i]]=i;
	}
	if(!z)
		return cout<<0<<endl,0;
	int ans=1;
	for(int j=n*m;j>=1;j--)
	{
		if(r[j]&&c[j])
		{
			cells+=rows+cols;
			rows++,cols++;
			continue;
		}
		if(r[j])
		{
			rows++;
			cells+=cols-1;
			ans=(ans*1ll*cols)%MOD;
		}
		else if(c[j])
		{
			cols++;
			cells+=rows-1;
			ans=(ans*1ll*rows)%MOD;
		}
		else
		{
			ans=(ans*1ll*cells)%MOD;
			cells--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2304
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <sstream>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

vector<int> edges[11000];
set<int> memo[11000];

set<int> dfs(int index) {
  if (!memo[index].empty()) { return memo[index]; }
  set<int> ret;
  if (edges[index].empty()) {
    ret.insert(index);
  } else {
    FORIT(it, edges[index]) {
      set<int> nret = dfs(*it);
      FORIT(it2, nret) { ret.insert(*it2); }
    }
  }
  return memo[index] = ret;
}

int main() {
  int n;
  while (scanf("%d", &n), n) {
    REP(i, 11000) { edges[i].clear(); memo[i].clear(); }
    map<string, int> mapto;
    int m = 0;
    REP(i, n) {
      string str;
      cin >> str;
      FORIT(it, str) {
        if (*it == ':' || *it == ',' || *it == '.') { *it = ' '; }
      }
      stringstream sin(str);
      string group;
      sin >> group;
      if (!mapto.count(group)) { mapto[group] = m++; }
      int from = mapto[group];
      while (sin >> str) {
        if (!mapto.count(str)) { mapto[str] = m++; }
        int to  = mapto[str];
        edges[from].push_back(to);
      }
    }
    cout << dfs(0).size() << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

int main(void){
    int a;
    cin >> a;
    cout << a/3 << endl;
    return 0;
}


Measured memory_bytes: 256
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+1];
    int check =0;
    for (int i =1; i<= N; i++) {
      A[i] = sc.nextInt();
      if (A[i] % 2 == 0) {
        if (A[i] % 3 != 0 && A[i] % 5 != 0) {
          check++;
        }
      }
    }
    if (check != 0) {
      System.out.print("DENIED");
    } else {
      System.out.print("APPROVED");
    }
  }
}

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

using namespace std;

int main(){
    int N, Q;
    string S;

    cin >> N >> Q;
    cin >> S;

    int n;
    int t[N];

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

        if(i == 0) t[i] = 0;
        else t[i] = t[i-1];

        if(S[i] == 'A'){
            flag = 1;
        }
        else{
            if(flag == 1 && S[i] == 'C'){
                t[i] +=1;
            }
            flag = 0;
        }
    }
    
    int l[Q] ,r[Q];
    for(int i=0;i<Q;i++){
        cin >> l[i] >> r[i];
    }
    for(int i=0;i<Q;i++){
        cout <<  t[r[i]-1] - t[l[i]-1] <<endl;
    }

    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
using namespace std;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0,1,0,-1};
signed main(){
  int gems{};
  while(cin >> gems, gems){
      int cnt{};
      int v[21][21]{};
      for(int i = 0, i_len = (int)gems; i < i_len; ++i){
          int x;int y;cin >> x >> y;
          v[x][y] = 1;
      }

      int m;cin >> m;
      int x = 10;int y = 10;
      for(int i = 0, i_len = (int)m; i < i_len; ++i){
          char dir{};int dis{};cin >> dir >> dis;
          if(dir == 'N'){
              for(int i = 0, i_len = (int)dis; i < i_len; ++i){ 
                  y += dy[1];
                  if(v[x][y] == 1){
                    ++cnt;
                    v[x][y] = 0;
                  }
              }
          }
          else if(dir == 'E'){
              for(int i = 0, i_len = (int)dis; i < i_len; ++i){
                  x += dx[2];
                  if(v[x][y] == 1){
                    ++cnt;
                    v[x][y] = 0;
                  }
              }
          }
          else if(dir == 'S'){
              for(int i = 0, i_len = (int)dis; i < i_len; ++i){
                  y += dy[3];
                  if(v[x][y] == 1){
                    ++cnt;
                    v[x][y] = 0;
                  }
              }
          }
          else if(dir == 'W'){
              for(int i = 0, i_len = (int)dis; i < i_len; ++i){
                  x += dx[0];
                  if(v[x][y] == 1){
                    ++cnt;
                    v[x][y] = 0;
                  }
              }
          }
        }
      if(cnt == gems) cout << "Yes" << endl;
      else cout << "No" << endl;
    }
  return 0;
}




Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
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;}

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int d1 = (c + b - 1) / b;
  int d2 = (a + d - 1) / d;
  if (d1 <= d2) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

enum SELECT_TYPE
{
	NONE,
	SELECT_A,
	SELECT_B,
	SELECT_C,
	SELECT_TYPE_MAX
};

vector<int> v( 9, 0 );
vector<int> l( 9, 0 );
int ans = 10000000;
int A, B, C;
int N;

void calc()
{
	int a = 0, b = 0, c = 0;
	int mp = 0;
	for( int i = 0; i < N; ++i )
	{
		if( v[i] == SELECT_A )
		{
			if( a != 0 ) mp += 10;
			a += l[i];
		}
		else if( v[i] == SELECT_B )
		{
			if( b != 0 ) mp += 10;
			b += l[i];
		}
		else if( v[i] == SELECT_C )
		{
			if( c != 0 ) mp += 10;
			c += l[i];
		}
	}
	if( !a || !b || !c ) return;
	mp += abs( A - a ) + abs( B - b ) + abs( C - c );
	ans = min( ans, mp );
}

void dfs( int depth )
{
	if( depth == N )
	{
		calc();
		return;
	}

	for( int i = 0; i < SELECT_TYPE_MAX; ++i )
	{
		v[depth] = i;
		dfs( depth + 1);
	}
}

int main()
{
	cin >> N;
	cin >> A >> B >> C;
	for( int i = 0; i < N; ++i )
		cin >> l[i];
	dfs( 0 );

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
h = list(map(int, input().split()))
arr = [[] for i in range(n)]
for i in range(m):
  a,b = map(int, input().split())
  arr[a-1].append(b-1)
  arr[b-1].append(a-1)
res = 0
for i in range(n):
  flg = 0
  for j in range(len(arr[i])):
    if h[i] <= h[arr[i][j]]:
      flg = 1
  if flg == 0:
    res += 1
print(res)

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

int main(void){
	int n;
	int s[10010];
	int q;
	int t[510];
	int i, j;
	int count;
	int flag=0;

	cin >> n;
	for(i=0; i<n; i++){
		cin >> s[i];
	}

	cin >> q;
	for(i=0; i<q; i++){
		cin >> t[i];
	}

	for(i=0; i<q; i++){
		for(j=0; j<n; j++){
			if(t[i]==s[j]){
				flag = 1;
			}
		}
		if(flag==1){
			count++;
		}
		flag=0;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3140
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var d = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&d[i])
	}
	//最大値を求める
	idx, up := maxInt(d)
	d = delete(d, idx)
	count := 1

	for i := 0; i < n-1; i++ {
		idx, max := maxInt(d)
		d = delete(d, idx)
		if max < up {
			up = max
			count++
		} else if max == up {
			continue
		} else {
			break
		}
	}
	fmt.Println(count)
}

func maxInt(a []int) (int, int) {
	max := a[0]
	var idx int
	for i, e := range a {
		if e > max {
			max = e
			idx = i
		}
	}
	return idx, max
}

func delete(s []int, i int) []int {
	s = append(s[:i], s[i+1:]...)
	n := make([]int, len(s))
	copy(n, s)
	return n
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <vector>
#define INF 1e5
using namespace std;
struct data{
	int v,c;
	data(){}
	data(int vv,int cc){
		v=vv;
		c=cc;
	}
	bool operator <(const data& d1)const{
		return d1.c<c;
	}
};

struct edge{
	int t,c;
	edge(){}
	edge(int tt,int cc){
		t=tt;
		c=cc;
	}
};

int n,m;
vector<edge> G[101];
int a[10001],b[10001],w[10001];
int dist[101];

int main(void){
	while(1){
		scanf("%d %d",&n,&m);
		if(n+m==0)break;
		for(int i=0;i<n;i++){
			G[i].clear();
		}
		for(int i=0;i<m;i++){
			scanf("%d %d %d",&a[i],&b[i],&w[i]);
			a[i]--;
			b[i]--;
			G[a[i]].push_back(edge(b[i],w[i]));
			G[b[i]].push_back(edge(a[i],w[i]));
		}
		int res=INF;
		for(int i=0;i<m;i++){
			fill(dist,dist+n,INF);
			int now=0;
			priority_queue<data> que;
			que.push(data(a[i],0));
			que.push(data(b[i],0));
			dist[a[i]]=0;
			dist[b[i]]=0;
			while(que.size()){
				data p=que.top();
				que.pop();
				//printf("%d\n",p.c);
				if(dist[p.v]<p.c)continue;
				now=max(now,p.c);
				for(int j=0;j<G[p.v].size();j++){
					edge e=G[p.v][j];
					int ncost=e.c-w[i];
					if(ncost<0)continue;
					if(ncost<dist[e.t]){
						dist[e.t]=ncost;
						que.push(data(e.t,ncost));
					}	
				}
			}
			bool flag=true;
			for(int i=0;i<n;i++){
				if(dist[i]==INF)flag=false;
			}
			if(flag)res=min(res,now);
		}
		printf("%d\n",res!=INF?res:-1);
	}
	return 0;
}

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

public class Main {
    static int mod = (int)1e9+7;
    static long[]fact;
    static long pow(long a,int pow){
        long res=1;
        while (pow>0){
            if (pow%2==1){
                res=(res*a)%mod;
            }
            a=(a*a)%mod;
            pow>>=1;
        }
        return res;
    }
    static long ncr(int n,int r){
        if (r>n)
            return 0;
        long ans = fact[n]*pow(fact[n-r],mod-2);
        ans%=mod;
        ans*=pow(fact[r],mod-2);
        return ans%mod;
    }
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        fact= new long[(int)3e6];
        fact[0]=1;
        for (int i =1;i<fact.length;i++){
            fact[i]=(i*fact[i-1])%mod;
        }
        long ans =0;int k = sc.nextInt();
        int n = sc.nextLine().length();
        for (int i =n;i<=n+k;i++){
            long here=(ncr(i-1,n-1)*pow(25,i-n))%mod;
            here*=pow(26,n+k-i);
            ans+=here;
            ans%=mod;
        }
        pw.println(ans);
        pw.flush();
    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public int[] nextIntArr(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < arr.length; i++)
                arr[i] = nextInt();
            return arr;
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}

Measured memory_bytes: 63444
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
    boost();
    ll n;
    cin >> n;
    n = n%10;
    if(n==2||n==4||n==5||n==7||n==9)
    cout << "hon" << endl;
    else if(n==0||n==1||n==6||n==8)
    cout << "pon" << endl;
    else
    cout << "bon " << endl;
}

Measured memory_bytes: 3616
a = int(input())
l = list(map(int,input().split()))
m = l[0]
M = l[0]
for i in range(1,a):
  if l[i]<m:
    m = l[i]
  else:
    if l[i]>M:
      M = l[i]
    else:
      pass
print(M-m)

Measured memory_bytes: 3060
s = input()
reverse_s = s[::-1]

num = [0] * len(s)

for i in range(len(s)):
    if s[i] == 'R':
        nearest = s.index('L', i)
        if (nearest - i) % 2 == 0:
            num[nearest] += 1
        else:
            num[nearest - 1] += 1
    else:
        reverse_i = len(s) - (i + 1)
        reverse_nearest = reverse_s.index('R', reverse_i)
        nearest = len(s) - (reverse_nearest + 1)
        if (i - nearest) % 2 == 0:
            num[nearest] += 1
        else:
            num[nearest + 1] += 1
print(*num)


Measured memory_bytes: 6512
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long Int;
#define REP(i,n) for(int i=0;i<(int)n;++i)

long long table[] = {
1ll
,2ll
,4ll
,6ll
,12ll
,24ll
,36ll
,48ll
,60ll
,120ll
,180ll
,240ll
,360ll
,720ll
,840ll
,1260ll
,1680ll
,2520ll
,5040ll
,10080ll
,15120ll
,25200ll
,27720ll
,55440ll
,110880ll
,166320ll
,277200ll
,332640ll
,554400ll
,665280ll
,720720ll
,1441440ll
,2162160ll
,3603600ll
,4324320ll
,7207200ll
,8648640ll
,10810800ll
,21621600ll
,36756720ll
,61261200ll
,73513440ll
,122522400ll
,147026880ll
,183783600ll
,367567200ll
,698377680ll
,735134400ll
,1102701600ll
,1163962800ll
,1396755360ll
,2327925600ll
,2793510720ll
,3491888400ll
,6983776800ll
,13967553600ll
,20951330400ll
,27935107200ll
,41902660800ll
,48886437600ll
,80313433200ll
,160626866400ll
,321253732800ll
,481880599200ll
,642507465600ll
,963761198400ll
,1124388064800ll
,1927522396800ll
,2248776129600ll
,3373164194400ll
,4497552259200ll
,4658179125600ll
,6746328388800ll
,9316358251200ll
,13974537376800ll
,18632716502400ll
,27949074753600ll
,32607253879200ll
,55898149507200ll
,65214507758400ll
,97821761637600ll
,130429015516800ll
,144403552893600ll
,195643523275200ll
,288807105787200ll
,433210658680800ll
,577614211574400ll
,866421317361600ll
,1010824870255200ll
,1732842634723200ll
,2021649740510400ll
,3032474610765600ll
,4043299481020800ll
};
double table2[]={1.000000,1.500000,1.750000,2.000000,2.333333,2.500000,2.527778,2.583333,2.800000,3.000000,3.033333,3.100000,3.250000,3.358333,3.428571,3.466667,3.542857,3.714286,3.838095,3.900000,3.936508,3.966032,4.051948,4.187013,4.254545,4.294372,4.326580,4.363636,4.396364,4.398268,4.509091,4.581818,4.624709,4.659394,4.699301,4.734545,4.736597,4.778866,4.855944,4.896750,4.933476,4.975730,5.013048,5.015220,5.059975,5.141588,5.154474,5.182394,5.184434,5.193133,5.237611,5.276893,5.279179,5.326290,5.412198,5.455152,5.457299,5.476629,5.500611,5.508844,5.557868,5.647511,5.692332,5.694573,5.714743,5.739768,5.748359,5.762366,5.793981,5.796262,5.816792,5.842252,5.842264,5.888619,5.890938,5.911803,5.937691,5.946578,5.961068,5.993773,5.996133,6.017371,6.030712,6.043722,6.078575,6.080968,6.102506,6.129230,6.138403,6.153361,6.187121,6.189557,6.211480};
/*
long long divisor(long long n){
	long long i = 1 , sum = 0;
	for(; i*i < n ; i++) if(n%i == 0) sum += i + n/i;
	if(i*i == n) sum += i;
	return sum;
}
*/
int main(){
	int X = sizeof(table) / sizeof(table[0]);
	long long n;
	while(cin >> n && n){
		double mx = 0;
		printf("%.6lf\n",table2[upper_bound(table,table+X,n)-table-1]);
	}
}

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

#define MAX 100002

int n;
vector<int> v;

int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		v.push_back(a);
	}
	long long int cnt = 0;
	for (int i = 0; i < v.size(); i++){
		cnt += v[i] / 2;
		v[i] %= 2;
		if (i + 1 < v.size()){
			
		}
		else{
			break;
		}
		long long int m = min(v[i + 1], v[i]);
		cnt += m;
		v[i + 1] -= m;
	}
	printf("%lld\n", cnt);
	//cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 892
#include <stdio.h>

int main()
{
	int a, b, x;

	scanf("%d %d", &a, &b);
	
	if (0 == (a + b) % 2) {
		x = (a + b) / 2;
	}
	else {
		x = (a + b) / 2 + 1;
	}

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

	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
 
int main(){
  int N,K;
  int h[100000];
  int sum = 0;
  cin >> N >> K;
  for(int i = 0;i < N;i++){
    cin >> h[i];
    if(h[i] >= K){
      sum ++;
    }
  }
  
  cout << sum;
  
}

Measured memory_bytes: 640
import sys
N, A, B = list(map(int, input().split()))
if A > B:
    print(0)
    sys.exit()
if N == 1:
    if A == B:
        print(1)
    else:
        print(0)
elif N == 2:
    print(1)
else:
    print((B - A) * (N - 2) + 1)


Measured memory_bytes: 9168
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    ll a[n+5];
    REP(i,n)cin >> a[i];
    ll ball[n+6] = {};
    ll tmp=0;
    ll m=0;
    for(ll i= n;i >= 1;i--){
        tmp=0;
        for(ll j=2;i*j <= n;j++){
            tmp += ball[i*j];
        }
        ball[i] = (tmp + a[i-1])%2;
        m += ball[i];
    }
    cout << m << endl;
    for(ll i=1;i <=n;i++){
        if(ball[i])
            cout << i << " "; 
    }
    if(m!=0)
    cout << endl;
    return 0;
}

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

#define ll long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector

ll min(ll a,ll b)
{
    return (a<b)?a:b;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ll n,wmax;
    cin>>n>>wmax;
    ll w[n],v[n];
    for(ll i=0;i<n;i++)
        cin>>w[i]>>v[i];
    ll dp[n+1][wmax+1];
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=wmax;j++){
            if(i==0||j==0)
                dp[i][j]=0;
            else{
                dp[i][j]=dp[i-1][j];
                if(w[i-1]<=j)
                    dp[i][j]=max(dp[i][j],v[i-1]+dp[i-1][j-w[i-1]]);
            }
        }
    }
    /*for(int i=0;i<=n;i++){
        for(int j=0;j<=wmax;j++)
            cout<<dp[i][j]<<' ';
        cout<<'\n';
    }*/
    cout<<dp[n][wmax];
}

Measured memory_bytes: 82516
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int flag=0;
    for(int i=0;i<3;i++){
        if(s[i]==s[i+1])flag++;
    }
    if(flag>0)cout << "Bad" << endl;
    else cout << "Good" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
int Abs(int x){return x<0?-x:x;}
int x,y;
int main()
{
	scanf("%d%d",&x,&y);
	if((long long)x*y==0)printf("%d\n",abs(x+y)+(x>0)+(y<0));
	else if((long long)x*y>0)printf("%d\n",x>y?(x-y+2):(y-x));
	else x=-x,printf("%d\n",x>y?(x-y+1):(y-x+1));
	return 0;
}


Measured memory_bytes: 256
num = gets.chomp.to_i
lange = gets.chomp.split.map!(&:to_i)
check = 0
(lange[0]..lange[1]).each{ |i|
  if i % num == 0
    check = 1
  end
}
if check == 1
  puts "OK"
else
  puts "NG"
end

Measured memory_bytes: 14308
#include <bits/stdc++.h>
        using namespace std;
        #define dump(x) cout << (x) << '\n';
        typedef int64_t Int;
        Int mod = 1e9+7;
        Int INF = 1e9+18;

        int main() {
            ios::sync_with_stdio(false);
            string s;
            Int k;
            cin >> s >> k;
            Int n = (Int)s.size();
            for (Int i = 0; i < n; i++) {
                if (s[i] == 'a') continue;
                Int x = 'z' - s[i] + 1;
                if (k >= x) {
                    s[i] = 'a';
                    k -= x;
                }
            }
            k %= 26;
            Int x = s[n - 1] - 'a';
            x = (x + k) % 26;
            s[n - 1] = 'a' + x;
            dump(s);
            return 0;
        }

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

int main(){
    string s;
    cin>>s;
    if(s=="Sunny"){
        cout<<"Cloudy"<<endl;
        return 0;
    }
    if(s=="Cloudy"){
        cout<<"Rainy"<<endl;
        return 0;
    }
    if(s=="Rainy"){
        cout<<"Sunny"<<endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	answer := calcCircumference(n)
	fmt.Println(answer)
}

func calcCircumference(radius int) float64 {
	return float64(2*radius) * math.Pi
}


Measured memory_bytes: 1820
#include<stdio.h>
int main(void){
 int a, b, c, x, y;
 scanf("%d %d %d", &a, &b, &c);
 for(x = a; x <= b; x++){
 if(c%x == 0)y++;
}
 printf("%d\n", y);
 return 0;
}
 

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int n,a=-1,b=-1,mp[1005][1005];
int mex(vector<int> a){
	sort(a.begin(),a.end());
	int now=1;
	for(auto x:a){
		if(x>now)return now;
		else if(x==now)++now;
	}
	return now;
}
void p21(int x,int y){
	vector<int>t;
	if(mp[x-1][y])t.push_back(mp[x-1][y]);
	if(mp[x][y-1])t.push_back(mp[x][y-1]);
	if(mp[x][y+1])t.push_back(mp[x][y+1]);
	if(mp[x+1][y-1])t.push_back(mp[x+1][y-1]);
	if(mp[x+1][y+1])t.push_back(mp[x+1][y+1]);
	if(mp[x+2][y])t.push_back(mp[x+2][y]);
	mp[x][y]=mp[x+1][y]=mex(t);
}
void p12(int x,int y){
	vector<int>t;
	if(mp[x][y-1])t.push_back(mp[x][y-1]);
	if(mp[x-1][y])t.push_back(mp[x-1][y]);
	if(mp[x+1][y])t.push_back(mp[x+1][y]);
	if(mp[x-1][y+1])t.push_back(mp[x-1][y+1]);
	if(mp[x+1][y+1])t.push_back(mp[x+1][y+1]);
	if(mp[x][y+2])t.push_back(mp[x][y+2]);
	mp[x][y]=mp[x][y+1]=mex(t);
}
void p44(int x,int y){
	p12(x,y);
	p12(x+1,y);
	p12(x+2,y+2);
	p12(x+3,y+2);
	p21(x+2,y);
	p21(x+2,y+1);
	p21(x,y+2);
	p21(x,y+3);
}
void p55(int x,int y){
	p12(x,y+1);
	p12(x,y+3);
	p12(x+1,y+1);
	p12(x+4,y);
	p12(x+4,y+2);
	p21(x,y);
	p21(x+1,y+4);
	p21(x+2,y);
	p21(x+2,y+3);
	p21(x+3,y+4);
}
void p45(int x,int y){
	p12(x,y+1);
	p12(x,y+3);
	p12(x+1,y+3);
	p12(x+2,y);
	p12(x+3,y);
	p12(x+3,y+2);
	p21(x,y);
	p21(x+1,y+2);
	p21(x+2,y+4);
}
void p54(int x,int y){
	p21(x+1,y);
	p21(x+3,y);
	p21(x+3,y+1);
	p21(x,y+2);
	p21(x,y+3);
	p21(x+2,y+3);
	p12(x,y);
	p12(x+2,y+1);
	p12(x+4,y+2);
}
void p33(int x,int y){
	p12(x,y);
	p21(x+1,y+2);
}
const char s7[7][8]={".aaeeff","b..gghh","b..iijj","cko....","cko....","dpq....","dpq...."};
int main(){
	cin>>n;
	if(n<=2){puts("-1");return 0;}
	if(n==7){
		for(int i=0;i<7;++i)puts(s7[i]);
		return 0;
	}
	if(n==11){
		for(int i=1;i<=7;++i)for(int j=1;j<=7;++j)mp[i][j]=s7[i-1][j-1]-'a'+1;
		p44(8,8);
	}
	if(n%3==0){
		for(int i=1;i<=n;i+=3){
			for(int j=1;j<=n;j+=3){
				p33(i,j);
			}
		}
	}else{
		for(int i=0;i*5<=n;++i){
			if((n-i*5)%4==0){
				a=i,b=(n-i*5)/4;
			}
		}
		for(int i=0;i<a;++i){
			for(int j=0;j<a;++j){
				p55(i*5+1,j*5+1);
			}
		}
		for(int i=0;i<b;++i){
			for(int j=0;j<b;++j){
				p44(i*4+a*5+1,j*4+a*5+1);
			}
		}
		for(int i=0;i<a;++i){
			for(int j=0;j<b;++j){
				p54(i*5+1,j*4+a*5+1);
			}
		}
		for(int i=0;i<b;++i){
			for(int j=0;j<a;++j){
				p45(i*4+a*5+1,j*5+1);
			}
		}
	}
	for(int i=1;i<=n;++i)for(int j=1;j<=n;++j){
		putchar(mp[i][j]?mp[i][j]+'a'-1:'.');
		if(j==n)putchar('\n');
	}
	return 0;
}

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

int main() {
  long N;
  cin >> N;
  long long ans = 0, mini, count = 0;
  long long temp;
  cin >> temp;
  ans += abs(temp);
  if (temp < 0) count++;
  mini = abs(temp);
  for (int i = 1; i < N; i++) {
    cin >> temp;
    ans += abs(temp);
    if (temp < 0) count++;
    mini = min(mini, abs(temp));
  }
  if (count % 2 == 1) ans -= 2 * mini;
  cout << ans;
  return 0;
}

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

using namespace std;

int main(){
    vector<string> S(3);
    for(int i = 0; i < 3; i++){
        cin >> S[i];
    }

    char ans;
    char i = 'a';
    while(true){
        if(i == 'a'){
            if(S[0].length() == 0){
                ans = 'A';
                break;
            }
            i = S[0][0];
            S[0].erase(S[0].begin());
        }else if(i == 'b'){
            if(S[1].length() == 0){
                ans = 'B';
                break;
            }
            i = S[1][0];
            S[1].erase(S[1].begin());
        }else{
            if(S[2].length() == 0){
                ans = 'C';
                break;
            }
            i = S[2][0];
            S[2].erase(S[2].begin());
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#define INF 100000000000000
using namespace std;

typedef struct _RECT{
    long long H;
    long long W;
}RECT;

int main() {
    vector<RECT> rect_list;
    RECT rect;
    long long h, w;
    while(1){
        cin >> h >> w;
        if(h==0 && w==0){
            break;
        }
        rect.H = h;
        rect.W = w;
        rect_list.push_back(rect);
    }
    for(int i=0; i<rect_list.size(); i++){
        h = rect_list.at(i).H;
        w = rect_list.at(i).W;
        for(int j=0; j<h; j++){
            for(int k=0; k<w; k++){
                if((j+k)%2==0){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }   
        cout << endl;
    }
}




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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin >> n;
	ll sum=0, mp=0;
	rep(i, n){
		ll p; cin >> p;
		sum += p;
		mp = max(mp, p);
	}
	sum -= mp/2;
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define pb push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=a;i>b;i--)
#define mkp(a,b) make_pair(a,b)
#define all(v) v.begin(),v.end()
using namespace std;
bool compare(pair<int,int>& p1,pair<int,int>& p2)
{
    return p1.second<p2.second;
}
int main()
{
    fastio
    ll n;
    cin>>n;
    map<string,ll> m;
    REP(i,0,n)
    {
        string temp;
        cin>>temp;
        m[temp]++;
    }
    cout<<"AC x "<<m["AC"]<<"\n";
    cout<<"WA x "<<m["WA"]<<"\n";
    cout<<"TLE x "<<m["TLE"]<<"\n";
    cout<<"RE x "<<m["RE"]<<"\n";
}

Measured memory_bytes: 3664
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long int

int main()
{
 char ch[10];
 int res = 753;
 scanf("%s",ch);
 int min = INT_MAX;
 char sub1[3]={'\0'};

 for (int i = 0;i<strlen(ch);i++)
 {   if (i+2<strlen(ch))
  {
    strncpy(sub1, ch+i, 3);
    int ERG = atoi(sub1);
    int resultat = abs(res-ERG);
    if (resultat<min)min=resultat;
  }
 }

 printf("%d",min);


    return 0;
}

Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

n, k = map(int, readline().split())
a = np.array(readline().split(), np.int64)
f = np.array(readline().split(), np.int64)
a.sort()
f.sort()
f = f[::-1]
a_sum = a.sum()
left = - 1
right = 10 ** 12

while left + 1 < right:
    mid = (left + right) // 2
    if a_sum - np.minimum(a, mid // f).sum() <= k:
        right = mid
    else:
        left = mid

print(right)


Measured memory_bytes: 26148
A,B,C,X,Y=map(int,input().split())

ans1 = int(A*X + B*Y)
if X<=Y:
  ans2 = int(C*2*X + (Y-X)*B)
  ans3 = 10**10
  ans4 = int(2*Y*C)
else:
  ans2 = 10**10
  ans3 = int(C*2*Y + (X-Y)*A)
  ans4 = int(2*X*C)
  
  
print(min(ans1,ans2,ans3,ans4))


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

int main() {
	int k;
	string s;
	cin>>s>>k;
	
	int tmp=s.length();
	int l=min(k,tmp);
	int ans=1;
	for(int i=0;i<l;i++) {
		if(s[i]!='1') {
			ans=s[i];
			ans-=48;
			break;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}


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

def make_comb_dp(n):
    dp = [[0] * (n + 1) for i in range(n + 1)]
    for i in range(n + 1):
        dp[i][0] = 1
        dp[i][i] = 1
    for i in range(2, n + 1):
        for j in range(1, i):
            dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j]
    return dp

nCk = make_comb_dp(2000)
for i in range(1, K+1):
    print(int(nCk[N-K+1][i]*nCk[K-1][i-1])%(10 ** 9 + 7))


Measured memory_bytes: 356584
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

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

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

const double PI=acos(-1.0);

int main() {
    int n;
    cin >> n;
    vi a(n, 0);
    rep(i, n-1) {
        int x;
        cin >> x;
        --x;
        a[x]++;
    }

    rep(i, n) {
        cout << a[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 4024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

long long N;
vector<long long> A, B;
map<long long, vector<int>> MB;

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

	cin >> N;
	for(int i=0; i<N; i++){
		long long a, b;
		cin >> a >> b;
		A.push_back(a);
		B.push_back(b);
		MB[b].push_back(i);
	}
	sort(B.begin(), B.end());

	long long e = 0;
	int ng = 0;
	for(int i=0; i<B.size(); i++){
		if(i > 0 && B[i] == B[i-1]) continue;
		vector<int> &v = MB[B[i]];
		for(int j=0; j<v.size(); j++){
			e += A[v[j]];
			if(e > B[i]){
				ng = 1;
				break;
			}
		}
		if(ng == 1){
			break;
		}
	}
	if(ng == 1){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}

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

ll beki(ll n,vector<ll> &num)
{
  if(n==1) {num.at(0)=1; return 1;}
  if(num.at(n-1)!=0) {return num.at(n-1);}
  num.at(n-1)=beki(n-1,num)*n%MOD; return num.at(n-1);
}  


int main() 
{
  ll N,M; cin>>N>>M;
  ll mi=min(N,M);
  ll ma=max(N,M);
  vector<ll> num(ma,0);
  //cout<<ma-mi<<endl;
  if(ma-mi==0)
  {
    cout<<2*beki(N,num)*beki(M,num)%MOD<<endl;
    //cout<<beki(N,num)<<" "<<beki(M,num)<<endl;
    return 0;
  }
  if(ma-mi==1)
  {
    cout<<beki(N,num)*beki(M,num)%MOD<<endl; return 0;
  }
  cout<<0<<endl; return 0;
  return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>

using namespace std;

struct Node{
	Node(){
		left_child = right_child = parent = -1;
	}
	int left_child,right_child,parent;
};

class Heap{
public:
	Heap(int H){
		index = 0;
		array = new long long[H];
		struct_array = new Node[H];
	}
	~Heap(){
		delete[] array;
	}
	void push(long long data){
		array[index] = data;
		if(index != 0){
			if(index%2 == 0){
				struct_array[(index-1)/2].right_child = index;
				struct_array[index].parent = (index-1)/2;
			}else{
				struct_array[index/2].left_child = index;
				struct_array[index].parent = index/2;
			}
		}
		index++;
	}

	void print(){
		for(int i = 0; i < index; i++){
			printf("node %d: key = %d, ",i+1,array[i]);
			if(struct_array[i].parent != -1) printf("parent key = %lld, ",array[struct_array[i].parent]);
			if(struct_array[i].left_child != -1) printf("left key = %lld, ",array[struct_array[i].left_child]);
			if(struct_array[i].right_child != -1) printf("right key = %lld, ",array[struct_array[i].right_child]);
			printf("\n");
		}
	}

private:
	long long* array;
	Node* struct_array;
	int index;
};

int main(){
	int H;
	long long tmp;
	scanf("%d",&H);
	Heap heap(H);

	for(int i = 0; i < H; i++){
		scanf("%lld",&tmp);
		heap.push(tmp);
	}
	heap.print();
}



Measured memory_bytes: 2752
S=input()
N=len(S)
mod=998244353
L=[0]*(2*N)
L[0]=int(S[0])
for i in range(1,N):
    L[i]=L[i-1]+int(S[i])
for i in range(N,2*N):
    L[i]=L[i-1]
dp=[[0]*(2*N+1) for i in range(2*N+1)]
dp[0][0]=1
for n in range(1,2*N+1):
    for k in range(min(n,L[n-1])+1):
        if n-k>2*n-L[n-1]:
            continue
        dp[n][k]+=dp[n-1][k]
        dp[n][k]%=mod
        if k>=1:
            dp[n][k]+=dp[n-1][k-1]
            dp[n][k] %= mod
ans=dp[2*N][L[-1]]
print(ans)


Measured memory_bytes: 167772
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,l[50],dp[51],i,j,k,sum,high,mn,s1,m1,x;
	scanf("%d",&n);
	m1=-1;	s1=0;
	for(i=0;i<n;i++)	{
		scanf("%d",&l[i]);
		s1+=l[i];
		m1=max(m1,l[i]);
	}
	mn=50000;
	for(i=m1;i<s1;i++)	{
		for(j=0;j<n;j++)	dp[j]=0;
		sum=0;
		for(j=0;j<n;j++)	{
			sum+=l[j];
			if(sum>i)	break;
			dp[j]=sum;
		}
		for(j=0;j<n-1;j++)	{
			sum=0;
			for(k=j+1;k<n;k++)	{
				sum+=l[k];
				if(sum>i)	break;
				x=min(sum,dp[j]);
				dp[k]=max(dp[k],x);
			}
		}
//		printf(" %d %d\n",i,dp[n-1]);
		mn=min(mn,i-dp[n-1]);
	}
	printf("%d\n",mn);
	return 0;
}


Measured memory_bytes: 2760