akhauriyash/Code-Regression huggingface dataset:
# require "pp"

loop do
  w, h = gets.split.map(&:to_i)
  break if w == 0
  lines = [[[false, true]] * (w+1)] # [ ?????´????£?????????????, ???????£????????????? ]
  (2 * h - 1).times do |i|
    y = i / 2 + 1
    if i % 2 == 0
      lines[y] = [[true, false]] # ?£????????????°true
      gets.split.map(&:to_i).each do |ch|
        lines[y] << [false, false] if ch == 0
        lines[y] << [true, false]  if ch == 1
      end
      lines[y] << [true, false] # ??????
    else
      gets.split.map(&:to_i).each.with_index(1) do |ch, ci|
        lines[y][ci][1] = true if ch == 1
      end
    end
  end
  lines[-1].each do |c|
    c[1] = true
  end

  d = []
  queue = [[1, 1]]
  d[1] = []
  d[1][1] = 0
  visited = []
  while queue.size > 0
    cx, cy = queue.shift
    visited[cy] ||= []
    visited[cy][cx] = true # ?¨??????????
    # p [cx, cy]
    break if cx == w && cy == h

    if !lines[cy-1][cx][1] && !(visited[cy-1] && visited[cy-1][cx]) # ???
      queue << [cx, cy-1]
      d[cy-1] ||= []
      d[cy-1][cx] = d[cy][cx] + 1
    end
    if !lines[cy][cx][1] && !(visited[cy+1] && visited[cy+1][cx]) # ???
      queue << [cx, cy+1]
      d[cy+1] ||= []
      d[cy+1][cx] = d[cy][cx] + 1
    end
    if !lines[cy][cx][0] && !(visited[cy] && visited[cy][cx+1]) # ???
      queue << [cx+1, cy]
      d[cy][cx+1] = d[cy][cx] + 1
    end
    if !lines[cy][cx-1][0] && !(visited[cy] && visited[cy][cx-1]) # ???
      queue << [cx-1, cy]
      d[cy][cx-1] = d[cy][cx] + 1
    end

    queue.uniq!
  end

  puts (d[h] && d[h][w]) ? (d[h][w] + 1) : 0
end

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

int main() {
  ll x,ans=0;
  cin >> x;
  ans = (x/500)*1000 + x%500/5*5;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
N, K = map(int, open(0).read().split())

MAX = 5 * 10 ** 5
MOD = 10 ** 9 + 7

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1
for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    
# Inverse factorial
finv = [0] * (MAX + 1)
finv[MAX] = pow(fac[MAX], MOD - 2, MOD)
for i in reversed(range(1, MAX + 1)):
    finv[i - 1] = finv[i] * i % MOD

def comb(n, k):
    return fac[n] * finv[n - k] * finv[k]

def rep_perm(n, k):
    return comb(n + k - 1, k)

ans = 0
for k in range(0, min(N, K + 1)):
    ans += comb(N, k) * rep_perm(N - k, k)
    ans %= MOD
print(ans)


Measured memory_bytes: 48604
Var n,i,j:Longint;
    OK:Boolean;
Begin
    Readln(n); OK:=False;
    For i:=1 to 9 do
        For j:=1 to 9 do
            If i*j=n then begin
                OK:=True; Break;
            End;
    If OK then writeln('Yes') else writeln('No');
End.

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

int main() {
    int64_t N;
    std::cin >> N;

    int64_t sum = 0;
    for (int i = 1; i <= N; ++i) {
        if ((i % 3 != 0) && (i % 5 != 0)) {
            sum += i;
        }
    }

    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
    switch(ch) {
        case 'A':
            return 1;
        case 'C':
            return 2;
        case 'G':
            return 3;
        case 'T':
            return 4;
        default:
            return 0;
    }
}

long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p * (getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) return 0;
    }
}

int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main() {
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++) H[i][0] = '\0';
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s %s", com, str);

        if (com[0] == 'i') {
            insert(str);
        } else {
            if (find(str)) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
    return 0;
}


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

int main(){
   
    long long n;
    cin>>n;
    long long hp=0;

    hp = hp + 1000 * (n/500);
    //cout<<hp<<" "<<n<<endl;
    n = n % 500;
    hp = hp + 5 * (n/5);
    //cout<<hp<<" "<<n<<endl;
    

    cout<<hp;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long int ll;
typedef unsigned long long int ull;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t="";
  cin >>a>>s;
  rep(i,min(a,(int)s.size()))t+=s[i];
  if(a<s.size())t+="...";
  cout <<t;
}

Measured memory_bytes: 3664
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {0,1,1,1,0,-1,-1,-1};
const static int ty[] = {-1,-1,0,1,1,1,0,-1};
 
static const double EPS = 1e-8;

double dp[21][140001];

int main(){
  int N;
  while(~scanf("%d",&N)){
    int currency[21];
    for(int i=0;i<N;i++){
      scanf("%d",&currency[i]);
    }
    
    fill((double*)dp,(double*)dp + 21 * 140001,1e12);

    dp[0][1] = 0.0;
    for(int i = 0; i < N; i++){
      for(int start = 1; start <= 140000; start++){
        if(dp[i][start] >= 1e12) continue;
        for(int next = start; next <= 140000; next += start){
          dp[i+1][next] = min(dp[i+1][next],
                              max(dp[i][start],
                                  (double)abs(next - currency[i])/(double)currency[i]));
        }
      }
    }

    double res = 1e12;
    for(int next = 1; next <= 140000; next++){
      res = min(dp[N][next],res);
    }
    printf("%.12lf\n",res);
  }
}

Measured memory_bytes: 24196
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define deb(x) cout << #x << " => " << x << endl

int main() {

    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, k; cin >> n >> k;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }

    int dp[n];
    memset(dp, 0, sizeof dp);
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        dp[i] = INT_MAX;
        for (int j = max(0, i - k); j < i; j++) {
            dp[i] = min(dp[i], abs(arr[j] - arr[i]) + dp[j]);
        }
    }
    cout << dp[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>

#define INF 1000000000000000000
using namespace std;
typedef long long ll;

const ll mod = 1000000007;

ll scale(int n) {
	ll p;
	ll ret = 0;
	for (int i = 1; i <= n; i++) {
		cin >> p;
		ret += p * (2 * i - 1 - n);
		ret %= mod;
	}
	return ret;
}

int main() {
	int n,m;
	ll X, Y;
	cin >> n >> m;
	X = scale(n);
	Y = scale(m);

	cout << X * Y%mod << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define mod 10e9+7

#define rep(i,n) for(int i=1;i<=n;i++)
int main(){
   ll n,k,all=0;
   ll mini=INF;
   cin >> n >> k;
   vector <int> a(n);
   for(int i=0;i<n;i++){
       cin >> a.at(i);
   }
   sort(a.begin(),a.end());
   
   for (int i=0;i<=n-k;i++){
       all=a.at(i-1+k)-a.at(i);
       mini=min(all,mini);
   }
    cout << mini << endl;
  }



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

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

ll lcm(ll a, ll b){
    ll tmp = gcd(a, b);
    return tmp * (a/tmp) * (b/tmp);
}
void solve(long long N, std::vector<long long> T){
    ll res=1;
    for(ll i=0; i< N; i++){
        res = lcm(res, T[i]);
    }
    cout << res << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> T(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&T[i]);
    }
    solve(N, std::move(T));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	string s;
	cin >> s;
	int ans = 0;
	int cnt = 0;
	rep(i, 0, sz(s))
	{
		if (s[i] == 'R') {
			cnt++;
		}
		else {
			cnt = 0;
		}
		ans = max(ans, cnt);
	}
	cout << ans;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



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

	
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(NULL);
	
	int n; cin >> n;
	vector<pair<int, int> > p;    //ai students in class when student i entered(including him)
	for(int i = 1; i <= n; ++i){
		int x; cin >> x;
		p.push_back(make_pair(x, i));
	}
	sort(p.begin(), p.end());
	for(auto u : p) cout << u.second << " ";
      
	
	
	return 0;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,M,count;
    count = 0;
    cin >> N >> M;
    for(int i=0;i<M;i++){
    int a;
    cin >> a;
    count +=a;
    }
    if(N>=count)
    cout << N-count << endl;
    else
    cout << -1 << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] score = new int[5];
		int sum = 0;
		for(int i = 0 ; i < score.length ;i++){
			int num = sc.nextInt();
			if(num < 40 ){
				score[i] = 40;
			} else{
				score[i] = num;
			}
			sum += score[i];
		}
		System.out.println(sum/5);
		sc.close();
	}

}

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

int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 1; i < 20000; i++) {
    if (i * 8 / 100 == a && i * 10 / 100 == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
class Dice{
    public:
    int face[7],n;
    Dice(){}
    void role_E(){
        role(1,3,6,4);
    }
    void role_N(){
        role(1,5,6,2);
    }
    void role_S(){
        role(1,2,6,5);
    }
    void role_W(){
        role(1,4,6,3);
    }
    void role_z(){
        role(2,3,5,4);
    }
    void role(int i, int j, int k, int l){
        n=face[l], face[l]=face[k], face[k]=face[j],face[j]=face[i],face[i]=n;
    }
};
int right(Dice C, int a, int b){
    for(int i = 0; i < 6; i++){
        for (int j = 0; j < 4; j++){
            if(C.face[1] == a && C.face[2] == b) return C.face[3];
            C.role_z();
        }
        if(i % 2 == 0) C.role_E();
        else C.role_N();
    }
}
int main(){
    Dice dice;
    int n, a ,b;
    
    for(int i = 1; i < 7; i++){
        cin >>dice.face[i];
    }
    cin >> n;
    for(int i = 0; i < n; i++){
        cin>>a >>b;
        cout <<right(dice, a, b) << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
N, M = gets.split.map(&:to_i)
list = Array.new(N+1) { [] }
M.times.each do
  a, b = gets.split.map(&:to_i)
  list[b] << a
  list[a] << b
end

res = Array.new(N+1, -1)
current = 1
queue = [1]
while !queue.empty?
  current = queue.shift

  list[current].each do |next_room|
    next if res[next_room] != -1

    res[next_room] = current
    queue.push(next_room)
  end
end

flg = true
2.upto(N) do |n|
  flg = false if res[n] == -1
end

if flg
  puts "Yes"
  2.upto(N) do |n|
    puts res[n]
  end
else
  puts "No"
end


Measured memory_bytes: 32732
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
Scanner s = new Scanner(System.in);
		
		int n = s.nextInt();
		
     	int i=0;
		int j=n-1;
		int mid=0;
		String z="";
		
		System.out.flush();
		System.out.println(i);			
		System.out.flush();
		String x = s.next();
		if (x.equals("Vacant"))
			System.exit(0);
		
		System.out.flush();
		System.out.println(j);
		System.out.flush();
	    String y = s.next();
		if (y.equals("Vacant"))
			System.exit(0);
		
				
		while(i<j-1){	
			mid = (i+j)/2;
						
			System.out.flush();
			System.out.println(mid);
			System.out.flush();
		    z = s.next();
			if (z.equals("Vacant"))
				System.exit(0);

			if(i%2==mid%2){
				if(x.equals(z)){
					i=mid;	
					x=z;
				}
				else{
						j=mid;
						y=z;
				}
			}
			else{
				if(!x.equals(z)){
					i=mid;	
					x = z;
				}
				else{
					j=mid;
					y=z;

				}
			}					
			
		}	
		System.out.flush();
		System.out.println(i);
		System.out.flush();
	    z = s.next();
		if (z.equals("Vacant"))
			System.exit(0);
		
		System.out.flush();
		System.out.println(mid);
		System.out.flush();
	    z = s.next();
		if (z.equals("Vacant"))
			System.exit(0);
		
		System.out.flush();
		System.out.println(j);
		System.out.flush();
	    z = s.next();
		if (z.equals("Vacant"))
			System.exit(0);
	}
}


Measured memory_bytes: 23844
/*
 Abu Jafor Mohammad Saleh
 ios_base :: sync_with_stdio(false);
 cin.tie(NULL);
 
 */

#include<cstdio>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<limits>
#include <algorithm>
#include <unordered_map>
#include<fstream>
#define f first
#define s second
#define MOD 1000003

#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define BOUNDARY(i, j) ((i >= 0 && i < rows) && (j >= 0 && j < coloums))

//#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
const int maxn = 100001;
using namespace std;
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
int rows,coloums;
long long  gcd(long long  a, long long b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main()
{
    fast;
    int pos1 = 10;
    int pos2 = 10;
    int pos3 = 10;
    
    int n,m;
    cin>>n>>m;
    bool ans = false;
    for(int i=0;i<m;i++)
    {
        int s,c;
        cin>>s>>c;
        if((pos3 != 10 && pos3 != c && s==3) || (n != 1 && c ==0 && s== 1))
        {
            ans = true;
        }
        if((pos2 != 10 && pos2 != c && s == 2) )
        {
            ans = true;
        }
        if((pos1 != 10 && pos1 != c && s == 1))
        {
            ans = true;
        }
        if(s==1 && c!=0)
        {
            pos1 = min(pos1,c);
        }
        else if(s==2)
        {
            pos2 = min(pos2,c);
        }
        else if(s ==3)
        {
            pos3 = min(pos3,c);
        }
    }
    
    if(ans)
    {
        cout<<-1<<endl;
    }
    else if(n==1)
    {
        if(pos1==10)
        {
            cout<<0<<endl;
        }
        else
        {
            cout<<pos1<<endl;
        }
    }
    else
    {
        if(pos1 == 10)
        {
            pos1 = 1;
        }
        if(pos3 == 10)
            pos3 = 0;
        if(pos2 == 10)
            pos2 = 0;
        if(n==1)
        {
            cout<<pos1<<endl;
        }
        else if (n==2)
        {
            
            cout<<pos1<<pos2<<endl;
        }
        else
        {
            cout<<pos1<<pos2<<pos3<<endl;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int i,j;
  for(i=0;i<9;i++)
    {
      for(j=0;j<9;j++)
	{
	  printf("%dx%d=%d\n",i+1,j+1,(i+1)*(j+1));
	}
    }
  return 0;
}

Measured memory_bytes: 524
def solve(N, Y):
    for x in range(N + 1):
        for y in range(0, N - x + 1):
            z = N - x - y
            if z < 0:
                continue
            elif 10000 * x + 5000 * y + 1000 * z == Y:
                return x, y, z
    return -1, -1, -1


N, Y = list(map(int, input().split()))
x, y, z = solve(N, Y)
print('{} {} {}'.format(x, y, z))


Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
  int a,b,c,d,e,max_lost_time,lost_time,sum_time=0;
  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
  sum_time += a + (10 - a%10)%10;
  sum_time += b + (10 - b%10)%10;
  sum_time += c + (10 - c%10)%10;
  sum_time += d + (10 - d%10)%10;
  sum_time += e + (10 - e%10)%10;
  
  max_lost_time = (10 - a%10)%10;
  
  lost_time = (10 - b%10)%10;
  if(max_lost_time<lost_time) max_lost_time = lost_time;
  
  lost_time = (10 - c%10)%10;
  if(max_lost_time<lost_time) max_lost_time = lost_time;
  
  lost_time = (10 - d%10)%10;
  if(max_lost_time<lost_time) max_lost_time = lost_time;
  
  lost_time = (10 - e%10)%10;
  if(max_lost_time<lost_time) max_lost_time = lost_time;
  
  sum_time -= max_lost_time;
  printf("%d\n",sum_time);
}


Measured memory_bytes: 128
n,m=map(int,input().split())
ka=[list(map(int,input().split()))for _ in range(n)]
for i in range(n):
    del ka[i][0]
ka=list(map(set,ka))
for i in ka:
    ans=ka[0].intersection(i)
    ka[0]=ans
print(len(ans))

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

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        if ((i+1) % 2) {
            if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
                cout << "No\n";
                exit(0);
            }
        }
        else { 
            if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
                cout << "No\n";
                exit(0);
            }
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 764
S = input()
def main():
    cnt_0 = 0
    cnt_1 = 0
    for s in S:
        if s == '0':
            cnt_0 += 1
        if s == '1':
            cnt_1 += 1
    print(min(cnt_0, cnt_1)*2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import scala.io.StdIn.readLine

object Main extends App {

  val input = readLine().split(" ").map(_.toInt)
  val (a, b, c) = (input(0), input(1), input(2))
  var res = 0

  for(e <- a to b) {
    if (c % e == 0) res += 1 else res
  }

  println(res)
}



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

int main () {
  string S;
  int K;
  cin >> K >> S;
  if (S.size() <= K) {
    cout << S << endl;
  }
  if (K < S.size()) {
    for (int i=0;i<K;i++) {
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3632
import java.util.Scanner;

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

        String str = sc.next();

        while(str.contains("B")) {
            int idx = str.indexOf("B");
            str = (idx > 0 ? str.substring(0, idx - 1) : "") + str.substring(idx + 1);
        }

        System.out.println(str);
    }
}


Measured memory_bytes: 9424
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    HashMap<Integer,Integer> a = new HashMap<Integer,Integer>();
    int[] b = new int[n];
    for (int i=0;i<n;i++){
      int t = scan.nextInt();
      a.put(t,i+1);
      b[i] = t;
    }
    Arrays.sort(b);
    for (int j=0;j<n-1;j++){
      System.out.print(a.get(b[j])+" ");
    }
    System.out.println(a.get(b[n-1]));
  }
}


Measured memory_bytes: 69236
#include<iostream>
#include<algorithm>
#define N 3

using namespace std;
void output_arrey_int(int*,int,char);
void input_array_int(int*,int);

int main(){
  int a[N];

  input_array_int(a,N);
  sort(a,a+N);
  output_arrey_int(a,N,' ');

  return 0;
}

void output_arrey_int(int * a,int n,char ch){
  int i;

  for(i=0;i<n;i++){
    cout<<*(a+i);
    if(i<(n-1)){
      cout<<ch;
    }
  }

  cout<<endl;

  return;
}

void input_array_int(int *a,int n){
  int i;

  for(i=0;i<n;i++){
    cin>>*(a+i);
  }
}

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


namespace ACprac
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int nm = 0;

            for(int i = 0; i < 4; i++)
            {
                if(str.Substring(i, 1).Equals("+"))
                {
                    nm++;
                }
                else
                {
                    nm--;
                }
            }

            Console.WriteLine(nm);
        }
    }
}


Measured memory_bytes: 11092
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ret = 0
for i, b in enumerate(B):
    k1 = min(A[i], b)
    k2 = min(A[i + 1], b - k1)
    A[i + 1] -= k2
    ret += k1 + k2

print(ret)


Measured memory_bytes: 18476
#include<iostream>
using namespace std;
int main()
{
    int n,flak1=1,flak2=1,r;
    cin>>n;
    r=n%100;
    n=n-r;
    n/=100;
    if(r>=1 && r<=12)
    {
        flak1=0;
    }
    if(n>=1 && n<=12)
    {
        flak2=0;
    }
    if(flak1==0 && flak2==0)
    {
        cout<<"AMBIGUOUS"<<endl;
    }
    else if(flak1==0 && flak2!=0)
    {
        cout<<"YYMM"<<endl;
    }
    else if(flak2==0 && flak1!=0)
    {
        cout<<"MMYY"<<endl;
    }
    else
    {
        cout<<"NA"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    double t,x;
    cin>>t>>x;
    cout<<t/x<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

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

	private void run() {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long n = sc.nextLong();
		
		long r = (a/b);
//		for( long i=1 ; i<=n ; i++ ) {
//			long re = calc(a, b, i);
//			if( re > r ) r = re;
//		}
		
		long m = Math.min(b-1,n);
		System.out.println( calc(a,b,m));
	}

	private long calc(long a, long b, long i) {
		return (a*i/b) - a * (i/b);
	}
}


Measured memory_bytes: 35696
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();
			var n = firstLine[0];
			var m = firstLine[1];

			var paths = new Dictionary<int, List<int>>();
			
			for(int i = 0; i < m; i++)
			{
				var input = Console.ReadLine().Split(' ').Select(value => int.Parse(value) - 1).ToList();

				if(paths.ContainsKey(input[0]))
				{
					paths[input[0]].Add(input[1]);
				}
				else
				{
					paths.Add(input[0], new List<int>() { input[1] });
				}
				if (paths.ContainsKey(input[1]))
				{
					paths[input[1]].Add(input[0]);
				}
				else
				{
					paths.Add(input[1], new List<int>() { input[0] });
				}
			}

			var isArrivedList = new List<bool>();

			for(int i = 0; i < n; i++)
			{
				isArrivedList.Add(false);
			}

			var count = Dfs(paths, 0, isArrivedList, 0);

			Console.WriteLine(count);
        }

		private static int Dfs(Dictionary<int, List<int>> paths, int node, List<bool> isArrivedList, int count)
		{
			isArrivedList[node] = true;

			foreach(var nextNode in paths[node])
			{
				if(isArrivedList[nextNode])
				{
					continue;
				}

				count = Dfs(paths, nextNode, isArrivedList, count);
			}

			if(!isArrivedList.Any(value => !value))
			{
				count++;
			}

			isArrivedList[node] = false;

			return count;
		}
	}
}


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

int main(){
	int c[3][3];
	rep(i,3)rep(j,3) cin >>c[i][j];
	int d[3][2], e[2][3];
	rep(i,3)rep(j,2) d[i][j] = c[i][j+1] - c[i][j];
	rep(j,3)rep(i,2) e[i][j] = c[i+1][j] - c[i][j];

	rep(i,2) {
		if (d[i][0] == d[i+1][0] && d[i][1] == d[i+1][1]) continue;
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	rep(j,2) {
		if (e[0][j] == e[0][j+1] && e[1][j] == e[1][j+1]) continue;
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
typedef long long ll;

int main(){
  string str;
  cin >> str;

  char tmp=str[0];
  ll ret=0;
  for(ll i=1;i<str.size();i++){
    if(str[i]!= tmp){
      ret++;
      tmp =str[i];
    }
  }
  cout << ret <<endl;

}


Measured memory_bytes: 512
<?php
fscanf(STDIN, '%d %d %d %d', $n, $a, $b, $c);
for ($i  = 0; $i < $n; $i++) fscanf(STDIN, '%d', $l[]);
$ans = dfs(0, 0, 0, 0);
echo $ans . PHP_EOL;

function dfs($cur, $x, $y, $z) {
    global $n, $a, $b, $c, $l;

    if ($cur === $n) {
        if (min($x, $y, $z) > 0) return abs($a - $x) + abs($y - $b) + abs($z - $c) - 30;
        else return 10 ** 9;
    }

    $ret0 = dfs($cur + 1, $x, $y, $z);
    $ret1 = dfs($cur + 1, $x + $l[$cur], $y, $z) + 10;
    $ret2 = dfs($cur + 1, $x, $y + $l[$cur], $z) + 10;
    $ret3 = dfs($cur + 1, $x, $y, $z + $l[$cur]) + 10;
    return min($ret0, $ret1, $ret2, $ret3);
}

Measured memory_bytes: 4604
from fractions import*

class SEGMENTTREE():
    def __init__(self,lis,func,ele):
        self.monoidfunc=func
        self.identityelement=ele  # identity element
        self.n=len(lis)  # lis size
        self.node=[ele]*self.n+lis
        for i in range(self.n-1,0,-1):  # build
            self.node[i]=self.monoidfunc(self.node[i<<1],self.node[i<<1|1])
 
    def update(self, point, value):  # set value at position p (0-indexed)
        m=self.monoidfunc
        point+=self.n
        self.node[point]=value
        while point>1:
            self.node[point>>1]=m(self.node[point], self.node[point^1])
            point>>=1
 
    def get(self, l, r):  # result on interval [l, r) (0-indexed)
        m,e=self.monoidfunc,self.identityelement
        res=e
        l+=self.n
        r+=self.n
        while l<r:
            if l&1:
                res=m(res,self.node[l])
                l+=1
            if r&1:
                r-=1
                res=m(res,self.node[r])
            l>>=1
            r>>=1
        return res

n,*a=map(int,open(0).read().split())

segtree = SEGMENTTREE(a, gcd, 0)
 
ans = 1
for i, a in enumerate(a):
    segtree.update(i,0)
    ans = max(ans,segtree.get(0,n))
#    print(segtree.node)
    segtree.update(i,a)
print(ans)

Measured memory_bytes: 96952
#include<iostream>
#include<cmath>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
	
	int n,m,X,Y;
	int x[666],y[666];
	
	cin>>n>>m>>X>>Y;
	rep(i,n)cin>>x[i];
	rep(i,m)cin>>y[i];
	
	int ruler;
	
	for(int i=X+1;i<Y;i++){
		ruler=1;
		rep(j,n){
			if(x[j]>=i)ruler=0;
		}
		rep(j,m){
			if(y[j]<i)ruler=0;
		}
		if(ruler)break;
	}
	if(ruler)cout<<"No War"<<endl;
	else cout<<"War"<<endl;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int main() {
  int N;
  cin >> N;

  char p, q;
  string P, Q;
  rep(i,0,N-1) cin >> p, P += p;
  rep(i,0,N-1) cin >> q, Q += q;

  string s;
  rep(i,1,N) s += to_string(i);

  int a, b, cnt = 0;
  do {
    cnt++;
    if (s == P) a = cnt;
    if (s == Q) b = cnt;
  } while (next_permutation(s.begin(), s.end()));

  cout << abs(a - b) << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#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()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int g(string S) {
    return (S[0] - '0')*10 + (S[1] - '0');
}
int f(string S) {
    int h = g(S.substr(0,2));
    int m = g(S.substr(3,2));
    int s = g(S.substr(6,2));
    return h*3600 + m*60 + s;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    while (true) {
        int N; cin >> N;
        if (!N) break;
        vector<int> A(90000);
        rep(i,N) {
            string S,T; cin >> S >> T;
            int l = f(S);
            int r = f(T);
            A[l]++;
            A[r]--;
        }
        rep(i,88000) {
            A[i+1] += A[i];
        }
        cout << *max_element(all(A)) << ln;
    }
}


Measured memory_bytes: 3392
#include <stdio.h>
#include <string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch)
{
  if (ch == 'A')
    return 1;
  else if (ch == 'C')
    return 2;
  else if (ch == 'G')
    return 3;
  else if (ch == 'T')
    return 4;
  else
    return 0;
}

long long getKey(char str[])
{
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++)
  {
    sum += p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[])
{
  long long key, i, h;
  key = getKey(str);
  for (i = 0;; i++)
  {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0)
      return 0;
  }
  return 0;
}

int insert(char str[])
{
  long long key, i, h;
  key = getKey(str);
  for (i = 0;; i++)
  {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0)
    {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main()
{
  int i, n, h;
  char str[L], com[9];
  for (i = 0; i < M; i++)
    H[i][0] = '\0';
  scanf("%d", &n);
  for (i = 0; i < n; i++)
  {
    scanf("%s %s", com, str);
    if (com[0] == 'i')
    {
      insert(str);
    }
    else
    {
      if (find(str))
      {
        printf("yes\n");
      }
      else
      {
        printf("no\n");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 16968
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	bool k=false;
	for(int i=1;i<=n;i++)
	{
		int m;
		cin>>m;
		if(m%2==0)
		{
			if(m%3==0)
				continue;
			if(m%5==0)
				continue;
			k=true;
		}
	}
	if(k==true)
		cout<<"DENIED";
	else
		cout<<"APPROVED";
}

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

int main() {
    int n; cin >> n;
    vector<int> res;
    if(n == 0) {
        cout << "0" << endl;
        return 0;
    }
    while (n)
    {
        if(n % (-2) == 0) {
            res.push_back(0);
            n /= (-2);
        }
        else if(n % (-2) == -1) {
            res.push_back(1);
            n = n / (-2) + 1;
        }
        else {
            res.push_back(1);
            n = n / (-2);
        }
    }
    reverse(res.begin(), res.end());
    for (auto r : res)
    {
        cout << r;
    }
    cout << endl;
	return 0;
}



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

void smallersort_INT(int *x, int n);

int main() {

	int money[3];

	for (int i = 0; i < 3; i++) {
		cin >> money[i];
	}

	smallersort_INT(money, sizeof(money) / 4);

	cout << money[0] + money[1];

	return 0;
}

//*/

void smallersort_INT(int *x, int n) {
	int i, j, fake;

	for (i = 0; i < n; i++) {
		for (j = 0; j < n - 1; j++) {
			if (x[j] > x[j + 1]) {
				fake = x[j];
				x[j] = x[j + 1];
				x[j + 1] = fake;
			}
		}
	}
}

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

using namespace std;

int N;
int arr[100005];

int main(){
    cin >> N;
    for(int i= 1; i<=N; i++){
        cin >> arr[i];
    }
    sort(arr+1, arr+N+1);
    cout << arr[N/2+1] - arr[N/2] << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int x[4];
int y[4];

int b[4][4];

int solve(int pos){
  if(pos == 9){
    //REP(i,4) { REP(j,4) printf("%c ", 'A' + b[i][j] - 1); puts(""); } puts("");
    return 1;
  }
  
  int ret = 0;


  REP(i,4) REP(j,4){
    if(b[i][j] == 0){
      b[i][j] = pos;

      REP(k, 4){
	int xx = j + x[k];
	int yy = i + y[k];

	if(ISIN(xx,yy,4,4) && b[yy][xx] == 0){
	  b[yy][xx] = pos;
	  //printf("%c: (%d, %d) (%d, %d)\n", 'A' + pos - 1, j, i, xx, yy);
	  ret += solve(pos + 1);
	  b[yy][xx] = 0;
	}
      }

      b[i][j] = 0;
      goto end;
    }
  }
 end:

  return ret;
}

int main(){
  while(true){
    REP(i,4) cin>>x[i]>>y[i];
    if(x[0] > 4) break;

    REP(i,4) REP(j,4) b[i][j] = 0;

    print(solve(1));
  }
  return 0;
}

Measured memory_bytes: 0
N = int(input())
Nx = input().split()
g = []
for x in Nx:
    x = int(x)
    if x % 2 == 0:
        g.append(x)
ans = 0
for i in g:
    if not i % 3 == 0:
        if not i % 5 == 0:
            ans = 1
            break
        else:
          continue
    else:
        continue
if ans == 1:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string n;
  cin>>n;
  if (n.at(0) == '7' || n.at(1) == '7' || n.at(2) == '7') {  
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

class combination{
private:
    vector<mint> fact,finv;
public:
    combination(int N){
        fact = finv = vector<mint>(N+1);
        fact[0] = fact[1] = 1;
        finv[0] = finv[1] = 1;
        for(ll i=2;i<=N;i++){
            fact[i] = fact[i-1]*i;
            finv[i] = fact[i].inv();
        }
    }
    mint f(int i){
        return fact[i];
    }
    mint comb(int n,int k){
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return fact[n]*finv[k]*finv[n-k];
    }
    mint hcomb(int n,int k){
        if(n==0 && k==0) return 1;
        return comb(n+k-1,k);
    }
};



int main(){
    int N;
    string S;
    cin >> N >> S;
    auto id = [](char c){
        if(c=='R') return 0;
        if(c=='G') return 1;
        if(c=='B') return 2;
    };
    auto the_other = [](int x,int y){
        if(x>y) swap(x,y);
        if(x==0 && y==1) return 2;
        if(x==0 && y==2) return 1;
        if(x==1 && y==2) return 0;
    };
    ll res = N;
    vector<ll> cnt0(3,0),cnt1(3,0);
    mint ans = 1;
    for(int i=0;i<3*N;i++){
        int now = id(S[i]);
        if(cnt1[now]!=0){
            ans *= cnt1[now];
            cnt1[now]--;
        }else{
            bool ok = false;
            for(int k=0;k<3;k++){
                if(now==k) continue;
                if(cnt0[k]!=0){
                    ans *= cnt0[k];
                    cnt0[k]--;
                    cnt1[the_other(now,k)]++;
                    ok = true;
                    break;
                }
            }
            if(!ok){
                ans *= res;
                res--;
                cnt0[now]++;
            }
        }
    }
    cout << ans.x << endl;
}

Measured memory_bytes: 900
fn solve(xys: Vec<(f64, f64)>) -> f64 {
    let n = xys.len();
    let mut nf = (n * (n - 1) / 2) as f64;

    let mut s = 0.0;
    for (i, &(xi, yi)) in xys.iter().enumerate() {
        if i == n - 1 {
            break;
        }
        for &(xj, yj) in xys[(i + 1)..].iter() {
            s += ((xj - xi).powf(2f64) + (yj - yi).powf(2f64)).sqrt();
        }
    }

    s / (nf as f64) * ((n - 1) as f64)
}

#[test]
fn solve_test() {
    //    assert_eq!(
    //        solve(vec![(0.0, 0.0), (1.0, 0.0), (0.0, 1.0)]),
    //        2.2761423749
    //    );

    //    assert_eq!(solve(vec![(-879.0, 981.0), (-866.0, 890.0)]), 91.9238815543);

    /*    assert_eq!(
        solve(vec![
            (-406.0, 10.0),
            (512.0, 859.0),
            (494.0, 362.0),
            (-955.0, -475.0),
            (128.0, 553.0),
            (-986.0, -885.0),
            (763.0, 77.0),
            (449.0, 310.0)
        ]),
        7641.9817824387
    );*/
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let n = parse_line!(usize);
    let xys = (0..n).map(|_| parse_line!(f64, f64)).collect::<Vec<_>>();
    println!("{}", solve(xys));
}


Measured memory_bytes: 4352
#include <stdio.h>

int main() {
  int n, m, l;
  long long A[100][100], B[100][100], C[100][100] = {0};
  
  scanf("%d %d %d", &n, &m, &l);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%lld", &A[i][j]);
    }    
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < l; j++) {
      scanf("%d", &B[i][j]);
    }    
  }
  
  // Calculation  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l; j++) {
      C[i][j] = 0;
      for (int k = 0; k < m; k++) {
        C[i][j] = C[i][j] + A[i][k]*B[k][j];
      }
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l; j++) {
      if (j == 0)
        printf("%lld", C[i][j]);
      else
        printf(" %lld", C[i][j]);
    }
    printf("\n");
  }

  return 0;
}


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

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

  string ceil = string(w+2, '#');

  cout << ceil << endl;
  string line;
  for (int i = 0; i < h; i++) {
    cin >> line;
    cout << '#' << line << "#" << endl;
  }
  cout << ceil << endl;
}

  
      


Measured memory_bytes: 256
let [|_;K|] =
    stdin.ReadLine().Split()
    |> Array.map int
let A =
    stdin.ReadLine().Split()
    |> Array.map int

let maxA = Array.max A

let ansLt x =
    let k = Array.sumBy (fun item -> (item + x - 1)/x - 1) A
    k <= K

let rec culc low upper =
    if upper - low = 1 then low
    else
        let middle = (low + upper + 1) / 2
        if ansLt (middle - 1) then culc low middle
        else culc middle upper

culc 1 (maxA+1)
|> stdout.WriteLine

Measured memory_bytes: 44788
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N, M;
    cin >> N >> M;

    vector<vector<int>> Ss(M, vector<int>());
    vector<int> Ps(M);
    REP(m, M) {
        int K;
        cin >> K;
        REP(k, K) {
            int s;
            cin >> s;
            --s;
            Ss[m].pb(s);
        }
    }
    REP(m, M) cin >> Ps[m];

    int ans = 0;
    REP(i, 1 << N) {
        bool ok = true;
        REP(m, M) {
            int sum = 0;
            for(auto s: Ss[m]) {
                if (i & (1 << s)) sum++;
            }
            if ((sum % 2) != Ps[m]) {
                ok = false;
            }
        }
 
        ans += ok;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
    map<char,vector<int>> mp;
    string s,t;
    cin >> s >> t;
    for(int i = 0;i < s.size();i ++){
        mp[s[i]].push_back(i);
    }
    ll j = 0,cnt = -1,pt = 0;
    bool isp = true;
    while(isp && j < t.size()){
        map<char,int> cntmp;
        isp = false;
        cnt ++;
        for(int i = j;i < t.size();i ++){
            j = i;
            while(isp && cntmp[t[i]]<mp[t[i]].size() && mp[t[i]][cntmp[t[i]]] <= pt) cntmp[t[i]] ++;
            if(cntmp[t[i]]>=mp[t[i]].size()) break;

            pt = mp[t[i]][cntmp[t[i]]];
            cntmp[t[i]] ++;
            isp = true;
            if(i==t.size()-1) j = t.size();
        }
    }
    ll ans = ((ll)s.size())*cnt+pt+1ll;
    if(isp) cout << ans << endl;
    else    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#define INF 10000000
using namespace std;

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

  for(int i=0;i<n;i++)
    for(int j=n-2;j>=0;j--) {
      x[i][j]+=x[i][j+1];
      y[j][i]+=y[j+1][i];
    }
  
  int ans=y[0][n-1],sum,K[302][302]={},t=0,f=1;
  while(f){
    t++,f=0;
    for(int i=0;i<n;i++) //yoko
      for(int j=i+1;j<n;j++) {//yoko
	int a=K[i][j],nk=a;
	sum=-INF;
	for(int k=a+1;k<n;k++) { //tate
	  int X=(x[a][i]-x[a][j+1])+(x[k][i]-x[k][j+1]);
	  int Y=(y[a+1][i]-y[k][i])+(y[a+1][j]-y[k][j]);
	  if(sum<=X+Y)sum=X+Y,nk=k;
	}
	ans=max(ans,sum);
	
	if(nk!=n-1)f=1;
	for(int k=a+1;k<nk;k++){//tate
	  sum+=(x[k][i+1]-x[k][j])-(x[k-1][i]-x[k-1][j+1]);
	  ans=max(ans,sum);
	  }
	K[i][j]=nk;
      }
  }
  cout <<ans<<endl;
	  
  return 0; 
}

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

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> v(n);
  for (auto &e : v) {
    cin >> e;
    e = abs(e - x);
  }
  int r = v.front();
  for (auto e : v) {
    r = gcd(r, e);
  }
  cout << r << endl;
}


Measured memory_bytes: 640
s=input()
ans=0
def dfs(i,stri,sum): #i個土入れてstriを作ってる、和は？
    global ans
    #print(i,stri,sum)
    if i==3 and sum==7:
        #print("ore")
        ans=stri+"=7"
        
    
    if i<=2:
        dfs(i+1, stri+ f"+{s[i+1]}" , sum+int(s[i+1]))
        dfs(i+1, stri+ f"-{s[i+1]}", sum-int(s[i+1]))

dfs(0,s[0],int(s[0]))
print(ans)

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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll mod = pow(10,9) + 7;
    for (ll i=0; i<N; i++) {
        cin >> A.at(i);
        A.at(i) %= mod;
    }

    
    vector<ll> vec(N-1);
    vec.at(N-2) = A.at(N-1);

    for (ll i=N-3; i>=0; i--) {
        vec.at(i) = vec.at(i+1)+A.at(i+1);
        vec.at(i) %= mod;
    }
    
    vector<ll> seki(N-1);
    for (ll i=0; i<N-1; i++) {
        seki.at(i) = vec.at(i) * A.at(i);
        seki.at(i) %= mod;
    }
    ll sum = 0;
    for (ll i=0; i<N-1; i++) {
        sum += seki.at(i);
        sum %= mod;
    }
    cout << sum << endl;
    
}

Measured memory_bytes: 7984
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int n, y;
    cin >> n >> y;
    bool ok = false;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n - i; j++) {
            if (10000 * i + 5000 * j + 1000 * (n - i - j) == y) {
                ok = true;
                cout << i << " " << j << " " << n - i - j << endl;
                break;
            }
        }
        if (ok) break;
    }
    if (!ok) { cout << -1 << " " << -1 << " " << -1 << endl; }
    return 0;
}

Measured memory_bytes: 256