akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int factorial(int a[],int n);

int factorial(int a[],int n){
    int ans=0,nn=1;
    
    for(int i=2;i<=n-1;i++){nn*=i;}
    
    for(int i=0;i<n-1;i++){
        int count=0;
        for(int j=i+1;j<n;j++){
            if(a[i]<a[j]){count++;}
        }
        ans+=count*nn;
        nn=nn/(n-1-i);
    }
    return ans;
}

int main(void){
    int n,p[8],q[8];
    
    scanf("%d",&n);
    for(int i=0;i<n;i++){scanf("%d",&p[i]);}
    for(int i=0;i<n;i++){scanf("%d",&q[i]);}
    
    printf("%d",abs(factorial(q,n)-factorial(p,n)));
    
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tuple<ll,ll,ll> tll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,c;
  cin>>n>>c;
  vll x(n),v(n);
  rep(i,n) cin>>x[i]>>v[i];
  vll F(n,0),E(n,0);
  F[0]=v[0];
  rep(i,n){
    if(i==0) continue;
    F[i]+=F[i-1]+v[i];
  }
  E[n-1]=v[n-1];
  for(int i=n-2;i>=0;i--){
    E[i]+=E[i+1]+v[i];
  }
  rep(i,n) F[i]-=x[i];
  rep(i,n) E[i]-=c-x[i];
  ll ans=0;
  multiset<pll> fque;
  multiset<pll> eque;
  eque.insert(pll(0,0));fque.insert(pll(0,0));
  rep(i,n){
    eque.insert(pll(E[i],c-x[i]));
  }
  rep(i,n){
    pll me=*rbegin(eque);
    pll mf=*rbegin(fque);
    ll co=min(me.S,mf.S);
    chmax(ans,me.F+mf.F-co);
    fque.insert(pll(F[i],x[i]));
    eque.erase(eque.find(pll(E[i],c-x[i])));
  }
  chmax(ans,F[n-1]);
  COUT(ans);
}


Measured memory_bytes: 12760
/* Filename: ABC075C.java
 * Author: Mushiyo
 */
import java.util.Scanner;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		while(input.hasNext()){
			int N = input.nextInt();
			int M = input.nextInt();
			int[][] graph = new int[N][N];
			
			for(int i = 0; i < M; ++i){
				int a = input.nextInt() - 1;
				int b = input.nextInt() - 1;
				graph[a][b] = 1;
				graph[b][a] = 1;
			}
			
			int countBridge = 0;
			for(int i = 0; i < graph.length; ++i){
				for(int j = i + 1; j < graph[i].length; ++j){
					if(graph[i][j] == 1){
						graph[i][j] = 0;
						graph[j][i] = 0;
						
						boolean[] isVisited = new boolean[N];
						DFS(i, graph, isVisited);
						
						for(int v = 0; v < isVisited.length; ++v){
							if(isVisited[v] == false){
								++countBridge;
								break;
							}
						}
						
						graph[i][j] = 1;
						graph[j][i] = 1;
					}
				}
			}
			
			System.out.println(countBridge);
		}
	}

	private static void DFS(int current, int[][] graph, boolean[] isVisited){
		isVisited[current] = true;
		
		for(int i = 0; i < graph[current].length; ++i){
			if(graph[current][i] == 1){
				if(isVisited[i] == false){
					DFS(i, graph, isVisited);
				}
			}
		}
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

int a[101];

int main(){
	int n,l;
	scanf("%d %d",&n,&l);
	int sum=0;
	int minn=10000,x,y;
	for(int i=1;i<=n;i++){
		a[i]=l+i-1;
		sum+=a[i];
		x=abs(a[i]);
		if(x<minn){
			minn=x;
			y=i;
		}
//		printf("%d\n",minn);
	}
	sum-=a[y];
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

    As = sorted(A)

    res = 0

    for i in range(1,N):
        res += As[N-1-i//2]

    print(res)



main()


Measured memory_bytes: 31464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }



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

	int n; cin >> n;
	vector<int> six, nine;

	int tmp = 1;
	while(tmp <= n){
		six.push_back(tmp);
		tmp *= 6;
	}

	tmp = 1;
	while(tmp <= n){
		nine.push_back(tmp);
		tmp *= 9;
	}

	reverse(six.begin(), six.end());
	reverse(nine.begin(), nine.end());

	int ans = 1e9;
	for(int left=0; left<=n; ++left){
		int money = left;
		int cnt = 0;
		for(int i=0; i<six.size(); ++i){
			cnt += money/six[i];
			money %= six[i];
		}
		money = n-left;
		for(int i=0; i<nine.size(); ++i){
			cnt += money/nine[i];
			money %= nine[i];
		}
		chmin(ans, cnt);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a,b;
  cin >> a >>b;
  if( a == 'H'){
    cout << b;
  }
  if( a == 'D'){
    if(b == 'H'){
      cout << 'D';
    }
    else{
      cout << 'H';
    }
  }
    
}

Measured memory_bytes: 256
def pop_back_gen(nums)
  Fiber.new do
    nums.reverse_each do |i|
      Fiber.yield(i)
    end
  end
end

def pop_front_gen(nums)
  Fiber.new do
    nums.each do |i|
      Fiber.yield(i)
    end
  end
end

def main
  n = gets.chomp.to_i

  nums = Array.new(n)
  n.times do |i|
    nums[i] = gets.chomp.to_i
  end
  # puts nums

  nums.sort!

  # 先頭と末尾から値を取り出すgenerator
  front_gen = pop_front_gen(nums)
  back_gen = pop_back_gen(nums)

  # 中央値からスタート
  last_num = nums[n / 2]

  # 先頭（最小値）から取るパターン
  len_min_first = 0
  0.upto(n-2) do |i|
    cur_num = if i.even?
                # 前を取る
                front_gen.resume
              else
                # 後ろを取る
                back_gen.resume
              end
    len_min_first += (last_num - cur_num).abs
    last_num = cur_num
  end

  front_gen = pop_front_gen(nums)
  back_gen = pop_back_gen(nums)

  # 中央値からスタート
  last_num = nums[n / 2]

  # 末尾（最大値）から取るパターン
  len_max_first = 0
  1.upto(n-1) do |i|
    cur_num = if i.even?
                # 前を取る
                front_gen.resume
              else
                # 後ろを取る
                back_gen.resume
              end
    len_max_first += (last_num - cur_num).abs
    last_num = cur_num
  end

  puts [len_min_first, len_max_first].max
end

if __FILE__ == $0
  main
end

Measured memory_bytes: 5480
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
vector<int>  v[505];
bool cans[505];
bool can[505][505];
int a[505][505];
int main(){
    int n,m,q;
    scanf("%d %d %d",&n,&m,&q);
    //cin>>n>>m>>q;
    int t1,t2;
    for(int i=0;i<m;i++){
        scanf("%d %d",&t1,&t2);
        v[t1].push_back(t2);
    }
    for(int i=0;i<q;i++){
        scanf("%d %d",&t1,&t2);
        int sum=0;
        if(can[t1][t2])
            sum=a[t1][t2];
        else{
            for(int k=t1;k<=t2;k++){
                //int l=ma[k].size();
                if(!cans[k]){
                    sort(v[k].begin(),v[k].end());
                    cans[k]=1;
                }
                vector<int>::iterator up=upper_bound (v[k].begin(), v[k].end(), t2);
                sum+=(up- v[k].begin());
            }
            a[t1][t2]=sum;
            can[t1][t2]=1;
        }

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

    }
}

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

using namespace std;

int h,w;
int dist[1005][1005];
int dx[]={-1,0,1,0},dy[]={0,1,0,-1};

bool bounds(pair <int,int> u){
    if(u.first < 0 || u.first >=h){
        return 0;
    }
    if(u.second < 0 || u.second >=w){
        return 0;
    }
    return 1;
}

int main(){
    memset(dist,0x3f,sizeof(dist));
    cin >> h >> w;
    queue<pair <int,int>> q;
    for(int i=0;i<h;i++){
        string s;
        cin >> s;
        for(int j=0;j<w;j++){
            if(s[j]=='#'){
                q.emplace(i,j);
                dist[i][j]=0;
            }
        }
    }
    while(!q.empty()){
        auto u = q.front();
        q.pop();
        //cout << u.first << " " << u.second << endl;
        for(int i=0;i<4;i++){
            pair <int,int> v;
            v.first=u.first+dx[i];
            v.second=u.second+dy[i];
            if(bounds(v) && dist[v.first][v.second]>1e5){
                dist[v.first][v.second]=dist[u.first][u.second]+1;
                q.push(v);
            }
        }
    }
    int ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ans=max(ans,dist[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12432
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		sc.close();
		int l = N.length();
		int ans = 0;
		for(int i=0;i<l;++i){
			ans += N.charAt(i) - '0';
		}
		if(ans%9==0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
}



Measured memory_bytes: 40164
#include<iostream>
#include<string>
#include<cmath>
int main(){
  std::string input;
  std::cin>>input;
  int assuming_b{};//begins zero!
  int assuming_w{};
  for (int idx{};idx<input.size();++idx){
    switch(idx%2){
    case 0:
      if (input[idx]=='0')
	++assuming_w;
      else
	++assuming_b;
      break;
    case 1:
      if (input[idx]=='1')
	++assuming_w;
      else
	++assuming_b;
    }
  }
  std::cout<<std::min(assuming_w,assuming_b);
  return 0;
}


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

#define int long long 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define N 100005

const int  mod =1e9+7;
int n,k;

vector<vector<int> > mulitply(vector<vector<int> > A,vector<vector<int> > B){
    vector<vector<int> > res(n,vector<int> (n,0));

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int x=0;x<n;x++){
                res[i][j]=(res[i][j]+A[i][x]*B[x][j]) % mod;
            }
        }
    }
    return res;
}
vector<vector<int> > power(vector<vector<int> > mat,int exp){
    if(exp==1) return mat;

    vector<vector<int> > res=power(mat,exp/2);

    if(exp&1) return mulitply(mat,mulitply(res,res));

    return mulitply(res,res);

}

int solve(vector<vector<int> > adj,int k){

    vector<vector<int> > res=power(adj,k);
    int ans=0;
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) ans=(ans+res[i][j]) % mod;
    }
    return ans;
}
int32_t main(){
    cin>>n>>k;
    //chehra tera chand jesa baaki sab taare ni
    vector<vector<int> >adj(n,vector<int> (n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) cin>>adj[i][j];
    }
    cout<<solve(adj,k);
    return 0;
}

Measured memory_bytes: 1664
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
#define INT_MAX 2147483647
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)	
using namespace std;


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


int main() {
	int INF = INT_MAX;
	int n;
	cin >> n;
	vector<int> a(n);

	rep(i, n) {
		cin >> a[i];
	}

	int count_min = INF;

	rep(i, n) {

		int count = 0;
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			count++;
		}
		if (count < count_min) {
			count_min = count;
		}
	}

	cout << count_min << endl;
}

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

#define int long long

int32_t main(){
	int n;
	cin >> n; 
	priority_queue<pair<int,pair<int,int>>> pq ;
	int a[n] ;
	for(int i = 0 ; i < n ; i++){
		cin >> a[i] ;
	}
	sort(a,a+n,greater<int>()) ;
	pq.push({a[1] , {a[0] , a[1]}}) ;
	pq.push({a[1] , {a[0] , a[1]}}) ;
	int ans = a[0] ;
	for(int i = 2 ; i < n ; i++){
		auto x = pq.top() ;
		pq.pop() ;
		ans += x.first ;
		pq.push({a[i] , {a[i] , x.second.first}}) ;
		pq.push({a[i] , {a[i] , x.second.second}}) ;
	}
	cout << ans ;
	return 0 ;
}



Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int a, b;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> a >> b;
	if (a <= 0 && 0 <= b) cout << "Zero" << endl;
	else if (b < 0 && b-a+1 & 1) cout << "Negative" << endl;
	else cout << "Positive" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }
ll MOD = 1000000007;

int main(void){
  long double n,k; cin >> n >> k;
  long double ans = 0;
  for(long double i = 1; i <= n; i++){
    long double l = 0;
    while(1){
      if(i * pow(2.,l) >= k){
        break;
      }
      else{
        l++;
      }
    }
    ans += (1./n)*pow(1./2.,l);
  }
  cout << setprecision(19);
  cout << ans << endl;
  return 0;
}


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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   200005
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/






ll a[1000006];


int main()
{
    ll n,i,Max=0,k=0;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n-1;i++)
    {
        if(a[i]>=a[i+1])
            k++;
        else
        {
            if(k>Max)
                Max=k;
            k=0;
        }
    }
    if(k>Max)
        Max=k;
    cout<<Max<<endl;
	return 0;
}
































Measured memory_bytes: 1024
// AOJ CGL_5_A Closest Pair
// 2018.5.3 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef struct { double x, y; } PP;

#define INF     1e8
#define EPS     1e-8

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

double dbl()
{
	int minus = 0;
	double x, y;
	int n = 0, c = gc();
	if (c == '-') minus = 1, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');

	if (c == '.') {
		x = 0;
		y = 1, c = gc();
		do y *= 0.1, x += y * (c & 0xf), c = gc(); while (c >= '0');
		x += n;
	} else x = n;
	if (minus) x = -x;
	return x;
}

PP L[100002], R[100002];

int dcmp(double x) { if (fabs(x) < EPS) return 0; return x <= 0 ? -1 : 1; }
int cmp(PP *a, PP *b) { return dcmp(a->x - b->x); }

void merge(PP *p, int low, int mid, int high)
{
	int n1, n2, i, j, k;

	n1 = mid-low, n2 = high-mid;
	memcpy(L, p+low, sizeof(PP)*n1);
	memcpy(R, p+mid, sizeof(PP)*n2);
	L[n1].y = R[n2].y = INF;

	i = 0, j = 0;
	for (k = low; k < high; k++) {
		if (L[i].y <= R[j].y) p[k] = L[i++];
		else                  p[k] = R[j++];
	}
}

double closest_pair(int n, PP *p)
{
	int m, i, j, t;
	double ans, d, x;

	if(n <= 1) return INF;
	m = n >> 1;
	x = p[m].x;
	ans = closest_pair(m, p);
	d   = closest_pair(n-m, p+m);
	if (d < ans) ans = d;
	merge(p, 0, m, n);

	t = 0;
	for (i = 0; i < n; i++) {
		if (fabs(p[i].x - x) >= ans) continue;

		for (j = 0; j < t; j++) {
			double dx = p[i].x - L[t-1-j].x;
			double dy = p[i].y - L[t-1-j].y;
			if (dy >= ans) break;
			d = hypot(dx, dy);
			if (d < ans) ans = d;
		}
		L[t++] = p[i];
	}
	return ans;
}

PP p[100002];

int main()
{
	int n, i;

	n = in();
	for (i = 0; i < n; i++) p[i].x = dbl(), p[i].y = dbl();
	qsort(p, n, sizeof(PP), cmp);
	printf("%.10lf\n", closest_pair(n, p));
	return 0;
}



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

int n, x[1000010], a[1000010], b[15][1000010];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%1d", &x[i]);
    }
    if (n <= 14) {
        for (int i = 1; i <= n; i++) {
            b[1][i] = x[i];
        }
        for (int i = 2; i <= n; i++) {
            for (int j = 1; j <= n - i + 1; j++) {
                b[i][j] = abs(b[i - 1][j] - b[i - 1][j + 1]);
            }
        }
        printf("%d\n", b[n][1]), exit(0);
    }
    for (int i = 1; i <= n; i++) {
        b[1][i] = x[i];
    }
    for (int i = 2; i <= 14; i++) {
        for (int j = 1; j <= n - i + 1; j++) {
            b[i][j] = abs(b[i - 1][j] - b[i - 1][j + 1]);
        }
    }
    n -= 13;
    bool flag = 1;
    for (int i = 1; i <= n; i++) {
        flag &= (b[14][i] == 0 || b[14][i] == 2);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (flag && b[14][i] == 2) b[14][i] = 1;
        if (((n - 1) & (i - 1)) == (i - 1)) (ans += b[14][i]) %= 2;
    }
    if (flag && ans) ans = 2;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 62592
#include<bits/stdc++.h>
#define int long long
#define M 1000000007
#define deb(x) cout<<#x<<'='<<x<<endl
using namespace std;
const int N=1e6;
signed main()
{
    int n,m;
    cin>>n>>m;
    int a[m];
    int sum=0;
    for(int i=0; i<m; i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(n>=sum)
        cout<<(n-sum)<<endl;
    else
        cout<<-1<<endl;
}

Measured memory_bytes: 3712
import sys
import math
input = sys.stdin.readline
N,D = map(int, input().split())
ans = 0
point = [[] * N for _ in range(N)]
for i in range(N):
	point[i] = list(map(int, input().split()))

for i in range(N):
	for j in range(i+1,N):
		tmp = 0
		for k in range(D):
			tmp += (point[i][k]-point[j][k])*(point[i][k]-point[j][k])
		tmp = math.sqrt(tmp)
		if tmp.is_integer():
			ans += 1
print(ans)


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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e3) + 17;

int n, m;
string s[MAXN];
ll dp[MAXN][MAXN];

bool read() {
    if (!(cin >> n >> m))
        return false;

    forn (i, n)
        cin >> s[i];

    return true;
}

void solve() {
    dp[1][1] = 1;

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            if (s[i - 1][j - 1] != '#') {
                dp[i][j] += dp[i - 1][j];
                dp[i][j] += dp[i][j - 1];
                dp[i][j] %= INF;
            }

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

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



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

const long long INF = 0x3f3f3f3f3f3f3f3f;

long long dp[5010], ndp[5010];
int a[5010], pos[5010];

void chmin(long long &a, long long b){a = a < b ? a : b;}

struct Segment_tree{
	long long minj[20010], lazy[20010];
	void pushup(int now){
		minj[now] = min(minj[now << 1], minj[now << 1 | 1]);
	}
	void pushdown(int now){
		if (lazy[now] == INF) return ;
		long long v = lazy[now]; lazy[now] = INF;
		chmin(minj[now << 1], v);
		chmin(lazy[now << 1], v);
		chmin(minj[now << 1 | 1], v);
		chmin(lazy[now << 1 | 1], v);
	}
	void Build(int now, int l, int r){
		memset(minj, 0x3f, sizeof(minj));
		memset(lazy, 0x3f, sizeof(lazy));
	}
	void Update(int now, int l, int r, int L, int R, long long x){
		if (l == L && r == R){
			chmin(minj[now], x);
			chmin(lazy[now], x);
			return ;
		}
		pushdown(now);
		int mid = l + r >> 1;
		if (R <= mid) Update(now << 1, l, mid, L, R, x);
		else if (L > mid) Update(now << 1 | 1, mid + 1, r, L, R, x);
		else Update(now << 1, l, mid, L, mid, x), Update(now << 1 | 1, mid + 1, r, mid + 1, R, x);
		pushup(now);
	}
	void get_dp(int now, int l, int r){
		if (l == r){
			dp[l] = minj[now];
			return ;
		}
		pushdown(now);
		int mid = l + r >> 1;
		get_dp(now << 1, l, mid), get_dp(now << 1 | 1, mid + 1, r);
	}
}seg;

int main(){
	int n, A, B;
	scanf("%d%d%d", &n, &A, &B);
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		pos[a[i]] = i + 1;
	}
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	for (register int i = 1; i <= n; i++){
		int x = pos[i];
		long long minj = INF;
		for (register int j = 0; j <= n; j++){
			minj = min(minj, dp[j]);
			dp[j] = minj + (j < x ? B : j > x ? A : 0);
		}
	}
	long long ans = INF;
	for (int i = 0; i <= n; i++){
		chmin(ans, dp[i]);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define DEFAULT LL ans=solve();\
 	if(ans==NONE){\
 	}else{\
 		cout << ans << endl;\
 	}
#define YESNO three(solve(),OUT(YES),OUT(NO))
#define YesNo three(solve(),OUT(Yes),OUT(No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b-1);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
//const int SIZE1 = 5e5s + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE2;
const int MAPSIZE = 40;
//const LL p = 7 + 1e9;
const LL INF = 1LL << 14;
const long double EPS = 1e-7;
const LL NONE=-2;
typedef pair<ld, ut> pld;
ut N, M, K, Q, D, H, W,R;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
LL A[SIZE]={0,3,2,1},B[SIZE]={0,3,2,1};

LL solve(){
	LL a,b;
	cin >> a >> b;
	LL ans=A[a]+B[b];
	if(a==1 and b==1) ans=10;
	ans*=100000;
	return ans;
}
 signed main() {
 
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	string s;
	LL T;
	DEFAULT;
	
//	YesNo;
//	YESNO;
//	three(solve(),OUT("First"),OUT("Second"));
	//cin >> N;
	return 0;
 
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int d(long n){
  long i;
  for(i=0;n>0;i++){
      n = n/10;
  }
  return i;
}

int main(){
  int N;
  string S;
  cin >> N >> S;
  if(N%2==1){
      cout << "No";
  }else{
      for(int i=0;i<N/2;i++){
          if(S[i]==S[N/2+i]){
          }else{
              cout << "No";
              break;
          }
          if(i==N/2-1){
              cout << "Yes";
          }
      }
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
main()
{
   string s;
   cin >> s;
   int cnt = 0;
   int i = 0;
   int j = s.size() - 1;
   while(i <= j)
   {
       if(s[i] != s[j])
        cnt++;
        i++;
        j--;
   }
   
   cout << cnt;
   
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxc = 33;
struct Program {
    int s,t,c;
    explicit Program(const int s, const int t, const int c)
        : s(s),t(t),c(c) {}
    bool operator< (const Program& rhs) const
    { return s < rhs.s; }
};
vector<Program> A;
int N,C;

bool P(const int mid)
{
    map<int,int> M;
    const int n = A.size();
    FOR(i,0,n) {
        set<int> remove;
        FOR_ALL(m,M) {
            const int c = m->first;
            const int j = m->second;
            if (A[j].t+0.5 < A[i].s)
                remove.insert(c);
        }
        FOR_ALL(c,remove)
            M.erase(*c);
        M[A[i].c] = i;
        if (M.size() > mid)
            return false;
    }
    return true;
}

int main()
{
    while (cin >> N >> C) {
        A.clear();
        FOR(i,0,N) {
            int s,t,c; cin >> s >> t >> c;
            A.push_back(Program(s,t,c));
        }
        sort(ALL(A));
        int lo = 1, hi = C;
        while (lo < hi) {
            const int mid = (lo+hi)/2;
            if (P(mid))
                hi = mid;
            else
                lo = mid + 1;
        }
        cout << lo << endl;
    }
    return 0;
}


Measured memory_bytes: 2040
import sys

n = int(input())
a = list(map(int, input().split()))

a.sort()
answer = a[0]
for i in range(1, n):
    if a[i] % a[0] == 0: continue

    x, y = a[0], a[i] # x < y
    while x != 0:
        x, y = y % x, x
    answer = min(answer, y)

print(answer)



Measured memory_bytes: 14252
s = []
for _ in range(3):
    x = input().replace('a', '0').replace('b', '1').replace('c', '2')
    s.append(str(x))
    
now = 0
while True:
    if len(s[now]) == 0:
        if now == 0:
            print('A')
        if now == 1:
            print('B')   
        if now == 2:
            print('C')
        break
        
    after = int(s[now][0])
    s[now] =  s[now][1:]
    now = after

Measured memory_bytes: 3064
//package atcoder.dpContest;

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
//        try {
//            FastScanner in = new FastScanner(new FileInputStream("src/input.in"));
//            PrintWriter out = new PrintWriter(new FileOutputStream("src/output.out"));
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        solve(1, in, out);

//        }
//        catch (IOException e) {
//            e.printStackTrace();
//        }
    }

    private static void solve(int q, FastScanner in, PrintWriter out) {
        for(int qq = 0; qq < q; qq++) {
            int n = in.nextInt();
            int[] a = new int[n], b = new int[n], c = new int[n];
            for(int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                b[i] = in.nextInt();
                c[i] = in.nextInt();
            }

            int[][] dp = new int[n][3];
            dp[0][0] = a[0];
            dp[0][1] = b[0];
            dp[0][2] = c[0];

            for(int i = 1; i < n; i++) {
                dp[i][0] = Math.max(dp[i - 1][1], dp[i - 1][2]) + a[i];
                dp[i][1] = Math.max(dp[i - 1][0], dp[i - 1][2]) + b[i];
                dp[i][2] = Math.max(dp[i - 1][0], dp[i - 1][1]) + c[i];
            }
            out.println(Math.max(Math.max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]));
        }
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}




Measured memory_bytes: 49404
using Yorukatsu042.Questions;
using Yorukatsu042.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu042.Questions
{
    /// <summary>
    /// ABC080 B
    /// </summary>
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            if (n % F(n) == 0)
            {
                yield return "Yes";
            }
            else
            {
                yield return "No";
            }
        }

        int F(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }
            return sum;
        }
    }
}


namespace Yorukatsu042
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu042.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu042.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11092
# coding: utf-8

numt = input()
for i in xrange(numt):
    count = 0
    lis = [[0,0]]
    ma = 0
    tmpl = [0,0]
    while True:
        x,y = map(int,raw_input().split())
        tempx = lis[count][0] + x
        tempy = lis[count][1] + y
        count += 1
        if(x == 0 and y == 0):
            for l in lis:
                if(l[0]**2 + l[1]**2 > ma):
                    ma = l[0]**2 + l[1]**2
                    tmpl = l
                elif(l[0]**2 + l[1]**2 == ma):
                    if(tmpl[0] < l[0]):
                        tmpl = l
            print tmpl[0],tmpl[1]
            break
        lis.append([tempx,tempy])
    

Measured memory_bytes: 6260
/*@shutoshsuman99*/
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define pi 3.141592653589
#define pb push_back
#define ld long double
#define rem 1000000007
#define rem1 998244353
#define inf 1e18+1e17
#define F first
#define S second
#define pii pair<long long,long long>
#define p_q priority_queue <ll, vector<ll>, greater<ll> >
#define m_sp multiset <pair <ll,ll> > 
#define el "\n"
#define sp " "
typedef long long ll;
ll Pow(ll x,ll y,ll m) 
{ if (y == 0) return 1; ll p = Pow(x, y/2, m) % m; 
p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m; } 
main()
{ 
	// fast io
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);ll i,j,x; 
	ll n,k,mx=0;
	cin>>n>>k;
	vector <ll> a(n);
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=0;i<=min(n,k);i++)
	{
		for(j=0;j+i<=min(n,k);j++)
		{
			ll sum=0;
			vector <ll> v;
			for(x=0;x<i;x++)
			{
				sum+=a[x];
				if(a[x]<0)
				v.push_back(a[x]);
			}
			for(x=0;x<j;x++)
			{
				sum+=a[n-1-x];
				if(a[n-1-x]<0)
				v.push_back(a[n-1-x]);
			}
			sort(v.begin(),v.end());
			for(x=0;x<k-(i+j)&&x<v.size();x++)
			sum-=v[x];
			//cout<<i<<sp<<j<<sp<<sum<<el;
			mx=max(mx,sum);
		}
	}
	cout<<mx<<el;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int x,y;
    cin >> x >> y;
    int ans = 0;
    if (x == 3)ans += 100000;
    if (y == 3)ans += 100000;
    if (x == 2) ans += 200000;
    if (y == 2)ans += 200000;
    if (x == 1 ) ans += 300000;
    if (y == 1)ans += 300000;
    if (x == 1 and y == 1)ans += 400000;

    cout << ans << endl;
}

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

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

  int ans = 0;
  rep(i, n){
    int count = 0;
    if (i % 2 == 0) continue;
    rep(j, i){
      if (i % j == 0) count++;
    }
    if (count == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main() {FIN
    
    int i, n, a, m = 0;
    cin >> n;
    for (i = 1; i <= n; i++) {
		cin >> a;
		if (a & 1 and i & 1) m++;
	}
	cout << m << "\n";
    
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
struct point{
	double x,y;
};
void func(point a,point b,int cnt);
int n;
const double rad=M_PI*60.0/180.0;
int main(void){
	point a,b;
	cin>>n;
	a.x=0.0;	a.y=0.0;
	b.x=100.0;	b.y=0.0;
	printf("%.8f %.8f\n",a.x,a.y);
	func(a,b,0);
	printf("%.8f %.8f\n",b.x,b.y);
	return 0;
}
void func(point a,point b,int cnt){
	point s,t,u;
	if(n!=0){
		if(cnt<n){
			s.x=(2.0*a.x+1.0*b.x)/3.0;
			s.y=(2.0*a.y+1.0*b.y)/3.0;
			t.x=(1.0*a.x+2.0*b.x)/3.0;
			t.y=(1.0*a.y+2.0*b.y)/3.0;
			u.x=(t.x-s.x)*cos(rad)-(t.y-s.y)*sin(rad)+s.x;
			u.y=(t.x-s.x)*sin(rad)+(t.y-s.y)*cos(rad)+s.y;
			
			func(a,s,cnt+1);
			printf("%.8f %.8f\n",s.x,s.y);
			func(s,u,cnt+1);
			printf("%.8f %.8f\n",u.x,u.y);
			func(u,t,cnt+1);
			printf("%.8f %.8f\n",t.x,t.y);
			func(t,b,cnt+1);
		}
	}
}


Measured memory_bytes: 3228
/**
 * @author: shashankchdhry
 * @made:   2020-04-05 12:33:12 
**/
#include <bits/stdc++.h>

using namespace std;

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

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

    vector<pair<int,int>> students(n), checkpoints(m);
    for (int i = 0; i < n; i++)
        cin >> students[i].first >> students[i].second;
    for (int i = 0; i < m; i++)
        cin >> checkpoints[i].first >> checkpoints[i].second;

    for (int i = 0; i < n; i++)
    {
        int mn = INT_MAX, index = -1;
        int j;
        for (j = 0; j < m; j++)
        {
            int temp = abs(students[i].first - checkpoints[j].first)+abs(students[i].second - checkpoints[j].second);
            if (temp < mn)
            {
                mn = temp;
                index = j;
            }
            else if (temp == mn && checkpoints[j].first < checkpoints[index].first)
                index = j;
        }
        cout << index+1 << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, ans = -INFLL; cin >> n;

    // f[i][j][k], i:店番号, j:曜日, k:時間帯
    vvi f(n, vi(10, 0));
    // 全ての店
    rep(i, n){
        // 全ての曜日と午前・午後
        rep(j, 10){
            cin >> f[i][j];
        }
    }

    // 利益計算用
    vector<vector<ll>> p(n, vector<ll>(11, 0));
    rep(i, n){
        rep(j, 11){
            cin >> p[i][j];
        }
    }

    // ビット全探索
    for(ll bit=1; bit<(1LL<<10); bit++){
        vi run(10, 0);
        vi run_cnt(n, 0);
        // 1~10ビット目のマスク -> お姉ちゃんの営業日を決定
        for(ll mask=0; mask<10; mask++) if(bit&(1LL<<mask)) run[mask] = 1;
        for(ll i=0; i<10; i++){
            // 休業日なら飛ばす
            if(!run[i]) continue;
            // 営業日なら他の店の営業状況を調べる
            for(ll j=0; j<n; j++) if(f[j][i]) run_cnt[j]++;
        }
        // 利益の計算
        ll sum = 0;
        for(ll i=0; i<n; i++) sum += p[i][run_cnt[i]];
        // 最大値の更新
        chmax(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010

int main(){
	IOS;
	ll n;cin>>n;
	ll a[n+1];rep(i,1,n+1)cin>>a[i];
	multiset<ll>s;
	rep(i,1,n+1){
		auto it=s.lower_bound(a[i]);
		if(it!=s.begin()){
			it--,s.erase(it);
		}
		s.insert(a[i]);
	}
	cout<<sz(s);
	
	return 0;
}



Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
const ll mod = 1e9 + 9;
const ll maxn = 2e5 + 10;
const ll mxe = 1e6 + 10;
bool divided[mxe];
vector<int> arr;
map<int, int> occ;
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    arr.resize(n);
    for (auto &i:arr)cin >>i, occ[i]++;
    sort(all(arr));
    ll res = 0;
    for(auto i:arr){
        if(!divided[i] && occ[i] == 1){
            res++;
        }
        if(!divided[i]){
            for(int j = 1; j*i<mxe;j++){
                divided[j*i] = 1;
            }
        }
       
    }
    cout << res << endl;
}

Measured memory_bytes: 14172
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int K, X;
  cin >> K >> X;
  int ma = max(-1000000, X - K) + 1;
  int mb = max(-1000000, X + K) - 1;
  for (int i = ma; i <= mb; ++i) {
    cout << i << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def Main(A,B,C,D):
    while True:
        C -= B
        if C <= 0:
            return "Yes"
        A -= D
        if A <= 0:
            return "No"
        
def main():
    A, B, C, D = map(int, input().split())
    print(Main(A, B, C, D))

if __name__ == '__main__':
    main()

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

const int INF = 1e9;
const ll LINF = 1e18;


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

    if (s == "hi" ||
        s == "hihi" ||
        s == "hihihi" ||
        s == "hihihihi" ||
        s == "hihihihihi")
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256