akhauriyash/Code-Regression huggingface dataset:
/*author : Yashvardhan
Thursday, April 30, 2020
3:29 PM
*/

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

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}


signed main()
{

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

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int a,b;
	cin >> a >> b;

	if(a == b){
		for(int i = 0; i < b; i++) cout << a;
		cout << endl;
		return 0;
	}

	if(a > b) swap(a, b);
	for(int i = 0; i < b; i++) cout << a;
	cout << endl;
	

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 512
require 'pp'

a, b, h, m = gets.split.map(&:to_i)

# 分
r1 = (-m / 60.0 + 0.25) * 2 * Math::PI
r2 = (-h / 12.0 + -m / 60.0 / 12.0 + 0.25) * 2 * Math::PI

#pp r1
#pp r2

y1 = b * Math.sin(r1) 
y2 = a * Math.sin(r2) 

x1 = b * Math.cos(r1) 
x2 = a * Math.cos(r2)

puts Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)


Measured memory_bytes: 14964
#include <stdio.h>
int main() {
	int X, A, B;
	scanf("%d %d %d",&X,&A,&B);
	if (A -B  >= 0) {
		printf("delicious");
	}else if (B - A <= X) {
		printf("safe");
	}
	else { 
		printf("dangerous");
	}
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int main() {
  int nbr_vertices, nbr_edges, source;

  cin >> nbr_vertices;
  cin >> nbr_edges;
  cin >> source;

  vector<vector<pair<bool, int> > > matrix(nbr_vertices, vector<pair<bool, int> >(nbr_vertices, make_pair(true, 0)));
  int src, dest, dist;

  // Fill the matrix for vector[i][i] to 0
  for (int i = 0; i < nbr_vertices; i++) {
    matrix[i][i] = make_pair(false, 0);
  }

  // Fill the matrix with distances get from input
  for (int i = 0; i < nbr_edges; i++) {
    cin >> src;
    cin >> dest;
    cin >> dist;
    matrix[src][dest] = make_pair(false, dist);
  }

  for (int k = 0; k < nbr_vertices; k++) {
    for (int i = 0; i < nbr_vertices; i++) {
      for (int j = 0; j < nbr_vertices; j++) {
        if (!matrix[i][k].first && !matrix[k][j].first) {
          if (matrix[i][j].first) {
            matrix[i][j].first = false;
            matrix[i][j].second = matrix[i][k].second + matrix[k][j].second;
          } else if (matrix[i][j].second > matrix[i][k].second + matrix[k][j].second) {
            matrix[i][j].second = matrix[i][k].second + matrix[k][j].second;
          }
        }
      }
    }
  }

  //check negative cycles
  for (int i = 0; i < nbr_vertices; i++) {
    if (!matrix[source][i].first && matrix[i][i].second < 0) {
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }

  for (int i = 0; i < nbr_vertices; i++) {
    if (matrix[source][i].first)
      cout << "INF" << endl;
    else
      cout << matrix[source][i].second << endl;
  }
}



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

int main (){
    int x;
    cin >>x;
    int happy = 0;
    int rest;

    //cal of 500 yen
    happy += (x / 500) * 1000;
    rest = x - 500 * (x / 500);

    //5 yen
    happy += (rest / 5) * 5;

    cout <<happy <<endl; 
}

Measured memory_bytes: 256
n = int(input())
ab = [list(map(int, input().split(' '))) for i in range(n)]
cd = [list(map(int, input().split(' '))) for i in range(n)]
ab.sort()
cd.sort()
usedb = [0]*(n+1)
usedr = [0]*(n+1)
ymax = -1
ans = 0
for q,[c,d] in enumerate(cd):
    for p,[a,b] in enumerate(ab):
        if c>a and d>b and usedb[q] == 0 and usedr[p] == 0:
            if b>ymax:
                ymax = b
                r = p
    if ymax >= 0:
        usedr[r] = 1
        usedb[q] = 1
        ans += 1
    ymax = -1
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int a,b,c,s = 0,cun=0,week=0;
    scanf("%d%d%d\n",&a,&b,&c);
    
    while (1) {
        cun++;
        week++;
        s+=a;
        if(week==7){
            s+=b;
            week=0;
        }
        if(s>=c){
            printf("%d\n",cun);
            break;
        }
    }

    return 0;
}




Measured memory_bytes: 2120
N = int(input())
s = input()
s += s[0]

# S: 1, W: 0
for a0, a1 in ((0, 0), (0, 1), (1, 0), (1, 1)):
  l = [a0, a1]

  for c in s[1:]:
    if c == 'o':
      a0, a1 = a1, not (a0 ^ a1)
    else:
      a0, a1 = a1, (a0 ^ a1)
    l.append(a1)

  if (l[0] == l[-2]) and (l[1] == l[-1]):
    s = ''.join('S' if i == 1 else 'W' for i in l[:-2])
    print(s)
    exit()

print(-1)

Measured memory_bytes: 5616
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N = 105;
int a[N];
int main() {
    int n;
    cin >> n;
    for(int i = 1; i <= 2*n; ++i)
        cin >> a[i];
    sort(a+1,a+1+2*n);
    int ans = 0;
    for(int i = 1; i <= 2*n; i += 2) {
        ans += min(a[i],a[i+1]);
    }
    cout << ans << '\n';
return 0;
}

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

int main(){
  int N,x;
  cin >> N >> x;
  vector<int> A(N);
  for(int i=0;i<N;i++){cin >> A[i];}
  sort(A.begin(),A.end());
  int sum=0; int ans=0;
  for(int i=0;i<N;i++){
    sum+=A[i];
    if(sum<=x){ans++;}
    else{break;}
  }
  if(sum<x){ans--;}
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A,B=(int(x) for x in input().split())
scores = input().split()
num = [0,0,0]
for i in range(N):
    score = int(scores[i])
    if (score <= A):
        num[0] += 1
    elif(score <= B):
        num[1] += 1
    else:
        num[2] += 1
max_value = num[2]
for i in range(2):
    if max_value > num[i]:
        max_value = num[i]
print(max_value)

Measured memory_bytes: 3064
import java.util.Scanner;

/**
 * @author nakker
 */

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = scanner.nextInt();

        float result = 0f;
        for (int i = 0; i < count; i++) {
            result += 1 / scanner.nextFloat();
        }
        System.out.println(1 / result);
    }
}


Measured memory_bytes: 25300
#include<stdio.h>

int main(){
    
    int cases, term;
    scanf("%d %d", &cases, &term);
    int score[cases];
    for(int i = 0; i < cases; i++){
        scanf("%d", &score[i]);//terima input nilai
    }
    for(int i = term; i < cases; i++){
        if(score[i-term]<score[i])//jika lebih besar dari sebelumnya, maka ad perubahan
        {
            printf("Yes\n");
        }else//selain itu no
        {
            printf("No\n");
        }
    }
}

Measured memory_bytes: 3908
def get_count(v_array)
	
	v_array = v_array.sort
	
	v_hash = Array.new
	
	v_array.each_with_index do |i, index|
		if index == 0
			new_hash = {number: i, count: 1}
			v_hash.push(new_hash)
		else
			last_hash = v_hash.pop
			
			if i == last_hash[:number]
				last_hash[:count] += 1
				v_hash.push(last_hash)
			else
				v_hash.push(last_hash)
				new_hash = {number: i, count: 1}
				v_hash.push(new_hash)
			end
		end
	end
	
	v_hash = v_hash.sort_by { |hsh| hsh[:count] }.reverse
	return v_hash
end

n = gets.chop.to_i
v = gets.split.map(&:to_i)

v_par = Array.new
v_impar = Array.new
for i in 0..v.length-1
	if i % 2 == 0
		v_impar.push(v[i])
	else
		v_par.push(v[i])
	end
end

v_impar_hash = get_count(v_impar)
v_par_hash = get_count(v_par)

if v_impar_hash[0][:number] != v_par_hash[0][:number]
	result = n - v_impar_hash[0][:count] - v_par_hash[0][:count]
else
	if v_impar_hash.length == 1 && v_par_hash.length == 1
		result = n/2
	elsif v_impar_hash.length == 1
		result = n - v_par_hash[0][:count]
	elsif v_par_hash.length == 1
		result = n - v_impar_hash[0][:count]	
	else
		opt_1 = v_impar_hash[0][:count] + v_par_hash[1][:count]
		opt_2 = v_impar_hash[1][:count] + v_par_hash[0][:count]
		opt = opt_1 >=  opt_2 ? opt_1 : opt_2
		result = n - opt
	end
end

puts result

Measured memory_bytes: 35564
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if((abs(a-b)<=d && abs(b-c)<=d)||abs(a-c)<=d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int>(1000,10000)(rng)

ll binpow(ll a, ll b)
{
    if (b == 0)
        return 1;
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
        return res * a;
    return res;
}

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

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    cout<<1-n;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	int one;
	REP(i, N) {
		cin >> A[i];
	}
	cout << (N - 1) / (K - 1) + (int)(bool)((N - 1) % (K - 1)) << "\n";
	

	return 0;
}

Measured memory_bytes: 640
public class Main {


  private static void solve() {
    int n = ni();
    long k = nl();
    long[] a = nal(n);

    boolean just = true;
    long ret = 0;
    for (int j = 50; j >= 0; j--) {
      int cnt = 0;
      for (int i = 0; i < n; i++) {
        if (((a[i] >> j) & 1) != 0) {
          cnt++;
        }
      }
      if (just) {
        if (((k >> j) & 1) == 0) {
          ret += (1L << j) * cnt;
        } else if (cnt < n - cnt) {
          ret += (1L << j) * (n - cnt);
        } else {
          ret += (1L << j) * cnt;
          just = false;
        }
      } else {
        ret += (1L << j) * Math.max(cnt, n - cnt);
      }
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 47948
#include <cstdio>
#include <iostream>

using namespace std;

static int count(int n, int x) {
  int s = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      for (int k = j + 1; k <= n; ++k) {
        if (i + j + k == x)
          s += 1;
      }
    }
  }
  return s;
}

int main() {
  int n, x;
  for (;;) {
    cin >> n >> x;
    if (n == 0 && x == 0) {
      break;
    }
    cout << count(n, x) << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
while True:
    n = int(input())
    
    if n == 0:
        break
    
    S = [int(i) for i in input().split()]
    m = sum(S) / n
    
    a2 = sum([(s-m)**2 for s in S]) / n
    
    print(a2**0.5)
    


Measured memory_bytes: 5676
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN = 200005;
struct sb{
	int l, r, x, y;
	inline bool operator < (const sb &b) const
	{
		return x > b.x;
	}
};
priority_queue <sb> q;
int n, m, i, j, k, x, y, a[MAXN], f[20][MAXN], Lg[MAXN], b[MAXN], g[20][MAXN];
inline int getji(int l, int r)
{
	int k = Lg[r - l + 1];
	return min(f[k][l], f[k][r - (1 << k) + 1]);
}
inline int getou(int l, int r)
{
	int k = Lg[r - l + 1];
	return min(g[k][l], g[k][r - (1 << k) + 1]);
}
inline void solve(int l, int r)
{
	if (r < l) return;
	if (l & 1)
	{
		x = getji(l, r);
		y = getou(b[x] + 1, r);
		q.push((sb){l, r, x, y});
	}
	else
	{
		x = getou(l, r);
		y = getji(b[x] + 1, r);
	//	cout << x << " " << y << endl;
		q.push((sb){l, r, x, y});
	}
}
int main()
{
	cin >> n;
	memset(f, 127 / 3, sizeof(f));
	memset(g, 127 / 3, sizeof(g));
	for(i = 1; i <= n; i ++)
	{
		scanf("%d", &a[i]), b[a[i]] = i;
		if (i & 1) f[0][i] = a[i];
		else g[0][i] = a[i];
	}
	Lg[0] = -1;
	for(i = 1; i <= n; i ++)
		Lg[i] = Lg[i >> 1] + 1;
	for(j = 1; j <= Lg[n]; j ++)
		for(i = 1; i <= n - (1 << j) + 1; i ++)
		{
			f[j][i] = min(f[j - 1][i], f[j - 1][i + (1 << j - 1)]);
			g[j][i] = min(g[j - 1][i], g[j - 1][i + (1 << j - 1)]);
		}
	x = getji(1, n);
	y = getou(b[x] + 1, n);
	q.push((sb){1, n, x, y});
	for(i = 1; i * 2 <= n; i ++)
	{
		sb t = q.top();
		q.pop();
		printf("%d %d ", t.x, t.y);
		solve(t.l, b[t.x] - 1);
		solve(b[t.x] + 1, b[t.y] - 1);
		solve(b[t.y] + 1, t.r);
	}
}

Measured memory_bytes: 35828
n,x,y=map(int, input().split())
dist=[0]*(n+1)

for i in range(1,n+1):
    for j in range(i+1,n+1):
        dist[min(j-i,abs(j-y)+1+abs(i-x))]+=1
for i in range(1,n):
    print(dist[i])

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

int32_t main () {
	int n = 5;
	vector <int> abcde (5);
	for (int i = 0 ; i < n; i++)
		cin >> abcde[i];
	int k;
	cin >> k;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (abs(abcde[i] - abcde[j]) > k) {
				cout << ":(\n";
				return 0;
			}
		}
	}
	cout << "Yay!\n";
	return 0;
}


Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]
n,p = m()

a = l()

on= 0

su = 0

for i in range(n):
    a[i] %= 2
    if a[i] == 1:
        on += 1
no = n - on

if p % 2 == 0:
    if on % 2 == 0:
        for i in range(0,on+1,2):
            su += cmb(on,i)
        suu = 0
        for i in range(no+1):
            suu += cmb(no,i)
        su *= suu
    else:
        for i in range(1,on+1,2):
            su += cmb(on,i)
        suu = 0
        for i in range(no+1):
            suu += cmb(no,i)
        su *= suu

else:
    if on % 2 == 0:
        for i in range(1,on+1,2):
            su += cmb(on,i)
        suu = 0
        for i in range(no+1):
            suu += cmb(no,i)
        su *= suu

    else:
        for i in range(0,on+1,2):
            su += cmb(on,i)
        suu = 0
        for i in range(no+1):
            suu += cmb(no,i)
        su *= suu

print(su)



Measured memory_bytes: 3556
#include <iostream>
using namespace std;
int main(void){
    int start[2] = {0, 0};
    int i = 0;
    char c;
    while(cin >> c){
        if(c == '0'){
            start[(i & 1) ^ 1]++;
        }else{
            start[i & 1]++;
        }
        ++i;
    }
    cout << min(start[0], start[1]) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
const int INF = 10000;
int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    char grid[n][m];
    int dist[500][500];
    for (int i = 0; i < n; i++){
        scanf("%s",grid[i]);
    }
    for (int i = 0; i < 500; i++) {
        for (int j = 0; j < 500; j++)
            dist[i][j] = INF;
        dist[i][i] = 0;
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            if (grid[i][j] != '.') continue;
            int X = i*m+j;
            if (i){
                if (grid[i-1][j] == '.'){
                    dist[X-m][X] = dist[X][X-m] = 1;
                }
            }
            if (j){
                if (grid[i][j-1] == '.'){
                    dist[X-1][X] = dist[X][X-1] = 1;
                }
            }
        }
    }
    int N = n*m;
    for (int k = 0; k < N;k ++){
        for (int i = 0; i < N; i++){
            for (int j = 0; j < N; j++){
                dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    int ans = 0;
    for (int i =0;  i < N; i++){
        for (int j = 0; j <N; j++){
            if (dist[i][j] != INF){
                ans = max(ans,dist[i][j]);
            }
        }
    }
    printf("%d",ans);

}


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

#include <math.h>
#include <stdlib.h>


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

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
    int x, y; cin >> x >> y;
    
    vector<int> movx;
    vector<int> movy;
    bool gox = true;
    bool start = true;
    int cnt = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'F') cnt++;
        if(s[i] == 'T'){
            if(start){
                start = false;
                x-= cnt;
                cnt = 0;
            } else if(cnt != 0){
                if(gox) movx.push_back(cnt);
                else movy.push_back(cnt);
                cnt = 0;
            }
            gox = !gox;
        }
    }

    if(start){
        x-= cnt;
    } else if(cnt != 0){
        if(gox) movx.push_back(cnt);
        else movy.push_back(cnt);
    }


    sort(movx.rbegin(), movx.rend());
    sort(movy.rbegin(), movy.rend());

    int cx = 0;
    int cy = 0;
    for(int k : movx){
        if(cx < x) cx += k;
        else cx -= k;
    }

    for(int k : movy){
        if(cy < y) cy += k;
        else cy -= k;
    }

    if(x == cx && y == cy) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


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

    int n,m,k; cin>>n>>m>>k;
    vec a(n);
    vec b(m);
    rep(i,n) cin>>a[i];
    rep(i,m) cin>>b[i];

    ll t=0;
    int j=m;
    int ans=0;
    rep(i,m) t+=b[i];
    for(int i=0; i<n+1; i++){
        while(j>0 && t>k){
            j--;
            t-=b[j];
        }
        if(t>k) break;
        ans=max(ans,i+j);
        if(i==n) break;
        t+=a[i]; 
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4784
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <ctype.h>
using namespace std;

int main() {
    int A,B,C,D,E; cin >> A >> B >> C >> D >> E;
    int a = (A+9)/10;
    int b = (B+9)/10;
    int c = (C+9)/10;
    int d = (D+9)/10;
    int e = (E+9)/10;
    int aa = A - 10*(a-1);
    int bb = B - 10*(b-1);
    int cc = C - 10*(c-1);
    int dd = D - 10*(d-1);
    int ee = E - 10*(e-1);
    int diff = 10 - min({aa,bb,cc,dd,ee});
    cout << 10 * (a+b+c+d+e) - diff << endl;

}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define IN4(P1,P2,P3,P4) cin>>(P1)>>(P2)>>(P3)>>(P4)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
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;}

short A,B,C,D;
inline void solve(){
  IN4(A,B,C,D);
  if(A+B>C+D)OUT("Left");
  else if(A+B<C+D)OUT("Right");
  else OUT("Balanced");
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)

typedef long long ll;

#define INF 1145141919
#define size (int)1e+5

int arr[size];

int Min(int a, int b) {
    return a > b ? b : a;
}

int Max(int a, int b) {
    return a > b ? a : b;
}

int Swap(int *a, int *b) {
    int t = *b;
    *b = *a;
    *a = t;
}

bubbleSort(int *A, int N) {
    int cnt = 0;
    int flag = 1;
    while (flag != 0) {
        flag = 0;
        for (int i = N - 1; i >= 1; i--) {
            if (A[i] < A[i - 1]) {
                Swap(&A[i], &A[i - 1]);
                cnt++;
                flag = 1;
            }
        }
    }
    for (int i = 0; i < N - 1; ++i) {
        printf("%d ", arr[i]);
    }
    printf("%d\n%d\n", arr[N - 1], cnt);
}

void solver() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) {
        scanf("%d", &arr[i]);
    }
    bubbleSort(&arr,N);
}


int main() {
    solver();
    return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int>v(n);
    REP(i,n){
    	cin>>v[i];
    }
    int ans=1e9;
    for(int i=1;i<n;i++){
    	int s1=0;
    	for(int j=0;j<i;j++)s1+=v[j];
    	int s2=0;
    	for(int j=i;j<n;j++)s2+=v[j];
    	ans=min(ans,abs(s1-s2));
    }
    cout<<ans<<endl;
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

ll f(ll n){
    ll sum=0;
    for(int i=1;i<=n;i++){
        if(n%i==0) sum++;
    }
    return sum;
}

int main(void)
{
    ll a,b,k; cin>>a>>b>>k;
    ll cnt=0;
    for(int i=min(a,b);i>=1;i--){
        if(a%i!=0 || b%i!=0) continue;
        else cnt++;
        if(cnt==k){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    long double a, b, c;
    cin >> a >> b >> c;
    if (a + b + 2 * sqrt(a * b) < c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

int n;
int x[100001];

int atleast[100010];

const int mod = 1000000007;

int main()
{
	scanf("%d" , &n);
	for(int i = 1 ; i <= n ; i++)
		scanf("%d" , &x[i]);
	int cnt = 0;
	for(int i = 1 ; i <= n ; i++)
	{
		int space = x[i] - 1;
		int check = i - 1;
		
		atleast[i] = cnt + 1;
		if(2 * (i - cnt) - 1 > x[i])cnt++;
		//printf("atleast[%d] = %d\n" , i , atleast[i]);
	}

	sort(atleast + 1 , atleast + n + 1);
	int ans = 1;

	cnt = 0;
	for(int i = n ; i >= 1 ; i--)
	{
		if(n - atleast[i] + 1 < cnt)ans = 0;
		else
		{
			ans = (long long)ans * (n - atleast[i] + 1 - cnt) % mod;
		}
		cnt++;
	}
	printf("%d\n" , ans);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

int main(){
  ll n;
  cin >> n;
  ll num = n;
  vector<pair<ll, int>>  P;
  for(ll i = 2; i*i <=n ;i++){
     int x = 0;
     while(num%i ==0){
           num  /=  i;
           x++;
    }
    if(x >=1) P.emplace_back(i, x);
  }
   if( num !=1) P.emplace_back(num, 1);

int ans = 0;
for(auto& x : P){
       int s =  x.second;
       int k = 1;
       while(s >= k){
        s  -= k;
       k++;
        ans++;
        }
 }
 cout << ans <<endl;
return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
int n, k;
int h[100000];

cin >>n >> k;
for(int i=0; i<n; i++)
cin >> h[i];

sort(h, h+n);
int a = h[k-1]-h[0];
for(int i=1; i<n-k+1; i++){
if(a > h[i+k-1]-h[i])
a = h[i+k-1]-h[i];
}
cout << a;
return 0;
}

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

#define int long long

int32_t main() {
	double h , w , x , y ;
	cin >> h >> w >> x >> y ;
	cout <<fixed << setprecision(10) <<  (h*w) / 2 <<" "<< (x == h/2 && y == w/2) ? 1 : 0 ;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
ll Abs(ll x,ll y){
    if(x>=y)return x-y;
    else return y-x;
}

ll sum[200010];

int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n);
    map<ll,ll>m;
    for(ll i=0;i<n;i++)cin>>a[i];
    for(ll i=0;i<n;i++)sum[i+1]=sum[i]+a[i];
    for(ll i=1;i<=n;i++)m[sum[i]]++;
    ll ans = 0;
    for(auto itr=m.begin();itr!=m.end();++itr){
        ll f = itr->first;
        ll s = itr->second;
        if(f == 0)ans += s*(s+1)/2;
        else ans += (s-1)*s/2;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 15872
#include<stdio.h>

int main(){
	int i,j;
	int a[5];
	int rock, scissors, paper;

	while(1){
		
		rock=0; scissors=0; paper=0;
		for(i=0; i<5; i++){
			scanf("%d",&a[i]);
			if(a[i] == 0)
				break;
			if(a[i] == 1){
				rock++;
			}else if(a[i] == 2){
				scissors++;
			}else if(a[i] == 3){
				paper++;
			}
		}
		if(i<5)
			break;

		
		if((rock>0 && scissors>0 && paper>0) || rock == 5 || scissors == 5 || paper == 5){
			for(j=0; j<5; j++)
				printf("3\n");
		}else if(rock>0 && scissors>0){
			for(j=0; j<5; j++)
				if(a[j] == 1) printf("1\n");
				else if(a[j] == 2) printf("2\n");
		}else if(rock>0 && paper>0){
			for(j=0; j<5; j++)
				if(a[j] == 3) printf("1\n");
				else if(a[j] == 1) printf("2\n");
		}else if(scissors>0 && paper>0){
			for(j=0; j<5; j++)
				if(a[j] == 2) printf("1\n");
				else if(a[j] == 3) printf("2\n");
			}

	}
	
	
	return 0;

}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // cout << fixed << setprecision(10);
    LL n = 0, sum = 0;
    cin >> n;

    REP(i, n+1)
    {
        if(i % 3 == 0)
            continue;

        if(i % 5 == 0)
            continue;

        sum = sum + i;
    }
    cout << sum;
    return 0;
}

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

int main() {
  int N, Y;
  cin >> N >> Y;
  int sen, gosen, man;
  sen = -1;
  gosen = -1;
  man = -1;
  for(int i = 0; i <= N; i++){
   for(int j = 0; j+i <= N; j++){
    int k = N - i - j;
     int total = 10000*i + 5000*j + 1000*k;
     if(total == Y){
      man = i;
       gosen = j;
       sen = k;
     }
   }
  }
  cout << man << " " << gosen << " " << sen << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int m = scanner.nextInt();
    int[] a = new int[m];
    int[] b = new int[m];
    for (int i = 0; i < m; i++) {
      a[i] = scanner.nextInt() - 1;
      b[i] = scanner.nextInt() - 1;
    }
    scanner.close();

    long[] ans = new long[m];
    ans[m - 1] = (long) n * (n - 1) / 2;

    UnionFind uni = new UnionFind(n);

    for (int i = m - 1; i >= 1; i--) {
      ans[i - 1] = ans[i];

      if (uni.root(a[i]) != uni.root(b[i])) {
        ans[i - 1] -= (long) uni.size(a[i]) * uni.size(b[i]);
        uni.connect(a[i], b[i]);
      }
    }
    for (int i = 0; i < m; i++) {
      System.out.println(ans[i]);
    }
  }

  static class UnionFind {

    private int[] parent;

    public UnionFind(int n) {
      // 親の番号を格納する。
      // 自分自身が親だった場合は-(その集合のサイズ)を格納する。
      parent = new int[n];

      for (int i = 0; i < n; i++) {
        // 最初の時点では親は自分自身
        // 集合のサイズは１
        parent[i] = -1;
      }
    }

    // aがどのグループに属しているか調べる。
    public int root(int a) {
      if (parent[a] < 0) {
        return a;
      } else {
        // 再帰的に親をたどる。
        return parent[a] = root(parent[a]);
      }
    }

    // aの集合のサイズを返す
    public int size(int a) {
      return -parent[root(a)];
    }

    // aとbをつなぐ。
    // 大きい方(a)に小さい方(b)をつなぐ感じ。
    public boolean connect(int a, int b) {
      // 親同士をつなぐ。
      a = root(a);
      b = root(b);

      // すでにくっついている場合
      if (a == b) {
        return false;
      }

      if (size(a) < size(b)) {
        int r = a;
        a = b;
        b = r;
      }

      parent[a] += parent[b];
      parent[b] = a;

      return true;
    }
  }

}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

constexpr ll MOD = 1e9+7;

namespace tree {
template<class T> class BIT {
public:
  vector<T> dat;
  BIT() {}
  BIT(int N) { dat.assign(N, 0); }
  T sum(int i) { // sum [0, i)
    int ret = 0;
    for(--i; i>=0; i=(i&(i+1))-1) ret += dat[i];
    return ret;
  }
  T sum(int i, int j) { return sum(j) - sum(i); } // sum [i, j)
  void add(int i, T x) { for(; i < dat.size(); i|=i+1) dat[i] += x; }  // add x to i
};
}

ll fact[100001];

int main() {

  fact[0] = 1;
  REP(i, 1, 100001) {
    fact[i] = fact[i-1] * i % MOD;
  }

  for(int N, R; cin >> N && N;) {
    cin >> R;
    tree::BIT<int> bit(N);
    vector<int> vs(N);

    rep(i, N) vs[i] = i, bit.add(i, 1);

    rep(i, R) {
      int s, t; cin >> s >> t; s--, t--;
      swap(vs[s], vs[t]);
    }

    ll ans = 0;

    rep(i, N) {
      ans += (ll)bit.sum(vs[i]) * fact[N - i - 1] % MOD;
      bit.add(vs[i], -1);
      ans %= MOD;
    }

    cout << ans << endl;
  }

  return 0;
}

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

// --------------------------------------------------------------------------------

void solve()
{
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n)
    {
        ans += (n - 1) / (i + 1);
    }
    cout << ans << endl;
}

// --------------------------------------------------------------------------------

int main()
{
    // srand((unsigned)time(NULL));
    // int bt = clock();
    solve();
    // double et = 1.0 * (clock() - bt) / CLOCKS_PER_SEC;
    // printf("Execution Time: %.4lf sec\n", et);
    return 0;
}

Measured memory_bytes: 3596
package main

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

func main() {
	sc := NewScanner()

	a := sc.NextInt()
	b := sc.NextInt()
	c := sc.NextInt()

	if (a + b) >= c {
		fmt.Printf("%+v\n", b+c) // output for debug
	} else {
		fmt.Printf("%+v\n", a+b+b+1) // output for debug
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
# completeするsetを決め打って考える。

from itertools import product

d, g = map(int, input().split())
ans = 10 ** 10
PC = [list(map(int, input().split())) for _ in range(d)]
kumiawase = list(product([1, 0], repeat=d))
for kumi in kumiawase:
    cnt = 0
    temp = 0
    unused = []
    for i in range(d):
        p, c = PC[i]
        if kumi[i] == 1:
            temp += (i + 1) * 100 * p
            temp += c
            cnt += p
        else:
            unused.append(((i + 1) * 100, p))
    if temp >= g:
        ans = min(ans, cnt)
    else:
        if not unused:
            continue
        remain = g - temp
        unused.sort(reverse=True)
        saidai, kaisu = unused[0]
        if remain <= (kaisu - 1) * saidai:
            cnt += (remain + saidai - 1) // (saidai)
            ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 3188
n, m = map(int, input().split())
a = set(map(int, [input() for _ in range(m)]))

dp = [0] * (n+1)
# 0段目と1段目は1通り（但し、１段目が壊れていない場合）（0 段目は「なにもしない」という から1 通り）
dp[:2] = 1, 1 if 1 not in a else 0 

for i in range(2, n+1):
    if i not in a:
        dp[i] = (dp[i-1] + dp[i-2])

print(dp[-1] % (10**9+7))


Measured memory_bytes: 460020
#define _'			'
A[_];long P[_],M=1e9+7,F[_],I[_],X;i,j,k,t;c(a,b)int*a,*b;{t=a[*I=1]-b[1]?:*a-*b;}p(a,b){return b?p(a%M*a%M,b/2)*(b%2?a:1L)%M:1;}f(a,b){return F[a+b]*I[a]%M*I[b]%M;}main(s){for(;++X<_;)I[X]=p(s=F[X]=X*s%M,M-2);for(;~scanf("%d",A+i);)i++-1||gets(P);for(qsort(A,i/2,8,c);j<i;P[j++-1]=X)for(X=f(t=A[++j]-=1,s=A[k=j]-=1);k;X=s<A[k-=2]?X:(X-f(s-A[k],t-A[k+1])*P[k]%M+M)%M);printf("%d",X);}

Measured memory_bytes: 14460
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int>s;
int n,a,L;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        L=lower_bound(s.begin(),s.end(),a)-s.begin();
        if(!L)s.insert(s.begin(),a);
        else s[L-1]=a;
    }
    cout<<s.size()<<endl;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
long long a,b;
char ch;

int main()
{
    scanf("%lld %c %lld",&a,&ch,&b);
    if(ch=='+')
    {
        printf("%lld\n",a+b);
    }
    else
    {
        printf("%lld\n",a-b);
    }
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n,0);
	for(int i = 0;i < n;i++)
	{
		cin >> a.at(i);
	}
	sort(a.begin(),a.end());
	string k = "YES";
	for(int i = 0;i < n - 1;i++)
	{
		if(a.at(i) == a.at(i+1))
		{
			k = "NO";
		}
	}
	cout << k <<endl;
	return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}
	sort.Ints(h)

	min := 1000000000
	for i := 0; i < n-k+1; i++ {
		diff := h[i+k-1] - h[i]
		if diff < min {
			min = diff
		}
	}
	fmt.Println(min)
}

Measured memory_bytes: 5504
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    int a,b,c,d;
	cin >> a >> b >> c >> d;
	if((abs(b-a) <= d && abs(c-b) <= d) || abs(c-a) <= d)
		cout << "Yes\n";
	else
		cout << "No\n";
}


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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main() {

    string s;
    cin >> s;

    if ( s == "ABC" ) {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }

    return 0;

}


Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <iostream>
#include <string>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <queue>
#include <deque>
#include <math.h>
#include <cmath>
#include <stack>
#include <algorithm>
#include <list>
#include <array>
#include <valarray>
#include <unordered_map>
#include <cassert>
#include <random>
#include <cstring>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if (i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = INF + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);
//const li MOD = 100055128505716009;
//const li P = 3e4 + 11;

const int N = 1e5 + 7;

int n, k;
int h[N];

bool read() {
	if (!(cin >> n >> k))
		return false;

	forn(i, n) {
		cin >> h[i];
	}

	return true;
}

void solve() {
	int ans = 0;
	forn(i, n) {
		ans += (h[i] >= k);
	}

	cout << ans << endl;
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);

	int tt = clock();

#endif

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

	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while (read()) {
#else
	if (read()) {
#endif

		solve();

#ifdef _DEBUG
		cout << "TIME = " << clock() - tt << endl;
		tt = clock();
#endif
	}
	}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<bitset>
using namespace std;
#define M 1000000007
const int N = 5e5 +10;


int main()
{
	int H, W, h, w;
	cin>>H>>W>>h>>w;
	int tot = (H-h)*(W-w);
	cout<<tot<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
int a,b,c,d;
int main()
{
  scanf("%d%d%d%d",&a,&b,&c,&d);
  while(1)
  {
    c-=b;if(c<=0){printf("Yes\n");return 0;}
    a-=d;if(a<=0){printf("No\n");return 0;}
  }
  return 0;
}

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

	char grid[100][100];

	int main(){
		int a,b;
		cin>>a>>b;

		for(int i = 0;i<50;i++){
			for(int j = 0; j<100;j++){
				grid[i][j] = '#';
			}
		}


		for(int i = 50;i<100;i++){
			for(int j = 0; j<100;j++){
				grid[i][j] = '.';
			}
		}

		for(int i = 0;i < 50 && a-1>0;i+=2){
			for(int j = 0; j<100 && a-1>0;j+=2){
				grid[i][j] = '.';
				a--;
			}
		}


		for(int i = 51;i < 100 && b-1>0;i+=2){
			for(int j = 0; j<100 && b-1>0;j+=2){
				grid[i][j] = '#';
				b--;
			}
		}
		cout<<100<<" "<<100<<endl;
		for(int i = 0; i < 100; i++){
			for(int j = 0; j < 100;j++){
				cout<<grid[i][j];
			}
			cout<<endl;
		}

	}

Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
     
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = 1e18;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 111;
     
using namespace std;

int q, a, b, c, n, x;
vector <string> v;

void solve(){ 
	cin >> n >> x;

	for (int i = 1; i <= n; i++){
		string s;
		cin >> s;
		v.pb(s);
	}

	sort(all(v));

	for (auto i : v)
		cout << i;
}

main(){
    boost;
	    
	q = 1;

	while (q--){
		solve();
	}
}

Measured memory_bytes: 256