akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def build_grid(H, W, intv, _type, space=True, padding=False):
    # 入力がスペース区切りかどうか
    if space:
        _input = lambda: input().split()
    else:
        _input = lambda: input()
    _list = lambda: list(map(_type, _input()))
    # 余白の有無
    if padding:
        offset = 1
    else:
        offset = 0
    grid = list2d(H+offset*2, W+offset*2, intv)
    for i in range(offset, H+offset):
        row = _list()
        for j in range(offset, W+offset):
            grid[i][j] = row[j-offset]
    return grid

grid = build_grid(3, 3, 0, int)
D = {}
for i in range(3):
    for j in range(3):
        D[grid[i][j]] = (i, j)

N = INT()
res = list2d(3, 3, 0)
for _ in range(N):
    a = INT()
    if a in D:
        i, j = D[a]
        res[i][j] = 1

for i in range(3):
    if sum(res[i]) == 3:
        Yes()
        exit()
res = list(zip(*res))
for i in range(3):
    if sum(res[i]) == 3:
        Yes()
        exit()
if res[0][0] and res[1][1] and res[2][2] or res[0][2] and res[1][1] and res[2][0]:
    Yes()
else:
    No()


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#include<math.h>
#include<string.h>
#include<set>
#include<algorithm>
using namespace std;

int main() {
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;

    int diff = (a+b) - c*2;
    int old = a*x+b*y;
    if(diff <= 0){
        cout<<old<<endl;
    }
    else{
        int New = old - diff*min(x,y);
        int Yokei = c*max(x,y)*2;
        if(New < Yokei) cout<<New<<endl;
        else cout<<Yokei<<endl;
    }
}





Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a1 = 0;
	int a2 = 0;
	int a3 = 0;
	int t1, t2;
	int x, i;
	
	for(i = 0; i< 10; i++){
		scanf("%d", &x);
		if(x >= a1){
			t1 = a1; t2 = a2;
			a1 = x;
			a2 = t1;
			a3 = t2;
		}else if(x >= a2){
			t2 = a2;
			a2 = x;
			a3 = t2;
		}else if(x >= a3){
			a3 = x;
		}
	}
	
	printf("%d\n%d\n%d\n", a1, a2, a3);
	
	return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    rep(i, n + 1) {
        rep(j, n + 1) {
            int ab = r * i + g * j;
            if (ab > n)break;
            if ((n - ab) % b == 0)ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int N,X;
	cin >> N>>X;
	vector<int> L(N);
	for(int i=0;i<N;i++){
		cin>>L.at(i);
	}
	int count =1;
	int d=0;
	for(int i=1;i<N+1;i++){
		d=d+L.at(i-1);
		if(d<=X){
			count++;
		}
	}
	cout <<count<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int a, b, c, d;
int main(void) {
    int i;
    scanf("%c%c%c%c", &a, &b, &c, &d);
    a -= '0';
    b -= '0';
    c -= '0';
    d -= '0';
    for (i = 0; i < 8; ++i) {
        if (a + (i & 4 ? -b : b) + (i & 2 ? -c : c) + (i & 1 ? -d : d) == 7) {
            break;
        }
    }
    printf("%d%c%d%c%d%c%d=7\n", a, (i & 4 ? '-' : '+') , b, (i & 2 ? '-' : '+'), c, (i & 1 ? '-' : '+'), d);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>           // sorted map so O(logn)
#include <unordered_map> // O(1)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

int main()
{
    int n;
    cin >> n;
    double t = (n / 2) + (n % 2);
    cout << fixed << setprecision(10) << t / n << endl;
}


Measured memory_bytes: 3788
import copy

dirs = [[-1, -1], [-1, 0], [-1, 1],
        [0, -1], [0, 1],
        [1, -1], [1, 0], [1, 1]]

def place(board, r, c):
    if board[r][c] != '.':
        return False
    board[r][c] = 'Q'
    for d in dirs:
        rr = r + d[0]
        cc = c + d[1]
        while rr >= 0 and rr < 8 and cc >= 0 and cc < 8:
            board[rr][cc] = 'x'
            rr += d[0]
            cc += d[1]
    return True

def solve(board_):
    board = copy.deepcopy(board_)
    for r in range(8):
        for c in range(8):
            if place(board, r, c):
                tmp = solve(board)
                if tmp:
                    return tmp
                else:
                    board = copy.deepcopy(board_)
    if sum([row.count('Q') for row in board]) == 8:
        return board

def disp(board, clean=False):
    for row in board:
        if clean:
            row = ['.' if i == 'x' else i for i in row]
        print(''.join(row))

board = [['.'] * 8 for i in range(8)]
N = int(input())
for _ in range(N):
    r, c = map(int, input().split())
    place(board, r, c)

board = solve(board)

disp(board, True)




Measured memory_bytes: 6348
import numpy as np
H, W = map(int, input().split())

grid = np.array([[0] * (W + 2)] * (H + 2))

bombs = [0] * H
for h in range(H):
    bombs[h] = input()

for h in range(H):
    for w in range(W):
        if bombs[h][w] == '#':
            grid[h + 2][w + 2] += 1
            grid[h + 2][w + 1] += 1
            grid[h + 2][w + 0] += 1
            grid[h + 1][w + 2] += 1
            grid[h + 1][w + 0] += 1
            grid[h + 0][w + 2] += 1
            grid[h + 0][w + 1] += 1
            grid[h + 0][w + 0] += 1
            grid[h + 1][w + 1] = 100

grid[grid>=100] = 100
arr = grid.astype('str')
arr[arr=='100'] = '#'
for i in range(1, H + 1):
    print(''.join(arr[i][1:-1]))

Measured memory_bytes: 12620
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

int dp[200010][5];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	rep(i, n) {
		rep(j, 5) {
			int prev = INF;
			rep(k, j + 1) chmin(prev, dp[i][k]);
			if (j == 0 || j == 4) dp[i + 1][j] = prev + a[i];
			else if (j == 1 || j == 3) {
				if (a[i] == 0) dp[i + 1][j] = prev + 2;
				else if (a[i] % 2 == 0) dp[i + 1][j] = prev;
				else dp[i + 1][j] = prev + 1;
			}
			else {
				if (a[i] % 2 == 0) dp[i + 1][j] = prev + 1;
				else dp[i + 1][j] = prev;
			}
		}
	}
	int ans = INF;
	rep(j, 5) chmin(ans, dp[n][j]);
	cout << ans << endl;
}

Measured memory_bytes: 9728
import collections
N = int(input())
S = [str(input()) for i in range(N)]
new_S = collections.Counter(S)
M = max(new_S.values())
X = []
for K,V in new_S.items():
  if V == M:
    X.append(K)
X.sort()
for x in X:
  print(x)

Measured memory_bytes: 35568
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    
    cin >> a >> b;
    
    if (a * b % 2 == 0 ){
     cout << "Even" << endl;
    }
    
    else {
     cout << "Odd" << endl;
    }
    
}


Measured memory_bytes: 3592
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int w,d;cin>>w>>d,w|d;){
		set<int> s;
		map<int,int> a,b;
		rep(i,w){
			int temp;
			cin>>temp;
			s.insert(temp);
			a[temp]++;
		}
		rep(i,d){
			int temp;
			cin>>temp;
			s.insert(temp);
			b[temp]++;
		}
		int res=0;
		foreach(i,s)
			res+=(*i)*max(a[*i],b[*i]);
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,m;
  cin>>n>>m;
  vector<pll> ans(0);
  ll cu=1;
  ll nn=n;
  ll mm=m;
  if(n%2==1){
    nn--;
    while(mm){
      ans.pb(pll(cu,nn));
      nn--;cu++;mm--;
    }
    rep(i,sz(ans)){
      cout<<ans[i].F<<" "<<ans[i].S<<endl;
    }
  }
  else{
    nn=n/2;
    while(mm&&cu<nn){
      ans.pb(pll(cu,nn));
      cu++;nn--;
      mm--;
    }
    if(mm){
      ll cu=n/2+1;
      nn=n-1;
      while(mm){
        ans.pb(pll(cu,nn));
        cu++;
        nn--;
        mm--;
      }
    }
    rep(i,sz(ans)){
      cout<<ans[i].F<<" "<<ans[i].S<<endl;
    }
  }
}


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

int ans=100000001;

void keychoise(int bn, int &sum, vector<vector<int>> &box, vector<pair<int,vector<int>>> &key, vector<bool> &check);

void open(int kn, int bn, int sum, vector<vector<int>> &box, vector<pair<int,vector<int>>> &key, vector<bool> check){
  auto p=key.at(kn);
  sum+=p.first;
  if (sum>=ans) return;
  for (int j: p.second) check.at(j)=true;
  keychoise(bn+1,sum,box,key,check);
}

void keychoise(int bn, int &sum, vector<vector<int>> &box, vector<pair<int,vector<int>>> &key, vector<bool> &check){
  if (bn==box.size()){
    ans=min(ans,sum);
    return;
  }
  if (check.at(bn)) keychoise(bn+1,sum,box,key,check);
  else for (int i: box.at(bn)) open(i,bn,sum,box,key,check);
}

int main(){
  int n,m,a,b,c;
  cin>> n >> m;
  vector<vector<int>> box(n);
  vector<pair<int,vector<int>>> key(m);
  for (int i=0; i<m; i++){
    cin>> a >> b;
    key.at(i)=pair<int,vector<int>>(a,{});
    for (int j=0; j<b; j++){
      cin>> c;
      key.at(i).second.push_back(c-1);
      box.at(c-1).push_back(i);
    }
  }
  
  vector<bool> check(n);
  
  int sum=0;
  bool possible=true;
  for (int i=0; i<n; i++){
    auto v=box.at(i);
    if (v.size()==0){
      possible=false;
      ans=-1;
      break;
    }
    else if (v.size()==1){
      auto p=key.at(v.at(0));
      sum+=p.first;
      for (int j: p.second) check.at(j)=true;
    }
  }
  
  if (possible) keychoise(0,sum,box,key,check);
  
  cout<< ans <<endl;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import numpy as np
N = int(input())
H = np.array(list(map(int, input().split())))
sum = 1
for i in range(1, N):
  max_hight = np.max(H[:i])
  if(H[i] >= max_hight):
    sum += 1

print(sum)


Measured memory_bytes: 12424
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int h,w;
    cin>>h>>w;
    char s[h][w];

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

    int dp[100][100] = {};

    if(s[0][0] == '#') dp[0][0] = 1;

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i==0&&j==0) continue;

            if(i == 0){
                dp[i][j] = dp[i][j-1] + (s[i][j-1]=='.'&&s[i][j]=='#');
            }
            else if(j == 0){
                dp[i][j] = dp[i-1][j] + (s[i-1][j]=='.'&&s[i][j]=='#');
            }
            else{
                dp[i][j] = min(
                        dp[i][j-1] + (s[i][j-1]=='.'&&s[i][j]=='#'),
                        dp[i-1][j] + (s[i-1][j]=='.'&&s[i][j]=='#')
                        );
            }
        }
    }

    cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

public class Main
{

	static class C implements Comparator<Item>
	{

		@Override
		public int compare(Item arg0, Item arg1) 
		{
			if(arg0.num == true && arg1.num == false) return -1;
			else
			{
				if(arg0.num == true) 
				{
					return Integer.parseInt(arg0.con) - Integer.parseInt(arg1.con);
				}
				else
				{
					return arg0.con.compareTo(arg1.con);
				}
			}
			// TODO Auto-generated method stub
		}
	}
	
	static class Item implements Comparable<Item>
	{
		boolean num;
		String con;
		
		public Item(String t, boolean isnum)
		{
			con = t;
			num = isnum;
		}

		@Override
		public int compareTo(Item o) 
		{
			if(num == true && o.num == false) return -1;
			else
			{
				if(num == true) 
				{
					return Integer.parseInt(con) - Integer.parseInt(o.con);
				}
				else
				{
					return con.compareTo(o.con);
				}
			}
		}
	}
	
	static class Filename implements Comparable<Filename>
	{
		ArrayList<Item> con = new ArrayList<Item>();
		String text = "";
		
		public Filename(String t)
		{
			text = t;
			
			boolean num = true;
			boolean wasnum = true;
			int itemstartindex = 0;
			
			for(int i = 0; i <= t.length(); i++)
			{
//				System.out.println(i);
				if(i < t.length())
				{
					num = (t.charAt(i) >= '0' && t.charAt(i) <= '9');
				}
				else
				{
//					wasnum = (t.charAt(i) >= '0' && t.charAt(i) <= '9');
				}
				
				if(num != wasnum || i == 0 || i == t.length())
				{ //new item
//					System.out.println("NEW AT i = " + i);
//					if(i == t.length()-1)i++;
					//end previous item
					if(i > 0)
					{
						String itemc = t.substring(itemstartindex, i);
//						System.out.println("ADDING NEW ITEM " + itemc + " " + wasnum);
						con.add(new Item(itemc, wasnum));
					}
					itemstartindex = i;
					//new item
				}
				
				wasnum = num;
			}
		}

		@Override
		public int compareTo(Filename o) 
		{
			for(int i = 0; i < Math.min(con.size(), o.con.size()); i++)
			{
				Item i1 = con.get(i);
				Item i2 = o.con.get(i);
				int comp = i1.compareTo(i2);
				
				if(comp != 0)
				{
					return comp;
				}
			}
			
			return con.size() - o.con.size();
		}
	}
	
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String s = sc.next();
		Filename f0 = new Filename(s);
		
		for(int i = 0; i < n; i++)
		{
			String in = sc.next();
			Filename f = new Filename(in);
			
			if(f.compareTo(f0) < 0)
			{
				System.out.println("-");
			}
			else
			{
				System.out.println("+");
			}
		}

	}

}



Measured memory_bytes: 32228
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2e5+10;
int a[maxn];
int main(){
	int n=read();
	REP(i,1,n) a[i]=read();
	if(a[1]!=0){
		printf("-1\n");
		return 0;
	}
	REP(i,2,n) if(a[i]>a[i-1]+1){
		printf("-1\n");
		return 0;
	}
	ll ans=a[n];
	DREP(i,n-1,2) if(a[i]!=a[i+1]-1) ans+=a[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
n=int(input())
f=[list(map(int,input().split())) for i in range(n)]
p=[list(map(int,input().split())) for i in range(n)]
ans=-10**18
for i in range(1,2**10):
  d=0
  for j in range(n):
    cnt=0
    for k in range(10):
      if i>>k&1==f[j][k]==1:
        cnt+=1
    d+=p[j][cnt]
  ans=max(ans,d)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
// long long m=1000000007;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    long long t,m,n,i=5,j,k,temp,sum=0,flag=0,count=0,mi=300000,x,y;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> temp;
        if(temp<= mi){
            count++;
            mi =temp;
        }
    }
    cout << count;
}

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

using namespace std;

long long int len[1000];

int n, m;

bool check(long long int w){
	int count = 0;
	int sum = 0;
	for(int i = 0; i < n; i++){
		if(len[i] > w){
			return false;
		}
	}
	for(int i = 0; i < n; i++){
		sum += len[i];
		if(sum > w){
			sum = len[i];
			count++;
		}
	}
	count += 1;
	return count <= m;
}

long long int bin_search(long long int wmin, long long int wmax){
	if(wmax - wmin <= 1){
		if(check(wmin)){
			return wmin;
		}else{
			return wmax;
		}
	}
	long long int wmid = (wmin + wmax) / 2;
	if(check(wmid)){
		wmax = wmid;
	}else{
		wmin = wmid;
	}
	bin_search(wmin, wmax);
}

int main(){
	
	while(true){
		cin >> m >> n;
		if(n == 0 && m == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			cin >> len[i];
		}
		
		cout << bin_search(0, 2000000) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2952
function Main(input) {
  var input = input.split("\n")[0];
  var h = input.split("").map(e => parseInt(e, 10)).reduce((acc, cur) => acc + cur);
  console.log(parseInt(input, 10) % h === 0 ? "Yes":"No");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

bool distance(vector<int> y, vector<int> z)
{
    int sum = 0;
    rep (i, SZ(y))
    {
        sum += (y[i] - z[i])*(y[i] - z[i]);
    }

    int tmp = (int)sqrt((double)sum);
    if (tmp*tmp == sum)
    {
        return true;
    }
    return false;
}

int main()
{
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X;

    X.resize(N);
    rep (y, N)
    {
        X[y].resize(D);
        rep (x, D)
        {
            cin >> X[y][x];
        }
    }

    int count = 0;
    for (int i = 0; i < N; ++i)
    {
        for (int k = i + 1; k < N; ++k)
        {
            if (distance(X[i], X[k]))
            {
                count++;
            }
        }
    }

    cout << count << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define INF LONG_MAX
#define io freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int32_t main()
{
   // io;
    boost;
    int n;
    cin>>n;
    if(n%2==1)
    {
        cout<<0<<endl;
        return 0;
    }
    int ans=0,cnt=1;
    while(cnt<n)
    {
        cnt*=5;
        ans+=n/(cnt*2);
    }
    cout<<ans<<endl;    
}



Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var X, Y int

func main() {
	sc.Split(bufio.ScanWords)
	X, Y = nextInt(), nextInt()

	if abs(X-Y) <= 1 {
		fmt.Println("Brown")
	} else {
		fmt.Println("Alice")
	}

}

func abs(a int) int {
	if a < 0 {
		return -1 * a
	}
	return a
}


Measured memory_bytes: 640
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
typedef long long ll;

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

int n;
int a[N][N];
int dp[1 << N], lg[1 << N];
int dp2[N][1 << N];

int solve(int i, int msk) {
  if(i >= n) return 1;
  int& r = dp2[i][msk];
  if(r != -1) return r;
  r = 0;
  for(int cur = msk; cur > 0; cur -= cur & -cur) {
    int j = lg[cur & -cur];
    if(a[i][j]) {
      r += solve(i + 1, msk ^ (1 << j));
      if(r >= Mod) r %= Mod;
    }
  }
  return r;
}

int main()
{
  cin >> n;
  lg[1] = 0;
  for(int i = 2 ; i < (1 << n) ; i++)
    lg[i] = 1 + lg[i >> 1];

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

  // dp[0] = 1;
  // for(int i = 0; i < n; i++) {
  //   for(int msk = (1 << n) - 1; msk >= 0; msk--) {
  //     dp[msk] = 0;
  //     for(int cur = msk; cur > 0; cur -= cur & -cur) {
  //       int j = lg[cur & -cur];
  //       if(a[i][j]) {
  //         dp[msk] += dp[msk ^ (1 << j)];
  //         if(dp[msk] > Mod) dp[msk] -= Mod;
  //       }
  //     }
  //   }
  // }
  memset(dp2, -1, sizeof dp2);
  cout << solve(0, (1 << n) - 1) << endl;
  // cout << dp[(1 << n) - 1] << endl;
  return 0;
}


Measured memory_bytes: 182528
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - 500 Yen Coins
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int k, x;
  scanf("%d%d", &k, &x);

  if (500 * k >= x) puts("Yes");
  else puts("No");
  return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const int N=200000;
double dp[20][N+1];

inline double cost(int before, int after)
{
    return fabs(before-after)/before;
}

int main()
{
    int n;
    cin >>n;
    vector<int> a(n);
    rep(i,n) cin >>a[i];

    fill(dp[0],dp[20],1e10);
    for(int i=1; i<=N; ++i) dp[0][i]=cost(a[0],i);
    for(int i=1; i<n; ++i)for(int j=1; j<=N; ++j)for(int k=j; k<=N; k+=j) dp[i][k]=min(dp[i][k],max(dp[i-1][j],cost(a[i],k)));
    
    double ans=1e10;
    for(int i=1; i<=N; ++i) ans=min(ans,dp[n-1][i]);
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 34464
//
// Created by yamunaku on 2019/08/04.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int n, k;
vi a;

bool check(int x){
    int plus = 0, minus = 0;
    vector<int> p(n);
    ll sum=0;
    rep(i,n){
        p[i]=a[i]%x;
        sum+=p[i];
    }
    sort(all(p));
    ll q=sum/x;
    ll move=0;
    rep(i,n-q){
        move+=p[i];
    }
    return move<=k;
}

int main(){
    cin >> n >> k;
    ll sum = 0;
    a = vi(n);
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }
    ll ans = 1;
    for(ll i = 1; i <= sqrt(sum) + 1; i++){
        if(sum % i == 0){
            if(check(i)) ans = max(ans, i);
            if(check(sum / i)) ans = max(ans, sum / i);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <vector>
#include <iomanip>
#include <utility>
using namespace std;
#define ll long long

int main(void){
    string s;
    cin >> s;
    for(ll i = 0; i < s.length(); i++)
        cout << 'x';
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >>N>>M;
  string a,b,c,d;
  c=to_string(N);
  d=to_string(M);
  for(int i=0;i<N;i++){
    a+=d;
  }
  for(int i=0;i<M;i++){
    b+=c;
  }
  if(N<M){
    cout<<b<<endl;
  }
  else {
    cout<<a<<endl;
  } 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef TEST
#include <mytest.h>
#else
#define open(...) 0
#define print(...) 42
#endif
using namespace std;
namespace io {
  const int SZ = (1 << 22) + 1;
  char buf[SZ], *ptr = NULL, *bnd = NULL;
  #define GC() ((ptr == bnd) ? (ptr = buf, bnd = buf + fread(buf, 1, SZ, stdin), (ptr == bnd) ? EOF : (*(ptr++))) : (*(ptr++)))
  #define STATE(c) { if (c == '-') sgn = -1; else if (c == EOF) return false; }
  inline bool skip(const char& c) { return c < '0' || c > '9'; }
  template <class V>
  inline bool Read(V &v) {
    register char c, sgn = 1;
    while (skip(c = GC())) STATE(c);
    for (v = c - '0'; !skip(c = GC()); v = v * 10 + c - '0');
    return (v *= sgn), true;
  }
  char oBuf[SZ], *oCur = oBuf, *oBnd = oBuf + SZ, oStk[21], top = 0;
  inline void flush() { if (oCur - oBuf) fwrite(oBuf, 1, oCur - oBuf, stdout), oCur = oBuf; }
  inline void pc(char c) { *(oCur++) = c; if (oCur == oBnd) flush(); }
  template <class V>
  inline void Print(V v) {
    if (!v) return pc('0');
    if (v < 0) v = -v, pc('-');
    while (v) oStk[top++] = v % 10, v /= 10;
    while (top) pc(oStk[--top] + '0');
  }
  template <class V>
  inline void Println(const V& v) { Print(v), pc('\n'); }
  struct flusher { ~flusher() { flush(); } } __flusher__;
}
using io::Read;
using io::Println;
const int N = 1e3 + 5;
int a[N][N], nx[N];
bool vis[N];
int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  // cin >> n;
  Read(n);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < n - 1; j++) {
      // cin >> a[i][j];
      Read(a[i][j]);
    }
  }

  int ans = 0, flg = 1, cnt = 0;
  while (flg) {
    flg = 0;
    memset(vis, 0, sizeof vis);
    for (int i = 1; i <= n; i++) {
      if (nx[i] == n || vis[i]) continue;
      int t = a[i][nx[i]];
      if (i == a[t][nx[t]] && !vis[t]) {
        flg = 1;
        vis[i] = vis[t] = 1, cnt++;
        nx[t]++, nx[i]++;
      }
    }
    if (flg) ans++;
  }
  if (cnt != n * (n - 1) / 2) ans = -1;
  cout << ans << endl;
}


Measured memory_bytes: 10240
#include<stdio.h>
main()
{
    int k[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    int n;
    scanf("%d",&n);
    printf("%d",k[n-1]);

    
}

Measured memory_bytes: 128
'use strict';
function Main(is) {
  const i = is.split("\n");
  let s = i[0], p = parseInt(i[1]);
  let code, lastLetter;
  for(let i = 0;i < s.length;i++){
    code = s[i].charCodeAt(0);
    if (s.length - 1 == i) {
      code += p%26;
      if(code > 122){
        code += (- 122 + 97 - 1);
      }
      lastLetter = String.fromCharCode(code);
      s = s.slice(0, i) + lastLetter + s.slice(i+1);
    } else {
      if((27 - (code - 97 + 1)) <= p && !(s[i] == "a")){
        p = p - (27 - (code - 97 + 1));
        s = s.slice(0, i) + "a" + s.slice(i+1);
      }
    }
  }
  console.log(s);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

vector<int> to[200001];
vector<int> ans;

void dfs(int i, int x) {
  // (*ans)[i] += x;
  for (int aa : to[i]) {
    if (aa == x) continue;
    ans[aa] += ans[i];
    dfs(aa, i);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  rep(i, n - 1) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    to[x].push_back(y);
    to[y].push_back(x);
  }

  ans.resize(n);
  rep(i, q) {
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0, -1);
  for (int a : ans) cout << a << endl;
  return 0;
}

Measured memory_bytes: 23552
A, B, C, X, Y = map(int, input().split())
res = A*X + B*Y
for i in range(max(X,Y)):
    if i >= X:
        res = min(res-B+2*C,res)
    elif i >= Y:
        res = min(res-A+2*C,res)
    else:
        res = min(res-A-B+2*C,res)
print(res)

Measured memory_bytes: 64812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=2e9;

int main(){
    ll n,k;
    cin>>n>>k;
    pair<ll,ll> array[100010];
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        array[i]=make_pair(a,b);
    }
    sort(array,array+n);
    for(int i=1;i<n;i++){
        array[i].second+=array[i-1].second;
    }
    for(int i=0;i<n;i++){
        if(k<=array[i].second){
            cout<<array[i].first<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1792
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int weight = sc.nextInt();
        int[] w = new int[n+1];
        int[] v = new int[n+1];
        int sum = 0;
        long INF = 1000000000000L;
        for(int i=1;i<w.length;i++)
        {
        	w[i] = sc.nextInt();
        	v[i] = sc.nextInt();
        	sum = sum + v[i];
        }

        long[][] dp = new long[n+1][sum+1];

        Arrays.fill(dp[0],INF);
        dp[0][0] = 0L;
        for(int i=1;i<dp.length;i++)
        {
        	Arrays.fill(dp[i],INF);
        	dp[i][0] = 0L;
        	for(int j=1;j<dp[i].length;j++)
        	{
        		
        		if(j-v[i]>=0)
        		{
        			dp[i][j] = Math.min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
        		}
        		
        		dp[i][j] = Math.min(dp[i][j],dp[i-1][j]);
        	}
        }
        
        int ans  = 0;

        for(int i=dp[n].length-1;i>=0;i--)
        {
        	if(dp[n][i]<=weight)
        	{
        		ans = i;
        		break;
        	}	
        }

        System.out.println(ans);
       
 	}
}

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

vector<long long>adj[100005];

int main()
{


        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=0,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        multiset<long long>mst,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        scanf("%lld %lld",&n,&m);
        for(i=1;i<=n;i++)
        {
            scanf("%lld %lld",&a,&b);
            adj[a].push_back(b);

        }

        for(i=1;i<=m;i++)
        {

           sz=adj[i].size();
           for(j=0;j<sz;j++)
           {
               fr=adj[i][j]; mst.insert(fr);
           }

           if(!mst.empty())
           {
               d=*mst.rbegin(); ans=ans+d; mst.erase(mst.lower_bound(d));
           }

        }


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






    return 0;
}





Measured memory_bytes: 11344
#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int MOD = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  int n, k, q;
/*  string Sn, Sk, Sq;
  cin.get( Sn, 10, ' ' );
  cin.get( Sk, 10, ' ' );
  cin.get( Sq, 10, ' ' );
  n = Integer.valueOf(Sn).intValue();
  k = Integer.valueOf(Sk).intValue();
  q = Integer.valueOf(Sq).intValue();*/
  cin >> n;
  cin >> k;
  cin >> q;
  int* p = new int[n];
  int* a = new int[q];
  for (int i = 0; i < n; i++)
  {
    p[i] = k - q;
  }
  
  for (int i = 0; i < q; i++)
  {
    int a;
    cin >> a;
    p[a-1]++;
  }
  
  for (int i = 0; i < n; i++)
  {
    if (p[i] > 0)
    {
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	long N,i;
	long long x;
	while(~scanf("%ld",&N))
	{
		x=1;
		for(i=1;i<=N;i++)
		x=x*i%(1000000007);
		printf("%lld\n",x);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    long found=0;
    long i;
    for(i=0; i<n; i++) {
        char str[1024]={0};
        scanf("%s", str);
        if(str[0]=='Y') {
            found = 1;
        }
    }
    if( found) {
        printf("Four\n");
    }
    else {
        printf("Three\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  string s;
  cin>>s;
  if(s=="zyxwvutsrqponmlkjihgfedcba"){
    cout<<-1;
    return 0;
  }
  set<char> st;
  for(auto&& e: s) {
    st.insert(e);
  }
  if(st.size()!=26){
    for (char c = 'a'; c <='z' ; ++c)
    {
      if(st.find(c)!=st.end()) continue;
      cout<<s<<c;
      return 0;
    }
  }

  for (int i = 25; i >= 0; --i)
  {
    for(char c=s[i]+1;c<='z';c++){
      bool flag=true;
      for(int j=0;j<i;j++){
        if(s[j]==c) flag=false;
      }
      if(flag){
        for(int k=0;k<i;k++){
          cout<<s[k];
        }
        cout<<c;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}
struct UnionFind{
    vector<int> pare;
    vector<int> rank;
    UnionFind(int N):pare(N),rank(N){
        rep(i,N){
            pare[i]=i;
            rank[i]=0;
        }
    }
    int root(int x){
        if(pare[x]==x)return x;
        return pare[x]=root(pare[x]);
    }
    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx==ry)return ;
        if(rank[rx]>rank[ry]){
            pare[rx]=ry;
        }else {
            pare[ry] = rx;
            if (rank[rx] == rank[ry])rank[rx]++;
        }
    }

    bool same(int x,int y){
        return root(x)==root(y);
    }
};
int main(){
    int n,m;
    cin>>n>>m;
    UnionFind u(n+1);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        u.unite(a,b);
    }
    map<int,int> ma;
    rep(i,n){
        int roo = u.root(i+1);

        ma[roo]++;
    }
   ll ans = 0;
    for(auto &a:ma){
        if(a.second>ans){
            ans=a.second;
        }
    }
    cout<<ans<<endl;

return 0;
}


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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

//INSERT ABOVE HERE
const int MAX = 505;
int alive[MAX][MAX];
int dp[MAX][MAX];

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

  int n;
  cin>>n;
  auto ps=read(n*n);
  for(int &p:ps) p--;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      alive[i][j]=1;
      dp[i][j]=min({i,j,n-1-i,n-1-j});
    }
  }

  int dy[]={0,0,1,-1};
  int dx[]={1,-1,0,0};
  auto in=[&](int y,int x){return 0<=y and y<n and 0<=x and x<n;};

  auto bfs=[&](int y,int x){
    using P = pair<int, int>;
    queue<P> que;
    alive[y][x]=0;
    que.emplace(y,x);
    while(!que.empty()){
      auto [y,x]=que.front();que.pop();
      for(int k=0;k<4;k++){
        int ny=y+dy[k],nx=x+dx[k];
        if(!in(ny,nx)) continue;
        int nd=dp[y][x]+alive[y][x];
        if(dp[ny][nx]>nd){
          dp[ny][nx]=nd;
          que.emplace(ny,nx);
        }
      }
    }
  };

  int ans=0;
  for(int p:ps){
    ans+=dp[p/n][p%n];
    bfs(p/n,p%n);
  }
  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 6080
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int h[100005];
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&h[i]);
	}
	sort(h,h+n);
	int min=1000000001;
	for(int i=0;i<n+1-k;i++)
	{
		int re=h[i+k-1]-h[i];
		min=min<re?min:re;
	}
	printf("%d",min);
}

Measured memory_bytes: 512
N = gets.to_i

def gen(n)
  (1..n).map{ |i|
    (i+1..n).map{ |j|
      (i + j) == (n + 1) ? nil : "#{i} #{j}"
    }.compact
  }.flatten(1)
end

if N == 3
  puts [2, "1 3", "2 3"]; exit
end

es = nil
if N % 2 == 0
  es = gen(N)
else
  es = gen(N-1)
  (1..N-1).each{ |i| es << "#{i} #{N}" }
end
puts es.size, es


Measured memory_bytes: 2172
import java.util.Scanner;
import java.lang.Math;
public class Main {

    public static void main(String[] args) {
        Scanner a = new Scanner(System.in);
        int flag=0;
        int W = a.nextInt();
        int H = a.nextInt();
        int x = a.nextInt();
        int y = a.nextInt();
        int r = a.nextInt();
        for (double i = 0; i < 90; i++) {
            double x_r = r * Math.cos(i);
            double y_r = r * Math.sin(i);
            if (x_r + x > W || y_r + y > H || y_r+y<0 ||x_r+x<0) {
                System.out.println("No");
                flag=1;
                break;
            }
        }
        if(flag==0){
            System.out.println("Yes");
        }
    }
}

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

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

	int N;
	int i,j;
	int tmp;
	int counter=0;
	double ave;
	vector<int> given;

	cin >> N;
	int ans[N]={};

	for(i=0;i<N;i++){
		cin >> tmp;
		given.push_back(tmp);
	}

	for(i=0;i<N;i++){
		ans[given[i]-1]=i+1;	
	}

	for(i=0;i<N;i++){
		cout << ans[i] << ' ' << flush;
	}
	cout << endl;


	return 0;
}



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

int main() {
  string x;
  cin >> x;
  char c1, c2, c3, c4;
  c1 = x.at(0); c2 = x.at(1); c3 = x.at(2); c4 = x.at(3);
  if(c1 != c2 && c2 != c3 && c3 != c4) cout << "Good" << endl;
  else cout << "Bad" << endl;
  return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll X[20][20];

int main()
{
    ll N, D;
    cin >> N >> D;
    REP(i, N)
    {
        REP(j, D)
        {
            cin >> X[i][j];
        }
    }

    ll ans = 0;
    REP(i, N)
    {
        FOR(j, N, i + 1)
        {
            ll s = 0;
            REP(d, D)
            {
                s += (X[i][d] - X[j][d]) * (X[i][d] - X[j][d]);
            }

            ll t = 1;
            while (s >= t * t)
            {
                if (s == t * t)
                    ans++;
                t++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main(void){
    std::string cUp,cDawn;
    std::cin >> cUp >> cDawn;

    std::reverse(cUp.begin(),cUp.end());

    std::cout << (cUp == cDawn ? "YES" : "NO");
    return 0;
}




Measured memory_bytes: 888
#include<stdio.h>
int sum (int n,int s,int cnt);

int N,S;

int main (void)
{
    int i;
    while(1){
        scanf("%d%d",&N,&S);
        if(N==0&&S==0)break;
        printf("%d\n",sum(0,0,0));
    }
    return 0;
}
int sum(int n,int s,int cnt)
{
    if(n>9){
        if(cnt==N && s==S) return 1;
        else return 0;
    }
    return sum(n+1,s+n,cnt+1)+sum(n+1,s,cnt);
}

Measured memory_bytes: 596
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define EPS 1e-15
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;
}

const long long INF = 1LL << 60;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

int N;
ll h[100010];
ll dp[100010];

int main()
{
    cin >> N;
    rep(i, N)
    {
        cin >> h[i];
    }
    rep(i, 100010)
    {
        dp[i] = INF;
    }
    dp[0] = 0;

    rep(i, N)
    {
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }
    cout << dp[N - 1] << "\n";
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int xs[110];
int ys[110];

int main(void) {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  REP(i, N) {
    cin >> xs[i];
  }
  REP(i, M) {
    cin >> ys[i];
  }
  for(int z = -105; z <= 105; ++z) {
    bool ok = true;
    if(z <= X) {
      ok = false;
    }
    if(Y < z) {
      ok = false;
    }
    REP(i, N) {
      if(xs[i] >= z) {
        ok = false;
      }
    }
    REP(i, M) {
      if(ys[i] < z) {
        ok = false;
      }
    }
    if(ok) {
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
  return 0;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;


int main(){
    int n;
    cin >> n;
    int ans = 0;
    int x = 1;
    while(x <= n){
        int yakusu = 0;
        int y = 1;
        while(y <= x){
            if(x % y == 0) yakusu++;
            y += 2;
        }
        if (yakusu == 8) ans++;
        x += 2;
    }

    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,x,y;
    cin>>n>>x>>y;
    int cntr[n];
    fill(cntr, cntr+n, 0);
    
    for(int i=1; i<n; i++){
        for(int j=i+1; j<=n; j++){
            int dist=min({abs(j-i), abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j)});
            cntr[dist]++;
        }
    }
    
    for(int k=1; k<n; k++){
        cout<<cntr[k]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
using tpl = tuple<char, int>;
typedef pair<int,int> pii;
typedef long long ll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int A, B, C, D, E, F;

struct frac{
    int num;
    int den;
    bool operator<(const frac &f){
        return num * f.den < den * f.num;
    }
};


int main(){

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

    frac res = {-1, 1};
    for(int a = 0; a * A * 100 <= F; a++){
        for(int b = 0; b * B * 100  <= F; b++){
            for(int c = 0; c <= 100; c++){
                for(int d = 0; d <= 100; d++){
                    int sum = b * B * 100 + a * A * 100;
                    int sato = c * C + d * D;
                    if(sato <= E * (sum / 100) && sum != 0){
                        if(sum + sato <= F){
                            frac now{sato, sum + sato};
                            if(res < now) res = now;
                        }
                    }
                }
            }
        }
    }


    cout << res.den << " " << res.num << endl;
    
    return 0;
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> p(m);
    vector<string> s(m);
    rep(i, 0, m) cin >> p[i] >> s[i];
    map<int, bool> mp;
    vector<int> a(n+1);
    int ac = 0;
    int wa = 0;
    rep(i, 0, m){
        if(mp[p[i]] == false && s[i] == "AC"){
            mp[p[i]] = true;
            ac++;
            wa += a[p[i]];
        }
        if(mp[p[i]] == false && s[i] == "WA"){
            a[p[i]]++;
        }
    }
    cout << ac << " " << wa << endl;
    return 0;
}


Measured memory_bytes: 11884
import java.util.Scanner

fun main (args: Array<String>) {
  val s = Scanner(System.`in`).next()
  var a = ""
  s.forEach { c ->
    if (c == 'B') {
      if (a.length > 0) {
        a = a.substring(0..a.length - 2)
      }
    }
    else a += c
  }
  println(a)
}

Measured memory_bytes: 31396