akhauriyash/Code-Regression huggingface dataset:
'use strict';
(function(stdin) {
  var lines  = stdin.toString().split('\n');
  var result = (function(data) {
    var result = [];
    var index = 0;
    while(true) {
        var cols = data[index++].split(' ').map(Number);
        if (cols.every(function(v){
            return v === 0;
        })) break;
 
        result.push(cols.sort(function(a,b){
            return a - b;
        }).join(' '));
    }
    return result.join('\n');
  }(lines
  ));
  console.log(result);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 18288
#include<stdio.h>

int main(){
int i,j;
int n;
int u[500];
int sum;
int cnt;

while(scanf("%d", &n), n!=0){
for(i=0; i<n; i++){
scanf("%d", &u[i]);
}
cnt=0;
for(i=n-1;i>0;i--) {
            for(j=0;j<i;j++) {
                if(u[j]>u[j+1]) {
                    sum=u[j];
                    u[j]=u[j+1];
                    u[j+1]=sum;
                    cnt++;
                }
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}

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

typedef long long ll;

ll ans;

struct slope {
	priority_queue <ll> pq;
	ll delta;

	void upd(ll x) { delta += x; }
	void push(ll x) { pq.push(x - delta); }
	ll top() { return pq.top() + delta; }
	void pop() { pq.pop(); }

	void debug() {
		cerr << "\tdelta = " << delta << endl;
		priority_queue <ll> tmp = pq;
		cerr << "\tDEBUG\n";
		cerr << "\t";
		while(!tmp.empty()) {
			cerr << abs(tmp.top() + delta) << ' ';
			tmp.pop();
		}
		cerr << endl;
	}
} lef, rig;

const int N = 1e5 + 5;
int n;
ll l[N], r[N];

ll cost(ll l, ll r, ll x) {
	if (x < l) return l - x;
	if (x > r) return x - r;
	return 0;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> l[i] >> r[i];

	lef.push(l[1]);
	rig.push(-l[1]);

	for (int i = 2; i <= n; ++i) {
		lef.upd(l[i] - r[i]);
		rig.upd(-(r[i - 1] - l[i - 1]));

		ans += cost(lef.top(), -rig.top(), l[i]);

		lef.push(l[i]);
		rig.push(-l[i]);

		while(lef.top() > -rig.top()) {
			ll x = lef.top(); lef.pop();
			ll y = -rig.top(); rig.pop();
			lef.push(y); rig.push(-x);
		}
	}

	cout << ans << endl;
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ');
            int count = 0;
            if (line[0] == line[1]) count++;
            if (line[1] == line[2]) count++;
            if (line[2] == line[0]) count++;
            if (count == 1) Console.WriteLine("Yes");
            else Console.WriteLine("No");
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  vector<int> B(N);
  int tot = 0;
  for (int i=0; i<N; i++) {
    cin >> A[i];
    tot += A[i];
  }
  int ans = 1;
  int wa,totB;
  int Kcop = K;
  
  for (int i=2; i<=sqrt(tot); i++) {
    if (tot % i != 0) {
      continue;
    }
    totB = 0;
    Kcop = K;
    for (int j=0; j<N; j++) {
      B[j] = A[j] % i;
      totB += B[j];
    }
    sort(B.begin(),B.end());
    for (int j=N-1; j>=0; j--) {
      if (Kcop - (i-B[j]) >= 0) {
        Kcop -= i - B[j];
        totB -= B[j];
      }
      else {
        break;
      }
    }
    if (totB <= K) {
      ans = max(ans,i);
    }
  }
  
  for (int i=1; i<=sqrt(tot); i++) {
    if (tot % i != 0) {
      continue;
    }
    wa = tot/i;
    totB = 0;
    Kcop = K;
    for (int j=0; j<N; j++) {
      B[j] = A[j] % wa;
      totB += B[j];
    }
    sort(B.begin(),B.end());
    for (int j=N-1; j>=0; j--) {
      if (Kcop - (wa-B[j]) >= 0) {
        Kcop -= wa - B[j];
        totB -= B[j];
      }
      else {
        break;
      }
    }
    if (totB <= K) {
      ans = max(ans,wa);
    }
  }
  
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define umap std::unordered_map
#define uset std::unordered_set
#define _all(container) std::begin(container), std::end(container)
#define _in(container, value) (std::find(_all(container), value) != std::end(container))
#define _in_if(container, predicate) (std::find_if(_all(container), predicate) != std::end(container))
#define _odd(value) (value & 1)
#define _even(value) !(value & 1)
#define _for(i, n) for (int i = 0; i < n; ++i)
#define _FOR(i, k, n) for (int i = k; i <= n; ++i)
#define _FORR(i, k, n) for (int i = n; i >= k; --i)

using Integer = long long;
using vint = vector<int>;
using pint = pair<int, int>;
using vpint = vector<pint>;
using vdouble = vector<double>;
using cint = const int;
using cdouble = const double;

void solve()
{
    int N, K;
    cin >> N >> K;
    vint h(N);

    _for(i, N)
    {
        cin >> h[i];
    }

    int num = std::count_if(_all(h), [&K](int val) { return val >= K; });
    cout << num << "\n";
}

int main(int argc, char**)
{
    if (argc > 1) {
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();
}


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

int main(void){
    int N;
    int d[200];
    int num[200] = {};
 
    cin >> N;
    for (int i = 0; i < N; i++) cin >> d[i];

    for (int i = 0; i < N; i++){
        num[d[i]]++;
    }

    int count =0;
    for (int i = 0; i < 200; i++){
     if(num[i] != 0) count++;
    }

    cout << count << endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int m[100][100];
int n;
int used[100];
int d[100], f[100];
int ti = 0;

void dfs(int u)
{
    used[u] = 1;
    d[u] = ++ti;

    rep(i, n)
    {
        if (m[u][i] == 0)
            continue;
        if (used[i] == 0)
            dfs(i);
    }
    f[u] = ++ti;
}

int main()
{
    cin >> n;
    rep(i, n) used[i] = 0;
    rep(i, n) rep(j, n) m[i][j] = 0;

    rep(i, n)
    {
        int u, k;
        cin >> u >> k;
        --u;
        rep(j, k)
        {
            int v;
            cin >> v;
            m[u][--v] = 1;
        }
    }

    rep(i, n) if (!used[i]) dfs(i);

    rep(i, n)
    {
        cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3140
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        int k=ni();
        int a=ni();
        int b=ni();
        for(int i=a;i<=b;i++)
            if(i%k==0)
            {
                pn("OK");
                return;
            }
        pn("NG");
    }

    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj = true;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

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

int A[ 5010 ];
set<int> S;

int main()
{
int i;
int j;
int iChk;
int N, K;
long long iSum;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> K;

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

	sort( A, A + N );

 	for( i = N - 1; i >= 0 && A[ i ] >= K; i-- )
		S.insert( i );

	iChk = i;
	iSum = 0;
	for( ; i >= 0; i-- )
	{
		iSum += A[ i ];
		if( iSum >= K )
		{
			for( j = i; j <= iChk; j++ )
				S.insert( j );

			iChk = i;
			iSum -= A[ i ];
		}
	}

	cout << N - (int) S.size() << endl;

	return 0;
}


Measured memory_bytes: 512
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, A):
    m = [[0] * 19 for _ in range(19)]
    Ad = []
    for a in A:
        p = a.index('.') if a.count('.') > 0 else len(a) - 1
        l = len(a) - p - 1
        n = int(a.replace('.', '') + '0' * (9 - l))
        if n == 0:
            m[18][18] += 1
            Ad.append((18, 18))
            continue
        d2, d5 = 0, 0
        while n % 2 == 0:
            d2 += 1
            n //= 2
        while n % 5 == 0:
            d5 += 1
            n //= 5
        d2 = min(d2, 18)
        d5 = min(d5, 18)
        m[d2][d5] += 1
        Ad.append((d2, d5))
    for i in range(18, 0, -1):
        for j in range(19):
            m[i - 1][j] += m[i][j]
    for i in range(19):
        for j in range(18, 0, -1):
            m[i][j - 1] += m[i][j]
    ans = 0
    for d2, d5 in Ad:
        dd2, dd5 = 18 - d2, 18 - d5
        ans += m[dd2][dd5]
        if d2 >= dd2 and d5 >= dd5:
            ans -= 1
    print(ans // 2)

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    A = [input().rstrip() for _ in range(N)]
    main(N, A)


Measured memory_bytes: 98340
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

//J,C,E,A,P,M

string Mr(string op,string str){
	if(op=="A"){
		reverse(str.begin(),str.end());
		return str;
	}

	else if(op=="C"){
		rotate(str.begin(),str.begin()+1,str.end());
		return str;
	}

	else if(op=="E"){
		if(str.size() % 2 == 0){
			string front = str.substr(0,str.size()/2);
			string rear = str.substr(str.size()/2,str.size()/2);
			return rear+front;
		}
		else{
			string front = str.substr(0,str.size()/2);
			string mid = str.substr(str.size()/2,1);
			string rear = str.substr(str.size()/2+1,str.size()/2);
			return rear + mid + front;
		}
	}

	else if(op=="J"){
		rotate(str.begin(),str.end()-1,str.end());
		return str;
	}

	//increament
	else if(op=="M"){
		for(int i=0;i<str.size();i++){
			if(isdigit(str[i])){
				str[i] = (str[i] < '9' ? str[i] + 1 : '0');
			}
		}
		return str;
	}

	//decrement
	else if(op=="P"){
		for(int i=0;i<str.size();i++){
			if(isdigit(str[i])){
				str[i] = (str[i] > '0' ? str[i] - 1 : '9');
			}
		}
		return str;
	}

}

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		for(int i=0;i<n;i++){
			string msger;
			string msg;
			cin >> msger;
			cin >> msg;

			for(int j=msger.size()-1;j>=0;j--){
				msg = Mr(msger.substr(j,1),msg);
			}
			cout << msg << "\n";
		}
	}
}

Measured memory_bytes: 1248
#include <stdio.h>

int main(){
	int a,c,f;
	char b;
	scanf("%d",&a);
	f=a;
	while(1){
		scanf(" %c",&b);
		if(b=='='){
			printf("%d\n",f);
			return 0;
		}
		scanf("%d",&c);
		if(b=='+'){
			f=f+c;
		}else if(b=='-'){
			f=f-c;
		}else if(b=='*'){
			f=f*c;
		}else if(b=='/'){
			f=f/c;
		}
		
	}
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define minimize(a,b) (a>(b)?a=(b),1:0)
#define maximize(a,b) (a<(b)?a=(b),1:0)
#define ceil(a,b) (((a)+(b)-1)/(b))
#define yn(i) print((i)?"Yes":"No")
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define abs(n) max((n),-(n))
#define dist(a,b) max((a)-(b),(b)-(a))
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}




string key="keyence";

void add(char m,string s,set<string> st){
  int n=s.size();
  rep(i,n){
    if(s[i]!=m) continue;
    string t;
    repa(j,i,n){
      t.push_back(s[j]);
      st.insert(t);
    }
  }
}

int gcd(int a,int b){
  return b?gcd(b,a%b):a;
}

int main(){
  int n; cin >>n;
  li ans=0,tmp=-1;
  rep(i,n){
    li a; cin >>a;
    if(!maximize(tmp,a))ans+=tmp-a;
  }
  print(ans);
}





Measured memory_bytes: 3636
k,n = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
from collections import deque
d = deque()
d.append(k-l[n-1]+l[0])
for i in range(n-1):
  d.append(l[i+1]-l[i])
print(k-max(d))

Measured memory_bytes: 26444
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int W;
	int C[10]={1,2,4,8,16,32,64,128,256,512};
	while(cin>>W){
		int V=W;
		int digit=0,output=0;
		while(V){
			if(V&1){
				if(output++) cout << ' ';
				cout << C[digit];
			}
			V>>=1;
			digit++;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int main(){
int i,n,m;
cin>>n>>m;
int a[n];
int s=0;
for(i=0;i<n;i++){
    cin>>a[i];
    s+=a[i];
}
float x=((1/(float)(4*m))*s);
int ans=0;
//cout<<x<<endl;
for(i=0;i<n;i++){
    if(a[i]>=x) ans++;
}
//cout<<ans<<endl;
if(ans>=m) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}
  


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

#define SYNC ios::sync_with_stdio(0);
#define F first
#define S second
#define endl '\n'


using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const int MAXN = 58;
const ll mod = 1000000007;



int main() {
    SYNC
    int a[3], equal = 0;
    for (auto &i : a) {
        cin >> i;
    }
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (i == j) continue;
            if (a[i] == a[j]) equal++;
        }
    }
    equal /= 2;
    int ans = 3 - equal;
    if (!ans) ans = 1;
    cout << ans << endl;


    return 0;
}

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

using namespace std;

#define int long long

const int mod = 1e9 + 7;

int32_t main() {
	int n;
	cin >> n;
	int ans = 1;
	if (n == 1) {
		cout << 0;
		return 0;
	}
	vector<vector<vector<int>>> dp(n, vector<vector<int>>(2, vector<int>(2, 0)));
	dp[0][1][0] = 1;
	dp[0][0][1] = 1;
	dp[0][0][0] = 8;
	for (int i = 1; i < n; ++i) {
		dp[i][0][0] = dp[i - 1][0][0] * 8;
		dp[i][0][0] %= mod;
		dp[i][1][0] = dp[i - 1][1][0] * 9 + dp[i - 1][0][0];
		dp[i][1][0] %= mod;
		dp[i][0][1] = dp[i - 1][0][1] * 9 + dp[i - 1][0][0];
		dp[i][0][1] %= mod;
		dp[i][1][1] = dp[i - 1][1][1] * 10 + dp[i - 1][1][0] + dp[i - 1][0][1];
		dp[i][1][1] %= mod;
	}
	cout << dp[n - 1][1][1];
}

Measured memory_bytes: 151468
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define elif else if
#define y2 y1919810
typedef pair <int, int> PII;
typedef vector <int> VI;
//#define int long long
#define all(x) x.begin(),  x.end()
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define range(i, s, t)  for (int i = s; i <= (int)t; i++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
long long qread() {
    char c = getchar();
    int neg = 1;
    long long val = 0;
    while (c != '-' && !isdigit(c)) c = getchar();
    if (c == '-') c = getchar(), neg = -1;
    while (isdigit(c)) val = (val << 3) + (val << 1) + c - '0', c = getchar();
    return neg * val;
}
const int N = 200020;
vector <int> G[N];
int n, m;
bool vis[N]; int low[N]; int dep[N];
void getDepth(int u, int f) {
//    fprintf(stderr, "getDepth(%d, %d)\n", u, f);
    vis[u] = true;
    if (f != -1) dep[u] = dep[f] + 1;
    rep(i, G[u].size()) {
        int v = G[u][i];
        if (v != f && !vis[v]) getDepth(v, u);
    }
}
void findBridge(int u, int f) {
//    fprintf(stderr, "findBridge(%d, %d)\n",u, f);
    low[u] = dep[u];
    vis[u] = true;
    rep(i, G[u].size()) {
        int v = G[u][i];
        if (v != f) {
            if (!vis[v]) findBridge(v, u);
//            fprintf(stderr, "low[%d] = %d\n", v, low[v]);
            low[u] = min(low[u], low[v]);
        }

    }
}
void solve() {
    n = qread(); m = qread();
    rep(i, m) {
        int u = qread(), v = qread();
        u--; v--;
        G[u].pb(v);
        G[v].pb(u);
    }
    getDepth(0, -1);
//    rep(i, n) fprintf(stderr, "%d ", dep[i]);
    memset(vis, 0, sizeof vis);
    findBridge(0, -1);
    int nBridges = 0;
//    rep(i, n) fprintf(stderr, "%d ", low[i]);
    rep(i, n) if (low[i] == dep[i]) nBridges++;
    printf("%d\n", nBridges - 1);
}
int main() {
    int T = 1;
    //T = qread();
    while (T--) solve();
    return 0;
}


Measured memory_bytes: 8628
import java.io.*;
import java.util.Arrays;

public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line1 = br.readLine();
		String[] spl = line1.split(" ");
		int n = Integer.parseInt(spl[0]);
		int m = Integer.parseInt(spl[1]);
		int l = Integer.parseInt(spl[2]);
		int[][] a = new int[n][m];
		int[][] b = new int[m][l];
		long[][] c = new long[n][l];
		for (int i = 0; i<n ; i++) {
			String line = br.readLine();
			String[] str = line.split(" ");
			for (int j = 0; j<m ; j++ ) {
				a[i][j] += Integer.parseInt(str[j]);
			}
		}

		for (int i = 0; i<m ; i++ ) {
			String line = br.readLine();
			String[] str = line.split(" ");
			for (int j = 0; j<l ; j++ ) {
				b[i][j] += Integer.parseInt(str[j]);
			}
		}

		for (int i = 0; i<n ; i++ ) {
			for (int j = 0; j<m ; j++ ) {
				for (int k = 0; k<l ;k++ ) {
					c[i][k] += (long) (a[i][j] * b[j][k]);
				}
			}
		}

		for (int i = 0; i<n ; i++ ) {
			for ( int j = 0; j<(l-1) ; j++ ) {
				System.out.print(c[i][j]+" ");
			}
			System.out.println(c[i][l-1]);
		}
		
	}
}

Measured memory_bytes: 34280
n,m,c=gets.split.map &:to_i
b=gets.split.map &:to_i
a = []
ans=0
for i in 1..n
  u=gets.split.map &:to_i
  tot = c
  for j in 0...m
    tot+=u[j]*b[j]
  end
  if tot>0;ans+=1;end
end
puts ans



Measured memory_bytes: 1788
import numpy as np
N=int(input())
A = [0]*N
B = [0]*N
for i in range(N):
  A[i],B[i] = map(int, input().split())
  
  
index = np.argsort(B)
Asort = [0]*N
Bsort = [0]*N
for i in range(N):
  Bsort[i] = B[index[i]]
  Asort[i] = A[index[i]]
  
flag = True
val = 0
for i in range(N):
  val = val+Asort[i]
  if val > Bsort[i]:
    flag = False
if flag==True:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 31152
package main
import (
  "fmt"
  "math"
)
func isPrime(a int) []bool {
  result := make([]bool, a+1)
  for i := 2; i <= a; i++ {
    result[i] = true
  }
  rootA := int(math.Sqrt(float64(a)))
  for i := 2; i <= rootA; i++ {
    for j := i+1; j <= a; j++ {
      if result[j] && j%i == 0 {
        result[j] = false
      }
    }
  }
  return result
}

func main() {
  var q int
  fmt.Scan(&q)
  ls := make([]int, q)
  rs := make([]int, q)
  for i := 0; i < q; i++ {
    fmt.Scan(&ls[i], &rs[i])
  }
  N := 100000
  ps := isPrime(N)
  arr := make([]int, N+1)
  for i := 1; i < N; i++ {
    if ps[i] && ps[(i+1)/2] {
      arr[i+1] = arr[i] + 1
    } else {
      arr[i+1] = arr[i]
    }
  }
  for i := 0; i < q; i++ {
    fmt.Println(arr[rs[i]+1]-arr[ls[i]])
  }
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
  if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

int main(){
  ll N; cin>>N;
  ll a[N]; CINA(a,N); sort(a,a+N);
  ll pred,start;
  ll ans = 1;
  if(N%2==1){
    if(a[0]!=0){ ans = 0; }
    start = 1;
    pred = 2;
  }
  else{ 
    start = 0;
    pred = 1;
  }

  for(int i=start;i<N;i+=2){
    if(a[i]!=pred || a[i+1]!=pred){
      ans = 0; break;
    }
    ans *= 2;
    ans %= MOD;
    pred += 2;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void) {
	_Bool flag[1000];
	int n, m;
	int select;
	int i, j;
	while (1) {
		scanf("%d %d", &n, &m);
		if (!n && !m)
			break;
		memset(flag,0,sizeof(flag));
		select = n-1;
		for (i = 1; i < n; i++) {
			for (j = 0; j <= m; j++) {
				if (j == m) {
					if (flag[select]) {
						select = ++select % n;
						j--;
					}
				}
				else {
					if (flag[select])
					if (j)
							j--;
					select = ++select % n;
				}
			}
			flag[select] = 1;
		}
		for (i = 0; i < n; i++) {
			if (!flag[i])
			printf("%d\n", i+1);
		}
	}
	return 0;
}

Measured memory_bytes: 596
i_n = int(input())
i_str = input()
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
lastIndex = 26
resStr = ''

for i in i_str:
  targetIndex = alphabet.index(i)
  if targetIndex + i_n >= lastIndex:
    resStrIndex = targetIndex + i_n - lastIndex
  else:
    resStrIndex = targetIndex + i_n

  resStr += alphabet[resStrIndex]

print(resStr)

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

int n,k;
ll t[100005];

int main() {
  cin >> n;
  rep(i,n) cin >> t[i];
  ll l=t[0],g;
  rep(i,n){
    g=__gcd(l,t[i]); l=l/g*t[i];
  } 
  cout << l << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
long long  n,number,max,min,sum=0,i;
	scanf("%lld",&n);
	for(i=1;i<=n;i++)
	{scanf("%lld",&number);
	if(i==1)
		max=min=number;
	 if(max<number)
	max=number;
	else if(min>number)
		min=number;
		sum=sum+number;
	}
	printf("%d %d %lld\n",min,max,sum);
	return 0;}



Measured memory_bytes: 2104
import java.util.*;
public class Main {

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = -1;
    int c = -1;
    int aCount = 1;
    int bCount = 0;
    int cCount = 0;
    for(int i=1; i<n; i++) {
      int temp = sc.nextInt();
      if(temp == a) {
        aCount++;
      } else if(b == -1){
        b = temp;
        c = a ^ b;
        bCount++;
      } else if(temp == b) {
        bCount++;
      } else if(temp == c) {
        cCount++;      
      }
    }
    sc.close();

    boolean result = false;
    if(aCount + bCount + cCount == n){
      if(aCount == bCount && bCount == cCount){
        result = true;
      } else if(a == 0 && aCount * 2 == bCount && cCount == 0) {
        result = true;
      } else if(b == 0 && aCount == bCount * 2 && cCount == 0) {
        result = true;
      } else if(a == 0 && aCount == n) {
        result = true;
      }
    }
    
    if(result) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 49824
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;

struct P {
  int x,y;
  P(int x,int y):x(x),y(y){}
  bool operator<(const P&a)const {
    return x<a.x;
  }
};

ll cal(vector<P>&L){
  priority_queue<int, vector<int>,greater<int>> q;
  ll cur = 0;
  for(int i=0;i<L.size();i++){
    if(q.size()+1>L[i].x){
      int tt = q.top();
      if(tt<L[i].y){
        q.pop();
        q.push(L[i].y);
        cur-=tt;
        cur += L[i].y;
      }
    } else {
      q.push(L[i].y);
      cur+=L[i].y;
    }
  }
  return cur;
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int T;
  cin>>T;
  while(T--){
    vector<P>L,R;
    int n;
    cin>>n;
    ll ret = 0;
    for(int i=0;i<n;i++){
      int k,l,r;
      cin>>k>>l>>r;
      ret+=min(l,r);
      if(l>r){
        L.push_back(P(k, l-r));
      } else if(l<r&&k<n) {
        R.push_back(P(n-k, r-l));
      }
    }
    sort(L.begin(),L.end());
    sort(R.begin(),R.end());

    ret+=cal(L);
    ret+=cal(R);
    cout<<ret<<endl;
  }
  return 0;
}

Measured memory_bytes: 5624
class UnionFind
  attr_reader :parent
  attr_reader :rank

  def initialize(size)
    @rank = Array.new(size, 0)
    @parent = Array.new(size, -1)
  end

  def find(x)
    return x if (@parent[x]).negative?

    @parent[x] = find(@parent[x])
    @parent[x]
  end

  def union(x, y)
    px = find(x)
    py = find(y)

    return if px == py

    px, py = py, px if @parent[px] > @parent[py]
    @parent[px] += @parent[py]
    @rank[px] += 1
    @rank[py] = 0
    @parent[py] = px
  end

  def roots
    @parent.each_index.select { |i| @parent[i].negative? }
  end

  def count_groups
    roots.length
  end

  def same_parent?(x, y)
    find(x) == find(y)
  end
end

n, m = gets.strip.split.map(&:to_i)
uf = UnionFind.new n + 1

m.times do
  a, b = gets.strip.split.map(&:to_i)
  uf.union(a, b)
end

puts uf.count_groups - 2


Measured memory_bytes: 16264
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define ull         unsigned long long int
#define ll          long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> 
 
const long long INF = (long long) 1e11+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

ll power(ll x,ll y){
  ll res=1;
  while(y>0){
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;    
    y=y/2;
  }
  
  return res%hell;
}
 
ll modinv(ll x){
  return power(x,hell-2);
}

ll gcd(ll a,ll b){
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}    
    
void fastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

void solve(){
    ll n;
    cin>>n;
    ll a[n];
    //set<ll> st;
    forn(i,0,n){
        cin>>a[i];
        //st.insert(a[i]);
    }
    bool pr[1000006];
    memset(pr,false,sizeof(pr));
    sort(a,a+n);
    
    map<ll,ll> st;
    forn(i,0,n)
    st[a[i]]++;
    
    ll ans=0;
    forn(i,0,n){
        if(st[a[i]]==1 and pr[a[i]]==false)
        ans++;
        
        if(pr[a[i]])
        continue;
        
        for(ll j=a[i];j<=1000000;j+=a[i]){
            pr[j]=true;
        }
    }
    cout<<ans;    
}    

int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;    
      
   while(test--)
   solve();
}

Measured memory_bytes: 18652
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] l = new int[N];
            int[] r = new int[N];
            for (int i = 0; i < N; i++) {
                l[i] = in.nextInt();
                r[i] = in.nextInt();
            }

            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += r[i] - l[i] + 1;
            }

            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 25844
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(b>=c)cout<<"delicious"<<endl;
	else if(a+b<c)cout<<"dangerous"<<endl;
	else cout<<"safe"<<endl;	
}


Measured memory_bytes: 256
#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>;

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

    int n, h;
    string s;
    while (cin>>s) {
        if (s == "-") break;

        cin>>n;
        rep(i, n) {
            cin>>h;
            s = s.substr(h, s.size()) + s.substr(0, h);
        }
        cout<<s<<endl;
    }
}


Measured memory_bytes: 3200
#include <stdio.h>

int main(void){
  int n,m,a,b,flag=0;
  int fl[200001]={0};
  scanf("%d %d",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%d %d",&a,&b);
    if(a==1){
      fl[b]=fl[b]+1;
    }
    if(b==n){
      fl[a]=fl[a]+1;
    }
  }
  for(int i=1;i<=n;i++){
    if(fl[i]==2){
      printf("POSSIBLE\n");
      flag=1;
      break;
    }
  }
  if(flag==0)printf("IMPOSSIBLE\n");
  return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = int(1e5);
int N, a[MAX_N];

void solve() {
    ll ans = 0;
    REP(i, MAX_N - 2) {
        ll temp = 0;
        REP(j, 3) temp += a[i + j];
        ans = max(temp, ans);
    }
    cout << ans << endl;
}

int main() {
    cin >> N;
    int temp;
    REP(i, N) {
        cin >> temp;
        a[temp]++;
    }
    solve();
    return 0;
}

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

int main(){
    int h, w, sum, row[100] = {}, col[100] = {};
    char a[100][101];
   
    cin >> h >> w;
    for ( int i = 0; i < h; i++ ) {
        cin >> a[i];
    }
    
    for ( int i = 0; i < h; i++ ) {
        sum = 0;
        for ( int j = 0; j < w; j++ ) {
            if ( a[i][j] == '.' ) {
                sum++;
            }
        }
        
        row[i] = sum / w;
    }
    
    for ( int i = 0; i < w; i++ ) {
        sum = 0;
        for ( int j = 0; j < h; j++ ) {
            if ( a[j][i] == '.' ) {
                sum++;
            }
        }
        
        col[i] = sum / h;
    }
    
    for ( int i = 0; i < h; i++ ) {
        for ( int j = 0; j < w; j++ ) {
            if ( row[i] == 0 && col[j] == 0 ) {
                cout << a[i][j];
            }
        }
        if ( row[i] == 0 ) {
            cout << endl;
        }
    }
    
    return (0);
}

Measured memory_bytes: 3628
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int V[100010];
map<int, int> even, odd;
signed main() {
    int N; cin >> N;
    for(int i=0; i<N; i++) {
        cin >> V[i];
        (i % 2 == 0 ? even : odd)[ V[i] ]++;
    }

    set< pair<int, int> > even_S, odd_S;
    for(auto x : even) {
        even_S.insert(make_pair(x.second, x.first));
    }
    for(auto x : odd) {
        odd_S.insert(make_pair(x.second, x.first));
    }

    int ans = INF;
    const pair<int, int> NONE = make_pair(-1, -1);
    for(auto x : even_S) {
        int val = x.second, cnt = x.first;
        pair<int, int> tmp = NONE;
        if(odd.count(val)) {
            tmp = make_pair(odd[val], val);
        }

        odd_S.erase(tmp);
        int ans_A = N / 2 - cnt;
        int ans_B = N / 2 - (odd_S.size() ? odd_S.rbegin()->first : 0);
        ans = min(ans, ans_A + ans_B);

        if(tmp != NONE) odd_S.insert(tmp);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int N;
int arr[55];

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> arr[i];
    sort (arr, arr + N);

    double ans = arr[0];
    for (int i = 1; i < N; i++)
    {
        ans = (ans + arr[i]) / 2.;
    }

    cout << fixed << setprecision(10);
    cout << ans << "\n";
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char const *argv[])
{
	string S; cin >> S;
	int ans = INF;
	rep(i, S.size() - 2) {
		string sub = S.substr(i, 3);
		ans = min(ans, abs(stoi(sub) - 753));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define all(a)  (a).begin(),(a).end()

int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
signed main(){
  int n,m;
  cin>>n>>m;
  V<P<int,int>> a(m);
  fo(i,m){
    cin>>a[i].fi>>a[i].se;
  }
  Sort(a);
  int b=0;
  fo(i,m-1){
    if(a[i].fi==a[i+1].fi&&a[i].se!=a[i].se)
      b=1;
  }
  if(b){
    cout<<-1<<endl;
    return 0;
  }
  uni(a);
  if(n==1&&m==0){
    cout<<0<<endl;
    return 0;
  }
  if(n==2&&m==0){
    cout<<10<<endl;
    return 0;
  }
  if(n==3&&m==0){
    cout<<100<<endl;
    return 0;
  }
  if(n==1&&a[0].se==0){
    cout<<0<<endl;
    return 0;
  }
  if(n==2||n==3){
    fo(i,m){
      if(a[i].fi==1&&a[i].se==0){
        cout<<-1<<endl;
        return 0;
      }
    }
  }
  for(int i=1; i<=999; i++){
    if(keta(i)!=n)
      continue;
    int d=1;
    string c=to_string(i);
    fo(j,m){
      if(c[a[j].fi-1]-'0'!=a[j].se){
        d=0;
      }
    }
    if(d){
      cout<<i<<endl;
      return 0;
    }
    
  }
  cout<<-1<<endl;
}


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

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int x=Integer.parseInt(bu.readLine());
        if(x==0) sb.append(1);
        else sb.append(0);
        System.out.print(sb);
    }
}


Measured memory_bytes: 32376
#include <bits/stdc++.h>
#define rep0(a,b) for(int a = 0; a < b; a++)
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a > b)cout << a + a - 1 << endl;
  else if(b > a)cout << b + b - 1 << endl;
  else cout << a + b << endl;
  return 0;
}

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

int main() {
	int w, h, x, y, r;
		cin >> w >> h >> x >> y >> r;
			if (0 <= x - r && x + r <= w){
				if (0 <= y - r && y + r <= h) {
					cout << "Yes" << endl;
				}
		        else {
					cout << "No" << endl;
				}
			}           
			else {
				cout << "No" << endl;
			}
		
}


Measured memory_bytes: 3100
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int A = Integer.parseInt(st.nextToken());
         int B = Integer.parseInt(st.nextToken());
         int C = Integer.parseInt(st.nextToken());
         int K = Integer.parseInt(st.nextToken());
         if(K <= A+B)
            System.out.println(Math.min(K, A));
         else
         {
            int left = K-A-B;
            System.out.println(A-left);
         }
      }
   }

Measured memory_bytes: 32516
n, k = map(int, input().split())
a = list(sorted(list(map(int, input().split()))))
mod = 1000000007
fact = [1]
for i in range(1,n+1):
  fact.append((fact[-1] * i)%mod)
res = 0
for i in range(k-1, n):
  cnt = (a[i]*fact[i])%mod
  cnt = (cnt*pow(fact[k-1], mod-2, mod))%mod
  cnt = (cnt*pow(fact[i-k+1], mod-2, mod))%mod
  res = (res + cnt)%mod
  cnt = (a[n-i-1]*fact[i])%mod
  cnt = (cnt*pow(fact[k-1], mod-2, mod))%mod
  cnt = (cnt*pow(fact[i-k+1], mod-2, mod))%mod
  res = (res - cnt + mod)%mod
print(res)


Measured memory_bytes: 65448
#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>

using namespace std;

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

    double res=0;
    for(int i=0; i<N-1; ++i){
        for(int j=i; j<N; ++j){
            res += sqrt(pow(x[i]-x[j], 2) + pow(y[i]-y[j], 2)) * 2 / N;
        }
    }
    cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 256
#-*- coding: utf-8 -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(a, b, c):
    return min(int(b/a), c)


do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(int, line.split())) for line in lines]
    a, b, c = parsed_lines[0]
    return a, b, c


if not do_submit:
    a, b, c = input_parse("""
    2 11 4
    """)
    print(sol(a, b, c))
else:
    a, b, c = list(map(int, input().split()))
    print(sol(a, b, c))
    # S = input().strip()
    # print(sol(S))



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

#define IO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define m(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=3e5+10;

int main(){
	IO;
	int a,b,c;
	while(cin>>a>>b>>c){
		int ans=0;
		if (a>b) swap(a,b);
		if (b>c) swap(b,c);
		int d1=b-a,d2=c-b;
		a+=d2,b+=d2;
		ans+=d2;
		int x=c-a;
		if (x==1) ans+=2;
		else if (x%2==0) ans+=x/2;
		else{
			ans+=(b-1-a)/2+2;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int N,M,X,Y;

  cin>>N>>M>>X>>Y;

    vector<int> x(N);
  vector<int> y(M);
  rep(i,N)cin>>x[i];
  rep(i,M)cin>>y[i];
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  repeat(z,x[N-1]+1,y[0]+1) {
    if(X<z&&z<=Y) {
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
  return 0;
}


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

const int MAX = 1001001001;

int main() {
  int N, H;
  cin >> H >> N;
  vector<int> dp(H + 1, MAX);
  dp[0] = 0;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    for (int j = 0; j < H; j++) {
      int index = min(j + a, H);
      dp[index] = min(dp[index], dp[j] + b); 
    }
  }
  cout << dp[H] << endl;
}


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

int main() {
    int n, W;
    cin >> n >> W;
    int weight[110], value[110];
    for (int i = 0; i < n; i++) cin >> value[i] >> weight[i];

    int dp[110][10010];
    for (int w = 0; w <= W; w++) dp[0][w] = 0;

    for (int i = 0; i < n; i++) {
        for (int w = 0; w <= W; w++) {
            if (w >= weight[i]) dp[i + 1][w] = max(dp[i][w], dp[i][w - weight[i]] + value[i]);
            else dp[i + 1][w] = dp[i][w];
        }
    }

    cout << dp[n][W] << endl;
    return 0;
}


Measured memory_bytes: 7060