akhauriyash/Code-Regression huggingface dataset:
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
 
using namespace std;
//using namespace __gnu_pbds;

//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;                         

const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
int a[N];
void solve () {
	for (int i = 1; i <= 5; i ++) cin >> a[i];
	for (int i = 1; i <= 5; i ++) {
		if (a[i] == 0) {
			cout << i;
			exit (0);
		}
	}	
}   	
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 3540
require 'set'

def main
    n = gets.chomp
    if ["2","4","5","7","9"].include? n[-1]
        puts 'hon'
    elsif n[-1] == "3"
        puts 'bon'
    else
        puts 'pon'
    end
end

main

## イディオムなど
# until s.empty? do
#
## 配列のインデックス
# s[0,6] # 0番目から6文字
# s[0..6] # 0番目から6番目まで
# s[5..-1] # 5番目から最後まで
#
## 全探索
# [0, 1].repeated_permutation(n) do |combination| # 2^n の全探索
# array.combination(i) do |selected| # array から要素が i 個である部分列を全部抽出

Measured memory_bytes: 14396
a = list(map(int,input().split()))
su = 0

while sum(a) != 0:
	for i in range(1,a[2]):
		for j in range(i,a[2]):
			if ((i *(100+a[0]))//100+(j *(100+a[0]))//100==a[2]):
				su = max(su,(i *(100+a[1]))//100+(j*(100+a[1]))//100)
	print(su)
	su = 0
	a = list(map(int,input().split()))


Measured memory_bytes: 5600
#include<queue>
#include<cstdio>
#include<utility>
using namespace std;
typedef pair<int, int> P;
int main() {
	int W, H;
	int i, j, k;
	int map[50][50];
	int vector[8][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
	int count;
	queue<P> q;
	while (1) {
		scanf("%d %d", &W, &H);
		if (!(W||H)) break;
		count = 0;
		for (i = 0; i < H; i ++) for (j = 0; j < W; j ++) scanf("%d", &map[i][j]);
		for (i = 0; i < H; i ++) {
			for (j = 0; j < W; j ++) {
				if (map[i][j]) {
					map[i][j] = 0; count ++;
					q.push(P(i, j));
					while (!q.empty()) {
						P p = q.front(); q.pop();
						int x, y;
						for (k = 0; k < 8; k ++) {
							x = p.first + vector[k][0]; y = p.second + vector[k][1];
							if (-1 < x && x < H && -1 < y && y < W && map[x][y]) {
								q.push(P(x, y));
								map[x][y] = 0;
							}
						}
					}
				}
			}
		}
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 1064
#![allow(non_snake_case,unused_imports,dead_code)]
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::Ordering;

use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {
    input!{
        N:usize,
        AB:[(Usize1,Usize1);N-1],
    }

    let mut E = vec![Vec::new();N];
    for &(a,b) in &AB{
        E[a].push(b);
        E[b].push(a);
    }
    let D = bfs_dist(N,&E,0);
    let n = dfs_subtree_size(N, &E, 0);
    let d = D[N-1]/2+1;

    let mut i = N-1;
    while D[i] != d{
        for &j in &E[i]{
            if D[j]<D[i]{
                i = j;
                break
            }
        }
    }

    if n[i] as usize >= (N+1)/2{
        println!("Snuke");
    } else {
        println!("Fennec");
    }

}

fn dfs_subtree_size(N:usize,E:&Vec<Vec<usize>>,start:usize) -> Vec<isize>{
    let mut n = vec![-1;N];
    let mut q = vec![(start,start)];
    while let Some((i,p)) = q.pop(){
        let mut popped = true;
        let mut cnt = 1;
        for &j in &E[i]{
            if j == p{ continue;}
            if n[j] == -1{
                if popped {
                    q.push((i,p));
                    popped = false;
                }
                q.push((j,i));
            } else {
                cnt += n[j];
            }
        }
        if popped{
            n[i] = cnt;
        }
    }
    n
}


fn bfs_dist(N:usize,E:&Vec<Vec<usize>>,start:usize) -> Vec<isize>{
    let mut d = vec![-1;N];
    let mut q = VecDeque::new();
    q.push_back(start);
    d[start] = 0;
    while let Some(i) = q.pop_front(){
        for &j in &E[i]{
            if d[j]!= -1{continue;}
            d[j] = d[i]+1;
            q.push_back(j);
        }
    }
    d
}

Measured memory_bytes: 13624
INF = 10 ** 7
N,T = map(int,input().split())
foods = []
for _ in range(N):
    foods.append(list(map(int,input().split())))

foods.sort()
dp = [[-INF for i in range(T)] for j in range(N+1)]
dp[0][0] = 0
ans = 0

for i in range(N):
    food = foods[i]
    for j in range(T):
        ans = max(ans, dp[i][j] + food[1])
        if dp[i][j] != INF:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
            if j + food[0] < T:
                dp[i+1][j + food[0]] = max(dp[i+1][j + food[0]], dp[i][j] + food[1])

print(ans)

Measured memory_bytes: 124524
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














ll X;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> X;

	ll x = 100;
	int ans = 0;
	while (x < X) {
		x = x + x / 100;
		ans++;
	}
	cout << ans << endl;
}







Measured memory_bytes: 3624
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        x: usize,
        y: usize
    }
    let mut ans = 0;
    match x {
        1 => {ans += 300000;},
        2 => {ans += 200000;},
        3 => {ans += 100000;},
        _ => {}
    }
    match y {
        1 => {ans += 300000;},
        2 => {ans += 200000;},
        3 => {ans += 100000;},
        _ => {}
    }
    if x == 1 && y == 1 {
        ans += 400000;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

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

int main() {

  int n; cin >> n;
  int j, a = 0, b = 0, cnt = 1;

  int p[n]; rep(i, n) cin >> p[i];
  int q[n]; rep(i, n) cin >> q[i];
  int s[n]; rep(i, n) s[i] = i+1;

  do {
    for(j = 0; j<n; ++j){
      if(s[j]!=p[j]) break;
    }
    if(j==n) a = cnt;
    for(j = 0; j<n; ++j){
      if(s[j]!=q[j]) break;
    }
    if(j==n) b = cnt;
    if(a!=0&&b!=0) break;
    ++cnt;
  }while(next_permutation(s, s+n));
  cout << abs(a-b) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

int x[110], y[110];

int main() {
    int n, m, X,Y;
    cin>>n>>m>>X>>Y;
    for (int i = 0; i < n; i++) {
        cin>>x[i];
    }   
    for (int i = 0; i < m; i++) {
        cin>>y[i];
    }
    
    for(int i = -100;i<=100;i++){
        bool ok=true;
        if(i<=X||i>Y)ok=false;
        for (int j = 0; j < n; j++) {
            if(x[j]>=i){
                ok=false;
                break;
            }
        }
        for (int j = 0; j < m; j++) {
            if(y[j]<i){
                ok=false;
                break;
            }
        }
        if(ok){
            cout<<"No War"<<endl;
            return 0;
        }
    }

    cout<<"War"<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        
        int L = A + B;
        int R = C + D;
        
        if(L > R){
            System.out.println("Left");
        } else if(L < R){
            System.out.println("Right");
        } else {
            System.out.println("Balanced");
        }
        
        sc.close();
        
    }
}


Measured memory_bytes: 20948
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <queue>

#define MAX_N (100000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  long N, as[MAX_N], bs[MAX_N];
  scanf("%ld", &N);
  for (long i = 0; i < N; i++) {
    scanf("%ld", &as[i]);
  }
  for (long i = 0; i < N; i++) {
    scanf("%ld", &bs[i]);
  }

  // impossible case
  long sa = 0, sb = 0;
  for (long i = 0; i < N; i++) {
    sa += as[i];
    sb += bs[i];
  }
  if (sa < sb) {
    printf("-1\n");
    return 0;
  }

  // possible find ans
  priority_queue<long> que;
  long shortage = 0, ans = 0;
  for (int i = 0; i < N; i++) {
    const int a = as[i], b = bs[i];
    if (a < b) {
      shortage += b - a;
      ans++;
    } else {
      que.push(a - b);
    }
  }
  while (shortage > 0) {
    const int x = que.top();
    que.pop();
    shortage -= x;
    ans++;
  }
  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 2808
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#define INFTY (pow(10,9)+1);

int count=0;
void merge(int x[],int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    int *array1=malloc(sizeof(int)*n1+1);
    int *array2=malloc(sizeof(int)*n2+1);

    for(int i=0;i<n1;i++){
        array1[i]=x[left+i];
    }
    for(int j=0;j<n2;j++){
        array2[j]=x[mid+j];
    }
    array1[n1]=INFTY;
    array2[n2]=INFTY;

    for(int i2=0,j2=0,k=left;k<right;k++){
        if(array1[i2]<=array2[j2]){
            x[k]=array1[i2];
            i2=i2+1;
        }
        else{
            x[k]=array2[j2];
            j2=j2+1;
        }
        count++;
    }
    free(array1);
    free(array2);
}

void mergesort(int x[],int left,int right){
    int mid;
    if(left+1<right){
        mid=(left+right)/2;
        mergesort(x,left,mid);
        mergesort(x,mid,right);
        merge(x,left,mid,right);
    }
}

int main(){
    int n;
    int *array;

    scanf("%d",&n);
    array=malloc(sizeof(int)*n);
    for(int i=0;i<n;i++){
        scanf("%d",&array[i]);
    }
    mergesort(array,0,n);

    for(int j=0;j<n-1;j++){
        printf("%d ",array[j]);
    }
    printf("%d\n%d\n",array[n-1],count);

    free(array);

    return 0;

}



Measured memory_bytes: 5456
#pragma once
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const ll MAX = 210000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string & S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
ll slide(vector<ll> & v, ll a, ll b) {
	ll azv = abs(v[0] - a);
	ll bzv = abs(v[0] - b);
	ll aov = abs(v[1] - a);
	ll bov = abs(v[1] - b);
	v[0] = a;
	v[1] = b;
	return max((azv + bov), (bzv + aov));
}


bool a[100010];
string gcs(string s, string t) {

	ll high = min(s.size(), t.size());
	ll low = 0;
	ll mid = -1;
	for (size_t i = 0; i < 20; i++)
	{
		mid = (high + low) / 2;
		string st = s.substr(0, mid);
		string tt = t.substr(0, mid);
		if (st == tt) {
			low = mid;
		}
		else high = mid;

		if (s.size() <= mid || t.size() <= mid) continue;
		st = s.substr(0, mid + 1);
		tt = t.substr(0, mid + 1);
		if (st == tt) {
			low = mid + 1;
			mid = mid + 1;
		}
	}
	return s.substr(0, mid);
}

ll dp[100010][6];
int pi[100010][6];
ll dist[7][7];

ll calc(ll now, ll b, int c, int p, int v) {

	if (b < 0) return INF;
	ll dis = now - b - 1LL;

	ll val = dp[b][p] + max(dis, dist[p][c]);
	if (v > val) {
		val = min(val, calc(now, pi[b][p], c, p, val));
	}
	return val;
}

struct bridge {
	int l, r;
};
bridge bs[100010];
bool cm(bridge& left, bridge& right) {
	return left.r < right.r;
}
struct edge {
	int t;
	ll cost;
	edge(int t, ll cost) : t(t), cost(cost) {}
};
vector<edge> es[100010];
int calc(int a, int b) {
	int rem = 24 - a;
	int tb = (b + rem) % 24;
	if (tb == 0) tb = 24;
	return min(tb, 24 - tb);

}

void solv() {
	
	int a, b;
	cin >> a >> b;
	cout << max((a + a - 1), max(b + b - 1, a + b)) << endl;
	
}

int main() {
	//COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string n;
    cin >> n;
    REPS(c, n) {
        if (c == '7') {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <iostream>
#include <vector>

#define ll long long int

int main() {
  int n, k, max = 0, max2 = 0;
  std::vector<int> a;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    std::cin >> k;
    a.push_back(k);
    if(max <= k) {
      max2 = max;
      max = k;
    } else if (max2 < k) {
      max2 = k;
    }
  }

  for (int i = 0; i < n; i++) {
    if (a.at(i) == max) {
      std::cout << max2 << std::endl;
    } else {
      std::cout << max << std::endl;
    }
  }

}

Measured memory_bytes: 2548
package main

import "fmt"

func main() {
	H := make([]int, 0)
	W := make([]int, 0)
	for {
		var h, w int
		fmt.Scan(&h, &w)
		if h == 0 && w == 0 {
			break
		}
		H = append(H, h)
		W = append(W, w)
	}
	for i := 0; i < len(H); i++ {
		for h := 0; h < H[i]; h++ {
			for w := 0; w < W[i]; w++ {
				if h%2 == 0 {
					if w%2 == 0 {
						fmt.Print("#")
					} else {
						fmt.Print(".")
					}
				} else {
					if w%2 == 0 {
						fmt.Print(".")
					} else {
						fmt.Print("#")
					}
				}
			}
			fmt.Println()
		}
		fmt.Println()
	}
}



Measured memory_bytes: 1124
N = int(input())
L = list(map(int, input().split()))

cnt = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j] and L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                cnt += 1

print(cnt)

Measured memory_bytes: 9208
#include<iostream>
using namespace std;
int M,K,i;
int main(){
	cin>>M>>K;
	if(M==1)
		if(K==0)
            cout<<"0 0 1 1"<<endl;
		else 
            cout<<-1<<endl;
	else if(K>=1<<M)
        cout<<-1<<endl;
	else{
		for(i=0;i<1<<M;i++)
            if(i!=K)
                cout<<i<<" ";
		cout<<K<<" ";
		for(i=1<<M;i--;)
            if(i!=K)
                cout<<i<<" ";
		cout<<K<<endl;
	}
	return 0;
}

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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 998244353
#define debug(x) cerr<<#x<<"="<<x<<'\n'

const int maxn=2e5+10;
int x,y,A,B,C;
int a[maxn],b[maxn],c[maxn*3];

int main(){
	scanf("%d%d%d%d%d",&x,&y,&A,&B,&C);
	for (int i=0;i<A;i++) scanf("%d",&a[i]);
	sort(a,a+A);
	for (int i=0;i<B;i++) scanf("%d",&b[i]);
	sort(b,b+B);
	for (int i=0;i<C;i++) scanf("%d",&c[i]);
	for (int i=C;i<C+x;i++) c[i]=a[A-1-(i-C)];
	for (int i=C+x;i<C+x+y;i++) c[i]=b[B-1-(i-C-x)];
	sort(c,c+x+y+C);
	ll res=0;
	for (int i=0;i<x+y;i++) res+=(ll)c[C+x+y-1-i];
	printf("%lld",res);
	return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>
int main(void)
{ int S;
  int h;
  int m;
  int s;
  int x; 
  
  scanf("%d",&S);

  s=S%60;
  x=S/60;
  m=x%60;
  h=S/3600;

 printf("%d:%d:%d\n",h,m,s );

return 0;
}

Measured memory_bytes: 1836
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
	int n;
	cin >> n;
	vector<int>L(n);
	rep(i, n) {
		cin >> L[i];
	}
	sort(L.begin(), L.end());
	int ans = 0;
	for (int i = 0;i < n;++i) {
		for (int j = i + 1;j < n;++j) {
			int total = L[i] + L[j];
			int r = lower_bound(L.begin(), L.end(), total) - L.begin();
			int l = j + 1;
			ans += r - l;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
n = input()
m = [0]*a
for i in range(1,a):
  if n[i-1:i+1]=="AC":
    m[i]=m[i-1]+1
  else:
    m[i]=m[i-1]
for j in range(b):
  s,t=map(int,input().split())
  print(m[t-1]-m[s-1])

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

typedef unsigned long long ll;

int main() {
  ll n;
  cin >> n;
  ll sum = 0;
  ll tmp = 0;
  bool same = true;
  ll rem = 1001001001;
  for (int i = 0; i < n; ++i) {
    ll a, b;
    cin >> a >> b;
    sum += b;
    if (a < b) { same = false; } 
    if (a > b) {
      rem = min(rem, b);
    }
  }
  if (same) {
    cout << 0 << endl;
  }
  else {
    cout << sum - rem << endl;
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=0,aa[220000],ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char c,ca;
queue<int> que;
signed main(){
    cin>>aa[0]>>aa[1]>>aa[2]>>aa[3]>>aa[4];
    cout<<15-aa[0]-aa[1]-aa[2]-aa[3]-aa[4]<<endl;
}


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

int dp1[110][110];
int dp2[110][110][110];
int dp3[110][110*110];
int e[100],c[100],h[100],a[100];
int N;
int S;
int U;
int T;
int O;
int D;

int dfs(int t,int hp,int u){
	if( u < 0 ) return -1e9;
	if( hp < 0 ) return -1e9;
	if( t == -1 ) return u==0?0:-1e9;
	if( ~dp2[t][hp][u] ) return dp2[t][hp][u];
	int ans = -1e9;
	ans = max(ans,dfs(t-1,hp,u));
	ans = max(ans,dfs(t-1,hp-e[t],u-1)+c[t]);
	return dp2[t][hp][u] = ans;
}
int dfs3(int n,int hp){
	if( hp < 0 ) return -1e9;
	if( n < 0 ) return 0;
	if( ~dp3[n][hp] ) return dp3[n][hp];
	int ans = -1e9;
	ans = max(ans,dfs3(n,hp-a[n])+h[n]);
	ans = max(ans,dfs3(n-1,hp));
	return dp3[n][hp] = ans;
}
int dfs2(int d,int hp){
	if( hp < 0 ) return -1e9;
	if( d < 0 ) return 0;
	hp = min(S,hp+O);
	if( ~dp1[d][hp] ) return dp1[d][hp];

	int ans = -1e9;
	for(int i = 0 ; i <= hp ; i++)
		ans = max(ans,dfs2(d-1,hp-i) + dfs3(N-1,dfs(T-1,i,U)));
	return dp1[d][hp] = ans;
}

int main(){
	memset(dp1,-1,sizeof(dp1));
	memset(dp2,-1,sizeof(dp2));
	memset(dp3,-1,sizeof(dp3));
	cin >> S >> T >> U >> N >> O >> D;
	for(int i = 0 ; i < T ; i++){
		cin >> e[i] >> c[i];
	}
	for(int i = 0 ; i < N ; i++)
		cin >> h[i] >> a[i];
	cout << max(-1,dfs2(D-1,S)) << endl;
};

Measured memory_bytes: 11628
# -*- coding: utf-8 -*-
def prize(n):
    if n == 1:
        return 300000
    elif n == 2:
        return 200000
    elif n == 3:
        return 100000
    else:
        return 0


x, y = map(int, input().split())
rst = prize(x) + prize(y)
if x == 1 and y == 1:
    rst += 400000
 
print(rst)


Measured memory_bytes: 2940
def min_bs(l,r):
    l-=1
    while r-l>1:
        m=(r+l)/2
        if check(m):
            r=m
        else:
            l=m
    return r

def check(m):
    cnt=0
    for i in xrange(n):
        if h[i]-b*m<=0:continue
        cnt+=(h[i]-b*m-1)/(a-b)+1
    return True if m>=cnt else False

n,a,b=map(int,raw_input().split())
h=[int(raw_input()) for _ in xrange(n)]
print min_bs(1,10**9)

Measured memory_bytes: 35688
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		StringBuffer aString = new StringBuffer();
		StringBuffer bString = new StringBuffer();
		for(int i = 0; i < b; i++) {
			aString.append(a);
		}
		for(int i = 0; i < a; i++) {
			bString.append(b);
		}
		
		if(a < b) {
			System.out.println(aString);
		}else {
			System.out.println(bString);
		}
		sc.close();
	}
}

Measured memory_bytes: 21588
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
  int i,j,n,dmax,dmin;
  int *price;

  scanf("%d",&n);
  price = (int *)malloc(n * sizeof(int));

  for(i=0; i<n; i++) scanf("%d",&price[i]);

  dmax = price[1]-price[0];
  dmin = price[0];
  for(j=1; j<n; j++){
    dmax = (int)fmax((double)dmax,(double)(price[j] - dmin));
    dmin = (int)fmin((double)dmin,(double)price[j]);
  }

  printf("%d\n",dmax);

  free(price);

  return 0;
}



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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    cout << (n-1)*(m-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define N 1003

int n,m;
int arm[50];
int x[N],y[N];
bool odd[2];

inline int Abs(int x) {
	if(x>-x) return x;return -x;
}
//1:Up 2:Down 3:Left 4:Right
void Print(int x,int y) {
	for(int i=1;i<=m;i++) {
		if(Abs(x)<Abs(y)) {
			if(y>0)
				printf("U"),y-=arm[i];
			else printf("D"),y+=arm[i];
		} else {
			if(x>0)
				printf("R"),x-=arm[i];
			else printf("L"),x+=arm[i];
		}
	}
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d %d",&x[i],&y[i]);
		odd[Abs(x[i]+y[i])%2]=true;
	}
	if(odd[0]&&odd[1]) {
		printf("-1");
		return 0;
	}
	/******************/
	m=32;arm[31]=arm[32]=1;
	if(odd[1]) m--;
	for(int i=30;i>=1;i--)
		arm[i]=2*arm[i+1];
	printf("%d\n",m);
	for(int i=1;i<m;i++)
		printf("%d ",arm[i]);
	printf("%d\n",arm[m]);
	/******************/
	for(int i=1;i<=n;i++)
		Print(x[i],y[i]),puts("");
	return 0;
}

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


//      DEEP


using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fwd(i,a,n) for(int i=a;i<=n;i++)
#define bak(i,a,n) for(int i=a;i>=n;i--)
#define all(v) v.begin(),v.end()
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef set<int> si;
const ll mod = 1e9 + 7;
ll inf=1e9;
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}
ull gcd(ull x,ull y){
   if(y==0)return x;
   return gcd(y,x%y);
}
int main(){
    ll n,i;
    cin>>n;
    ll a,b,c;
    cin>>a>>b>>c;
    ll dp[n+1][3];
    dp[1][0]=a;
    dp[1][1]=b;
    dp[1][2]=c;
    fwd(i,2,n){
       cin>>a>>b>>c;
       dp[i][0]=max(dp[i-1][1]+a,dp[i-1][2]+a);
       dp[i][1]=max(dp[i-1][0]+b,dp[i-1][2]+b);
       dp[i][2]=max(dp[i-1][0]+c,dp[i-1][1]+c);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
}







Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair< ll, ll >;
 
string U = "UNRESTORABLE";
 
int main() {
    string s, t;
    cin >> s >> t;
    string ans = "X";
    rep(i, s.size()) {
        if ((s[i] == t[0] or s[i] == '?') and s.size() - i >= t.size()) {
            bool flag = true;
            for (int j=i; j<i+t.size(); ++j) {
                if (s[j] != '?' and s[j] != t[j-i]) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                string tmp = "";
                rep(j, s.size()) {
                    if (i == j) {
                        tmp += t;
                        j += t.size() - 1;
                    }
                    else if (s[j] == '?') {
                        tmp += 'a';
                    }
                    else {
                        tmp += s[j];
                    }
                }
                if (ans == "X") {
                    ans = tmp;
                }
                else {
                    ans = min(ans, tmp);
                }
            }
        }
    }
    cout << (ans == "X" ? U : ans) << endl;
}

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

const int maxn = 1e5 + 3;
int n, a[maxn], b[maxn], c[maxn];
long long d[3][maxn], ans;

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) {
		scanf("%d", a + i);
	}
	std::sort(a, a + n);
	for(int i = 0; i < n; ++i) {
		scanf("%d", b + i);
	}
	std::sort(b, b + n);
	for(int i = 0; i < n; ++i) {
		scanf("%d", c + i);
	}
	std::sort(c, c + n);
	for(int i = 0; i < n; ++i)
		d[2][i] = 1;
	for(int i = 1; i < n; ++i)
		d[2][i] += d[2][i - 1];
	for(int i = 0, j = 0; i < n; ++i) {
		while(j < n && c[j] <= b[i])
			++j;
		d[1][i] = d[2][n - 1] - (j > 0 ? d[2][j - 1] : 0);
	}
	for(int i = 1; i < n; ++i)
		d[1][i] += d[1][i - 1];
	for(int i = 0, j = 0; i < n; ++i) {
		while(j < n && b[j] <= a[i])
			++j;
		d[0][i] = d[1][n - 1] - (j > 0 ? d[1][j - 1] : 0);
	}
	for(int i = 0; i < n; ++i)
		ans += d[0][i];
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;

#define REP(i,N) for(int i=0;i<(int)(N);++i)

typedef long long Int;

int main()
{
  Int sum = 0;
  Int u, n;
  Int x = 0;
  int c = 0;
  while (~scanf("%lld, %lld", &u, &n)) {
      sum += u * n;
      x += n;
      c++;
  }
  printf("%lld\n", sum);
  printf("%.0f\n", (double)x / c + 0.0000001);
  return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main{
public static void main(String args[])
{
  Scanner sp=new Scanner(System.in);
   int k=sp.nextInt();
    int x=sp.nextInt();
    int n=k+x;
    int c=x-k;
   
 
   for(int i=c+1;i<n;i++)
   {
      if(i<1000000 && i>-1000000)
      {
                 System.out.print(i+" ");
      }
       
   }
      
   }
 
 
} 
   

Measured memory_bytes: 21972
import java.util.Scanner;

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

        double ans=0;

        for(int i=1;i<=n;i++){
            int kakuritu=n;
            int score=i;
            while(score<k){
                score*=2;
                kakuritu*=2;
            }
            ans+=1/(double)kakuritu;
        }

        System.out.println(ans);

    }
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s; cin >> s;
    ll k; cin >> k;
    rep(i,k){
        if(s[i] != '1'){
            out(s[i]);
            return 0;
        }
    }
    out('1');
}


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

using namespace std;
typedef long long ll;
int gcd(int a, int b) {
	if (b == 0) {
		return a;			
	}
	return gcd(b, a % b);
}
int main(){
ll a,b;
  cin>>a>>b;
  int flag=0;
  for(ll i=1;i<=3;i++){
  if((a*b*i)%2==1){
  flag=1;
  }
  }
  if(flag==0)
    cout<<"No";
  else
    cout<<"Yes";
  return 0;
}



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

map<int, int> primeFactor(int n){
  map<int, int> ret;
  for (int i = 2; i*i <= n; i++){
    while(n%i==0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n !=1 ) ret[n]++;
  return ret;
}
map<int, int> factorialPrimes(int n){  
  if (n==1) {
    map<int, int> blank;
    return blank;
  }
  map<int, int> ret = factorialPrimes(n-1);
  map<int, int> primes = primeFactor(n);
  for (auto prime: primes){
    ret[prime.first] += prime.second;
  }
  return ret;
}

int main(){
  int N;
  cin >> N;
  
  map<int, int> primeFacts = factorialPrimes(N);
  
  int ans = 0;
  for (auto pf: primeFacts) {
    if (pf.second>=74) ans++;
    
    if (pf.second>=24) {
      for (auto pf2: primeFacts) {
        if (pf2.first == pf.first) continue;
        
        if (pf2.second>=2) ans++;
      }
    }

    if (pf.second>=14) {
      for (auto pf2: primeFacts) {
        if (pf2.first==pf.first) continue;
        
        if (pf2.second>=4) ans++;
      }
    }

    if (pf.second>=4) {
      for (auto pf2: primeFacts) {
        if (pf2.first<=pf.first) continue;
        
        if (pf2.second>=4) {
          for (auto pf3: primeFacts) {
            if(pf3.first==pf2.first) continue;
            if(pf3.first==pf.first) continue;
            
            if (pf3.second>=2) ans++;
          }
        }
      }
    }
      
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

int main(int argc, char const *argv[]) {
    int N;
    cin>>N;
    vector<ll> a(N),island;
    ll sum=0;
    REP(i,N) {
        cin>>a[i];
        if(a[i]==0) {
            island.push_back(sum);
            sum=0;
        }
        else sum+=a[i];
    }
    if(sum!=0) island.push_back(sum);

    ll ans=0;
    FORE(x,island) {
        ans += x/2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
    int N,M; cin >> N >> M;
    ll a,b;
    vector<pair<ll,ll> > v(0);
    for (int i = 0; i < N; i++){
        cin >> a >> b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end());
    priority_queue<ll> mx;
    ll ans = 0;
    int index = 0;
    for (int i = 1; i <= M; i++){
        while (v[index].first <= i && index < N){
            mx.push(v[index].second);
            index++;
        }
        if (mx.size()){
            ans += mx.top();
            mx.pop();
        }
    }
    cout << ans << endl;
}

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

#if debug
#include "printer.hpp"
#define dump(a) cerr << #a << "(" << __LINE__ << ") = " << a << endl;
#else
#define dump(...)
#endif

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a, b) for (int i = (b) - 1; i >= a; i--)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
const ll mod = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(8);

  ll N;
  cin >> N;
  ll i = 1;
  for (ll j = 1; j * j <= N; j++) {
    if (N % j == 0) i = j;
  }
  cout << i + (N / i) - 2 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.nextLine();
		char[] t = sc.next().toCharArray();
		int ans = 0;
		for (int i = 0; i < s.length; i++) {
			if (s[i] !=  t[i]) {
				ans++;
			}
		}
		System.out.println(ans);
	}
	
}


Measured memory_bytes: 42500
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;
#define endl '\n'
#define what_is(x) cout << #x << " is " << x << endl;
#define ll long long
#define int long long
#define ld long double
#define pii pair<int,int>
#define rand() abs((rand()<<15)|rand())
#define randll() abs(((long long)rand()<<30)|rand())
const int INF = 1000000001;
const int MOD = 1000000007;

int n;
vector<int> a, b;

bool posAtoB[55][55];
bool canDoWithout[55];

vector<int> path[55];

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);

  cin >> n;
  for(int i = 0; i < n; i++) {
  	int x;
  	cin >> x;
  	a.push_back(x);
  }
  for(int i = 0; i < n; i++) {
  	int x;
  	cin >> x;
  	b.push_back(x);
  }


  for(int i = 1; i <= 50; i++)
		for(int j = 1; j <= i; j++)
			if(!canDoWithout[j])
				posAtoB[i][i%j] = 1;
  for(int i = 0; i <= 50; i++) posAtoB[i][i] = 1;

	for(int k = 0; k <= 50; k++)
		for(int i = 0; i <= 50; i++)
			for(int j = 0; j <= 50; j++)
				posAtoB[i][j] |= posAtoB[i][k] & posAtoB[k][j];

	for(int i = 0; i < n; i++)
		if(!posAtoB[a[i]][b[i]]) {
			cout << -1 << endl;
			return 0;
		}

  for(int x = 50; x > 0; x--) {
  	memset(posAtoB, 0, sizeof(posAtoB));
  	canDoWithout[x] = 1;

	  for(int i = 1; i <= 50; i++)
			for(int j = 1; j <= i; j++)
				if(!canDoWithout[j])
					posAtoB[i][i%j] = 1;
	  for(int i = 0; i <= 50; i++) posAtoB[i][i] = 1;

		for(int k = 0; k <= 50; k++)
			for(int i = 0; i <= 50; i++)
				for(int j = 0; j <= 50; j++)
					posAtoB[i][j] |= posAtoB[i][k] & posAtoB[k][j];

		for(int i = 0; i < n; i++)
			if(!posAtoB[a[i]][b[i]])
				canDoWithout[x] = 0;
  }

  int ans = 0;
  for(int k = 1; k <= 50; k++)
  	if(!canDoWithout[k])
  		ans += 1ll<<k;
  cout << ans << endl;
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	
	int p= m/n, ans = 0;
	for(int i=1; i*i<=m; i++){
		if(m%i==0){
			if( i<=p) ans = max(ans, i);
			if(m/i <=p) ans = max(ans, m/i);
		}
	}
	
	cout << ans <<"\n";
	
	return 0;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	for i := 1; i <= 5; i++ {
		if nextInt() == 0 {
			fmt.Println(i)
			return
		}
	}
}

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

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

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

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


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

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

long long lcm(long long a, long b){
	long long ans;
	ans = (long long) a / gcd(a, b) * b;
	return ans;
}

int main(){
	int n;
	long t;
	long long ans;
	cin >> n >> ans;
	for(int i=1; i < n; i++){
		cin >> t;
		ans = lcm(ans, t);
	}
	cout << ans;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

struct DATA {
	bool used = false;
	int64_t sum_aft = 0;
	int64_t mul_bef = 0;
	int64_t add_bef = 0;
	int64_t patt = 0;
};
int64_t MOD;
int H, W;
char map[2010][2010];
DATA dp[2010][2010];
const DATA& func(int i, int j)
{
	int value = map[i][j] - '0';
	if (i == H - 1 && j == W - 1)
	{
		dp[i][j].used = true;
		dp[i][j].sum_aft = 0;
		dp[i][j].mul_bef = value;
		dp[i][j].add_bef = 10;
		dp[i][j].patt = 1;
	}
	auto& memo = dp[i][j];
	if (memo.used) {
		return memo;
	}

	memo.used = true;
	memo.sum_aft = 0;
	memo.mul_bef = 0;
	memo.add_bef = 0;
	memo.patt = 0;
	if (i != H - 1) {
		auto& next = func(i + 1, j);
		if (map[i][j] == '+') {
			memo.sum_aft += next.sum_aft;
			memo.sum_aft += next.mul_bef;
			memo.add_bef += next.patt;
		}
		else if (map[i][j] == '*') {
			memo.sum_aft += next.sum_aft;
			//memo.mul_bef += next.mul_bef;
			memo.mul_bef += 0;
			memo.add_bef += next.mul_bef;
		}
		else {
			memo.sum_aft += next.sum_aft;
			memo.mul_bef += (next.add_bef * value) % MOD + next.mul_bef;
			memo.add_bef += (next.add_bef * 10) % MOD;
		}
		memo.sum_aft %= MOD;
		memo.mul_bef %= MOD;
		memo.add_bef %= MOD;
		memo.patt += next.patt;
		memo.patt %= MOD;
	}
	if (j != W - 1) {
		auto& next = func(i, j + 1);
		if (map[i][j] == '+') {
			memo.sum_aft += next.sum_aft;
			memo.sum_aft += next.mul_bef;
			memo.add_bef += next.patt;
		}
		else if (map[i][j] == '*') {
			memo.sum_aft += next.sum_aft;
			//memo.mul_bef += next.mul_bef;
			memo.mul_bef += 0;
			memo.add_bef += next.mul_bef;
		}
		else {
			memo.sum_aft += next.sum_aft;
			memo.mul_bef += (next.add_bef * value) % MOD + next.mul_bef;
			memo.add_bef += (next.add_bef * 10) % MOD;
		}
		memo.sum_aft %= MOD;
		memo.mul_bef %= MOD;
		memo.add_bef %= MOD;
		memo.patt += next.patt;
		memo.patt %= MOD;
	}
	return memo;
}

int main()
{
	cin >> H >> W >> MOD;
	for (int i = 0; i < H; i++)
	{
		cin >> map[i];
	}
	auto& res = func(0, 0);
	cout << ((res.mul_bef + res.sum_aft) % MOD) << endl;

}


Measured memory_bytes: 159884
N,W = map(int, input().split())
v = [0] * (N+1)
w = [0] * (N+1)
dp = [[0 for x in range(W+1)] for y in range(N+1)]

for i in range(1,N+1):
    v[i], w[i] = map(int, input().split())

for i in range(1,N+1):
    for j in range(W+1):
        if j < w[i]:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i])

print(dp[N][W])

Measured memory_bytes: 25940
#include <iostream>
using namespace std;
int n,a[120],b[120],ans;
int main()
{
    cin>>n;
    for (int i=0;i<n;i++)
        cin>>a[i];
    for (int i=0;i<n;i++)
        cin>>b[i];
    for (int i=0;i<n;i++)
    {
        int sum=0;
        for (int j=0;j<=i;j++) sum+=a[j];
        for (int j=i;j<n;j++)  sum+=b[j];
        if (sum>ans) ans=sum;
    }
    cout<<ans<<endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
n = int(input())
s = []
for i in range(n):
    s.append(input())
ans = {}
for i in s:
    if i in ans:
        ans[i] += 1
    else:
        ans[i] = 1
ans2 = sorted(ans.items(), key=lambda x:x[1], reverse=True)
ans_list = {ans2[0][0]}
ans_cnt = ans2[0][1]
for i, j in ans2:
    if ans_cnt == j:
        ans_list.add(i)

ans_list2 = list(ans_list)
ans_list2.sort(reverse=False)
for i in ans_list2:
    print(i)

Measured memory_bytes: 60020