akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep( i, n ) for (long long i = 0; i < ( long long )(n); i++)

using namespace std;
typedef long long ll;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;


int main(){
  ll x;
  cin>>x;
  map<ll,ll> c;
  for(ll i = 0 ;i<1000000;i++){
    c[i*i*i*i*i]=i;
  }

  for(ll i = 0 ;i<1000000;i++) {
    ll d = i*i*i*i*i;
    if(x-d>0&&c[x-d]!=0){
      cout<<i<<" "<<-c[x-d];
      //cout<<"k";
      return 0;
    }
    else if(x-d<0&&c[d-x]!=0){
      cout<<i<<" "<<c[d-x];
      return 0;
    }
    else if(x-d==0) {
      cout<<i<<" "<<"0";
      return 0;
    }
  }
}

Measured memory_bytes: 66072
#include <bits/stdc++.h>
using namespace std;
const string YES = "Yes";
const string NO = "No";
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;


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

    ll n; cin >> n;
    cout << n/2 + n%2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans=0,n,m,c;
    cin>>n>>m>>c;
    ll b[m];
    for(int i=0;i<m;i++){
        cin >>b[i];
    }
    for(int i=0;i<n;i++){
        ll val=0;
        for(int j=0;j<m;j++){
            ll a=0;
            cin>>a;
            val+=a*b[j];
        }
        val+=c;
        if(val>0)ans++;
    }

    dbg{
        if(true)cout <<"YES"<<endl;
        else cout <<"NO"<<endl;
    }

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()

for s in S:
  if s == "c":
    print("No")
  elif s == "a":
    if A + B == 0:
   	  print("No")
    else:
      A -= 1
      print("Yes")
  elif s == "b":
    if A + B == 0 or B == 0:
      print("No")
    else:
      B -= 1
      print("Yes")
      

Measured memory_bytes: 9300
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, l = list(map(int,ipti().split()))
    a = [i+l for i in range(n)]

    if l > 0:
        print(sum(a[1:]))
    elif (n - 1) >= abs(l):
        print(sum(a))
    else:
        print(sum(a[:n-1]))



if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  char c;
  cin >> c;
  cout << char( c + 1 ) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	ll res = 0LL;
	int right = 0;
	int sum = 0;
	for (int left = 0; left < n; left++) { //左端
		while (right < n && (sum ^ a[right]) == (sum + a[right])) { //lからrまでのa[i]を加算する
			sum += a[right];
			right++;
		}
		res += right - left; //区間の個数
		if (right == left) right++; //同じときは右端をずらす。
		else {
			sum -= a[left]; //左端をずらす分だけ減らす
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  vector<int> delicious;
  cin >> n;
  for (int i = 0; i < n; i++){
    int a;
    cin >> a;
    delicious.push_back(a);
  }
  
  int way = n * (n - 1 ) / 2;
  
  int result = 0;
  for (int i = 0; i < n; i++){
    for (int j = i + 1; j < n ; j++){
      result = result + delicious[i] * delicious[j];
    }
  }
  cout << result << endl;
}

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

using namespace std;

int arr[3];

int main()
{
    for (int i=0; i<3; i++)
    {
        cin>>arr[i];
    }
    for (int i=1; i<3; i++)
    {
        if (arr[i]==arr[i+1] && arr[i]==arr[i-1])
        {
            cout<<"No";
            break;
        }
        else if (arr[i]==arr[i+1] || arr[i]==arr[i-1] || arr[0]==arr[2])
        {
            cout<<"Yes";
            break;
        }
        else
        {
            cout<<"No";
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#  入力
#  足場の高さ
input()
h = list(map(int, input().split()))


#  方針
#  i番目の足場にいるという状態に対して
#  その足場に最も少ないコストを記録する．

#  初期化は大きは数で
dp = [1e20 for i in range(len(h))]
#  スタートはコスト0
dp[0] = 0

#  i番目の足場でのコストを利用して
#  i+1, i+2番目のコストを計算する
for i in range(len(h) - 1):
    dp[i + 1] = (
        dp[i + 1]
        if dp[i + 1] < dp[i] + abs(h[i + 1] - h[i])
        else dp[i] + abs(h[i + 1] - h[i])
    )
    if i + 2 < len(h):
        dp[i + 2] = (
            dp[i + 2]
            if dp[i + 2] < dp[i] + abs(h[i + 2] - h[i])
            else dp[i] + abs(h[i + 2] - h[i])
        )

print(dp[len(h) - 1])


Measured memory_bytes: 13908
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
using namespace std;

vector<pair<int, int>> mapvector(unordered_map<int, int> map){
    vector<pair<int, int>> pairs;
    for (pair<int, int> p : map){
        pairs.push_back(make_pair(p.second, p.first));
    }
    sort(pairs.begin(), pairs.end(), greater<pair<int, int>>());
    return pairs;
}

int main(){
    int n;
    cin >> n;
    vector<int> even(n/2);
    vector<int> odd(n/2);
    for(int i = 0; i < n; i++)
    {
        if (i%2 == 0) {
            cin >> even.at(i/2);
        }
        else
        {
            cin >> odd.at(i/2);
        }
    }

    unordered_map<int, int> evenmap, oddmap;
    for (int i : even){
        if (evenmap.find(i) != evenmap.end()) {
            evenmap[i]++;
        }
        else
        {
            evenmap[i] = 1;
        }
    }
    for (int i : odd){
        if (oddmap.find(i) != oddmap.end()) {
            oddmap[i]++;
        }
        else
        {
            oddmap[i] = 1;
        }
    }

    vector<pair<int, int>> evenfreq = mapvector(evenmap);
    vector<pair<int, int>> oddfreq = mapvector(oddmap);
    pair<int, int> e1 = evenfreq.at(0);
    pair<int, int> o1 = oddfreq.at(0);
    pair<int, int> e2, o2;
    if (evenfreq.size() > 1) {
        e2 = evenfreq.at(1);
    }
    else
    {
        e2 = make_pair(0, -1);
    }
    if (oddfreq.size() > 1) {
        o2 = oddfreq.at(1);
    }
    else
    {
        o2 = make_pair(0, -1);
    }

    int ans;
    if (e1.second != o1.second) {
        ans = n - e1.first - o1.first;
    }
    else
    {
        ans = min(n-e1.first-o2.first, n-e2.first-o1.first);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 8096
fn main() {
    proconio::input! {
        n: usize,
        k: usize,
        r: usize,
        s: usize,
        p: usize,
        t: String,
    }
    let t=t.as_bytes();
    let mut h=Vec::with_capacity(n);
    let f=|c| match c {
        b'r' => 0,
        b's' => 1,
        _ => 2,
    };
    let mut a=0;
    for (i,&c) in t.iter().enumerate() {
        let mut v=(f(c)+2)%3;
        if i>=k && h[i-k]==v {
            v=if i+k<n {
                let w=f(t[i+k]);
                if w!=v {
                    w
                }
                else {
                    (w+1)%3
                }
            }
            else {
                v+1
            }
        }
        else {
            a+=match v {
                0 => r,
                1 => s,
                _ => p,
            };
        }
        h.push(v);
    }
    println!("{}",a);
}

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

const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;

long long fac[MAXN];

void pre_calc (int lim) {
	fac[0] = 1;
	for (int i = 1; i <= lim; i++) {
		fac[i] = fac[i-1] * i % MOD;
	}
}

int main (void) {
	pre_calc(1e5);

	int n, m;
	scanf("%d%d", &n, &m);
	if (n < m) swap(n, m);
	if (n > m + 1) {
		printf("0\n");
	} else if (n == m + 1) {
		printf("%lld\n", fac[n] % MOD * fac[m] % MOD);
	} else if (n == m) {
		printf("%lld\n", 2 * fac[n] % MOD * fac[m] % MOD);
	}
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int n;
void dfs(string s, char mx) {
    if (s.size() == n) {
        cout << s << endl;
        return;
    }
    for (char c = 'a'; c <= mx+1; c++) {
        string t = s;
        t += c;
        dfs(t, max(mx, c));
    }   
}

int main() {
	cin >> n;
    dfs("", 'a'-1);
	return 0;
}


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

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

	stack<int> s1;
	stack<pair<int, int>> s2;
	int sum = 0;
	for( int i = 0; i < S.size(); i++ ) {
		if( S[i] == '\\' ) {
			s1.push( i );
		}
		else if( S[i] == '/' && s1.size() ) {
			int j = s1.top();
			s1.pop();
			sum += i - j;
			int a = i - j;
			while( s2.size() > 0 && s2.top().first > j ) {
				a += s2.top().second;
				s2.pop();
			}
			s2.push( make_pair( j, a ) );
		}
	}
	vector<int> ans;
	while( s2.size() ) {
		ans.push_back( s2.top().second );
		s2.pop();
	}
	reverse( ans.begin(), ans.end() );

	cout << sum << endl;
	cout << ans.size();
	for( int i = 0; i < ans.size(); i++ ) {
		cout << " ";
		cout << ans[i];
	}
	cout << endl;
}



Measured memory_bytes: 3208
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main(){
	int n;
	cin >> n;
	int a[51];
	int b[51];
	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++){
		if(a[i] != b[i] && (a[i] - 1) / 2 < b[i]){
			cout << -1 << endl;
			return 0;
		}
	}

	int graph[51][51] = {};
	for(int i = 0; i <= 50; i++){
		for(int j = 1; j <= 50; j++){
			graph[i][j] = i % j;
		}
	}
	vector<bool> isused(51, true);
	isused[0] = false;
	for(int i = 50; i >= 1; i--){
		// iを使わなくても大丈夫かをチェック
		isused[i] = false;
		for(int j = 0; j < n; j++){
			vector<bool> ischecked(51, false);
			queue<int> qu;
			qu.push(a[j]);
			ischecked[a[j]] = true;
			while(!qu.empty()){
				int now = qu.front();
				qu.pop();
				for(int k = 0; k <= 50; k++){
					if(!isused[k]) continue;
					int next = graph[now][k];
					if(!ischecked[next]){
						ischecked[next] = true;
						qu.push(next);
					}
				}
			}
			if(!ischecked[b[j]]){
				isused[i] = true;
				break;
			}
		}
	}
	long long int ans = 0;
	for(int i = 0; i <= 50; i++){
		if(isused[i]) ans += (long long int)1 << i;
	}
	cout << ans << endl;
}

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

bool meguruSearch(const std::vector<int> &vec, const int v, int ng, int ok){
    int mid = (ng + ok) / 2;
    if(v == vec.at(mid)){
//    std::cout << vec.at(mid) << std::endl;
        return true;
    }else if(1 == std::abs(ok - ng)){
//    std::cout << vec.at(mid) << std::endl;
        return false;
    }

    if(v < vec.at(mid)){ // elements in the right part of vec including vec.at(mid) are set as okay in this code
        return meguruSearch(vec, v, ng, mid);
    }else{
        return meguruSearch(vec, v, mid, ok);
    }
}

int main(){
    int n;
    std::cin >> n;

    std::vector<int> s(n);
    for(int i = 0; i < n; ++i){
        std::cin >> s.at(i);
    }

    int q;
    std::cin >> q;

    std::vector<int> t(q);
    for(int i = 0; i < q; ++i){
        std::cin >> t.at(i);
    }

    int count = 0;
    for(int i = 0; i < q; ++i){
        if(meguruSearch(s, t.at(i), -1, s.size())){
//            std::cout << t.at(i) << std::endl;
            ++count;
        }
    }

//    std::cout << "------" << std::endl;
    
    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 3364
#include <iostream>
using namespace std;
bool prime[10000001];
const int MAX = 10000000;
int main(){
	int n;
	bool f;
	for(int i = 0;i <= MAX;++i){
		if(i % 2 == 0) prime[i] = false; 
		else prime[i] = true;
	}
	prime[2] = true;
	prime[1] = false;
	for(int i = 3;i <= MAX;++i){
		if(prime[i]){
			for(int j = 2;j <= MAX/i;++j){
				prime[i*j] = false;
			}
		}
	}
	while(cin >> n,n){
		f = false;
		for(;!f;--n){
			if(prime[n] == true && prime[n - 2] == true && prime[n - 8] == true && prime[n - 6] == true) f = true;
		}
		cout << n+1 << endl;	
	}
	return 0;
}

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

int main() {
  string S,T;
  cin >> S >> T;
  
  int N = S.size();
  
  int c=0;
  //違うところ数える
  
  for(int i=0;i<N;i++){
    if(S.at(i) != T.at(i)) c++;
  }
  
  cout << c << endl;
}


Measured memory_bytes: 3916
/* 
 * Project: AtCoder Beginners Contest 164 A - Sheep and Wolves
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/04/26
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cmath>
using namespace std;

int s;
int w;

void solve() {
    if (s > w)
        printf("safe\n");
    else
        printf("unsafe\n");
}

int main() {

    scanf("%d", &s);
    scanf("%d", &w);

    solve();

}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;

istringstream iss;
int a;

bool parse() {
  char ch;
  iss >> ch;
  
  if( isalpha(ch) ) {
    if(ch == 'T') return true;
    if(ch == 'F') return false;
    return ( a >> (ch-'a') ) & 1;
  }

  if( ch == '-' ) {
    return !parse();
  }

  bool f1 = parse();
  iss >> ch;
  if( ch == '-' ) iss.ignore();
  bool f2 = parse();
  iss.ignore();
  if( ch == '*' ) return f1 && f2;
  if( ch == '+' ) return f1 || f2;
  return f1 <= f2;
}

bool solve(const string &input) {
  for( a = 1 << 11; a--; ) {
    iss.clear();
    iss.str(input);
    
    bool left = parse();
    iss.ignore();
    bool right = parse();
    if( left != right ) return false;
  }
  return true;
}

int main() {
  string s;
  while(cin >> s, s[0] != '#' ) {
    cout << (solve(s) ? "YES" : "NO") << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include <stdio.h>
#include <stdlib.h>

int gcd(int x, int y);

int main(void)
{
    int n, start, x[100000], ans;
    int i;
    scanf("%d%d", &n, &start);
    for (i=0; i<n; i++)
    {
        scanf("%d", &x[i]);
    }
    ans = abs(start - x[0]);
    for (i=1; i<n; i++)
    {
        ans = gcd (ans, abs(start - x[i]));
    }
    printf("%d\n", ans);
    return 0;

}

int gcd(int x, int y)
{
    int r;
    if (x==y) {
        return x;
    } else if (x>y) {
        while ((r=x%y) != 0) {
            x = y;
            y = r;
        }
        return y;
    } else if (x<y) {
        while ((r=y%x) != 0) {
            y = x;
            x = r;
        }
        return x;
    }
    return 0;

}


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

int main(){
  int H, W, N;
  cin >> H >> W >> N;
  set<pair<int,int>> S;
  vector<vector<int>> V(W,vector<int>(1,H));
  int x, y;
  for(int i = 0; i < N; ++i){
    cin >> x >> y;
    --x,--y;
    V[y].push_back(x);
    S.emplace(x,y);
  }
  for(int i = 0; i < W; ++i)
    sort(V[i].begin(), V[i].end());
  
  // for(int i = 0; i < W; ++i){
  //   cerr << i << " : ";
  //   for(size_t j = 0; j < V[i].size(); ++j)
  //     cerr << V[i][j] << " ";
  //   cerr << endl;
  // }

  int ans = H;
  x = 0, y = 0;
  while(x < H and y < W){
    int k = upper_bound(V[y].begin(), V[y].end(), x) - V[y].begin();
    //cerr << i << " " << j << " " << k << endl;
    ans = min(ans,V[y][k]);
    if(S.count({x+1,y})) break;
    ++x;
    if(S.count({x,y+1})) continue;
    ++y;
  }
  cout << ans << endl;
}


Measured memory_bytes: 20992
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;

int a[200010];
int prv[200010],nxt[200010];
bool win[200010];

int main(void){
	int n,m,q;
	cin >> n >> m >> q;

	for(int i=0;i<n;++i){
		prv[i]=(i+n-1)%n,nxt[i]=(i+1)%n;win[i]=true;
	}
	int cur=0;
	for(int i=0;i<m;++i){
		cin >> a[i];
		if(a[i]&1){
			for(int j=0;j<a[i];++j) cur=prv[cur];
		}else{
			for(int j=0;j<a[i];++j) cur=nxt[cur];
		}
		win[cur]=false;
		nxt[prv[cur]]=nxt[cur];
		prv[nxt[cur]]=prv[cur];
		cur=nxt[cur];
	}

	for(int i=0;i<q;++i){
		int in;
		cin >> in;
		cout << win[in] << endl;
	}
	return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    string s;
    cin>>s;
    int n=s.length();
    string ans;
    while(s.length()>0)
    {
        s=s.substr(0,s.length()-1);
        if(s.length()%2==0)
        {
            string first=s.substr(0,s.length()/2);
            string second=s.substr(s.length()/2,s.length()/2);
            if(first==second)
            {
                ans=s;
                break;
            }
        }
    }
    cout<<ans.length();
}


Measured memory_bytes: 256
N = int(raw_input())
a = [int(i[-2:])for i in raw_input().split(" ")]

c1 = 0
c2 = 0

for ai in a:
    if ai % 2 != 0:
        c1 += 1
    elif ai % 4 == 0:
        c2 += 1
if c1 <= c2:
    print "Yes"
elif c1 - 1 == c2 and N == c1 + c2:
    print "Yes"
else:
    print "No"


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

const long long mod = 1e9 + 7;
int dp[100010][13]; // dp[i][j]はi桁あった時あまりがjとなる数

int main(){
    string s; cin >> s;
    int len = s.size();
    reverse(s.begin(), s.end());

    if(s.at(0) == '?'){
        for(int i = 0; i < 10; i++){
            dp[1][i] = 1;
        }
    }
    else{
        int idx = s[0] - '0';
        dp[1][idx] = 1;
    }
    int num = 1;
    for(int i = 1; i < len; i++){
        num *= 10;
        num %= 13;
        if(s.at(i) == '?'){
            for(int j = 0; j < 10; j++){
                for(int k = 0; k < 13; k++){
                    int res = (k + j * num) % 13;
                    dp[i+1][res] += dp[i][k];
                    dp[i+1][res] %= mod;
                }
            }
        }
        else{
            for(int j = 0; j < 13; j++){
                int k = s[i] - '0';
                int res = (k * num + j) % 13;
                dp[i+1][res] += dp[i][j];
                dp[i+1][res] %= mod;
            }
        }
    }
    cout << dp[len][5] << endl;
}

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

using namespace std;
int main()
{
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    if(n<=k) printf("%d\n",x*n), exit(0);
    printf("%d\n",(k*x)+(n-k)*y);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3

import array
import math
import os
import sys


def main():
    A, B = read_ints()
    print(max(0, A - 2 * B))


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int H,W,N;cin>>H>>W>>N;
    int A[N];
    int S[H][W];
  	REP(i,H)REP(j,W)S[i][j]='0';
    REP(i,N)cin>>A[i];
    int count=0;
    REP(i,N){
        REP(j,A[i]){
            if((count/W)%2==0)S[count/W][count%W]=1+i;
            else S[count/W][W-1-count%W]=1+i;
          	count++;
        }
    }
    REP(i,H){
        REP(j,W)cout<<S[i][j]<<" ";
        cout<<endl;
    }
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<queue>
#include<map>
using namespace std;

int used[1000][1000];
int field[1000][1000];
int mx[] = {0, 1, 0, -1}, my[] = {1, 0, -1, 0};
int main(){
  int h, w, n, sx, sy, ans = 0;
  scanf("%d%d%d", &h, &w, &n);
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      char c;
      scanf(" %c", &c);
      if(c =='.' || c == 'S')field[i][j] = 0;
      else if(c == 'X')field[i][j] = -1;
      else field[i][j] = c - '0';
      if(c == 'S')sx = i, sy = j;
    }
  }
  for(int goal = 1;goal <= n;goal++){
    memset(used, 0, sizeof(used));
    queue< pair<int, int> > qu;
    qu.push(make_pair(sx, sy));
    bool fin = false;
    while(!fin){
      ans++;
      for(int i = qu.size();i > 0 && !fin;i--){
	int tx = qu.front().first;
	int ty = qu.front().second;
	qu.pop();
	for(int j = 0;j < 4 && !fin;j++){
	  int nx = tx + mx[j];
	  int ny = ty + my[j];
	  if(nx < 0 || nx >= h || ny < 0 || ny >= w)continue;
	  if(field[nx][ny] == -1 || used[nx][ny] != 0)continue;
	  used[nx][ny] = 1;
	  if(field[nx][ny] == goal){
	    fin = true;
	    sx = nx;
	    sy = ny;
	  }
	  qu.push(make_pair(nx, ny));
	}
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 8864
#include<iostream>

using namespace std;


int fact[110];

int cnt[5];


int main(){
  int n;
  cin>>n;
  for(int i=2;i<=n;i++){
     int tmp=i;
     fact[i]=1;
     for(int j=2;j<=i;j++){
       while(tmp%j==0){
        fact[j]++;
        tmp/=j;
      }
     }
  }
  for(int i=2;i<=n;i++){
    if(fact[i]>=75)cnt[4]++;
    if(fact[i]>=25)cnt[3]++;
    if(fact[i]>=15)cnt[2]++;
    if(fact[i]>=5)cnt[1]++;
    if(fact[i]>=3)cnt[0]++;
  }
  int ans=cnt[4]+cnt[3]*(cnt[0]-1)+cnt[2]*(cnt[1]-1)+cnt[1]*(cnt[1]-1)*(cnt[0]-2)/2;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

typedef long long ll; //64bit型
using namespace std;
const ll INF = 1LL << 20;

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

int main()
{
        int a, b, c, d, e, k;
        cin >> a >> b >> c >> d >> e >> k;
        string ans;
        ans = (e - a > k ? ":(" : "Yay!");
        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
string format(int x){
	stringstream ss ; 
	ss << x ; 
	string s ; 
	ss >> s ; 
	while((int)s.size()<6){
		s = "0" + s ; 
	}
	return s ; 
}
int main(){
    fastio
    int n , m ; 
    cin >> n >> m ; 
    vector<int> v[n+1] ; 
    vector<pair<int,int> > vp(m) ; 
    for(int i=0;i<m;i++){
    	int p , y ; 
    	cin >> p >> y ; 
    	vp[i] = {p,y} ; 
    	v[p].push_back(y) ; 
    }
    for(int i=1;i<=n;i++){
    	sort(v[i].begin(),v[i].end()) ; 
    }
    for(int i=0;i<m;i++){
    	int index = lower_bound(v[vp[i].first].begin(), v[vp[i].first].end(),vp[i].second) - v[vp[i].first].begin() ; 
    	index++ ; 
    	cout << format(vp[i].first) + format(index) << endl;
    }
    return 0 ;
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int mINF = 1e9;
const int MOD = 1e9+7;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int d,g;cin >> d >> g;
    vector<int> p(d);
    vector<int> c(d);
    rep(i,d)cin >> p[i] >> c[i];
    
    int ans = mINF;
    for(int bit=0;bit<(1<<d);bit++){
        int maxBit = 0;
        int num = 0;
        int point = 0;
        for(int i=0;i<d;i++){
            if(bit & (1<<i)){
                point += p[i]*100*(i+1) + c[i];
                num += p[i];
            }else{
                maxBit = i;
            }
        }

        if(point < g){
            int maxBitPoint = 100*(maxBit+1);
            int tmp = (g - point + maxBitPoint - 1) / maxBitPoint;
            if(tmp > p[maxBit])continue;
            num += tmp;
        }
        chmin(ans,num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,d,ans;
  cin>>n>>d;
  int b=2*d+1;
  if(n%b!=0){
    int ans= n/b+1;
    cout <<ans<<endl;
  }
  else{
    int ans= n/b;
    cout <<ans<<endl;
  }
}

Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>

using namespace std;

int main() {
	int i, j, k;
	int n;
	vector<int>a(100000, 99999999);

	cin >> n;

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


	sort(a.begin(), a.end());

	int inde = 0; long long sum = 1, ama = 0;
	if (n % 2 == 0) {

		for (i = 1, inde; i <= n - 1; i+=2) {
			if (a[inde] != i) {
				cout << 0 << endl;

				getchar();
				getchar();
				return 0;
			}

			inde++;

			if (a[inde] != i) {
				cout << 0 << endl;

				getchar();
				getchar();
				return 0;
			}
			inde++;

			sum = sum * 2 % 1000000007;;

			
		}

	}
	else {	//奇数

		if (a[0] != 0) {
			cout << 0 << endl;

			getchar();
			getchar();
			return 0;
		}

		for (i = 2, inde=1; i <= n - 1; i += 2) {
			if (a[inde] != i) {
				cout << 0 << endl;

				getchar();
				getchar();
				return 0;
			}

			inde++;

			if (a[inde] != i) {
				cout << 0 << endl;

				getchar();
				getchar();
				return 0;
			}
			inde++;

			sum = sum * 2 % 1000000007;

		}

	}

		cout << sum << endl;
	





	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <unordered_set>

using namespace std;

int main() {
  int N;
  cin >> N;
  unordered_set<int> S;
  int _S = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    if (a <= 399) {
      S.insert(0);
    } else if (400 <= a && a <= 799) {
      S.insert(1);
    } else if (800 <= a && a <= 1199) {
      S.insert(2);
    } else if (1200 <= a && a <= 1599) {
      S.insert(3);
    } else if (1600 <= a && a <= 1999) {
      S.insert(4);
    } else if (2000 <= a && a <= 2399) {
      S.insert(5);
    } else if (2400 <= a && a <= 2799) {
      S.insert(6);
    } else if (2800 <= a && a <= 3199) {
      S.insert(7);
    } else {
      ++_S;
    }
  }
  printf("%d %d\n", max(1, (int)S.size()), (int)S.size() + _S);
}

Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int a,b,c;
    cin >> a >> b >> c;
    cout << min({a+b,b+c,c+a}) << "\n";
}

Measured memory_bytes: 256
use std::cmp::*;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let s: Vec<i64> = s.trim().chars().map(|c| c.to_digit(10).unwrap() as i64).collect();
    let mut dp = (0, 1_000_000_000);// carry あり、なし
    for &d in s.iter().rev() {
        let mut next = (std::i64::MAX, std::i64::MAX);
        for &k in [0, d, d + 1].iter() {
            if k >= d {
                next.0 = min(next.0, k + k - d + dp.0);
                if k > d {
                    next.0 = min(next.0, k + k - d - 1 + dp.1);
                } else {
                    next.1 = min(next.1, k + 10 + k - d - 1 + dp.1);
                }
            } else {
                next.1 = min(next.1, k + 10 + k - d + dp.0);
                next.1 = min(next.1, k + 10 + k - d - 1 + dp.1);
            }
        }
        dp = next;
    }
    let ans = min(dp.0, dp.1 + 1);
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 14588
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;

bool binary_search(vector<int> v, int kay, bool is_sorted){
    if (!is_sorted) sort(ALL(v));

    int left = 0;
    int right = SZ(v);
    int mid;
    while(left < right){
        mid = (left + right)/2;
        if (v[mid] == kay) return true;
        else if (kay < v[mid]) right = mid;
        else left = mid+1; 
    }
    return false;
}

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

    int n;
    cin >> n;

    vector<int> v;
    int t;
    REP(_, n){cin >> t; v.PB(t);}

    cin >> n;
    int count = 0;
    REP(_, n){
        cin >> t;
        if (binary_search(v, t, true)) count++;
    }

    cout << count << endl;
}


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

def z_algo(S):
    N = len(S)
    LCPs = [0]*N
    i = 1 ## iから何文字一致してるか調べる
    j = 0
    LCPs[0] = N
    while i < N:
        while i+j < N and S[j] == S[i+j]:
            j += 1
        if j == 0:
            i += 1
            continue
        LCPs[i] = j
        k = 1
        while k+i < N and k+LCPs[k] < j:
            LCPs[i+k] = LCPs[k]
            k += 1
        i += k
        j -= k
    return LCPs

def solve(N: int, S: str):
    answer = 0
    for i in range(N):
        LCP = z_algo(S[i:])
        for j in range(len(LCP)):
            # jの長さまでなら重ならない
            a = min(j,LCP[j])
            answer = max(answer,a)
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 48476
using System;

namespace AOJ0032
{
    class Program
    {
        static void Main(string[] args)
        {
            int countRec = 0;
            int countLoz = 0;

            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;

                string[] num = input.Split(',');
                int X = int.Parse(num[0]);
                int Y = int.Parse(num[1]);
                int Z = int.Parse(num[2]);
                
                if (X == Y) countLoz++;
                if (X * X + Y * Y == Z * Z) countRec++;
            }

            Console.WriteLine(countRec);
            Console.WriteLine(countLoz);
        }
    }
}

Measured memory_bytes: 9128
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    private static final int MOD = 1000000007;

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int k = scanner.nextInt();
        long p = (long) k * (k - 1) / 2 % MOD;
        int[] a = new int[n];
        for (int i = 0; i < n; ++i)
            a[i] = scanner.nextInt();
        long ans = 0;
        for (int i = 0; i < n; ++i) {
            long less = 0;
            long reverse = 0;
            for (int j = 0; j < i; ++j) {
                if (a[j] < a[i])
                    ++less;
            }
            for (int j = i + 1; j < n; ++j) {
                if (a[j] < a[i]) {
                    ++less;
                    ++reverse;
                }
            }
            ans = (ans + less * p % MOD + reverse * k % MOD) % MOD;

        }
        writer.println(ans);
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        private void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        private char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        private String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        private int nextInt() {
            return Integer.valueOf(next());
        }

        private long nextLong() {
            return Long.valueOf(next());
        }

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

Measured memory_bytes: 24276
import java.util.*;

public class Main {

	public static void main (String[] args)
	{
		Scanner sc = new Scanner (System.in);
		int[] A= new int[2];
		int[] B  = new int[2];
		int max_low=0;
		int min_high=0;
		
		    A[0] = sc.nextInt();
	        A[1] = sc.nextInt();
	        B[0]= sc.nextInt();
	        B[1] = sc.nextInt();
		
		
		max_low=Math.max(A[0],B[0]);
		min_high= Math.min(A[1],B[1]);
		
		if (max_low>min_high)
			System.out.println("0");
		
		else
			System.out.println(min_high-max_low);
		
		
	}
}


Measured memory_bytes: 35600
def main():
    Q = int(input())
    L = [0 for _ in range(Q)]
    R = [0 for _ in range(Q)]
    for i in range(Q):
        L[i], R[i] = map(int, input().split())

    N = 100000
    sosu = [1 for _ in range(N)]
    sosu[0] = 0
    for i in range(1,int(N**0.5)):
        k = i+1
        if sosu[i] == 1:
            j = k + k
            while j <= N:
                sosu[j-1] = 0
                j = j+k
    like = [0 for _ in range(N)]
    for i in range(2, N, 2):
        if sosu[i]==1 and sosu[(i+2)//2-1]==1:
            like[i] = 1
    like_wa = [0 for _ in range(N+1)]
    for i in range(N):
        like_wa[i+1] = like_wa[i] + like[i]

    for i in range(Q):
        print(like_wa[R[i]] - like_wa[L[i]-1])

if __name__ == '__main__':
    main()



Measured memory_bytes: 16336
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner yomi = new Scanner(System.in);
        int a = yomi.nextInt();
        int b = yomi.nextInt();
        int c = yomi.nextInt();
        int d = a-b;
        if (d>=c){
            System.out.println(0);
            }else System.out.println(c-d);
        }

    }

Measured memory_bytes: 23892
N = int(input())
xy = []
x = []
y = []
for i in range(N):
  xi,yi = map(int,input().split())
  xy.append([xi,yi])
  x.append(xi)
  y.append(yi)

res = []
count = 0
for i in range(N):
  for j in range(i,N):
#コストの和の最小値を求める
#これ以上進めない点が何個あるか数えれば良い
    p = x[i] - x[j]
    q = y[i] - y[j]
    count = 0
    for item in xy:
      if [item[0]+p,item[1]+q] not in xy:
        count += 1
    if count != 0: res.append(count)

if res == []:
  res.append(1)

print(min(res))




Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  vector<ll> b(n),c;
  b=a;
  reverse(b.begin(),b.end());
  ll d=0;
  for(int i=n/2-1;i>=0;i--){
    if(i%2==0)
      c.push_back(a.at(i));
    else
      c.push_back(b.at(i));
  }
  for(int i=0;i<n/2;i++){
    if(i%2==0)
      c.push_back(b.at(i));
    else
      c.push_back(a.at(i));
  }
  if(n%2==1){
    if(abs(c.front()-a.at(n/2))>abs(c.back()-a.at(n/2)))
      c.insert(c.begin(),a.at(n/2));
    else
      c.push_back(a.at(n/2));
  }
  for(int i=1;i<n;i++){
    d+=abs(c.at(i)-c.at(i-1));
  }
  cout<<d;
}

Measured memory_bytes: 2936
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = 3;
        //入力の格納
        int[]a = new int[N];
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }
        sc.close();
        //公約数の格納リスト
        ArrayList<Integer> list = new ArrayList<Integer>();
        //1<=Aより1から
        // for(int i = 1; i <= 100; i++){
        //     //A、Bがiで割り切れたとき＝公約数の時
        //     if((a[0] % i == 0) && (a[1] % i == 0)){
        //         list.add(i);
        //     }
        // }
        //何番目に大きいものなので上から回す(降順で格納）
        for(int i = 100; 1 <= i; i--){
            //A、Bがiで割り切れたとき＝公約数の時
            if((a[0] % i == 0) && (a[1] % i == 0)){
                list.add(i);
            }
        }
        //get(a)=a番目の要素なので1引いて合わせる
        System.out.println(list.get(a[2] - 1));
    }
}

Measured memory_bytes: 21844
#include <stdio.h>

int main(){
  int count[4][4][10];
  int n,b,f,r,v;
  int i,j,k;
  for(i=0;i<4;i++)
    {
      for(j=0;j<3;j++)
	{
	  for(k=0;k<10;k++)
	    {	  
	      count[i][j][k] = 0;
	    }
	}
    }
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d%d%d%d",&b,&f,&r,&v);    
      count[b-1][f-1][r-1]+=v;
    }
  
  for(i=0;i<4;i++)
    {
      for(j=0;j<3;j++)
	{
	  for(k=0;k<10;k++)
	    {	  
	      printf(" %d",count[i][j][k]);
	    }
	  
	  printf("\n");
	}
      if(i != 3)
	{
	  printf("####################\n");
	}
      
    }
  return 0;
}

Measured memory_bytes: 612
n=int(input())
A=list(map(int,input().split()))
r=[]
def f(s,k):
    if k>=0:
        global r
        r+=[s]
        f(s+A[k-1],k-1)
        f(s,k-1)
f(0,n)
input()
for e in map(int,input().split()):print(['no','yes'][e in r])


Measured memory_bytes: 51252
#include <iostream>
#include <list>
#include <vector>

#define rep(i, n) for(int i = 0; i < n; i++)
#define range(min, x, max) ((min <= x) && (x <= max))

using namespace std;

int main(void)
{
    int n = 0; cin >> n;

    list<double> ls;

    double tmp = 0;

    rep(i, n) {
        cin >> tmp;
        ls.push_front(tmp);
    }

    ls.sort();

    while(ls.size() != 1) {
        tmp = ls.front(); ls.pop_front();
        ls.front() = (ls.front() + tmp) / 2.0;
    }

    cout << ls.front() << endl;

    return 0;
}


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

using namespace std;
typedef long long int ll;

#define INF (1e9)

int main() {
    int a[26] = {};
    int b[26] = {};
    string S, T;
    cin >> S >> T;

    for (int i = 0; i < S.size(); i++) {
        if (a[S[i] - 'a'] == 0) {
            a[S[i] - 'a'] = T[i] - 'a' + 1;
        } else {
            if (a[S[i] - 'a'] != T[i] - 'a' + 1) {
                cout << "No" << endl;
                return 0;
            }
        }
        if (b[T[i] - 'a'] == 0) {
            b[T[i] - 'a'] = S[i] - 'a' + 1;
        } else {
            if (b[T[i] - 'a'] != S[i] - 'a' + 1) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

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


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int> (m, 0));
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
    }
  }

  int rtn = INF;
  for (int bit = 0; bit < (1 << n); ++bit) {
    int rtnCst = 0;
    vector<int> rikai(m, 0);
    for (int i = 0; i < n; ++i) {
      if ((bit >> i) & 1) {
        rtnCst += c[i];
        for (int j = 0; j < m; ++j) {
          rikai[j] += a[i][j];
        } 
      }
    }
    bool allok = true;
    for (int k = 0; k < m; ++k)
      if (rikai[k] < x) allok = false;
    if (allok) rtn = min(rtn, rtnCst);
  }
  if (rtn == INF) cout << "-1\n";
  else cout << rtn << endl;
}


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

int main() {
  int N, A, ans;
  ans = 30;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> A;
    for (int j = 0; j < 30; j++) {
      if (A % 2 == 0) {
        A /= 2;
      }
      else if (j < ans) {
        ans = j;
        break;
      }
    }
  }
  
  cout << ans << endl;
        
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<functional>
#include<iterator>
#include<math.h>

using namespace std;

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

	int n,h;
	cin >> n >> h;
	
	int a, max_a = 0, b[n];
	for(int i=0;i<n;i++){
		cin >> a >> b[i];
		if(a > max_a) max_a = a;
	}
	sort(b, b+n, greater<int>());
	
	int ans=0;
	for(int i=0; b[i] >= max_a && h > 0 && i < n; i++){
		h -= b[i];
		ans++;
	}
	if(h > 0){
		ans += h / max_a;
		if(h%max_a != 0) ans++;
	}
	cout << ans << "\n";

	return 0;
}

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

int main() {
  long long n,a,b;
  cin >> n >> a >> b;
  
  cout << min(n%(a+b),a) + ((n-(n%(a+b)))/(a+b))*a << endl;
  
	return 0;
}


Measured memory_bytes: 256