akhauriyash/Code-Regression huggingface dataset:
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb emplace_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) sort(all(v)),v.erase(unique(all(v)), v.end());
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
#define deb(x) cout<<"\n["<<#x<<" = "<<x<<"]\n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n,ans;
void solve(){
  cin>>n;
  rep(i,1,n){
    ans+=(n/i);
    if(i*(n/i)==n)ans--;
  }
  cout<<ans;
}
int32_t main()
{
  ibs;cti;
  solve();return 0;
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  char a;
  cin >> a;
  char ans = 'A';
  for (char c = 'a'; c <= 'z'; c++) {
    if (a == c) {
      ans = 'a';
      break;
    }
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 3552
import math
h,w=map(int,input().split())
ans,cnt=h*w,0
if h%3==0 or w%3==0:
  ans=0
else:
  for i in range(1,h):
    cnt=max((h-i)*(w%2),abs(math.floor(w/2)*(h-i)-w*i),abs(math.ceil(w/2)*(h-i)-w*i))
    ans=min(ans,cnt,h,w)
  for i in range(1,w):
    cnt=max((w-i)*(h%2),abs(math.floor(h/2)*(w-i)-h*i),abs(math.ceil(h/2)*(w-i)-h*i))
    ans=min(ans,cnt,h,w)
print(ans)


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

#define NUM 10000
bool prime[NUM+1];

void sieve()
{
  prime[0]=prime[1]=false;
  for(int i=2;i<=NUM;i++)
    prime[i]=true;
  for(int i=2;i<=NUM;i++)
    if(prime[i])
      for(int j=i*2;j<=NUM;j+=i)
	prime[j]=false;
}

int main()
{
  int n;

  sieve();
  for(;;){
    cin>>n;
    if(!n) break;
    for(int i=n;i>=5;i--)
      if(prime[i]&&prime[i-2]){
	cout<<i-2<<" "<<i<<endl; break;
      }
  }
}


Measured memory_bytes: 1172
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

const int MEMO_MAX = 7000;

int main()
{
	int memo[ MEMO_MAX ];
	int m;

	while( cin >> m && m ){
		memset( memo, 0, sizeof(memo) );
		vector< pair< int, int > > cardList;
		for( int i = 0; i < m; ++i ){
			int figure, pieces;
			cin >> figure >> pieces;
			cardList.push_back( make_pair( figure, pieces ) );
		}
		int sumMax = 0;
		for( int i = 0; i < m; ++i ){
			int number = cardList[ i ].first;
			int pieces = cardList[ i ].second;
			int high = sumMax;
			int tmpMemo[ 7000 ];
			memset( tmpMemo, 0, sizeof(tmpMemo) );
			for( int j = 1; j <= pieces; ++j ){
				int sumMono = number * j;
				for( int k = 1; k <= high; ++k ){
					int sum = k + sumMono;
					tmpMemo[ sum ] += memo[ k ];
					if( sumMax < sum ){
						sumMax = sum;
					}
				}
				++tmpMemo[ sumMono ];
				if( sumMax < sumMono ){
					sumMax = sumMono;
				}
			}
			for( int j = 1; j <= sumMax; ++j ){
				memo[ j ] += tmpMemo[ j ];
			}
		}

		int g;
		cin >> g;
		for( int i = 0; i < g; ++i ){
			int d;
			cin >> d;
			cout << memo[ d ] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
int main(){
  ll n;
  cin>>n;
  V<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  V<int> d(9,0);
  for(int i=0;i<n;i++){
      ll t=a[i]/400;
      if(t>=8)d[8]++;
      else d[t]++;
  }
  int mi=0;
  for(int i=0;i<8;i++){
    if(d[i])mi++;
  }
  cout<<max(mi,1)<<" "<<mi+d[8]<<endl;
}

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

int main()
{
  int K;
  cin >> K;
  long long sum = 0;
  for (int i = 1; i <= K; i++)
  {
    for (int j = 1; j <= K; j++)
    {
      for (int k = 1; k <= K; k++)
      {
        sum += __gcd(i, __gcd(j, k));
      }
        }
    
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int N;cin>>N;
    vector<p> V;
    for(int i=0; i<N;i++){
      ll a,b; cin>>a>>b;
      V.push_back(make_pair(b, a));
    }
    // cout<<endl;
    sort(V.begin(), V.end());
    for(int i=0; i<N;i++){
      // cout<<V[i].second<<" "<<V[i].first<<endl;
    }
    ll p=0; ll s=0;
    for(int i=0; i<N;i++){
      ll d = V[i].first - V[i].second;
      s= s+ d - p;
      // cout<<i<<" "<<s<<" "<<p<<" "<<d<<endl;
        if(s<0) {
          cout<<"No"<<endl; return 0;
        }
      p = V[i].first;
    }

    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 6256
#include<iostream>
#include<cstdio>
#include<list>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<cmath>
#include<map>
using namespace std;
#define LL long long
int main()
{
	string s;
	cin>>s;
	int flag=0;
	if(s.size()%2==1)
		flag=1;
	else
	{
		for(int i=0;i<s.size();i++)
		{
			if(i%2==0)
			{
				if(s[i]!='h')
				{
					flag=1;
					break;
				}
			}
			else
			{
				if(s[i]!='i')
				{
					flag=1;
					break;
				}
			}
		}
	}
	if(flag==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 888
import math
N = int(input())
li = [list(map(int, input().split())) for x in range(N)]
length = 0
for i in range(len(li)):
	for j in range(len(li)):
		if i != j:
			length += ((li[i][0]-li[j][0])**2+(li[i][1]-li[j][1])**2)**0.5
n = math.factorial(N-1)
ans = (length*n)/math.factorial(N)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;

int main() {
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int a, b;
    const char c = 'x';
    a = 0;
    b = (int)s.length() - 1;
    int ans = 0;
    int delta;
    delta = 0;
    while(a < s.length() && s[a] == c){
        ++a;
        ++delta;
    }
    while(b >= 0 && s[b] == c){
        --b;
        --delta;
    }
    ans += (delta > 0 ? delta : -delta);
    while(a < b){
        if(s[a] != s[b]){
            cout << -1 << endl;
            return 0;
        }
        --b;
        ++a;
        delta = 0;
        while(a < s.length() && s[a] == c){
            ++a;
            ++delta;
        }
        while(b >= 0 && s[b] == c){
            --b;
            --delta;
        }
        if(a <= b){
            ans += (delta > 0 ? delta : -delta);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	int i,num;
	double x[4],y[4];
	cin >> num;

	for ( i = 0 ; i< num; i++ ) {
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];

		if(  (x[0]-x[1])*(y[2]-y[3]) == (y[0]-y[1])*(x[2]-x[3])  ){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
  string s,t;
  cin>>s>>t;
  int a=0;
  for(int i=0;i<3;i++) {
    if(s[i]==t[i]) a++;
  }
  cout<<a;
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

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

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	n := readInt()
	d := readInt()

	x := 2*d + 1
	if n%x == 0 {
		fmt.Println(n / x)
	} else {
		fmt.Println(n/x + 1)
	}
}


Measured memory_bytes: 640
let rec solve i n = function
  | [] -> n
  | [p] -> if i = p then n + 1 else n
  | p :: p' :: ps ->
      if i = p then
        solve (i + 1) (n + 1) (p :: ps)
      else
        solve (i + 1) n (p' :: ps)
let solve = solve 1 0

let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let ps = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun p -> p)) in
  Printf.printf "%d\n" @@ solve ps

Measured memory_bytes: 5888
#include <iostream>
using namespace std;
int main(){
int x,y;
cin>>x>>y;
char h;
string a="";
for(int i=0;i<x;i++){
	for(int j=0;j<y;j++){
		cin>>h;
		a+=h;
	}
	for(int k=0;k<2;k++){
		cout<<a<<endl;
	}
	a="";
	
}


}				

Measured memory_bytes: 256
def main():
    s = input()

    cs = [chr(i) for i in range(ord("a"), ord("z") + 1)]

    ans = len(s)
    for c in cs:
        cnt = 0
        mx = 0
        for e in s:
            if e == c:
                mx = max(mx, cnt)
                cnt = 0
            else:
                cnt += 1

        mx = max(mx, cnt)

        ans = min(ans, mx)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
string s;
int m;
int main(){
	int n,max=0,v=0;
	cin>>n;
	cin>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='I')max++;
		else max--;
		if(max>v)v=max;
	}
	cout<<v<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <stack>
#include <string>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
//const int INF = INT_MAX/3;

/*------------------------------------------------------------------------------*/

int main(){
  int a, b, c, ans;

  cin >> a >> b >> c;

  if(a == b && b == c){
    ans = 1;
  } else if(a == b || b == c || a == c){
    ans = 2;
  } else{
    ans = 3;
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
	string S;
	cin>>S;
	if(S=="SUN"){
		cout<<7<<endl;
	}
	else if(S=="MON"){
		cout<<6<<endl;
	}
	else if(S=="TUE"){
		cout<<5<<endl;
	}
	else if(S=="WED"){
		cout<<4<<endl;
	}
	else if(S=="THU"){
		cout<<3<<endl;
	}
	else if(S=="FRI"){
		cout<<2<<endl;
	}
	else if(S=="SAT"){
		cout<<1<<endl;
	}	
	
}


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

const int maxn = 1e5 + 10;
int h[maxn], dp[maxn];

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &h[i]);
    }
    for (int i = 0; i < maxn; ++i) {
        dp[i] = 2e9;
    }
    dp[1] = 0;
    for (int i = 2; i <= n; ++i) {
        for (int j = 1; j <= k && i - j > 0; ++j) {
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
    printf("%d\n", dp[n]);
}

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

using namespace std;

int f[5003];
int n, m;
vector <int> c, vals;
const int oo = 1000000009;

int main() {
    cin >> n >> m;
    for (int i = 1; i < (1 << n); i++) {
        f[i] = oo;
    }
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        c.emplace_back(a);
        int val = 0;
        for (int j = 0; j < b; j++) {
            int x;
            cin >> x;
            val |= (1 << (x - 1));
        }
        vals.emplace_back(val);
    }
    f[0] = 0;

    for (int i = 0; i < (1 << n); i++) {
        for (int j = 0; j < (int)vals.size(); j++) {
            int kost = c[j];
            int val = vals[j];
            f[i | val] = min(f[i | val], f[i] + c[j]);
        }
    }
    int ans = f[(1 << n) - 1];
    if (ans >= oo) {
        cout << -1;
    } else {
        cout << ans;
    }
	return 0;
}


Measured memory_bytes: 256
// : (Colon) 

import Foundation

func main() {
    let i = readLine()!.split(separator: " ").map{Double($0)!}
        
    let (a,b,h,m) = (i[0], i[1], i[2], i[3])
    let pi = Double.pi
    // それぞれの針の角度
    let x = 2 * pi * (h * 60 + m) / (60 * 12)
    let y = 2 * pi * (m) / (60)

    let (ax, ay) = (a * cos(x), a * sin(x))
    let (bx, by) = (b * cos(y), b * sin(y))
    
    let distance = pow(pow(ax - bx, 2) + pow(ay - by, 2), 0.5)
    print(distance)
}

main()

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

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

LLi lcm(LLi a, LLi b) {
    return a/gcd(a, b)*b;
}

int main(){

	LLi n, m, l;
	string s, t;
  	map<LLi, char> ma;
	cin>> n >> m;
	cin>> s;
	cin>> t;
  
  	l=lcm(n, m);
  
  	rep(i, n){
      	ma[i*l/n]=s[i];
    }
  
  	rep(i, m){
      	if(ma.count(i*l/m)){
          	if(ma[i*l/m]!=t[i]){
              	cout<< "-1" <<endl;
              	return 0;
            }
        }
    }
  
  	cout<< l <<endl;

	return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
//#define int long long
using namespace std;



signed main() {
	int ans = 0;
	int n, m;
	cin >> n >> m;
	vector<vector<int>>v(n);
	for (int i = 0; i < m; ++i) {
		int k;
		cin >> k;
		for (int j = 0; j < k; ++j) {
			int tmp;
			cin >> tmp;
			v[tmp - 1].push_back(i);
		}
	}
	vector<bool> p;
	for (int i = 0; i < m; ++i) {
		int a;
		cin >> a;
		p.push_back(!a);
	}
	for (int bit = 0; bit < (1 << n); ++bit)
	{
		auto np = p;
		for (int i = 0; i < n; ++i) {
			if (bit & (1 << i)) { // i が bit に入るかどうか
				for (int x : v[i]) {
					np[x] = !np[x];
				}
			}
		}
		bool flag = true;
		for (int i = 0; i < m; ++i)flag &= np[i];
		ans += flag;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
a=list(map(int,input().split()))
N=a[0]
D=a[1]
A = []
count=0
for _ in range(N): 
    A.append(input().split())
for i in range(N):
    w=int(A[i][0])
    s=int(A[i][1])
    if s**2+w**2<=D**2:
        count=count+1
    else:
        pass
print(count)

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

int main() {

  int H, N;
  cin >> H >> N;
  int sum_A = 0;

  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    sum_A += A;
  }

  H -= sum_A;

  if (H > 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
} 

Measured memory_bytes: 384
open Batteries
open Printf
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let a_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in

  let l = List.mapi (fun i x -> x-i-1) a_lst in
  let l = List.sort (fun x y -> compare (abs x) (abs y)) l in
  let a = List.filter (fun x -> x > 0) l in
  let b = List.filter (fun x -> x < 0) l in
  let c = List.filter (fun x -> x = 0) l in
  let lena = List.length a in
  let lenb = List.length b in
  let lenc = List.length c in
  let lenl = List.length l in

  let ans =
    if lenb > lenl / 2 then
      let c = List.nth b ((lenb - lenl/2)-1) in
      let e = List.map (fun x -> x - c) l in
      List.fold_left (fun x y -> x + (abs y)) 0 e

    else 
    if lena > lenl / 2 then
      let c = List.nth a ((lena - lenl/2)-1) in
      let e = List.map (fun x -> x - c) l in
      List.fold_left (fun x y -> x + (abs y)) 0 e

    else begin
      List.fold_left (fun x y -> x + (abs y)) 0 l
    end
  in

  Printf.printf "%d\n" ans;


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int di2[] = {1, 1, -1, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1};
const int dj2[] = {1, -1, 1, -1, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 2};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  if(*min_element(ALL(a)) == 0) {
    cout << 0 << endl;
    return 0;
  }
  double num = pow(10, 18);
  rep(i, n) {
    num /= a[i];
  }
  if(num < 1) {
    cout << -1 << endl;
    return 0;
  }
  ll ans = 1;
  rep(i, n) ans *= a[i];
  if(ans <= 1000000000000000000ll) cout << ans << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 4028
N=int(input())
L=[list(map(int,input().split())) for _ in range(N)]
L.sort(key=lambda x:x[1])
t=0
p=True
for l in L:
  t+=l[0]
  if t > l[1]:
    p=False
    break
print("Yes" if p else "No")

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

using namespace std;


int main(){
 long long n; cin >> n;
 long long p;
 p = (long long)pow(n,0.5);
 long long mn = n+1;
 for (int i = 1; i < p+1; ++i)
 {
    long long div = n/i;
     if (n%i==0)
     {
        mn = min((div-1)+(i-1),mn); 
     }
 }

 cout << mn;


return 0;
}


Measured memory_bytes: 256
def solve(a, minA):
    cnt = 0
    while cnt < minA:
        if a % 2 == 1:
            break
        cnt += 1
        a = a // 2
    return cnt


def resolve():
    N = int(input())
    A = [int(i) for i in input().split()]
    minA = 10**9
    for a in A:
        minA = min(minA, solve(a, minA))
    print(minA)


resolve()


Measured memory_bytes: 9192
n=int(input())
l=[];t=0;flg=0
for i in range(1,n+1,1):
    a,b=map(int,input().split())
    c=(b,a)
    l.append(c)
l.sort()
for x,y in l:
    t+=y
    if t>x:
        flg=1
if flg==0:print("Yes")
else:print("No")



Measured memory_bytes: 29456
#include<cstdio>
#include<cstring>
#include<algorithm>

#define Fast register
#define uint unsigned int
#define LL long long

struct IO{
	#define ISIZE 262144
	#define OSIZE 262144

	char IBUF[ISIZE],*IS,*IT;
	char OBUF[OSIZE+128],*OS,*OT;

	IO():IS(IBUF),IT(IBUF),OS(OBUF),OT(OBUF+OSIZE){}
	~IO(){Flush();}
	
	inline char Getchar(){return(IS==IT)&&(IT=(IS=IBUF)+fread(IBUF,1,ISIZE,stdin),IS==IT)?EOF:*IS++;}
	template<class T>inline IO&operator>>(T&x){
		Fast T s=0;Fast char c;
		if(IS+25<IT){
			do c=*IS++;while(c<48||c>57);
			do s=s*10+c-48,c=*IS++;while(c>47&&c<58);
		}else{
			do c=Getchar();while(c<48||c>57);
			do s=s*10+c-48,c=Getchar();while(c>47&&c<58);
		}return(x=s,*this);
	}

	inline void Flush(){fwrite(OBUF,1,OS-OBUF,stdout);OS=OBUF;}
	inline void Putchar(const char&c){if(OS>OT)Flush();*OS++=c;}
	inline IO&operator<<(const char&c){return(Putchar(c),*this);}
	template<class T>inline IO&operator<<(T x){
		if(OS>OT)Flush();
		static char OStack[30];static int Top;Top=0;
		if(x<0)*OS++='-',x=-x;
		do OStack[++Top]=x%10|48;while(x/=10);
		while(Top)*OS++=OStack[Top--];
		return*this;
	}

	#undef ISIZE
	#undef OSIZE
}io;

#define Maxn 200001

int X[Maxn];
int Xx[Maxn];

int main(){
	Fast int n;io>>n;
	for(Fast int i=1;i<=n;++i)io>>X[i];
	memcpy(Xx+1,X+1,n<<2);
	std::sort(Xx+1,Xx+n+1);
	for(Fast int i=1,Mid=n>>1,Ans1=Xx[Mid],Ans2=Xx[Mid+1];i<=n;++i)
		io<<((X[i]<=Ans1)?Ans2:Ans1)<<'\n';
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int c[10][10] = {};
  for(int i = 1; i <= N; i++) {
    string s = to_string(i);
    c[s[0] - '0'][s[s.length()-1] - '0']++;
  }
  ll ans = 0;
  for(int i = 0; i < 10; i++) for(int j = 0; j < 10; j++) ans += c[i][j] * c[j][i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
char S[2020];
int T[2020],n;
int main(){
	scanf("%s",S+1);
	n=strlen(S+1);
	int Min=202020;
	for (int i=1;i<=n-2;i++)
		Min=min(Min,abs((S[i]-'0')*100+(S[i+1]-'0')*10+S[i+2]-'0'-753));
	cout<<Min;			
				
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
 
int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> roads(50), x(50), y(50);
  rep(i,N){roads.at(i)=0;}
  rep(i,M)
  {
    cin >> x.at(i) >> y.at(i);
    roads.at(x.at(i)-1)++;
    roads.at(y.at(i)-1)++;
  }
  rep(i,N){cout << roads.at(i) << endl;}
}

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

using namespace std;

ll func(vector<ll> &v, vector<ll> &dp, ll k){
    for(ll i=2;i<v.size();i++){
        ll val = dp[i-1]+abs(v[i] - v[i-1]);
        for(ll j=2;j<=k && i-j >= 0;j++){
            val = min(val, dp[i-j] + abs(v[i] - v[i-j]));
        }
        dp[i] = val;
    }

    return dp[v.size()-1];
}

int main(){

    ll n, k;
    cin>>n>>k;

    vector<ll> v(n);
    for(ll i=0;i<n;i++)
        cin>>v[i];

    vector<ll> dp(n, -1);
    dp[0] = 0;
    dp[1] = abs(v[1] - v[0]);
    ll ans = func(v, dp, k);

    cout<<ans<<endl;

    return 0;
}

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

int main() {
  int n,sum = 1,k;
  cin >> n >> k;
  
  for ( int i=0; i < n ; i++ ) {
    if ( sum <= k ) {
      sum *= 2 ;
    }
    else {
      sum += k;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
while (n = gets.to_i) != 0
  a, b = []*n, []*n
  0.upto(n-1) do |i|
    a[i], b[i] = gets.split(" ").map(&:to_i)
  end
  a_sum, b_sum = 0, 0
  0.upto(n-1) do |i|
    if a[i] > b[i]
      a_sum += a[i] + b[i]
    elsif a[i] < b[i]
      b_sum += a[i] + b[i]
    else
      a_sum += a[i]
      b_sum += b[i]
    end
  end

  puts "#{a_sum} #{b_sum}"
end

Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D, E,a, b, c, d, e;
  int time, mint;
  cin >> A >> B >> C >> D >> E;
  time=0;
  a=A%10;
  b=B%10;
  c=C%10;
  d=D%10;
  e=E%10;

  mint=200;
  if(a!=0&&mint>a) mint=a;
  if(b!=0&&mint>b) mint=b;
  if(c!=0&&mint>c) mint=c;
  if(d!=0&&mint>d) mint=d;
  if(e!=0&&mint>e) mint=e;
  
  if(mint==200) mint=0;
  
  if(a!=0) time+=(A/10+1)*10;
 else time+=A;
  if(b!=0) time=time+(B/10+1)*10;
  else time+=B;
  if(c!=0) time=time+(C/10+1)*10;
   else time+=C;
  if(d!=0) time=time+(D/10+1)*10;
  else time+=D;
  if(e!=0) time=time+(E/10+1)*10;
   else time+=E;
  time=time+mint-10;
  if(mint==0) time+=10;
  cout<<time<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*既に塗った色の配列　tuple(親、子、その間の辺の色)の配列
  を用意
*/
struct edge{
    int to,color;
};

using Graph = vector<vector<edge>>;

int main() {
    string S;
    cin >> S;
    int K;
    cin >> K;
    vector<string> vec;
    set<string> s;
    for(int i = 0;i<S.size();i++){
        for(int j = 0;j<S.size()-i;j++){
          if(j+1 > K) break;
          s.insert(S.substr(i,j+1));
        }
    }
    for(auto value : s){
        vec.push_back(value);
    }
    sort(vec.begin(),vec.end());
    /*rep(i,vec.size()){
      cout << vec[i] << endl;
    }*/
    cout << vec[K-1] << endl;
  }

Measured memory_bytes: 1920
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

const int MAXN = 300005;
const int MOD = 998244353;

ll ADD(ll a, ll b){
    return (a+b)%MOD;
}
ll MUL(ll a, ll b){
    return a*b%MOD;
}
ll EXP(ll b, int e){
    if(e==0) return 1;
    if(e%2) return MUL(b, EXP(b, e-1));
    else return EXP(MUL(b, b), e/2);
}
ll DIV(ll a, ll b){
    return MUL(a, EXP(b, MOD-2));
}
ll f[MAXN];
ll C(ll n, ll k){
    return DIV(f[n], MUL(f[k], f[n-k]));
}



int main(){
    f[0]=1;
    for(int i=1;i<MAXN;++i) f[i]=MUL(f[i-1], i);
    ll n, a, b, k, sol=0;
    scanf("%lld%lld%lld%lld", &n, &a, &b, &k);
    if(a<b) swap(a,b );

    if(b==0){
        if(a==0){
            puts((k==0?"1":"0"));
        }else{
            if(k%a==0) puts("1");
            else puts("0");
        }
        return 0;
    }
    for(ll i=0;i<=n;++i){
        if(i*a<=k && (k-i*a)%b==0 && (k-i*a)/b<=n){
            sol = ADD(sol, MUL(C(n, i), C(n, (k-i*a)/b)));
        }
    }
    printf("%lld\n", sol);
}


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

const int64_t mod = 998244353;

int64_t power(int64_t n, int64_t k) {
  if (k == 0) return 1;
  int64_t half = power(n, k / 2), half2 = half * half % mod;
  if (k % 2 == 0) {
    return half2;
  } else {
    return n * half2 % mod;
  }
}

int main() {
  int n;
  cin >> n;
  vector<int64_t> d(n);
  for (int i = 0; i < n; i++) cin >> d.at(i);
  if (d.at(0) != 0) {
    cout << 0 << endl;
    return 0;
  }
  map<int64_t, int64_t> a;
  for (int i = 0; i < n; i++) a[d.at(i)]++;
  if (a[0] != 1) {
    cout << 0 << endl;
    return 0;
  }
  int64_t ans = 1, m = *max_element(d.begin(), d.end());
  for (int i = 0; i <= m; i++) {
    ans *= power(a[i], a[i + 1]);
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N;
  vector<int> d(N);
  REP(i,N) cin >> d[i];
  sort ALL(d);
  cout << d[N/2]-d[N/2-1] << endl;
}

Measured memory_bytes: 640
import sys

list_abc = [chr(ord('a') + i) for i in range(26)]
list_abc_count = [0 for _ in range(26)]
for line in sys.stdin.readlines():
    line_low = line.lower()

    for i, abc in enumerate(list_abc):
        n_count = line_low.count(abc)
        list_abc_count[i] += n_count
    
for i, abc in enumerate(list_abc):
    n_count = list_abc_count[i]
    print(f"{abc} : {n_count}")


Measured memory_bytes: 5580
import java.util.*;

public class Main {
	
	   

		public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int n = sc.nextInt();
	        int k = sc.nextInt();
	        int[] all = new int[n];
	        for(int i = 0 ; i<n; i++) {
	        	all[i] = sc.nextInt();
	        }
	        Arrays.sort(all);
	        int sum = 0;
	        for(int j=0; j<k; j++) {
	        	sum += all[j];
	        }
	        
	        
	        
	        
	       
            System.out.println(sum); 
	        
	}
}

Measured memory_bytes: 38756
#include <iostream>

using namespace std;
//int dp[10][45][10];

int dpc(int n,int s,int num)
{
  //  if(dp[n][s][num]!=-1)
  //  return dp[n][s][num];
  if(n==0)
    return 0;
  if(s==num && n==1)
    return 1;
  if(num==9)
    return 0;
  int sum=0;
  if(n-1>=0 && s-num>=0)
    sum+=dpc(n-1,s-num,num+1);
  sum+=dpc(n,s,num+1);
  //  dp[n][s][num]=sum;
  //  cout<<"sum="<<sum<<endl;
  return sum;
}

int main()
{
  int n,s;
  for(;cin>>n>>s,n;)
    {
      /*
      for(int i=0;i<10;i++)
	for(int j=0;j<45;j++)
	  for(int x=0;x<10;x++)
	  dp[i][j][x]=-1;*/
      cout<<dpc(n,s,0)<<endl;
    }
}

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

int main(){
    int n, i;
    char str[21];
    scanf("%s", str);
    n = strlen(str);
    for(i=n-1;i>=0;i--){
        if(i==0) printf("%c\n", str[i]);
        else printf("%c", str[i]);
    }
    return 0;
}

Measured memory_bytes: 540
//tt89 ;)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void testcase(int t) { cout<<"Case #"<<t<<": "; }
void online() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif //ONLINE_JUDGE
}
const int mod= 1e9+7;

int main() {
    fastIO;
    int n; cin>>n;
    vector<int> arr(n);
    for(int i=0;i<n;i++) cin>>arr[i];
    int sum_xor=0;
    for(int i:arr) sum_xor^=i;

    for(int i: arr) cout<<(sum_xor^i)<<" ";

    return 0;
}

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

int main() {
  int H, W, cnt = 0;
  cin >> H >> W;
  char C;
  while (cin >> C) if (C == '#') cnt++;
  cout << ((cnt == H + W - 1) ? "Possible" : "Impossible") << "\n";
}

Measured memory_bytes: 3580
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力

		if(a%2 ==0){
  System.out.println(a);
		}else{
		System.out.println(a*2);
		}

	}
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define f first
#define s second
int main(){
  int n;
  while(cin>>n,n){
    pair<int,int>p[n];
    r(i,n)cin>>p[i].s>>p[i].f;
    sort(p,p+n);
    int sum=0;
    r(i,n){
      sum+=p[i].s;
      if(sum>p[i].f)goto L;
    }
    cout<<"Yes"<<endl;
    if(0){L:;cout<<"No"<<endl;}
  }
}

Measured memory_bytes: 2972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef long double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=201000;
int n,b[N];
ll a[N];
db f[N],p[N];

struct point {
	db x,y;
	point() {}
	point(db x,db y):x(x),y(y) {} 
};
bool operator < (const point &a, const point &b) {
	return a.x<b.x||(a.x==b.x&&a.y<b.y);
}
vector<point> pt;
int h,t,q[N];
bool cmp(point a,point b,point c) {
	// b在c上面
	b.x-=a.x, b.y-=a.y;
	c.x-=a.x, c.y-=a.y;
	if (b.x==c.x) return 1;
	return b.y*c.x<b.x*c.y;
}
void rebuild() {
	h=0; t=-1;
	rep(i,0,SZ(pt)) {
		while (t>=1&&cmp(pt[q[t-1]],pt[q[t]],pt[i])) --t;
		q[++t]=i;
	}
	for (int i=0;i<t;i++) {
		for (int j=q[i]+1;j<=q[i+1]-1;j++) {
			p[j]=((j-pt[q[i]].x)*pt[q[i+1]].y+(pt[q[i+1]].x-j)*pt[q[i]].y)/(pt[q[i+1]].x-pt[q[i]].x);
		}
	}
}

int main() {
	scanf("%d",&n);
	for (int i=0;i<n;i++) scanf("%lld",a+i);
	rep(i,0,n) scanf("%d",b+i);
	int pos=max_element(a,a+n)-a;
	rotate(a,a+pos,a+n); rotate(b,b+pos,b+n);
	db q=0,s=0;
	for (int i=1;i<n;i++) q+=b[i],s+=q;
	s=-s*2/n;
	for (int i=1;i<n;i++) {
		f[i]=f[i-1]+s;
		s=s+2*b[i];
//		printf("%d %.10f\n",i,f[i]);
	}
/*	for (int i=1;i<n;i++) {
		printf("%.10f %.10f\n",f[i],0.5*(f[i-1]+f[(i+1)%n])-b[i]);
	}*/
	for (int i=0;i<n;i++) p[i]=a[i]-f[i];
	for (int i=0;i<n;i++) {
		pt.pb(point(i,p[i]));
	}
	pt.pb(point(n,p[0]));
	rebuild();
	db ans=0;
	rep(i,0,n) {
		ans+=p[i]+f[i];
	//	printf("%.10f\n",p[i]);
	}
	//ans+=a[0];
	printf("%.10f\n",(double)(ans/n));
	//printf("%.10f\n",p[i]+f[i]);
//	puts("");
}


Measured memory_bytes: 20256
//
// Created by Hideaki Imamura on 2020-03-14.
//
# include <bits/stdc++.h>

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

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

string a, b, c;

bool match(char c1, char c2) {
    return c1 == '?' || c2 == '?' || c1 == c2;
}

int main() {
    cin >> a >> b >> c;
    int n_a = a.length(), n_b = b.length(), n_c = c.length();
    const int X = 40000;
    const int Y = 2000;
    bool ab[2 * X], ac[2 * X], bc[2 * X];

    for (int i = 0; i < n_a; ++i) for (int j = 0; j < n_b; ++j) if (!match(a[i], b[j])) ab[i-j+X] = true;
    for (int i = 0; i < n_a; ++i) for (int j = 0; j < n_c; ++j) if (!match(a[i], c[j])) ac[i-j+X] = true;
    for (int i = 0; i < n_b; ++i) for (int j = 0; j < n_c; ++j) if (!match(b[i], c[j])) bc[i-j+X] = true;

    int ans = 1e9;
    for (int i = - 2 * Y; i <= 2 * Y; ++i) {
        for (int j = - 2 * Y; j <= 2 * Y; ++j) {
            if (!ab[i + X] && !ac[j + X] && !bc[j - i + X]) {
                int L = min(0, min(i, j));
                int R = max(n_a, max(n_b + i, n_c + j));
                chmin(ans, R - L);
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int i,n,a[110],result=0;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a[i];
    result += a[i];
  }
  sort(a,a+n,greater<int>());
  for(i=1;i<n;i+=2){
    result -= 2*a[i];
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3596
ddd = list(map(int, input().split()))
n = ddd[0]
k = ddd[1]
count = 0

for i in range(n):
    a = i + 1
    if k % 2 == 1:
        if a % k != 0:
            bccount = 0
        else:
            bccount = (n // k) ** 2
    else:
        if a % k == 0:
            bccount = (n // k) ** 2
        elif a % k == k // 2:
            if n % k < k // 2:
                bccount = ((n // (k // 2)) // 2) ** 2
            else:
                bccount = ((n // (k // 2)) // 2 + 1) ** 2
        else:
            bccount = 0
    count = count + bccount

print(count)

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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int D,T,S;
    cin >>D>>T>>S;
    float min_spd = float(D)/(T);

    if(float(S) >= min_spd)
    {
        cout<<"Yes\n";
    }   
    else
    {
        cout<<"No\n";
    }
    
}

Measured memory_bytes: 3636
import math

N = int(input())

a = pow(10,12)

is_not_prime = False
#for k in range(2, int(math.sqrt(N)) + 1):
#    if N % k == 0:
#        is_not_prime = True
#        break
#if is_not_prime:
for i in range(1, int(math.sqrt(N))+1):
    #print(i)
    j = N/i
    if j.is_integer():

        if (i+int(j)) < a:
            a = i+int(j)
    #if j < 2:
    #    break

print(a - 2)
#else:
#    print(N - 1)

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

int main(void) {

    int N; cin >> N;
    map<int,int> problems;
    for (int i = 0; i < N; i++) {
        int D; cin >> D;
        problems[D]++;
    }

    int M; cin >> M;
    bool flag = false;
    for (int i = 0; i < M; i++) {
        int T; cin >> T;
        if (problems.find(T) != problems.end()) {
            problems[T]--;
            if (problems[T] < 0) flag = true;
        } else {
            flag = true;
        }
    }

    cout << (flag ? "NO" : "YES") << endl;

    return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>
#include<math.h>
int min(int o,int p)
{
    if(o>p)return p;
    else return o;
}
int main()
{
    int n,m,a,b,sum1=0,sum2=0,sum3=0;
    scanf("%d%d%d",&n,&a,&b);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&m);
        if(m<=a)sum1++;
        if(m>=a+1 &&m<=b)sum2++;
        if(m>=b+1)sum3++;
    }
    int q=min(sum1,sum2);
    sum1=min(q,sum3);
    printf("%d",sum1);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int a,b;
	int c,d;
	scanf("%d %d",&a,&b);
	c=a*b;
	d=c%2;
	if(d==0){
		printf("Even");
	}else{
		printf("Odd");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
#include<iomanip>
#include<cmath>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

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

	if (w == 1 || h == 1) {
		ans = 1;
	}
	else if (w * h % 2) {
		ans = w * h / 2 + 1;
	}
	else {
		ans = w * h / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
	int n;
  	cin>>n;
  	int arr[n];
  	for(int i=0;i<n;i++)
      cin>>arr[i];
  	
	int dp[n];
	
	for(int i=0;i<n;i++)
	{
		if(i==0)
			dp[i] = 0;
		else if(i==1)
			dp[i] = abs(arr[i]-arr[i-1]);
		else
		{
			int temp1 = abs(arr[i] - arr[i-1]) + dp[i-1];
			int temp2 = abs(arr[i] - arr[i-2]) + dp[i-2];
			dp[i] = min(temp1,temp2);
		}
	}
	
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 4376
def generate(lower, upper):
	s = ''
	for i in range(0, len(lower)):
		if lower[i] == upper[i]:
			s = s + str(lower[i])
		else:
			s = s + str(lower[i]) + '-' + str(upper[i])
		if i != len(lower) - 1:
			s = s + ' '
	return s

while True:
	n = int(raw_input())
	if n == 0:
		break
	else:
		inpt = map(int, raw_input().split())
		lower = [inpt[0]]
		upper = []
		for i in range(1, n):
			if inpt[i] - inpt[i-1] != 1:
				upper.append(inpt[i-1])
				if i != n:
					lower.append(inpt[i])
		upper.append(inpt[n-1])
		print generate(lower, upper)

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int count_one(ll n) {
  bitset<64> b = n;
  return b.count();
}

int main() {
  int n;
  cin >> n;
  V<V<int>> x(n), y(n);
  rep(i, n) {
    int num;
    cin >> num;
    x[i].resize(num);
    y[i].resize(num);
    rep(j, num) cin >> x[i][j] >> y[i][j];
  }

  int ans = 0;
  rep(i, 1 << n) {
    bool ok = true;
    V<int> p(n);
    rep(j, n) p[j] = (i & 1 << j) ? 1 : 0;
    rep(j, n) {
      if ((i & 1 << j) == 0) continue;
      int num = x[j].size();
      for (int k = 0; k < num; k++) {
        int no = x[j][k] - 1;
        if (p[no] != y[j][k]) ok = false;
      }
    }
    if (ok) ans = max(ans, count_one(i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3616
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
		Array.Sort(input);
		int ans = 10 * input[2] + input[0] + input[1];
		Console.WriteLine(ans);
	}
}


Measured memory_bytes: 13396
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right,bisect_left
from itertools import accumulate

def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    A = [0] + list(accumulate(A))
    B = list(accumulate(B))
    # print(A,B)
    ans = 0
    for i in range(N+1):
        if K - A[i] >= 0:
            j = bisect_right(B,K-A[i])
            # print(i,j,K-A[i])
            ans = max(ans,i+j)

    print(ans)
        


if __name__ == "__main__":
    main()


Measured memory_bytes: 41728
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 12345678901234567

const int maxn = 1e5 + 10;


//initialization here
//
vi v;
//
//initialization finish


// your function is here
//

//
// your function finished

void Prime(int x)
{
	bool check = true;
	FOR(i, 2, x)
	{
		if (x%i == 0)
		{
			check = false;
			break;
		}
	}
	if (check) v.pb(x);
	return;
}

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

	// your code is here
	//

	ll n; cin >> n;
	ll a, b; cin >>a >> b;

	ll x;
	ll pre;
	ll ans = 0;
	rep(i, n)
	{
		cin >> x;
		if (i == 0)
		{
			pre = x;
			continue;
		}
		ans += min(a*(x-pre), b);
		pre = x;
	}

	Print(ans);

	//
	// your code finished
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
using namespace std;
typedef long long ll;
ll par[100010],size[100010],ans[100010];
pair<ll,ll> p[100010];
ll init(ll n){
	for(int i=0;i<n;i++){
		par[i] = i; size[i] = 1;
	}
}

ll find(ll x){
	if(par[x]==x) return x;
	return par[x] = find(par[x]);
}

void unite(ll x, ll y){
	x = find(x); y = find(y);
	if(x==y) return;
	if(size[x]<size[y]) swap(x,y);
	size[x] += size[y]; par[y] = x;
}

bool same(ll x, ll y){
	return find(x)==find(y);
}

int main(){
	ll i,n,m,res;
	cin >> n >> m;
	for(i=0;i<m;i++){
		ll a,b;
		cin >> a >> b; a--; b--;
		p[i] = {a,b};
	}
	res = n*(n-1)/2;
	init(n);
	for(i=m-1;i>=0;i--){
		ans[i] = res;
		ll x = p[i].first,y = p[i].second;
		if(!same(x,y)){
			res -= size[find(x)]*size[find(y)];
			unite(x,y);
		}
	}
	for(i=0;i<m;i++){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 5248
// Aizu 3013: Clock
// 2017.9.22 bal4u@uu

#include <stdio.h>

int main(void)
{
	int a, h, m;

	scanf("%d", &a);
	a <<= 1;
	m = a % 60;
	h = (a - m) / 60;
	printf("%d %d\n", h, m);
	return 0;
}

Measured memory_bytes: 1852
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

void YesNo(bool x) {
    cout << (x ? "Yes" : "No") << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++)cin >> d[i];
    sort(d.begin(), d.end());

    cout << d[n / 2] - d[n / 2 - 1] << endl;
    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys


def solve(S: str, T: str):
    print(T + S)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940