akhauriyash/Code-Regression huggingface dataset:
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  $a = array_map("intval", explode(" ", trim(fgets(STDIN))));

  $cnt = array_fill(0, $n, 0);
  for($i=0;$i<$n;$i++){
    $cnt[$a[$i]]++;
  }
  if($n % 2 == 1){
    if($cnt[0] != 1){
      echo "0";
      exit;
    }
  }else{
    if($cnt[0] != 0){
      echo "0";
      exit;
    }
  }
  for($i=1;$i<$n;$i++){
    if($n % 2 == 1){
      if($i % 2 == 0){
        if($cnt[$i] !== 2){
          echo "0";
          exit;
        }
      }else{
        if($cnt[$i] !== 0){
          echo "0";
          exit;
        }
      }
    }else{
      if($i % 2 == 1){
        if($cnt[$i] !== 2){
          echo "0";
          exit;
        }
      }else{
        if($cnt[$i] !== 0){
          echo "0";
          exit;
        }
      }
    }
  }

  $p = intdiv($n, 2);
  $ans = 1;
  for($i = 0; $i < $p; $i++){
    $ans *= 2;
    $ans %= 1000000007;
  }
  echo $ans;

Measured memory_bytes: 25848
#coding:utf-8
N=input()
A=map(int,raw_input().split())
A.sort()
E=[False]*N

i=0;j=N-1
while i<j:
    if A[i]!=A[i+1]:
        i+=1
        continue
    if A[j]!=A[j-1]:
        j-=1
        continue
    E[i]=E[j]=True
    i+=1;j-=1
ans=0
for e in E:
    if not e:ans+=1
print(ans)

Measured memory_bytes: 11328
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int CheckInput(char * inputString)
{
    int haveCorrVal = (strncmp(inputString, "ABC", 3) && strncmp(inputString, "ARC", 3));
    if(haveCorrVal == 0)
    {
      return 1;
    }
    else
    {
        printf("Wrong Input \n");
        return 0;
    }
}

void ReadInput(char * inputString)
{
    int corrInput;
    
    //printf("Enter the name of the contest: \n");
    scanf("%s", inputString);
    corrInput = CheckInput(inputString);
    if(corrInput == 0)
    {
        ReadInput(inputString);
    }
}

void PrintOutput(char * inputString)
{
    int isABC = !strncmp(inputString, "ABC", 3);
    if(isABC)
    {
        printf("ARC \n");
    }
    else
    {
        printf("ABC \n");
    }
}


int main(int argc, const char * argv[])
{
    char * inputString = malloc(3 * sizeof(char));
    
    ReadInput(inputString);
    PrintOutput(inputString);
    free(inputString);
    
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i = (int)m; i < (int)n; i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPM(i,m,n) for(int i = (int)m; i >= (int)n; i--)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()
#define greater_queue  priority_queue <ll, vector<ll>, greater<ll> >

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

const int MAX_V = 2001;
vector<int> E[MAX_V];
int n, k;

int bfs_even(int s) {
    int dist[MAX_V];

    queue<int> que;
    fill(dist, dist + MAX_V, INF);
    dist[s] = 0;
    que.push(s);
    while (!que.empty()) {
        int q = que.front();
        que.pop();
        for (auto e : E[q]) {
            if (dist[e] == INF) {
                que.push(e);
                dist[e] = dist[q] + 1;
            } else if (dist[e] > dist[q] + 1) {
                dist[e] = dist[q] + 1;
            }
        }
    }

    int cnt = 0;
    rep2(i, n) if (dist[i] > k / 2) cnt++;
    return cnt;
}

int bfs_odd(int s, int t) {
    int dist[MAX_V];

    queue<int> que;
    fill(dist, dist + MAX_V, INF);
    dist[s] = 0;
    que.push(s);
    while (!que.empty()) {
        int q = que.front();
        que.pop();
        for (auto e : E[q]) {
            if (e == t) continue;
            if (dist[e] == INF) {
                que.push(e);
                dist[e] = dist[q] + 1;
            } else if (dist[e] > dist[q] + 1) {
                dist[e] = dist[q] + 1;
            }
        }
    }

    int cnt = 0;
    rep2(i, n) if (dist[i] != INF && dist[i] > k / 2) cnt++;
    return cnt;
}

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

    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        E[a].push_back(b);
        E[b].push_back(a);
    }

    int Min = INF;

    if (k % 2 == 0) {
        rep2(i, n) Min = min(Min, bfs_even(i));
    } else if (k % 2 == 1) {
        rep2(i, n) for (auto e : E[i]) Min = min(Min, bfs_odd(i, e) + bfs_odd(e, i));
    }

    cout << Min << endl;
    return 0;
}


Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        int[] input = Console.ReadLine().Split().Select(i =>int.Parse(i)).ToArray();
        Console.WriteLine(Math.Abs(input[0]-input[1])<Math.Abs(input[0]-input[2])?"A":"B");
        

        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法

        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();
        
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  vector<int> a(3);
  cin>>a.at(0)>>a.at(1)>>a.at(2);
  sort(a.begin(),a.end());
  if((a.at(1)-a.at(0))%2==0){
    cout<<(2*a.at(2)-a.at(1)-a.at(0))/2<<endl;
  }else{
    cout<<(2*a.at(2)-a.at(1)-a.at(0)+3)/2<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int lli;
const long long int MaxN=500005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli a[MaxN],b[MaxN];
	pair <lli,lli> par[MaxN];
	void solve(){
		lli N,i,j,p,q,tot=0,suma=0,res=0;
		cin>>N;
		for(i=0;i<N;i++){
			cin>>a[i];
		}
		for(i=0;i<N;i++){
			cin>>b[i];
		}
		vector <lli> cant;
		for(i=0;i<N;i++){
			if(a[i]<b[i])tot+=b[i]-a[i],res+=1;
			else {
				cant.push_back(a[i]-b[i]);
			}
		}	
		sort(cant.rbegin(),cant.rend());
		for(i=0;i<cant.size();i++){
			if(suma>=tot){
				cout<<res<<"\n";
				return;
			}
			suma+=cant[i];
			res+=1;
		}
		if(suma<=tot){
			cout<<"-1";
			return;
		}
		cout<<res<<"\n";
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}


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

int main(){
int N;
cin>>N;
 long long sum=0;
vector<long long>number(10000001,0);
  rep(i,N) {
   long long a;
   cin>>a;
   sum+=a;
   number.at(a)++;
 }
long long q;
  cin>>q;
  rep(i,q){
  	long long a,b;
    cin>>a>>b;
  	sum+=(b-a)*number.at(a);
    number.at(b)+=number.at(a);
    number.at(a)=0;
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 81388
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;



int main() {
	int n, a[100000];
	cin >> n;
	int count = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 1) {
			count++;
		}
	}
	if (count % 2 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;


	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
vector<string> a,maxn;
map<string,int> m; 
int ma=-99999;
int main(){
	int k;
	cin>>k;
	for(int i=0;i<k;i++){
		string x;
		cin>>x;
		if(m[x]==0)
			a.push_back(x);
		m[x]++;
	}
	for(int i=0;i<a.size();i++){
		if(m[a[i]]>ma){
			maxn.clear();
			maxn.push_back(a[i]);
			ma=m[a[i]];
		}
		else if(m[a[i]]==ma)
			maxn.push_back(a[i]);
	}
	sort(maxn.begin(),maxn.end());
	for(int i=0;i<maxn.size();i++)
		cout<<maxn[i]<<endl;
	return 0;	
}

Measured memory_bytes: 29040
//
// Created by 李青坪 on 2018/10/2.
//


#include <cstdlib>
#include <cstdio>

using namespace std;

struct Node{
    int key;
    Node *pre, *next;
};

class DLinkedList{
public:
    Node *head;
    DLinkedList(){
        head = new(Node);
        head->pre = head;
        head->next = head;
    }
    void addNode(int key){
        Node *node = new(Node);
        node->key = key;
        head->next->pre = node;
        node->next = head->next;
        head->next = node;
        node->pre = head;
    }
    Node* searchNode(int key){
        Node *cur = head->next;
        while (cur != head && cur->key != key){
            cur = cur->next;
        }
        return cur;
    }
    void deleteNode(Node *node){
        if (node == head) return;
        node->next->pre = node->pre;
        node->pre->next = node->next;
        free(node);
    }
};

int main(){
    int n;
    scanf("%d", &n);
    DLinkedList list = DLinkedList();
    for (int i = 0; i < n; ++i) {
        char command[20];
        scanf("%s", &command);
        int key;
        if (command[0] == 'i'){
            scanf("%d", &key);
            list.addNode(key);
        }
        else if (command[0] == 'd'){
            if (command[6] == 'F'){
                list.deleteNode(list.head->next);
            } else if (command[6] == 'L'){
                list.deleteNode(list.head->pre);
            } else{
                scanf("%d", &key);
                list.deleteNode(list.searchNode(key));
            }
        }

    }
    printf("%d", list.head->next->key);
    Node *cur = list.head->next->next;
    while(cur != list.head){
        printf(" %d", cur->key);
        cur = cur->next;
    }
    printf("\n");
    return 0;
}

 /*
7
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5
 */


Measured memory_bytes: 33876
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int[] pi = new int[N];
   for(int i = 0;i<N;i++)
   {
    pi[i] = sc.nextInt();
   }
   
   Arrays.sort(pi);
   pi[N-1] = pi[N-1]/2;
   int ans = 0;
   for(int i = 0;i<N;i++)
   {
    ans += pi[i]; 
   }
   System.out.println(ans);
 }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
const ll INF = ll(1e18)+1;
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; }

const int mod1 = 2019;

int main(){
    ll l,r;
    cin >> l >> r;
    r = min(r,l+4037);
    ll ans = 2018;
    for(ll i=l;i<r;i++){
        for(ll j=i+1;j<=r;j++){
            ans = min(ans,i*j%2019);
        }
    }
    cout << ans << endl;
}


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

long long INF = 1LL << 60;

const long long MAXV = 100000+1;
long long dp[100+1][MAXV];

int main() {
  long long N, W;
  cin >> N >> W;
  vector<long long> w(N), v(N);
  for (long long i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }
  for (long long i = 0; i <= N; i++) {
    for (long long j = 0; j < MAXV; j++) {
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < MAXV; j++) {
      if (v[i] <= j) dp[i+1][j] = min(dp[i+1][j], dp[i][j-v[i]]+w[i]);
      dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
    }
  }
  long long result = 0;
  for (long long j = 0; j < MAXV; j++) {
    if (dp[N][j] <= W) {
      result = j;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
bool sorter(pair<ll,ll> a, pair<ll,ll>b)
{
	if(a.first!=b.first)
		return (a.first > b.first);
	else
		return ((a.second < b.second));
}
int main()
{
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vector<ll> red(a), green(b), white(c);
	vector<pair<ll,ll>> all;
	for(int i  =0 ; i < a ; i++)
	{
		cin>>red[i];
		all.push_back({red[i],0});
	}
	for(int i = 0 ; i < b; i++)
	{

		cin>>green[i];
		all.push_back({green[i],1});
	}
	for(int i = 0 ; i < c; i++)
	{
		cin>>white[i];
		all.push_back({white[i],2});
	}
	sort(all.begin(),all.end(), sorter);
	ll ans = 0;
	int n = all.size();
	int thi = x+y;
	for(int i = 0 ; i < thi ; i++)
	{
	    if(x>0&&all[i].second==0)
	    {
	        ans+=all[i].first;
	        x--;
	    }
	    else if(all[i].second==0)
	        thi++;
	    if(y>0&&all[i].second==1)
	    {
	        ans+=all[i].first;
	        y--;
	    }
	    else if(all[i].second==1)
	        thi++;
	}
	sort(white.begin(),white.end(), greater<int>());
	for(int i = 0; i < x+y; i++)
	    ans+=white[i];
 	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12908
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    string s;cin >> s;
    int n=s.length();
    vector<vector<LL>> dp(n+1,vector<LL> (15,0));
    dp[0][0]=1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 13; j++) {
            if(s[i]=='?'){
                for (int k = 0; k < 10; k++) {
                    dp[i+1][(j*10+k)%13]=(dp[i+1][(j*10+k)%13]+dp[i][j])%mod;
                }
            }
            else{
                dp[i+1][(j*10+s[i]-'0')%13]=(dp[i+1][(j*10+s[i]-'0')%13]+dp[i][j])%mod;
            }
        }
    }
    cout << dp[n][5] << endl;
    return 0;
}


Measured memory_bytes: 15232
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline 


n,m,x = list(map(int,readline().split()))
ca = [list(map(int,readline().split())) for _ in range(n)]


ans = 10**9
N = 1<<n
for mask in range(N):
    res = [0]*m
    cost = 0
    for i in range(n):
        if mask>>i&1:
            cost += ca[i][0]
            for j in range(1,m+1):
                res[j-1] += ca[i][j]
    if all(ri >= x for ri in res):
        ans = min(ans,cost)

if ans != 10**9:
    print(ans)    
else:
    print(-1)
    
    
    
    

Measured memory_bytes: 9220
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <ctype.h>

using namespace std;
using ll=long long;

int main()
{
    int N, K, X, Y;
    
    cin >> N >> K >> X >> Y;
    
    int fee;
    if (K > N)
    {
        fee = N * X;
    }
    else
    {
        fee = K * X + (N - K) * Y;
    }

    printf("%d\n", fee);
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Stack;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Main
{

	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		Stack<Integer> a = new Stack<Integer>();
		Stack<Integer> b = new Stack<Integer>();
		boolean yes_no;
		for (int i = 0; i < n; i++) {
			String s = br.readLine();
			a.push(0); b.push(0);
			yes_no = true;
			for (int j = 0; j < 10; j++) {
				int num = Integer.parseInt(s.split(" ")[j]);
				int	subA = num - a.peek(); 
				int subB = num - b.peek();
				if(subA < 0 && subB < 0){
					yes_no = false;
					break;
				}
				else if (subA > 0 && subB > 0) {
					if(subA <= subB)
						a.push(num);
					else
						b.push(num);
				}
				else if	(subB >= subA)
					b.push(num);
				else
					a.push(num);
			}
			if(yes_no) System.out.println("YES");
			else 	   System.out.println("NO");
		}
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

const int MAXN = 100010;

int n, k;
int a[MAXN];

int main()
{
	scanf("%d%d", &n, &k);
	int d = 0;
	for (int i = 1; i <= n; ++ i)
	{
		scanf("%d", &a[i]);
		d = __gcd(d, a[i]);
	}
	if (k%d)
	{
		puts("IMPOSSIBLE");
		return 0;
	}
	k /= d;
	int m = 0;
	for (int i = 1; i <= n; ++ i)
	{
		a[i] /= d;
		m = max(m, a[i]);
	}
	puts(k <= m ? "POSSIBLE" : "IMPOSSIBLE");
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    for(int i=0;i<b.size();i++){
        cout<<a[i]<<b[i];
    }
    if(a.size()>b.size())cout<<a[a.size()-1]<<endl;
    else cout<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct cnt_t
{
	map<int,int> c;
};


struct segtree_t
{
	int n;
	int base;
	std::vector<int> t;
	segtree_t(int n) : n(n)
	{
		for(base=1;base<n;base*=2)
			;

		t.resize(base*2);
	}

	void set_i(int x)
	{
		if(x==0) return;
		t[x]=t[x*2]+t[x*2+1];
		set_i(x/2);
	}

	void set(int x, int v)
	{
		int y=base+x;
		t[y]=(v!=0);
		set_i(y/2);
	}

	int get_i(int x)
	{
		if(x==0) return 0;
		int add=0;
		if(x&1) add=t[x-1];
		return add+get_i(x/2);
	}

	int get(int x)
	{
		int y=base+x;
		return t[y]+get_i(y);
	}

void dump(void)
{
	for(auto&m:t) cout << m << " ";
	cout << "\n";
}

};


struct ilr_t
{
	int i, l, r;
};


bool cmp_r(const ilr_t&a, const ilr_t&b)
{
	return b.r>a.r;
}


struct solve
{
	int n;
	vi c;
	segtree_t t;
	vi ans;
	solve(int n, vi&c, vi&l, vi&r) : n(n), c(c), t(n+1) {
		vvi x(n+1);
		for(int i=1;i<=n;i++)
		{
			x[c[i]].push_back(i);
		}

		for(int i=1;i<=n;i++)
		{
			if(x[i].empty()) continue;
			t.set(x[i].back(), 1);
		}
//t.dump();
		int q=l.size();
		vector<ilr_t> rl;
		for(int i=0;i<q;i++)
		{
			rl.push_back(ilr_t{i, l[i], r[i]});
		}
		sort(rl.rbegin(), rl.rend(), cmp_r);

		ans.resize(q);
		int xr=n;
		for(int i=0;i<q;i++)
		{
			for(;xr>rl[i].r;xr--)
			{
				auto&tv=x[c[xr]];
				t.set(tv.back(), 0);
				tv.pop_back();
				if(tv.empty()) continue;
				t.set(tv.back(), 1);
			}
			ans[rl[i].i]=t.get(rl[i].r)-t.get(rl[i].l-1);
		}
	}
	ll operator()(int i) {
		return ans[i];
	}
};

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

	for(;;)
	{
		int n, q;
		cin >> n >> q;
		if(cin.fail()) break;
		vi c(n+1);
		for(int i=1;i<=n;i++) cin >> c[i];

		vi l(q), r(q);
		for(int i=0;i<q;i++) cin >> l[i] >> r[i];

		solve solver(n, c, l, r);
		for(int i=0;i<q;i++)
		{
			cout << solver(i) << "\n";
		}
	}
	return 0;
}


Measured memory_bytes: 50188
//package AtCoder;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		int sum=0;
		for(int i=0;i<n;i++)
		{
			a[i]=sc.nextInt();
			sum+=a[i];
		}
		int avg = sum/n;
		int ans=Integer.MAX_VALUE;
		int pos=-1;
		for(int i=avg;i<=avg+1;i++)
		{
			int s=0;
			for(int x:a)
			{
				s+=(Math.pow((i-x),2));
			}
			if(s<ans)
			{
				ans=s;
				pos=i;
			}
				
				
		}
		System.out.println(ans);
		
		

	}

}


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

int main() {
	int n, m, ans = 0;
	map<string, int> s;
	cin >> n;
	rep(i, n) {
		string str;
		cin >> str;
		s[str]++;
	}
	cin >> m;
	rep(i, m) {
		string str;
		cin >> str;
		s[str]--;
	}
	for (auto itr = s.begin(); itr != s.end(); ++itr) {
		ans = max(ans, itr->second);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
using namespace std;
#define M 1000000007
#define pb push_back
#define rep(i, a, b) for(int i = a; i <= b; i++)
ll mod = 998244353;


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t; t = 1;
	// cin >> t;
	while(t--)
	{
		string s, t;
		cin >> s >> t;int g = 0;
		int n1 = s.length();
		int n2 = t.length();
		if(n2 == n1+1)
		{
			for(int i = 0; i < n1; i++)
			{
				if(s[i] == t[i])
				{
					continue;
				}
				else
				{
					g = -1;
					break;
				}
			}
			if(g == 0)
				cout << "Yes" << endl;
			else
				cout << "No" << endl;
		}
		else
			cout << "No" << endl;
	}
		
}  

Measured memory_bytes: 3608
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 998244353
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
double search(double start,double end,double n){
    if(end-start<1e-9)return start;
    double mid=(start+end)/2;
    if(mid*mid>n)return search(start,mid,n);
    else return search(mid,end,n);
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    srand(time(0));
    int n,s;
    cin>>n>>s;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans[s+1]={0};
    ans[0]=1;
    int ans1=0;
    for(int i=0;i<n;i++){
        for(int j=s;j>0;j--){
            if(a[i]+j>s)continue;
            ans[a[i]+j]+=ans[j];
            ans[a[i]+j]%=mod;
        }
        if(a[i]<=s){ans[a[i]]+=i+1;ans[a[i]]%=mod;}
        ans1+=ans[s];
        ans1%=mod;
    }
    cout<<ans1;
    //cout<<ans[s];
    return 0;
}


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


mod = 1000000007

inv = [1] * 222222

# 0 = a * MOD/a + MOD % a
# a*MOD/a = -MOD%a
# a = -MOD%a * inv[MOD/a]
# inv[a] = -inv[MOD%a] * MOD/a
for i in range(2, 222222):
    inv[i] = -inv[mod % i] * (mod // i)
    inv[i] %= mod
    
def comb(n, a):
    res = 1
    for i in range(a):
        res *= n-i
        res *= inv[i+1]
        res %= mod
    return res

ans = pow(2, n, mod) - 1 - comb(n, a) - comb(n, b)

ans %= mod
if ans < 0:
    ans += mod

print(ans)

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

  int main() {
    int N; cin >> N;  // カードの枚数
    vector<int> C(N); // カードの中身
    rep(i,N){cin >> C.at(i);}
    int R = 0;  // 差（戻り値）

    // カードを大きい順に並べ替え
    sort(C.begin(),C.end(),greater<int>());

    rep(i,N){
      if ( i % 2 == 0 ) {   // 偶数番目は加算・奇数番目は減算
        R += C.at(i);
      } else {
        R -= C.at(i);
      }
    }

    cout << R << endl;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define rep(i, a, b) for(int i = a; i < b; ++i)

main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector <int> a(n, 0);
    rep(i, 0, n) {
        cin >> a[i];
    }
    int ans = 2e9;
    rep(i, 0, n) {
        vector <int> b;
        vector <int> cur;
        rep(j, 0, n + 1) {
            if (j == n || a[j] < a[i]) {
                {
                    int len = cur.size();
                    sort(cur.begin(), cur.end());
                    rep(jj, 0, len - k + 1) {
                        b.push_back(cur[jj]);
                    }
                    cur.clear();
                }
            } else {
                cur.push_back(a[j]);
            }
        }
        sort(b.begin(), b.end());
        int len = b.size();
        if (len >= q) {
            ans = min(ans, b[q - 1] - a[i]);
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 384
import java.util.Scanner;

//What is the Bottommost?
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int[] a = new int[10];
			char[] s = sc.next().toCharArray();
			for(int i=0;i<10;i++)a[i]=s[i]-'0';
			for(int j=9;j>0;j--){
				int[] b = new int[j];
				for(int i=0;i<j;i++){
					b[i]=(a[i]+a[i+1])%10;
				}
				a = b;
			}
			System.out.println(a[0]);
		}
	}
}

Measured memory_bytes: 12000
<?php
    $inArray = [];
    while (!feof(STDIN) ) {
        foreach(str_split(trim(fgets(STDIN))) as $a){
            $inArray[] = $a;
        }
    }
        
    $searchArray = range("a", "z");
    foreach($searchArray as $searchVal){
        $count = 0;
        foreach($inArray as $inVal){
            if($searchVal == $inVal || strtoupper($searchVal) == $inVal){
                $count = $count + 1; 
            }
        }
        echo $searchVal." : ".$count.PHP_EOL;
    }


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

int main(){
    int n,a,b;
    while(scanf("%d%d%d",&n,&a,&b)!=EOF){
        int ans=abs(a-b)+1;
        if(ans&1) printf("Alice\n");
        else printf("Borys\n");
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
sm = {}
for s in S:
    if s in sm:
        sm[s] += 1
    else:
        sm[s] = 1
for t in T:
    if t in sm:
        sm[t] -= 1
print(max(list(sm.values())+[0]))

Measured memory_bytes: 3064
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int a, b; cin>>a>>b;
    ll x = max(-1000000, b-a+1);
    ll y = min(1000000, b+a-1);
    f2(i,x,y) cout << i << " ";
    return 0;
}


Measured memory_bytes: 256
N = input()

result = 'Yes'
for i in range(len(N)):
    s = N[i]
    if (i+1)%2 == 1 :
        if s !='R' and s != 'U' and s != 'D':
            result = 'No'
            break
    elif (i+1)%2 == 0:
        if s !='L' and s != 'U' and s != 'D':
            result = 'No'
            break

print(result)



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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

const int mod = 1000000007;
const int FacN = 10000;//使わないなら0

constexpr int power(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)res *= a;
        a *= a;
        res %= mod;
        a %= mod;
        b /= 2;
    }
    return res;
}

constexpr int inv(int x) {
    return power(x, mod - 2);
}

const struct Fac {
    int val[FacN];

    constexpr Fac() : val() {
        if (FacN == 0)return;
        val[0] = 1;
        for (int i = 1; i < FacN; ++i) val[i] = val[i - 1] * i % mod;
    }

    const int &operator[](size_t i) const {
        return val[i];
    }
} fac;

const struct FacInv {
    int val[FacN];

    constexpr FacInv() : val() {
        if (FacN == 0)return;
        val[FacN - 1] = 1;
        for (int i = 1; i < FacN; ++i)val[FacN - 1] = val[FacN - 1] * i % mod;
        val[FacN - 1] = inv(val[FacN - 1]);
        for (int i = FacN - 1; i >= 1; --i)val[i - 1] = val[i] * i % mod;
    }

    const int &operator[](size_t i) const {
        return val[i];
    }
} fac_inv;

int Perm(int n, int r) {
    if (n < r) return 0;
    return fac[n] * fac_inv[n - r] % mod;
}

int Comb(int n, int r) {
    return Perm(n, r) * fac_inv[r] % mod;
}
//mod,Factorial書き換え
//要検証

int N, B;

signed main() {
    cin >> N >> B;
    int R = N - B;
    if (R == 0) {
        cout << 1 << endl;
        rep(i, B - 1)cout << 0 << endl;
        return 0;
    }
    for (int i = 1; i <= B; ++i) {
        //青をi個赤をi個 x2
        //青をi個赤を(i-1)個
        //青をi個赤を(i+1)個
        int b1 = fac[B - 1] * fac_inv[B - i] % mod * fac_inv[i - 1] % mod;
        int r1;
        if (R - i < 0)r1 = 0;
        else r1 = fac[R - 1] * fac_inv[R - i] % mod * fac_inv[i - 1] % mod;
        int r2;
        if (R - (i - 1) < 0 || i == 1)r2 = 0;
        else r2 = fac[R - 1] * fac_inv[R - (i - 1)] % mod * fac_inv[(i - 1) - 1] % mod;
        int r3;
        if (R - (i + 1) < 0)r3 = 0;
        else r3 = fac[R - 1] * fac_inv[R - (i + 1)] % mod * fac_inv[i + 1 - 1] % mod;
        int ans = b1 * r1 * 2 + b1 * r2 + b1 * r3;
        ans %= mod;
        ans += mod;
        ans %= mod;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

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

for i in range(n):
    dic[a[i]]+=1

# dic2=defaultdict(int)
ans=0
for i in dic.keys():
    ans+=dic[i]*(dic[i]-1)//2

# print(ans)
# print(dic)
for i in range(n):
    # print()
    # print(dic[a[i]]*(dic[a[i]]-1)//2)
    # print((dic[a[i]]-1)*(dic[a[i]-2])//2)
    tmp=ans-dic[a[i]]*(dic[a[i]]-1)//2+(dic[a[i]]-1)*(dic[a[i]]-2)//2
    print(tmp)

Measured memory_bytes: 108636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  while (true) {
    int n, m, t, p;
    cin >> n >> m >> t >> p;
    if (n == 0)
      break;
    int size = 2000;
    vector<vector<int>> mp(size, vector<int>(size));
    int h = 1000, w = 1000;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        mp[i + h][j + w] = 1;
    for (int i = 0; i < t; i++) {
      int d, c;
      cin >> d >> c;
      if (d == 1) {
        for (int j = 0; j < size; j++) {
          for (int k = 0; h + c - k - 1 >= 0 && h + c + k < size; k++) {
            if (mp[h + c + k][j] + mp[h + c - k - 1][j] == 0)
              break;
            mp[h + c + k][j] += mp[h + c - k - 1][j];
            mp[h + c - k - 1][j] = 0;
          }
        }
        if (n > c * 2) {
          n = n - c;
        } else {
          n -= n - c;
        }
        h += c;
      } else {
        c = m - c;
        for (int j = 0; j < size; j++) {
          for (int k = 0; w + c - k - 1 >= 0 && w + c + k < size; k++) {
            if (mp[j][w + c - k - 1] + mp[j][w + c + k] == 0)
              break;
            mp[j][w + c - k - 1] += mp[j][w + c + k];
            mp[j][w + c + k] = 0;
          }
        }
        if (m > c * 2) {
          w -= m - 2 * c;
          m = m - c;
        } else {
          m -= m - c;
        }
      }
    }
    for (int i = 0; i < p; i++) {
      int x, y;
      cin >> x >> y;
      y = m - y - 1;
      cout << mp[x + h][y + w] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 18720
#include<stdio.h>
int main(void)
{
	int x,y;
	
	while(1){
		scanf("%d%d",&x,&y);
		if(x == 0 && y == 0){
			break;
		}
	if(x < y){
		printf("%d %d\n",x,y);
	}
	if(y < x){
		printf("%d %d\n",y,x);
	}
	if(x == y){
		printf("%d %d\n",x,y);
	}
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

vector<ll> a;
map<P,ll> mem[20][20];
ll dfs(ll l,ll r,ll xl,ll xr){
  if(mem[l][r].count(P(xl,xr)))return mem[l][r][P(xl,xr)];

  if(l+1==r){
    return 0;
  }

  ll res=INF;
  repl(i,l+1,r){
    minch(res,dfs(l,i,xl,xl+xr)+dfs(i,r,xl+xr,xr)+(xl+xr)*a[i]);
  }

  return mem[l][r][P(xl,xr)]=res;
}

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

  ll n;
  cin>>n;
  a.resize(n);
  rep(i,n)cin>>a[i];

  cout<<dfs(0,n-1,1,1)+a[0]+a[n-1]<<endl;

  return 0;
}


Measured memory_bytes: 17920
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define ll long long

int main() {
	int h,w;
	//入力
	cin >> h >> w;
	vector<string> s(h+1);
	rep(i, w) s[h] += '#';
	vector<vector<int>> g(h,vector<int>(w));
	//読み込み＆横列カウント
	rep(i, h) {
		string s1;
		cin >> s1;
		s[i] = s1;
		int j = 0;
		for (;j < s1.size();++j) {
			int cnt = 0;
			if (s1[j] == '.') {
				while (s1[j + cnt] == '.') {
					++cnt;
				}
				rep(k, cnt)	g[i][j+k] = cnt;
			}
			j += cnt;
		}
	}
	//縦列カウント加算
	rep(i, w) {
		int j = 0;
		for (;j < h;++j) {
			int cnt = 0;
			if (s[j][i] == '.') {
				while (s[j+cnt][i] == '.') {
					++cnt;
				}
				rep(k, cnt) g[j + k][i] += cnt-1;
			}
			j += cnt;
		}
	}
	//ansを求める
	int ans = 0;
	rep(i, h) {
		rep(j, w) {
			ans = max(ans, g[i][j]);
		}
	}

	std::cout << ans << endl;
}


Measured memory_bytes: 23240
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll N; std::cin >> N;
  std::vector<ll> A(N+1);
  rep(i, N-1) {
    ll B; std::cin >> B;
    A[B-1]++;
  }

  rep(i,N) {
    std::cout << A[i] << std::endl;
  }
  return 0;
}



Measured memory_bytes: 4768
#include<bits/stdc++.h>
using namespace std;
char s[200005];
int n,x;
long long ans;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
		if(s[i]=='W')
		{
			x++;
			ans+=i-x;
		}
	printf("%lld",ans);
}

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

const vector<int> dx = {0, 0, -1, 1};
const vector<int> dy = {-1, 1, 0, 0};

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

    char ch;
    vector<vector<char>> s(h, vector<char> (w));
    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            cin >> ch;
            s.at(i).at(j) = ch;
        }
    }

    vector<vector<int>> passed(h, vector<int> (w, -1));
    vector<vector<pair<int, int>>> prev_pos(h, vector<pair<int, int>>(w));

    queue<pair<int, int>> que;

    passed.at(0).at(0) = 0;
    que.push(make_pair(0, 0));
    while(!que.empty()){
        auto p = que.front();
        int y = p.first;
        int x = p.second;
        que.pop();

        for (int d=0; d<4; d++){
            int n_y = y + dy.at(d);
            int n_x = x + dx.at(d);

            if(n_y < 0 || n_y >= h || n_x <0 || n_x >=w) continue;
            if(passed.at(n_y).at(n_x) != -1) continue;
            if(s.at(n_y).at(n_x) == '#') continue;

            passed.at(n_y).at(n_x) = 0;
            prev_pos.at(n_y).at(n_x) = make_pair(y, x);
            que.push(make_pair(n_y, n_x));
        }
    }

    //ゴールできなかった場合
    if (passed.at(h-1).at(w-1) == -1){
        cout << -1 << endl;
        return 0;
    }

    //ゴールできた場合

    int x = w - 1 , y = h - 1;
    s.at(0).at(0) = 'o';
    while(x != 0 || y != 0){
        s.at(y).at(x) = 'o';
        auto pp = prev_pos.at(y).at(x);
        x = pp.second;
        y = pp.first;
    }

    int count = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
//            cout << s.at(i).at(j);
            if(s.at(i).at(j) == '.') count++;
        }
//        cout << endl;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
def search_center(xyh_list):
    xyh_list.sort(key=lambda r: r[2], reverse=True)
    highest = xyh_list[0]
    for cx in range(101):
        for cy in range(101):
            h = highest[2] + abs(highest[0] - cx) + abs(highest[1] - cy)
            matched = True
            for xyh in xyh_list[1:]:
                if xyh[2] == 0:
                    if h - abs(xyh[0] - cx) - abs(xyh[1] - cy) > 0:
                        matched = False
                        break
                else:
                    hh = xyh[2] + abs(xyh[0] - cx) + abs(xyh[1] - cy)
                    if h != hh:
                        matched = False
                        break
            if matched:
                return cx, cy, h
    return None


def main():
    N = int(input())
    xyh_list = [list(map(int, input().split(' '))) for _ in range(N)]
    xyh_list.sort(key=lambda r: r[2], reverse=True)
    cx, cy, ph = search_center(xyh_list)
    print('{} {} {}'.format(cx, cy, ph))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdbool.h>
#include <stdio.h>
int main() {
	int x, y;
	bool isG4 = false;
	int list[4] = {4, 6, 9, 11};
	scanf("%d%d", &x, &y);
	if (x == 2 || y == 2) {
		printf("No\n");
		return 0;
	} else {
		for (int i = 0; i < 4; i++) {
			if (list[i] == x) {
				isG4 = true;
			}
		}
		for (int i = 0; i < 4; i++) {
			if (list[i] == y) {
				if (isG4) {
					printf("Yes\n");
					return 0;
				} else {
					printf("No\n");
				}
			}
		}
	}
	if (isG4) {
		printf("No\n");
	} else {
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
TA = []
AO = []
for i in range(N):
    T, A = map(int, input().split())
    TA += [T]
    AO += [A]

for i in range(N-1):
    D = ((TA[i]-1)//TA[i+1])+1
    E = ((AO[i]-1)//AO[i+1])+1
    F = max(D, E)
    TA[i+1] *= F
    AO[i+1] *= F
ans = int(TA[N-1] + AO[N-1])
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; ++i)
#define REPR(i,n) for(int i = n; i >= 0; --i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = b-1;i >= a;--i)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

static const ll MOD  = 1e9 + 7;
static const ll INF  = 1e18;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

void pvector(vector<int> A){
    cout << "[vector]";
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    string S;
    cin >> S;
    ll N  = S.size();
    ll cnta = 0,ans = 0;
    bool flagabc = 0, flagb = 0;
    REP(i, N-1){
        if(flagabc){//abcゾーン中
            if(S[i] == 'A'){
                cnta++;
            }else if(S[i] == 'B' && S[i+1] == 'C'){
                flagb = 1;
                ans += cnta;
            }else if(flagb == 1){ //BからCになった時
                flagb = 0;
                continue;
            }else{
                flagabc = 0;
                cnta = 0;
            }
        }else{
            if(S[i] == 'A'){
                flagabc = 1;
                cnta++;
            }
        }
    }
    p(ans);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

struct node
{
    int t,val;
    bool operator <(const node &b)const
    {
        if(val==b.val)return t<b.t;
        return val<b.val;
    }
}a[1005];

int main()
{
    int n=read(),t=read();
    for(int i=1;i<=n;i++){
        a[i].t=read(),a[i].val=read();
    }
    sort(a+1,a+1+n);
    bool ok=true;
    int ans=0xfffffff;
    for(int i=1;i<=n;i++){
        if(a[i].val<=t){
            ok=false;ans=min(ans,a[i].t);
        }
        else{
            break;
        }
    }
    if(!ok){
        printf("%d\n",ans);
    }
    else{
        puts("TLE");
    }
    return 0;
}
/*
3
UDU
0 3
*/


Measured memory_bytes: 256
#https://atcoder.jp/contests/arc061/tasks/arc061_a

s = input()

def xxx(residue, l):
    if len(s)==1:
        return [[1]] 
    elif residue==len(s)-1:
        return [l + [residue, len(s)], l + [len(s)]]
    else:
        return xxx(residue+1, l + [residue]) + (xxx(residue+1, l))

flaglist = xxx(1, [])

sum = 0
for value in flaglist:
    for i in range(len(value)):
        if i==0:
            sum += int(s[:value[i]])
        else:
            sum += int(s[value[i-1]:value[i]])

print(sum)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std;
using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using SS = stringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = vector< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &&e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + ( p ), ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

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

#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

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

	string S;
	cin >> S;

	const int L = SZ( S );

	if ( L == 2 && S[0] == S[1] )
	{
		cout << "1 2" << endl;
		return 0;
	}

	REP( i, L - 2 )
	{
		if ( SZ( set< char >( begin( S ) + i, begin( S ) + i + 3 ) ) < 3 )
		{
			cout << i + 1 << ' ' << i + 3 << endl;
			return 0;
		}
	}

	cout << "-1 -1" << endl;

	return 0;
}


Measured memory_bytes: 512
using System;
using System.Text.RegularExpressions;

namespace AizuOnLine
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = string.Empty;
            int count = 0;

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

                if (input == "-")
                {
                    break;
                }
                else if (Regex.IsMatch(input, "[a-z]"))
                {
                    word = input;
                }
                else if (count == 0)
                {
                    count = int.Parse(input);
                }
                else
                {
                    int len = int.Parse(input);
                    string front = word.Substring(0, len);
                    string back = word.Substring(len);
                    word = back + front;
                    count--;

                    if (count == 0)
                    {
                        Console.WriteLine(word);
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 11072