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

class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int h,m,s;
		h = a / 3600;
		m = a % 3600 / 60;
		s = a % 3600 % 60;
		System.out.println(h + ":" + m + ":" + s);
	}
}

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

using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	int a[1000];

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int max = 0, min = 1000;

	for (int i = 0; i < N; i++) {
		if (a[i] > max) {
			max = a[i];
		}
		if (a[i] < min) {
			min = a[i];
		}
	}

	cout << max-min << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 120


int main(){
  int N,L;
  cin>>N>>L;
  string s[MAX];
  for(int i=0;i<N;i++){
    cin>>s[i];
  }
  sort(s,s+N);
  for(int i=0;i<N;i++){
    cout<<s[i];
  }
  cout<<endl;
  
  

}


Measured memory_bytes: 256
from collections import deque

h, w = map(int, input().split())
AA = [list(input()) for _ in range(h)]
# AA[h][w]
infi = 10 ** 5
kouho = []
ans = [[infi] * (w) for _ in range(h)]

for i in range(h):
    for j in range(w):
        if AA[i][j] == "#":
            kouho.append((i, j, 0))
            ans[i][j] = 0

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]


que = deque(kouho)
while que:
    py, px, d = que.popleft()
    for i in range(4):
        nx = px + dx[i]
        ny = py + dy[i]
        if nx < 0 or nx >= w:
            continue
        if ny < 0 or ny >= h:
            continue
        if ans[ny][nx] == infi:
            ans[ny][nx] = d + 1
            que.append((ny, nx, d + 1))


cnt = 0
for i in range(h):
    for j in range(w):
        cnt = max(cnt, ans[i][j])

print(cnt)


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

signed main(){

  int a,b,c;
  cin>>a>>b>>c;
  if(a+b+c>21)puts("bust");
  else puts("win");

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    char s[11];
    scanf("%s",s);
    int p=strlen(s);
    if(p%2!=0){
        puts("No");
        return 0;
    }
    for(int i=0;i<p-1;){
        if(s[i]=='h'&&s[i+1]=='i'){
            i+=2;
        }
        else{
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}

int A[100006];
int N;

int f(double n){
	int ret=0;
	bool a = (n<A[0]);
	for(int i=0;i<N-1;i++){
		if((A[i]-n)*(A[i+1]-n)<0){
			if(a){
				ret++;
				a=false;
			}
			else a=true;
		}
	}
	if(a)ret++;
	//cout<<n<<" "<<ret<<endl;
	return ret;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N,M;
	cin>>N>>M;
	vector< pair<int,int> >v;
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		v.push_back(make_pair(b,a));
	}
	sort(v.begin(),v.end());
	int x=-1;
	int ans=0;
	for(int i=0;i<M;i++){
		//=cout<<v[i].second<<x;
		if(x<v[i].second){
			x=v[i].first-1;
			ans++;
		}
		else continue;
	}
	cout<<ans<<endl;
}
	


Measured memory_bytes: 1528
#include <iostream>

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

int main(){
    ll w, h, n;
    cin >> w >> h >> n;
    ll xd = 0, xu = w, yd = 0, yu = h;
    REP(i, n){
        ll xi, yi, ai;
        cin >> xi >> yi >> ai;
        if(ai == 1){
            xd = max(xd, xi);
        }else if(ai == 2){
            xu = min(xu, xi);
        }else if(ai == 3){
            yd = max(yd, yi);
        }else{
            yu = min(yu, yi);
        }
    }
    cout << max(xu - xd, 0LL) * max(yu - yd, 0LL) << endl;
    return 0;
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a = 0, b = 0;
  char c;
  cin >> c; a = (c == 'H' ? 1 : 0);
  cin >> c; b = (c == 'H' ? 1 : 0);
  cout << (a^b == 0 ? 'H' : 'D') << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Roc ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ll long long
#define NMAX 100009
#define LMAX 3009
using namespace std;

int n, m, pd[LMAX][LMAX];
string a,b, ans;
int main()
{
    Roc;
    cin >> a >> b;
    n = a.size();
    m = b.size();
    a = '0' + a;
    b = '0' + b;
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
        {
            pd[i][j] = max(pd[i - 1][j] , pd[i][j - 1]);
            if(a[i] == b[j])
                pd[i][j] = max(pd[i][j], pd[i - 1][j - 1] + 1);
        }
    int i = n, j = m;
    while(i >= 1 && j >= 1)
    {
        if(a[i] == b[j])
        {
            ans = a[i] + ans;
            i--;
            j--;
        }
        else if(pd[i][j] == pd[i-1][j])
            i--;
        else
            j--;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef std::string str;
#define sei set<int>
#define sell set<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vld vector<ld>
#define vstr vector<str>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(v) v.begin(),v.end()
#define foa(i,v) for(auto i : v)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define deb(x)  cerr << #x << " = " << x << endl
#define pb push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define OK order_of_key
#define FO find_by_order
#define nmax 1000100
const ld PI = 3.141592653589793238462643383279;
const ll inf = std::numeric_limits<ll>::max();
const int infint = std::numeric_limits<int>::max();
const ll mod = 1e9+7;
using namespace __gnu_pbds;
using namespace std;
/*#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")*/
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a,b;
    cin >> a >> b;
    if(a > 9 || b > 9) cout << -1;
    else cout << a*b;

    return 0;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer(x) cout<<endl<<"answer : "<<x<<endl<<endl;
#define op(x) cout<<x<<endl;
#define maxn 100005
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,d=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0,l=0,r=0,mid=0,lo=0,hi=0;string s;bool flag=false;
        cin>>x>>k>>d;
        y = abs(x)/d;
        if(k<y)
            ans = abs(x) - k*d;
        else
        {
            x = abs(x)- (y*d);
            k-=y;
            if(k%2==1)
                ans = abs(abs(x) - d);
            else
                ans = abs(x);
        }
        op(ans)
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 3648
use std::str::FromStr;
use std::io::stdin;
use std::cmp::min;

fn main() {
    let s = read::<String>();
    let mut black = 0 as u64;
    for i in s.chars().enumerate() {
        black += match (i.0 % 2, i.1) {
            (0, '0') => 1,
            (1, '1') => 1,
            (_, _) => 0,
        }
    }
    let mut white = 0 as u64;
    for i in s.chars().enumerate() {
        white += match (i.0 % 2, i.1) {
            (0, '1') => 1,
            (1, '0') => 1,
            (_, _) => 0,
        }
    }
    println!("{}", min(black, white));
}

fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().parse().ok().unwrap()
}

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

vector<int> result;
int used[2 * 100000 + 10];
int este[100000 + 10];

vector<vector<int>> edges(2 * 100000 + 10);
void dfs(int node) {
    used[node] = 1;
    result.push_back(node);
    for(int son : edges[node]) {
        if(!used[son]) {
            dfs(son);
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for(int j = 0; j < k; j++) {
            int x;
            cin >> x;
            edges[x].push_back(m + i + 1);
            edges[m + i + 1].push_back(x);
        }
    }
    dfs(m + 1);
    for(int i = 0; i < result.size(); i++) {
        if(result[i] > m) {
            este[result[i] - m] = 1;
        }
    }
    bool ok = true;
    for(int i = 1; i <= n; i++) {
        if(este[i] == 0) {
            ok = false;
        }
    }
    ok ? cout << "YES" : cout << "NO";
    return 0;
}


Measured memory_bytes: 9852
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        char[] s = Console.ReadLine().ToCharArray();
        int ans = 0;
        for (int i = 1; i < s.Length; i++)
        {
            if (i % 2 == 1 && s[i] == s[0])
                ans++;
            else if (i % 2 == 0 && s[i] != s[0])
                ans++;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13176
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 998244353, N = 3e3 + 211;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, m, dp[N][N], a[N];

void add (int &x, int y) {
	x += y;
	if (x >= mod)
		x -= mod;
	if (x < 0)
		x += mod;
}

main () {
	cin >> n >> m;	
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		for (int j = 0; j < N; ++j) {
			dp[i][j] = dp[i - 1][j]*2 % mod;
			if (j >= a[i])	
				add(dp[i][j], dp[i - 1][j - a[i]]);
		}
	}
/*	for (int i = 1; i <= n; ++i, cout << endl)
		for (int j = 0; j <= m; ++j)
			cout << dp[i][j] << ' ';*/

	cout << dp[n][m] << endl;
		
}

//check for the constants

                                                                                   	



Measured memory_bytes: 78888
while gets
  n=$_.to_i
  p_list=Array.new(n+1,1)
  p_list[0..1]=[nil,nil]
  (2..n**(1/2.0)).each do |i|
    if p_list[i]
      (2..n/i).each do |j|
        p_list[i*j]=nil
      end
    end
  end
  puts p_list.compact.size
end

Measured memory_bytes: 32324
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<P> a(n);
    unordered_map<int, vector<char> > ch;
    rep(i, n) {
        char c;
        cin >> c >> a[i].first;
        a[i].second = ch[a[i].first].size();
        ch[a[i].first].push_back(c);
    }

    auto partition = [&](int p, int r) {
        int x = a[r].first;
        int i = p-1;
        for(int j = p; j < r; ++j) {
            if(a[j].first <= x) {
                swap(a[j], a[++i]);
            }
        }
        swap(a[++i], a[r]);
        return i;
    };
    function<void(int, int)> quickSort = [&](int p, int r) {
        if(p < r) {
            int q = partition(p, r);
            quickSort(p, q-1);
            quickSort(q+1, r);
        }
    };

    quickSort(0, n-1);

    vector<pair<char, int> > ans(n);
    unordered_map<int, int> cou(n);
    bool x = true;
    rep(i, n) {
        ans[i].first = ch[a[i].first][a[i].second];
        ans[i].second = a[i].first;
        if(cou[a[i].first]++ != a[i].second) x = false;
    }
    cout << (x?"Stable":"Not stable") << '\n';
    rep(i, n) {
        cout << ans[i].first << ' ' << ans[i].second << '\n';
    }
}


Measured memory_bytes: 8440
if true then
  fh=STDIN
else
  fh=open("in0105.txt")
end

h = Hash.new
while fh.gets do
  f =$_.chomp.split
  w =f[0] 
  p = f[1].to_i
  if h.has_key?(w) then
    h[w].push(p)
  else
    h[w]=[p]
  end
end

h.keys.sort.each{|w|
  puts w
  puts h[w].sort.map{|x|x.to_s}.join(" ")
}

Measured memory_bytes: 8656
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;


int main(void){

int shk[102]={0}, su;
	while(cin >> su ){
		shk[su]++;
	}
	int j, mx = -999;
	rep2(j,1,101) mx = max(mx,shk[j]);
	rep2(j,1,101) if(mx==shk[j]) cout << j << endl;
	
	
	return 0;
}

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

int main() {
  int N,sum=0,originN;
  cin >> N;
  originN = N;
  for (int i=0; i < 8; i++){
    sum += N % 10;
    N /= 10;
  }
  //cout << sum;
  if(originN % sum == 0){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll n,l;
    cin>>n>>l;
    vector<string> s(n);
    rep(0,i,n)cin>>s[i];
    sort(s.begin(),s.end());
    rep(0,i,n){
        cout<<s[i];
    }
    
}


Measured memory_bytes: 3532
K = int(input())

A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(A[K-1])

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

int main(){
  char str[20];
  scanf("%s\n",str);
  for (int i = 0; i < strlen(str); i++) {
    if (str[i]==',') {
      printf(" ");
    }else{
      printf("%c",str[i]);
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
from collections import deque

mod = 10 ** 9 + 7

n, k = map(int, input().split())

g = [set() for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].add(b)
    g[b].add(a)

dq = deque()
dq.append((0, -1))
ans = k

while dq:
    v, pr = dq.popleft()
    can_use_color = k - 1 - (0 if pr == - 1 else 1)

    for u in g[v]:
        if u == pr:
            continue
        ans *= can_use_color
        ans %= mod
        can_use_color -= 1

    for u in g[v]:
        if u == pr:
            continue
        dq.append((u, v))

print(ans)


Measured memory_bytes: 43908
# -*- coding: utf-8 -*-


def main():
    N = input()
    inputs = list(map(int, input().split()))

    min = 100
    for i in range(1, int(N)):
        diff = abs(sum(inputs[:i]) - sum(inputs[i:]))
        if min > diff:
            min = diff

    print(min)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
/**
 *    author:  tourist
 *    created: 26.05.2018 15:07:14       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  const int MAX = 20;
  vector<int> last(MAX, -1);
  long long ans = 0;
  int bound = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    for (int j = 0; j < MAX; j++) {
      if (x & (1 << j)) {
        bound = max(bound, last[j] + 1);
        last[j] = i;
      }
    }
    ans += i - bound + 1;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  ll k=n/(a+b);
  ll ans=0;
  ans+=k*a;
  if(n-k*(a+b)>=a)ans+=a;
  else ans+=(n-k*(a+b));
  cout<<ans<<endl;
}

Measured memory_bytes: 256
def merge(A, left, mid, right):
    global count
    banpei = 1000000001
    L = A[left:mid]
    l = len(L)
    L += [banpei]
    R = A[mid:right] + [banpei]

    i, j = 0, 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            count += l - i
    return count


def merge_Sort(A, left, right):
    if 1 < right - left:
        mid = (left + right) // 2
        merge_Sort(A, left, mid)
        merge_Sort(A, mid, right)
        merge(A, left, mid, right)

n = int(input())
A = list(map(int, input().split()))
count = 0
merge_Sort(A, 0, n)
print(count)

Measured memory_bytes: 30356
import java.util.Scanner
import scala.collection.mutable.ArrayBuffer
object Main extends App {
  val in = new Scanner(System.in)
  val n, u, v = in.nextInt
  val edges = Array.fill(n + 1)(new ArrayBuffer[Int]())
  (1 until n).foreach{n =>
    val a, b = in.nextInt
    edges(a) += b
    edges(b) += a
  }

  val ts = Array.fill(n + 1)(-1)
  val as = Array.fill(n + 1)(-1)

  def fill(ar: Array[Int], curs: Array[Int], step: Int): Unit = {
    if (curs.nonEmpty) {
      val nexts = for {
          i <- curs
          _ = ar(i) = step
          j <- edges(i)
          if (ar(j) == -1)
        } yield j
      fill(ar, nexts, step + 1)
    }
  }

  fill(ts, Array(u), 0)
  fill(as, Array(v), 0)
  println(ts.tail.zip(as.tail).filter{case (t, a) => t <= a}.map(_._2 - 1).max)
}

Measured memory_bytes: 121908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[200500];
void solve() {
	int n;	
	cin >> n;
	ll t;
	cin >> t;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll res = 0, prev = 0;
	for (int i = 0; i < n; i++) {
		res += t;
		if (a[i] < prev) {
			res -= prev - a[i];
		}
		prev = a[i] + t;
	}
	cout << res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

Measured memory_bytes: 4324
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 100000007;
const int INF = 1 << 29;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	lint X, Y, Z, K;
	cin >> X >> Y >> Z >> K;

	vector<lint> A(X), B(Y), C(Z), ans(K);
	FOR(i, 0, X)cin >> A[i];
	FOR(i, 0, Y)cin >> B[i];
	FOR(i, 0, Z)cin >> C[i];

	sort(A.begin(), A.end(), greater<lint>());
	sort(B.begin(), B.end(), greater<lint>());
	sort(C.begin(), C.end(), greater<lint>());


	FOR(a,0,X)FOR(b,0,Y)FOR(c,0,Z){
		if ((a + 1)*(b + 1)*(c+1)<=K) ans.emplace_back(A[a] + B[b] + C[c]);
	}

	sort(ans.begin(), ans.end(), greater<lint>());
	FOR(i, 0, K) cout << ans[i] << "\n";
	return 0;
}

Measured memory_bytes: 1832
n, m = map(int, input().split())
 
a_li =[]
for i in range(n):
    li = input().split()
    del li[0]
    a_li += li
 
count_li =[]
for o in range(m+1):
    x = a_li.count(str(o))
    count_li.append(int(x))
    
print(count_li.count(n))

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
        int n,m;
        int nsum,msum;
        int s;
        scanf("%d"" %d ", &n,&m);
        if ( n < 2)
                nsum = 0;
        else if ( n > 1)
                nsum = n * (n - 1) / 2;

        if ( m < 2)
                msum = 0;
        else if ( m > 1)
                msum = m * (m - 1) / 2;

        s = nsum + msum ;
     printf("%d\n",s);

        return 0;
}

Measured memory_bytes: 1736
N = int(input())
S_map = {}
for _ in range(N):
    Si = input().rstrip('\r')
    if S_map.get(Si) == None:
        S_map[Si] = 1
    else:
        S_map[Si] += 1
S_map_sorted = sorted(S_map.items(), reverse=True, key=lambda x:x[1])
count = S_map_sorted[0][1]
ans = []
for s, c in S_map_sorted:
    if c == count:
        ans.append(s)
    else:
        break
for s in sorted(ans):
    print(s)

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

int64_t ryuka(int n,vector<int64_t> &DP){
    if(DP.at(n) != -1){
        return DP.at(n);
    }else{
        int64_t ans;
        ans = ryuka(n-1,DP)+ryuka(n-2,DP);
        DP.at(n) = ans;
        return ans;
    }
}

int main(){
    int N;
    cin>>N;
    vector<int64_t> DP(N+1,-1);
    DP.at(0) = 2;
    DP.at(1) = 1;
    int64_t ans;
    ans = ryuka(N,DP);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
int n, a[200001], l[200001], r[200001], deq[200001];

signed main()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    deq[0] = 0;
    int top = 0;
    for(int i = 1; i <= n; i++){
        while(top > 0 && a[deq[top]] >= a[i]) top--;
        l[i] = deq[top] + 1;
        top++;
        deq[top] = i;
    }    
    deq[0] = n + 1;
    top = 0;
    for(int i = n; i >= 1; i--){
        while(top > 0 && a[deq[top]] >= a[i]) top--;
        r[i] = deq[top] - 1;
        top++;
        deq[top] = i;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans += (i - l[i] + 1) * (r[i] - i + 1) * a[i];
    }
    cout << ans;
} 

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int N;
	cin >> N;
	if (N == (N & -N)) return cout << "No\n", 0;
	auto edge = [] (int u, int v) { cout << u << ' ' << v << '\n'; };
	cout << "Yes\n" << N + 1 << ' ' << N + 2 << '\n';
	for (int u = 2; u < N; u += 2) {
		edge(1, u);
		edge(1, u ^ 1);
		edge(u, N + (u ^ 1));
		edge(u ^ 1, N + u);
	}
	if (!(N & 1)) {
		int lowbit = N & -N;
		edge(N, N ^ lowbit);
		edge(N << 1, 1 ^ lowbit);
	}
}


Measured memory_bytes: 2304
import java.io.*;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			String[] split = str.split(" ",0);
			int a = Integer.parseInt(split[0]);
			int b = Integer.parseInt(split[1]);
			if (a > b) {
				System.out.println("a > b");
			} else if (a < b) {
				System.out.println("a < b");
			} else {
				System.out.println("a == b");
			}
		} catch (Exception e) {
			System.out.println("??¨??????");
		}
	}
}

Measured memory_bytes: 24440
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
//Prob 5
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int c[5005],r[5005];
vector<int>edge[5005];
int d[5005][5005];
int n,k;
void dijkstra()
{
	priority_queue<P1,vector<P1>,greater<P1> >que;
	d[1][r[1]]=c[1];
	que.push(mp(c[1],mp(1,r[1])));
	
	while(!que.empty())
	{
		P1 p=que.top(); que.pop();
		int cur=p.first;
		int v=p.second.first;
		int zan=p.second.second;
		if(cur!=d[v][zan]) continue;
		for(int i=0;i<edge[v].size();i++)
		{
			int ne=edge[v][i];
	/*ここです*/	if(zan>=1&&zan-1<r[ne])
			{
				if(d[ne][r[ne]]>d[v][zan]+c[ne])
				{
					d[ne][r[ne]]=d[v][zan]+c[ne];
					que.push(mp(d[ne][r[ne]],mp(ne,r[ne])));
				}
			}
			
			if(zan>=1)
			{
				if(d[ne][zan-1]>d[v][zan])
				{
					d[ne][zan-1]=d[v][zan];
					que.push(mp(d[ne][zan-1],mp(ne,zan-1)));
				}
			}
		}
	}
	int ret=INF;
	for(int j=0;j<5005;j++)
	{
		ret=min(ret,d[n][j]);
	}
	printf("%d\n",ret);
}
int main(){
	scanf("%d %d",&n,&k);
	
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d",&c[i],&r[i]);
	}
	for(int i=0;i<k;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		edge[a].pb(b);
		edge[b].pb(a);
	}
	for(int i=0;i<5005;i++)for(int j=0;j<5005;j++)d[i][j]=2e8;
	dijkstra();
	return 0;
}

Measured memory_bytes: 99592
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int max = 1000000;
        int tList[] = new int[181];
        for (int i = 1; i < 181; i++) {
            tList[i - 1] = i * (i + 1) * (i + 2) / 6;
        }
        int dp[] = new int[max + 1];
        int dpOdd[] = new int[max + 1];
        dp[0] = 0;
        dpOdd[0] = 0;
        for (int i = 1; i <= max; i++) {
            int dpmin = Integer.MAX_VALUE;
            int dpOddmin = Integer.MAX_VALUE;
            for (int j : tList) {
                if (j > i)
                    break;
                if (dp[i - j] < dpmin) {
                    dpmin = dp[i - j];
                }
                if (j % 2 != 0 && dpOdd[i - j] < dpOddmin) {
                    dpOddmin = dpOdd[i - j];
                }
            }
            dp[i] = dpmin + 1;
            dpOdd[i] = dpOddmin + 1;
        }
        Scanner scan = new Scanner(System.in);
        while (true) {
            String str = scan.nextLine();
            int input = Integer.parseInt(str);
            if (input == 0)
                break;
            System.out.printf("%d %d%n", dp[input], dpOdd[input]);
        }
    }
}


Measured memory_bytes: 35832
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())
#define MOD 1000000007 
#define mx 100003

int n, u, v, k, nilai[mx], P[mx], kecil[mx], besar[mx], lev[mx];
vector<int> g[mx];

void dfs(int now, int par, int level, int mini, int maks){
	if(nilai[now] != -1){
		if((level + nilai[now]) % 2 > 0){
			cout << "No\n";
			exit(0);
		}
		if(nilai[now] < mini || nilai[now] > maks){
			cout << "No\n";
			exit(0);
		}
		mini = maks = nilai[now];
	}
	kecil[now] = max(kecil[now], mini);
	besar[now] = min(besar[now], maks);
	P[now] = par;
	mini = kecil[now];
	maks = besar[now];
	lev[now] = level;
	for(int i : g[now]){
		if(i != par)
			dfs(i, now, level + 1, mini - 1, maks + 1);
	}
	for(int i : g[now]){
		if(i != par){
			int a = kecil[i] - 1;
			int b = besar[i] + 1;
			besar[now] = min(besar[now], b);
			kecil[now] = max(kecil[now], a);
		}
	}
}

int main(){
	cin >> n;
	for(int i = 1; i <= n; i++)
		kecil[i] = -1e9, besar[i] = 1e9;
	for(int i = 1; i < n; i++){
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	cin >> k;
	reset(nilai, -1);
	int root = -1, val = 1e9;
	for(int i = 0; i < k; i++){
		cin >> u >> v;
		nilai[u] = v;
		if(val > v){
			root = u;
			val = v;
		}
	}
	for(int i = 1; i <= n; i++)
		if(nilai[i] != -1)
			nilai[i] -= val;
	dfs(root, 0, 0, 0, 0);
	dfs(root, 0, 0, 0, 0);
	for(int i = 1; i <= n; i++){
		// cout << i << ' ' << kecil[i] << ' ' << besar[i] << endl;
		if(kecil[i] > besar[i]){
			cout << "No\n";
			return 0;
		}
		if(nilai[i] == -1){
			nilai[i] = besar[i];
		}
		else{
			if(nilai[i] < kecil[i] || nilai[i] > besar[i]){
				cout << "No\n";
				return 0;
			}
		}
	}
	cout << "Yes\n";
	for(int i = 1; i <= n; i++)
		cout << nilai[i] + val << '\n';
}

Measured memory_bytes: 17152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,r;
    cin>>n>>r;
    if(n>=10) cout<<r<<endl;
    else cout<<r+100*(10-n)<<endl;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
k = int(input())

for cnt in range(k):
    if a < b and b < c:
        break
    elif a >= b:
        b = int(b * 2)
        continue
    elif b >= c:
        c = int(c * 2)
        continue

if a < b < c:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9180
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <queue>
using namespace std;
int a[100005];
int main()
{
	int n,m,k=0,s=0;
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		s+=a[i];
	}
	cout<<s-n<<endl;
} 

Measured memory_bytes: 256
import math
num=list(map(float,input().split()))
a=num[0]
b=num[1]
C=num[2]
h=b*(math.sin(math.radians(C)))
S=a*h/2
L=a+b+(math.sqrt(b**2+a**2-(2*a*b)*(math.cos(math.radians(C)))))
print(S)
print(L)
print(h)


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

int main() {
  string s, t;
  cin >> s >> t;
  bool ans = false;
  for (int i = 0; i < s.size(); i++) {
    if (s == t) {
      ans = true;
      break;
    }
    s = s.back() + s.substr(0, s.size()-1);
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
} 

Measured memory_bytes: 3548
from collections import deque
N,K=map(int,input().split())
S=input()
zeros=deque()
ichistart=0
zeros.append([-1,-1])
streak=0#0が何人連続した塊なのか
hajime=0
for k,i in enumerate(S):
    if i=="0":
        if streak==0:
            hajime=k
        streak+=1
    elif streak!=0:
        owari=hajime+streak-1
        streak=0
        zeros.append([hajime,owari])
if streak!=0:
    zeros.append([hajime,N-1])
zeros.append([N,N])
curmax=0
done=0
z=len(zeros)
if z<=K+1:
    print(N)
    done=1
if not done:
    for n,[s,f] in enumerate(zeros):
        if n+K+1<z:
            curmax=max(curmax,zeros[n+K+1][0]-f-1)
    print(curmax)

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

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  long a[n], b[m];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (i) a[i] += a[i-1];
  }
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
    if (i) b[i] += b[i-1];
  }
  int ans(0);
  for (int i = 0; i < n && a[i] <= k; ++i) {
    int d = distance(b, upper_bound(b, b + m, k - a[i]));
    ans = max(d + i + 1, ans);
  }
  for (int i = 0; i < m && b[i] <= k; ++i) {
    int d = distance(a, upper_bound(a, a + n, k - b[i]));
    ans = max(d + i + 1, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6716
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>

const int INT_INF = 1000000000;  // 10^9

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    int r = 0, l = 1000;
    for(int i = 0; i < n; i++){
        cin >> x[i];
        r = max(r, x[i]);
        l = min(l, x[i]);
    }

    int sum_min = INT_INF;
    for(int i = l; i <= r; i++){
        int sum = 0;
        for(int j = 0; j < n; j++){
            sum += (x[j] - i) * (x[j] - i);
        }
        sum_min = min(sum_min, sum);
    }

    cout << sum_min << endl;

    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int d = sc.nextInt();
		if (d < 10) {
			System.out.println(0);
			return;
		}

		int count = 0;
		for (int j = 1; j <= m; j++) {
			for (int i = 10; i <= d; i++) {
				int d1 = i / 10;
				int d2 = i % 10;

				if (d1 == 1 || d2 == 1) {
					continue;
				}
				else if (j == d1 * d2) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 22740
h,w,d = map(int, input().split())
ad = {}
for i in range(h):
    line = list(map(int, input().split()))
    for j in range(w):
        ad[line[j]] = (i,j)
q = int(input())
lr = [list(map(int, input().split())) for _ in range(q)]

cl = [0]*(h*w+1)
for i in range(1,h*w+1):
    if i+d<len(cl):
        f = ad[i]
        t = ad[i+d]
        cl[i+d] = cl[i] + abs(f[0]-t[0]) + abs(f[1]-t[1])

for l,r in lr:
    print(cl[r]-cl[l])

Measured memory_bytes: 44780
N,M=map(int,input().split())
H=[0]+list(map(int,input().split()))
A=[0]*(N+1)
xy=[map(int,input().split()) for i in range(M)]
x,y=[list(i) for i in zip(*xy)]
for a,b in zip(x,y):
    for i in range(2):
        A[a]=max(A[a],H[b])
        a,b=b,a
print(sum(c>d for c,d in zip(H,A)))

Measured memory_bytes: 67736
package main

import "fmt"

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	m := make([][]byte, h)
	for i := range m {
		m[i] = make([]byte, w)
		fmt.Scan(&m[i])
	}
	var dx = [4]int{1, -1, 0, 0}
	var dy = [4]int{0, 0, -1, 1}
	ok := true
	var nx, ny, cnt int
	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			if m[y][x] == '#' {
				cnt = 0
				for k := 0; k < 4; k++ {
					nx = x + dx[k]
					ny = y + dy[k]
					if 0 <= nx && nx < w && 0 <= ny && ny < h && m[ny][nx] == '#' {
						cnt++
					}
				}
				if cnt == 0 {
					//fmt.Printf("(%d,%d) is island\n", x, y)
					ok = false
				}
			}
			if !ok {
				break
			}
		}
		if !ok {
			break
		}
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
n,m = map(int,input().split())
s = []
ans = 0
for i in range(n):
    a,b = map(int,input().split())
    s.append([a,b])
s.sort()
for i in s:
    if m<i[1]:
        ans += m*i[0]
        break
    else:
        ans += i[0]*i[1]
        m -= i[1]
print(ans)


Measured memory_bytes: 24160
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        t: Chars,
    }
    for c in t {
        if c == '?' {
            print!("D");
        } else {
            print!("{}", c);
        }
    }
    println!("");
}


Measured memory_bytes: 3012
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
int n;
vector<long long> a;
long long dp[3010][3010];
int main(){
 cin >> n;
 a.resize(n);
 for(int i = 0; i < n; ++i)cin >> a[i];
 for(int len = 1; len <= n; ++len){
   for(int i = 0; i+ len <= n; ++i){
     int j = i + len;
     if((n - len) %2 == 0){
       dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j-1]);
     }else{
       dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j-1]);
     }
   }
 }
 cout << dp[0][n] << endl;
 return 0;
}

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

//Compiler version g++ 6.3.0

int main()
{
   int a[5],x;
   for(int i=0;i<5;i++)
   {
     cin>>a[i];
     if(a[i]==0)
     x=i+1;
   }
   cout<<x;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> mochi(N);
	for(int i = 0; i < N; i++)
		cin >> mochi.at(i);

	sort(mochi.begin(), mochi.end());
	int stage = 1;
	for(int i = 1; i < N; i++)
		if(mochi.at(i) > mochi.at(i-1))
			stage++;
	cout << stage << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

vector<int> ansint((2e+5)/26 + 2,-1);
vector<vector<bool> > sub2((2e+5)/26 + 2,vector<bool>(26*26,false));
vector<vector<bool> > memo((2e+5)/26 + 2,vector<bool>(26,false));
ll ans = 1;
bool dfs(int id, int abc){ //true -> その後の文字を取れる
    if(memo[id][abc]) return false;
    if(id == ans - 1) {
        ansint[id] = abc;
        return true;
    }
    rep(i,26){
        if(sub2[id][abc*26 + i]) continue;
        if(dfs(id+1 ,i)){
            ansint[id] = abc;
            return true;
        }
    }
    memo[id][abc] = true;
    return false;
}

int main() {
    cin>>S;
    N = S.size();
    set<int> alpha;
    vector<int> sint(N);
    rep(i,N) sint[i] = S[i] - 'a';
    rep(i,N){
        for(int fst : alpha) sub2[ans - 1][fst*26 + sint[i]] = true;
        alpha.insert(sint[i]);
        if(alpha.size() == 26){
            alpha.clear();
            ++ans;
        }
    }
    for(int al : alpha) memo[ans - 1][al] = true;
    rep(i,26){
        if(dfs(0,i)) break;
    }
    rep(i,ans) cout<<char(ansint[i] + 97);
    cout<<endl;
}

Measured memory_bytes: 3588
'use strict';
(function(stdin) {
  var i = stdin.toString().trim();
  (function(r) {
    var r = (i * i * Math.PI).toFixed(6);
    var g = (2 * Math.PI * i).toFixed(6);
    console.log(r,g);
  }(parseInt(i,10)
      )); 
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

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

#define ls(x) ch[x][0]
#define rs(x) ch[x][1]
#define rep(i , j , k) for(int i = j ; i <= k ; i ++)
#define Rep(i , j , k) for(int i = j ; i >= k ; i --)

using namespace std ;
using ll = long long ;
using pii = pair <int , int> ;
using vii = vector <int> ;

auto ot = [&]() { cerr << "ATS TXDY" << '\n' ; int ATS_nantf_txdy = true ; } ;
auto _ios = [&]() { ios :: sync_with_stdio(false) ; cin.tie(nullptr) ; cout.tie(nullptr) ; } ;

namespace stO_ATS_Orz {
  template < class T > void cmax(T & x , T y) { if(x > y) x = y ; }
  template < class T > void cmin(T & x , T y) { if(x < y) x = y ; }
  template < class T > void abs(T x) { if(x < 0) x = -x ; }
  const int N = 1000000 ;
  bool dp[N] ; char s[N] ;
  int a[N] ;
  void main() {
    int n ; cin >> n;
    cin >> s + 1 ;
    for(int i = 1 ; i <= n ; i ++) a[i] = s[i] & 15 ;
    for(int i = 1 ; i <= n ; i ++) a[i] ++ ;
    dp[0] = 1 ;
    for(int i = 1 ; i <= n ; i ++) {
      for(int j = 11 * 11 ; ~ j ; j --) dp[j * 11 + a[i]] |= dp[j] ;
    }
    int ans = 0 ;
    for(int i = 11 * 11 + 1 ; i <= 11 * 11 * 11 ; i ++) if(dp[i]) ans ++ ;
    cout << ans << '\n' ;
  }
}
signed main() {
  // _ios() ;
  ot() ;
  return stO_ATS_Orz :: main() , 0 ;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;cin>>n;
    long long ans=1e18;
  for(long long i=1;i*i<=n;i++){
    if(n%i==0){
        ans=min(ans,i+n/i-2);
       
    }
}
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
typedef long long ll;

const int N=200005;
int n,c[N],p[26][N],Oc,f[N];
char s[N];

void Modify(int x,int v){for(;x<=n;x+=x&-x)c[x]+=v;}
int Query(int x,int s=0){for(;x;x^=x&-x)s+=c[x];return s;}

int main()
{
    scanf("%s",s+1),n=strlen(s+1);
    for(int i=1;i<=n;++i)p[s[i]-'a'][++p[s[i]-'a'][0]]=i;
    for(int i=0;i<26;++i)if(p[i][0]&1)++Oc;
    if(Oc>1)return puts("-1"),0;
    for(int i=0;i<26;++i)
        for(int j=1;j<=p[i][0];++j)
            f[p[i][p[i][0]-j+1]]=p[i][j];
    ll Ans=0;
    for(int i=n;i>=1;--i)Ans+=(n-i)-Query(f[i]),Modify(f[i],1);
    printf("%lld\n",Ans>>1);
    return 0;
}

Measured memory_bytes: 20480
#!/usr/bin/env python
# coding: utf-8

# In[8]:


abcd = list(map(int, list(input())))


# In[9]:


if abcd[0] + abcd[1] + abcd[2] + abcd[3] == 7:
    print(str(abcd[0])+"+"+str(abcd[1])+"+"+str(abcd[2])+"+"+str(abcd[3])+"=7")
elif abcd[0] + abcd[1] + abcd[2] - abcd[3] == 7:
    print(str(abcd[0])+"+"+str(abcd[1])+"+"+str(abcd[2])+"-"+str(abcd[3])+"=7")
elif abcd[0] + abcd[1] - abcd[2] + abcd[3] == 7:
    print(str(abcd[0])+"+"+str(abcd[1])+"-"+str(abcd[2])+"+"+str(abcd[3])+"=7")
elif abcd[0] + abcd[1] - abcd[2] - abcd[3] == 7:
    print(str(abcd[0])+"+"+str(abcd[1])+"-"+str(abcd[2])+"-"+str(abcd[3])+"=7")
elif abcd[0] - abcd[1] + abcd[2] + abcd[3] == 7:
    print(str(abcd[0])+"-"+str(abcd[1])+"+"+str(abcd[2])+"+"+str(abcd[3])+"=7")
elif abcd[0] - abcd[1] + abcd[2] - abcd[3] == 7:
    print(str(abcd[0])+"-"+str(abcd[1])+"+"+str(abcd[2])+"-"+str(abcd[3])+"=7")
elif abcd[0] - abcd[1] - abcd[2] + abcd[3] == 7:
    print(str(abcd[0])+"-"+str(abcd[1])+"-"+str(abcd[2])+"+"+str(abcd[3])+"=7")
elif abcd[0] - abcd[1] - abcd[2] - abcd[3] == 7:
    print(str(abcd[0])+"-"+str(abcd[1])+"-"+str(abcd[2])+"-"+str(abcd[3])+"=7")


# In[ ]:






Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) max_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

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

    string s, t; cin >> s >> t;

    if(s.size() < t.size()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    int num;
    bool able = false;

    for(int i = s.size() - t.size(); i>= 0; i--){
        bool check = true;
        rep(j,t.size()) {
            if(s[i+j] == t[j] or s[i+j] == '?') continue;
            check = false;
            break;
        }
        if(check)  {
            num = i;
            able = true;
            break;
        }
    }

    if(!able) {
        cout << "UNRESTORABLE"<< endl;
        return 0;
    }

    if(able) rep(i,t.size()) s[i + num] = t[i];
    rep(i,s.size()) if(s[i] == '?') s[i] = 'a';
    cout << s << endl;
    return 0; 
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	D, G := getInt(), getInt()
	p, c := make([]int, D), make([]int, D)
	s := make([]int, D)
	for i := 0; i < D; i++ {
		p[i], c[i] = getInt(), getInt()
		s[i] = 100*(i+1)*p[i] + c[i]
	}

	N := 1 << uint(D)
	ans := math.MaxInt64
	for i := 0; i < N; i++ {
		sum := 0
		cnt := 0
		for j := 0; j < D; j++ {
			if (i>>uint(j))%2 == 1 {
				sum += s[j]
				cnt += p[j]
			}
		}
		if sum >= G {
			// out(sum, D)
			for j := 0; j < D; j++ {
				cnt2 := 0
				sum2 := sum
				if (i>>uint(j))%2 == 1 {
					sum2 -= c[j]
					if sum2 > G {
						for k := 0; k < p[j]; k++ {
							sum2 -= 100 * (j + 1)
							if sum2 < G {
								break
							}
							cnt2++
						}
					}
				}
				// out(strconv.FormatInt(int64(i), 2), "---")
				// out(cnt, sum, cnt2, sum2)
				ans = min(ans, cnt-cnt2)
			}
			// out(sum)
		}
	}
	out(ans)
}


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

int main()
{
  string S;
  int K;
  cin >> S >> K;
  rep(i, K) {
	if (S[i] > '1') {
	  cout << S[i] << endl;
      break;
    }
    if (i == K-1) cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())

nowT = 1
nowA = 1
for i in range(N):
    nextT, nextA = map(int, input().split())

    # mul = max(ceil(nowT / nextT), ceil(nowA / nextA))
    mul = max(-(-nowT // nextT), -(-nowA // nextA))
    nowT = nextT * mul
    nowA = nextA * mul

print(nowT + nowA)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define VI vector<int>
#define VII vector<vector<int>>
#define all(v) (v.begin(),v.end())
#define MP make_pair
#define pb(n) push_back(n)


int main(){
    int D,L;cin>>D>>L;
    cout<<(D%L?D/L+D%L:D/L)<<endl;
}


Measured memory_bytes: 3084