akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]

//input
use proconio::input;
use proconio::marker::{Bytes, Chars};
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        n: i64,
        m: usize,
        a: [i64;m],
    }

    //tabで移動
    if n >= a.iter().sum() {
        println!("{}", n - a.iter().sum::<i64>());
    } else {
        println!("-1");
    }
}


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

int main()
{
  char a[102],b[102];
  int sum=0,t=0,mx=-1,mi=100000;
  cin>>a;
  cin>>b;
  for(int i=0; a[i]; i++)
  {
    mi=min(mi,(int)a[i]);

  }
  for(int i=0; b[i]; i++)
  {
    mx=max(mx,(int)b[i]);
  }
  if(mi<mx)
  {
    cout<<"Yes";
  }
  else if(mi==mx)
  {

    int i=0;
    for(; a[i]&&b[i]&&a[i]==b[i]; i++);
    if(a[i]||b[i]=='\0')
      cout<<"No";
    else
    {
      cout<<"Yes";
    }
  }

  else
  {
    cout<<"No";
  }



  return 0;
}


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

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int A, B;

	cin >>A >> B;

	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}



	return 0;
}

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

//解説、回答参考

//二数の最大公約数を求める関数（ユーグリッド互除法）
int GCD(int x,int y){
	if(x<y) swap(x,y); //xとyを交換する。
	if(x%y==0) return y;
	return GCD(y,x%y);
}

int main(){
	int n,x;
	cin>>n>>x;
	
	int a[100000];
	for(int i=0;i<n;i++) cin>>a[i];
	
	int ans=abs(a[0]-x);
	
	for(int i=1;i<n;i++){
		ans=GCD(ans,abs(a[i]-x));
	}
	
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int a,b,c,i,count;
	count=0;
	scanf("%d %d %d",&a,&b,&c);
	(((a>=0)&&(a<=10000))&&((b>=0)&&(b<=10000))&&((c>=0)&&(c<=10000)));
	(a<=b);
	for(i=a;i<=b;i++)
	{
		if(c%i==0) 
		{
			count++;
		}
	}
			printf("%d\n",count);
		
	
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define m 1000000007
using namespace std;
int main()
{
	int h,w;
	cin>>h>>w;
	char grid[h][w];
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			cin>>grid[i][j];
	int dp[h][w];
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
		{
			if(i==0||j==0)
			{
				if(i==0&&j==0)
					dp[i][j]=1;
				else if(grid[i][j]=='#')
					dp[i][j]=0;
				else
				{
					if(i==0)
						dp[i][j]=dp[i][j-1];
					else
						dp[i][j]=dp[i-1][j];
				}
			}
			else
			{
				if(grid[i][j]=='#')
					dp[i][j]=0;
				else
					dp[i][j]=(dp[i][j-1]+dp[i-1][j])%m;
			}
		}

	cout<<dp[h-1][w-1]<<endl;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <cstdio>
#include <math.h>

using namespace std;
 
double calculate_dist(int x, int y) {
	return sqrt(pow(x, 2) + pow(y, 2));
}

int main() {
  int n;
  int d;
  int count = 0;
  
  cin >> n;
  cin >> d;
  
  for (int i = 0; i < n; i++) {
	int x, y;
    
    scanf("%d%d", &x, &y);

	fflush(stdin);
    
    double dist = calculate_dist(x, y);

    if (dist <= d) {
    	count++;
    }
  }

  fflush(stdin);
  
  cout << count << endl;
}

Measured memory_bytes: 3736
def solve(s):
  for i in range(len(s)-1):
    if s[i] == s[i+1]:
      return '{0} {1}'.format(i+1, i+2)
  for i in range(len(s)-2):
    if s[i] == s[i+2]:
      return '{0} {1}'.format(i+1, i+3)
  return '{0} {1}'.format(-1, -1)

print(solve(input()))


Measured memory_bytes: 3188
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d\n",a+(a<=b?1:0)-1);
}


Measured memory_bytes: 256
n = int(input())

al = int(n * (n - 1)/2)
alls = []
for k in range(1,n+1):
    for i in range(k+1,n+1):
        alls.append((k,i))

if n%2 == 1:
    for k in range(1, (n-1)//2 + 1):
        alls.remove((k, n-k))    
else:
    for k in range(1,(n//2) +1):
        alls.remove((k,n-k+1))

print(len(alls))
for a in alls:
    print(a[0], a[1])



Measured memory_bytes: 3956
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int W[N], sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> W[i];
        sum += W[i];
    }
    int S1 = 0, S2;
    int min = sum - W[0];
    for (int T = 1; T < N; T++)
    {
        S1 = 0;
        for (int i = 0; i < T; i++)
        {
            S1 += W[i];
        }
        S2 = sum - S1;
        int min_val = S2 > S1 ? S2 - S1 : S1 - S2;
        if (min > min_val)
        {
            min = min_val;
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int sbuf[200020];
int tbuf[200020];

int main()
{
	char buf[100010];
	string S, T;
	scanf(" %s", buf);
	S = buf;
	scanf(" %s", buf);
	T = buf;

	sbuf[0] = 0; tbuf[0] = 0;
	for (int i = 1; i <= S.size(); i++) {
		sbuf[i] = sbuf[i - 1] + (S[i-1] == 'A' ? 1 : 2);
	}
	for (int i = 1; i <= T.size(); i++) {
		tbuf[i] = tbuf[i - 1] + (T[i-1] == 'A' ? 1 : 2);
	}
	int Q;
	scanf("%d", &Q);
	for (int i = 0; i < Q; i++) {
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		a--; c--;
		int sc = sbuf[b] - sbuf[a];
		int tc = tbuf[d] - tbuf[c];
		if (sc % 3 == tc % 3) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main()
{
	int i,j,k,n,m;
	cin>>i>>j>>k;
	n=j-i;
	m=k-j;
	if(n==m)
		cout<<"YES";
	else
		cout<<"NO";
	cout<<endl;
	return 0;	
} 

Measured memory_bytes: 256
import sys
from collections import defaultdict
input = sys.stdin.buffer.readline

count = defaultdict(lambda: 0)

H, W, N = map(int, input().split())
for _ in range(N):
    a, b = map(int, input().split())
    for a_2 in range(a-1, a+2):
        for b_2 in range(b-1, b+2):
            if 2 <= a_2 <= H-1 and 2 <= b_2 <= W-1:
                count[a_2, b_2] += 1

ans = [0] * 10
for _, v in count.items():
    ans[v] += 1

ans[0] = (H-2) * (W-2) - sum(ans)

print(*ans, sep = '\n')

Measured memory_bytes: 217928
#include <bits/stdc++.h>
#define maxn 200010
#define ms(x,y) memset(x,y,sizeof x)
#define inf 0x3f3f3f3f
#define fir first
#define sec second
#define lb(x) (x&(-x))
const int mod=1e9+7;
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
int mn[maxn<<2];
void modify(int p,int L,int R,int l,int r,int v){
	if(L==l&&r==R)return (void)(mn[p]=v);
	int mid=L+R>>1;
	if(r<=mid)modify(p<<1,L,mid,l,r,v);
	else if(l>mid)modify(p<<1|1,mid+1,R,l,r,v);
	else modify(p<<1,L,mid,l,mid,v),modify(p<<1|1,mid+1,R,mid+1,r,v);
//	mn[p]=min(mn[p<<1],mn[p<<1|1]);
}
int query(int p,int L,int R,int pos){
	if(L==R)return mn[p];
	int mid=L+R>>1;
	if(pos<=mid)return min(mn[p],query(p<<1,L,mid,pos));
	else if(pos>mid)return min(mn[p],query(p<<1|1,mid+1,R,pos));
}
int n,k;
int l[maxn],r[maxn],sum[maxn],a[maxn],b[maxn],hs[maxn],tot;
ll f[maxn];
int main(){
//	freopen("train.in", "r", stdin);
//    freopen("train.out", "w", stdout);
	ms(mn,inf);
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
		sum[i]=((sum[i-1]-2*a[i])%k+k)%k;
		if(b[i]==1&&a[i]*2>k){
			puts("-1");
			return 0;
		}
		if(b[i]==2)l[i]=0,r[i]=k-1;
		else l[i]=sum[i-1],r[i]=sum[i];
		hs[++tot]=l[i],hs[++tot]=r[i];
	}
	sort(hs+1,hs+1+tot);
	tot=unique(hs+1,hs+1+tot)-hs-1;
	for(int i=1;i<=n;i++){
		l[i]=lower_bound(hs+1,hs+tot+1,l[i])-hs;
		r[i]=lower_bound(hs+1,hs+tot+1,r[i])-hs;	
	}
	for(int i=n;i;i--){
		int p=query(1,1,tot,l[i]);
		if(p!=inf){
			f[i]=f[p]+(hs[l[p]]-hs[l[i]]+k)%k;
		}
		if(l[i]<=r[i]){
			if(r[i]<tot)modify(1,1,tot,r[i]+1,tot,i);
			if(l[i]>1)modify(1,1,tot,1,l[i]-1,i);
		}else{
			if(r[i]+1<=l[i]-1)modify(1,1,tot,r[i]+1,l[i]-1,i);
		}
	}
	ll res=8e18;
	for(int i=1;i<=tot;i++){
		int p=query(1,1,tot,i);
		if(p!=inf)res=min(res,1ll*f[p]+(hs[l[p]]-hs[i]+k)%k);
		else res=0;
	}
	for(int i=1;i<=n;i++)res+=a[i]*2;
	cout<<res<<endl;
	return 0;
}

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

int main() {
  string S;
  string S1="SSS";
  string S2="RSS", S3="SRS", S4="SSR";
  string S5="RRS", S6="RSR", S7="SRR";
  string S8="RRR";
  int cnt = 0;
  cin >> S;
  
  if(S == S1){
    cnt = 0;
  }else if(S == S2 || S == S3 || S == S4 || S == S6){
    cnt = 1;
  }else if(S == S5 || S == S7){
    cnt = 2;
  }else {
    cnt = 3;
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 3616
import sys
import bisect
input = sys.stdin.readline
a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
for i in range(q):
    x = int(input())
    idx_s = bisect.bisect_left(s, x)
    idx_t = bisect.bisect_left(t, x)

    indices_s = []
    indices_t = []

    if idx_s == 0:
        indices_s.append(0)
    elif idx_s == a:
        indices_s.append(a-1)
    else:
        indices_s.append(idx_s)
        indices_s.append(idx_s-1)

    if idx_t == 0:
        indices_t.append(0)
    elif idx_t == b:
        indices_t.append(b-1)
    else:
        indices_t.append(idx_t)
        indices_t.append(idx_t-1)

    ans = []
    for i in indices_s:
        for j in indices_t:
            l, r = min(s[i], t[j]), max(s[i], t[j])
            if x < l:
                ans.append(r-x)
            elif l <= x and x < r:
                ans.append(min(r-l+(x-l), r-l+(r-x)))
            else:
                ans.append(x-l)
    print(min(ans))



Measured memory_bytes: 12204
function euc(a, b) {
    var r0 = a;
    var r1 = b;
    var x0 = 1;
    var x1 = 0;
    var y0 = 0;
    var y1 = 1;

    while (r1 > 0) {
        var q = Math.floor(r0 / r1);
        var r2 = r0 % r1;
        var x2 = x0 - q * x1;
        var y2 = y0 - q * y1;

        r0 = r1;
        r1 = r2;
        x0 = x1;
        x1 = x2;
        y0 = y1;
        y1 = y2;
    }
    return [x0, y0];
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
var nums = input.split(' ').map(function(num){return +num;});
var a = nums[0];
var b = nums[1];

console.log(euc(a, b).join(' '));

Measured memory_bytes: 7644
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Main
{
    public static class Program
    {
        static void Main(string[] arg)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = GetIntList(Console.ReadLine());
            int[] b = GetIntList(Console.ReadLine());
            int[] c = GetIntList(Console.ReadLine());

            int answer = 0;
            int before = 0;
            int after = 0;
            for(int i = 0;i<n;i++){
                int num = a[i];
                answer += b[num-1];
                before = after;
                after = num;
                if(before+1 == after){
                    if(before == 0){}
                    else{
                        answer += c[before-1];
                   }
                }
            }


            Console.WriteLine(answer);
            Console.ReadLine();
 
        }
        
        #region libraries
        private static int[] GetIntList(string line)
        {
            return line.Split(' ').Select(x => int.Parse(x)).ToArray();
 
        }
        private static double[] GetDoubleList(string line)
        {
            return line.Split(' ').Select(x => double.Parse(x)).ToArray();
 
        }
        private static ulong[] GetUlongList(string line)
        {
            return line.Split(' ').Select(x => ulong.Parse(x)).ToArray();
        }
        private static long[] GetLongList(string line)
        {
            return line.Split(' ').Select(x => long.Parse(x)).ToArray();
        }
        private static int SearchNearest(this IEnumerable<int> list, int target)
        {
            var min = list.Min(c => Math.Abs(c - target));
            return list.First(c => Math.Abs(c - target) == min);
        }
        public static bool IsOdd(int i)
        {
            return i % 2 == 1 ? true : false;
        }
        public static int Gcd(int a,int b)
        {
            if(a < b)
            {
                Gcd(b, a);
            }
            while (b != 0)
            {
                var rm = a % b;
                a = b;
                b = rm;
            }
            return a;
        }
        #endregion
    }
}

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

#define INF 0x33433433

int m;
int ws[] = {15, 12, 10, 5, 3, 2, 1};
int vs[] = {2244, 1870, 1520, 850, 550, 380, 380};
int dp[7][51];

int main() {
  while (1) {
    scanf("%d", &m);
    if (m == 0) return 0;

    for (int i=0; i<7; i++) {
      for (int j=0; j<=50; j++) {
        dp[i][j] = INF;
      }
    }

    dp[0][0] = 0;
    for (int i=0; i<6; i++) {
      for (int j=0; j<=50; j++) dp[i+1][j] = dp[i][j];
      for (int j=0; j<=50-ws[i]; j++) {
        dp[i+1][j+ws[i]] = min(dp[i+1][j]+vs[i], dp[i+1][j+ws[i]]);
      }
    }
    printf("%d\n", dp[6][m/100]);
  }
}

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

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

      int[][] arr = new int[n][3];
      for(int i = s.length() - 2; i >= 0; i--) {
        arr[i][0] = arr[i+1][0];
        arr[i][1] = arr[i+1][1];
        arr[i][2] = arr[i+1][2];
        char c = s.charAt(i+1);
        if(c == 'R') {
          arr[i][0]++;
        } else if(c == 'G'){
          arr[i][1]++;
        } else {
          arr[i][2]++;
        }
      }
      
      long sum = 0;
      for(int i = 0; i < n; i++) {
        char a = s.charAt(i);
        
        for(int j = i + 1; j < n; j++) {
          char b = s.charAt(j);
          if(a == b) continue;
          
          if(a == 'R' && b == 'G' || a == 'G' && b == 'R') {
            sum += arr[j][2]; //B
            if(j + j - i < s.length() && s.charAt(j + j - i) == 'B')
              sum--;
          }
          else if(a == 'B' && b == 'G' || a == 'G' && b == 'B') {
            sum += arr[j][0]; // R
            if(j + j - i < s.length() && s.charAt(j + j - i) == 'R')
              sum--;
          }
          else {
            sum += arr[j][1]; // G
            if(j + j - i < s.length() && s.charAt(j + j - i) == 'G')
              sum--;
          }
        }
      } 

      System.out.println(sum);
  }
}


Measured memory_bytes: 28400
#include <bits/stdc++.h>
using namespace std;
int main() {


	long long int n,k;
	cin>>n>>k;
	long long int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=k;i<n;i++)
    {
        if(a[i]>a[i-k])
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
	return 0;
}


Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int N = read();
    vector<int> A(N);
    for (auto& a:A) {
        a = read();
    }
    int tmp = 0;
    for (auto& a:A) {
        tmp ^= a;
    }
    if (tmp == 0) {
        printf("Yes\n");
        return;
    }
    printf("No\n");
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

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

int map[10][5], h, ans = 0;

int main() {

	while (true) {
		cin >> h;
		if (h == 0)break;

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < 5; j++) {
				cin >> map[i][j];
			}
		}

		while (true) {
			int ans2 = 0;
			bool flag = false;
			for (int i = 0; i < h; i++) {
				int c = 0;
				//cout << "i:" << i << endl;
				for (int j = 1; j < 5; j++) {
					if (map[i][j - 1] == map[i][j]) {
						c++;
						//cout << "map[h][j - 1]:" << map[h][j - 1] << " map[h][j]:" << map[h][j] << endl;
					}
					else if (c >= 2) {
						//flag = true;
						for (int k = 0; k < c + 1; k++) {
							ans2 += map[i][j - 1 - k];
							map[i][j - 1 - k] = 0;
						}
						c = 0;
					}//??£????????£??????????????????????????????
					else {
						c = 0;
					}

					if (map[i][j - 1] == map[i][j] && c >= 2 && j == 4) {
						//flag = true;
						for (int k = 0; k < c + 1; k++) {
							ans2 += map[i][j - k];
							map[i][j - k] = 0;
						}
					}
					//cout << "c;" << c << " ";
				}
				//cout << endl;
				c = 0;
			}

			/*for (int i = 0; i < h; i++) {
				for (int j = 0; j < 5; j++) {
					cout << map[i][j] << " ";
				}
				cout << endl;
			}
			cout << endl;*/

			for (int i = h - 1; i >= 0; i--) {
				for (int j = 0; j < 5; j++) {
					if (map[i][j] == 0) {
						for (int k = i; k >= 0; k--) {
							if (map[k][j] != 0) {
								flag = true;
								map[i][j] = map[k][j];
								map[k][j] = 0;
								break;
							}
						}
					}
				}
			}
			/*for (int i = 0; i < h; i++) {
				for (int j = 0; j < 5; j++) {
					cout << map[i][j] << " ";
				}
				cout << endl;
			}*/
			
			//cout << "ans2:" << ans2 << endl;
			ans += ans2;
			if (!flag)break;
		}

		cout << ans << endl;
		ans = 0;
	}
}

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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do{cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)
//#define MOD pow(10, 9) + 7

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);

const long MOD = 1e9 + 7;

int main() {
    int n, x;
    cin >> n >> x;
    vector<long> s(n);
    vector<long> dp(x+1, 0);
    vector<long> tmp_dp(x+1, 0);

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

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

    // 動的計画法部分
    dp[x] = 1;
    // n回回す
    for(int i=n-1; i>=0; i--) {
        // それぞれの解の結果をメモしていく
        for(int j=0; j<=x; j++) {
            tmp_dp[j] = dp[j] * i % MOD; // 後回し

            tmp_dp[j%s[i]] += dp[j]; // 選んだ時
        }
        dp = tmp_dp;
    }

    long ans = 0;
    for(int i=0; i<=x; i++) {
        ans += (dp[i] * i);
    }
    ans %= MOD;
    cout << ans << endl;

    return 0;
}


/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

// integerの各桁を足す
int sum_digits(int num) {
    int rtn = 0;
    string num_str = to_string(num);
    for(int i=0; i<num_str.size(); i++) {
        rtn += num_str[i] - '0';
    }   
    return rtn;
}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}



Measured memory_bytes: 1792
from operator import itemgetter
n = int(input())

abn = [list(map(int,input().split())) for _ in range(n)]


#abn.sort()
abn.sort(key = itemgetter(1) )


#print(abn)

ts = 0 # time_stamp
enable = True
for abi in abn:
    a, b = abi

    if not ts + a <= b:
        enable = False
        break
    else:
        ts += a

print('Yes' if enable else 'No')

Measured memory_bytes: 53732
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;
typedef std::pair<LL, LL> P;

const LL inf = 1123456789012;

struct edge { LL to, cost; };
std::vector<std::vector<edge>>G;
std::vector<LL>dist;
void dijkstra(LL r)
{
	std::fill(dist.begin(), dist.end(), inf);
	dist[r] = 0;
	std::priority_queue<P, std::vector<P>, std::greater<P>>queue;
	queue.push(P(0, r));
	while (!queue.empty())
	{
		auto p = queue.top(); queue.pop();
		LL cost = p.first, v = p.second;
		if (dist[v] < cost) continue;
		for (auto e : G[v])
		{
			if (dist[e.to] > dist[v] + e.cost)
			{
				dist[e.to] = dist[v] + e.cost;
				queue.push(P(dist[e.to], e.to));
			}
		}
	}
}

int main()
{
	LL V, E, r;
	in >> V >> E >> r;
	std::vector<LL>s(E), t(E), d(E);
	rep(i, E) in >> s[i] >> t[i] >> d[i];

	G.resize(V); dist.resize(V);
	rep(i, E) G[s[i]].push_back({ t[i], d[i] });
	dijkstra(r);

	rep(i, V)
	{
		if (dist[i] >= inf) out << "INF" << std::endl;
		else out << dist[i] << std::endl;
	}
}



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

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int x, y;
    cin >> x >> y;
    if (x * 2 <= y && y <= x * 4 && y % 2 == 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return 0;
}


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

int a, b, c, k;

int main() {
	cin >> a >> b >> c >> k;
	
	int cnt = 0;
	while (b <= a) {
		b *= 2;
		cnt++;
	}
	
	while (c <= b) {
		c *= 2;
		cnt++;
	}
	
	if (cnt <= k) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N,A,B;
  cin >> N >> A >> B;
  int count=0;
  int wa;
  int sum =0;
  for(int i=1;i<=N;i++){
    if(i<10){
      wa = i;
    }
	else if(i<100){
     wa = i/10 + i%10;       
    }    
   	else if(i<100){
     wa = i/10 + i%10;       
    }
   	else if(i<1000){
     wa = i/100 + i%100/10 + i%10;       
    }
    else if(i<10000){
     wa = i/1000 + i%1000/100 + i%100/10 + i%10;       
    }   
    else{
     wa = 1;  
    }
   
    	if( A<=wa && wa<=B){
			sum += i;
    	}
  }
  
  cout << sum << endl;
}

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

int main() {
  int N;
  cin >> N;
  for(int i = 0; i < N; ++i) {
    int r, t;
    cin >> r >> t;
    vector<int> ans;
    if(!(r%100) && !(t%30)) {
      ans.push_back(r/100 + t/30*5);
    } else if(!(r%100)) {
      ans.push_back(r/100 + t/30*5);
      ans.push_back(r/100 + t/30*5 + 5);
    } else if(!(t%30)) {
      ans.push_back(r/100 + t/30*5);
      ans.push_back(r/100 + t/30*5 + 1);
    } else {
      ans.push_back(r/100 + t/30*5);
      ans.push_back(r/100 + t/30*5 + 1);
      ans.push_back(r/100 + t/30*5 + 5);
      ans.push_back(r/100 + t/30*5 + 6);
    }
    for(auto i: ans) cout << (i==ans.front()?"":" ") << i;
    cout << endl;
  }
}

Measured memory_bytes: 3136
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;
int n;
vector<vector<int>> map;
vector<int> db, dw;
int main()
{
	int a, b;
	scanf("%d", &n);
	map.resize(n + 1);	db.resize(n + 1); dw.resize(n + 1);
	for (int i = 1; i < n; i++)
	{
		scanf("%d%d", &a, &b);
		map[a].push_back(b);
		map[b].push_back(a);
	}
	queue<int> goblack,gowhite;
	goblack.push(1); gowhite.push(n);
	db[1] = 1;	dw[n] = 1;
	while (!goblack.empty())
	{
		int t=goblack.front();
		goblack.pop();
		for (auto& k : map[t])
		{
			if (!db[k])
			{
				goblack.push(k);
				db[k] = db[t] + 1;
			}
		}
	}
	while (!gowhite.empty())
	{
		int t = gowhite.front();
		gowhite.pop();
		for (auto& k : map[t])
		{
			if (!dw[k])
			{
				gowhite.push(k);
				dw[k] = dw[t] + 1;
			}
		}
	}

	a = 0, b = 0;
	for (int i = 1; i <= n; i++)
	{
		if (db[i] <= dw[i]) a++;
		else b++;
	}
	printf("%s\n", a > b ? "Fennec" : "Snuke");
}

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

int d,g;
int p[10],c[10];

int dfs(int i,int m,int po,int t){
  if(i == d){
    if(po >= g){
      return t;
    }else{
      for(int j = 0;j < p[m];j++){
        po += (m+1)*100;
        t++;
        if(po >= g){
          return t;
        }
      }
      return INT_MAX;
    }
  }

  return min(dfs(i+1,m,po+p[i]*(i+1)*100+c[i],t+p[i]),dfs(i+1,i,po,t));
}


int main(){
  cin >> d >> g;

  for(int i = 0;i < d;i++){
    cin >> p[i] >> c[i];
  }

  cout << dfs(0,0,0,0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int N; cin >> N;
	vector<string> V;
	for (int i = 0; i < N; i++) {
		char s[10];
		for (int j = 0; j < 10; j++) cin >> s[j];
		sort(s, s + 10);
		string S;
		for (int j = 0; j < 10; j++) S += s[j];
		V.push_back(S);
	}

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

	ll ans = 0;

	for (int i = 0; i < N; i++) {
		string cur = V[i];
		ll cnt = 1;
		while (i + 1 < N && V[i + 1] == cur) {
			i++;
			cnt++;
		}

		ans += cnt * (cnt - 1) / 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7284
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
	string S;
	int N;

	cin >> S;

	N = S.size();
	string Sr = string(S);

	string s1 = S.substr(0, (N - 1) / 2);
	string s1r = S.substr(0, (N - 1) / 2);
	string s2 = S.substr((N + 1) / 2, (N - 1) / 2);
	string s2r = S.substr((N + 1) / 2, (N - 1) / 2);

	reverse(s1r.begin(), s1r.end());
	reverse(s2r.begin(), s2r.end());
	reverse(Sr.begin(), Sr.end());

	if (s1 == s1r && s2 == s2r && S == Sr) {
		puts("Yes");
	} else {
		puts("No");
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
long long int recover_all(int a) {
	return a * (a + 1LL) / 2;
}
int main() {
	int n, m; long long int k; std::cin >> n >> m >> k;
	std::vector<int> magic(n); for (auto& a : magic) std::cin >> a;
	std::sort(magic.begin(), magic.end());
	const auto need_to_recover = std::accumulate(magic.begin(), magic.end(), 0LL) - m;
	if (need_to_recover <= 0) {
		std::cout << 0 << '\n'; return 0;
	}
	int min{ 0 }, max{ m };
	while (min < max) {
		const auto mid = (min + max) >> 1;
		auto cookie = k;
		auto recover = need_to_recover;
		for (auto a : magic) {
			if (cookie < 0) break;
			if (mid < a) {
				const auto minus = std::min<long long int>(a - mid, recover);
				cookie -= minus;
				recover -= minus;
				a -= minus;
			}
			recover -= std::min<long long int>(recover, a);
		}
		if (cookie < 0) {
			min = mid + 1;
		}
		else {
			max = mid;
		}
	}
	auto cookie = k;
	auto recover = need_to_recover;
	long long int time{ 0 };
	int just{ 0 };
	for (auto a : magic) {
		if (max < a) {
			const auto minus = std::min<long long int>(a - max, recover);
			cookie -= minus;
			recover -= minus;
			a -= minus;
		}
		const auto r = std::min<long long int>(recover, a);
		time += recover_all(a) - recover_all(a - r);
		recover -= r;
		if (a == max) ++just;
	}
	const auto additional = std::min<long long int>(just, cookie);
	time -= max * additional;
	std::cout << time << '\n';
}



Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    long double a,b;
    cin >> a >> b;
    long double p = floor(a*b);
    long long ans = p;
    cout << ans << endl;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int arr[upperlimit];
int main() {
	int n,m=0,m2=INF;
	n=3;
	for(int i = 1; i <= n; i++){
		sd(arr[i]);
		m=max(m,arr[i]);
		m2=min(m2,arr[i]);
	}
	pd(m-m2);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	int N;
	vector<string> S;
	cin >> N;
	REP(i, 0, N) {
		string str;
		cin >> str;
		S.push_back(str);
	}

	bool flag = true;
	int a_cnt = 0, un_cnt = 0;
	REP(i, 0, N) {
		if (S[i] == "A") a_cnt++;
		else un_cnt++;

		if (a_cnt < un_cnt) {
			flag = false;
			break;
		}
	}
	if (flag && a_cnt == un_cnt) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
int N,i,ans,t;
char s;
int main()
{
	scanf("%d\n",&N);
	for(i=1;i<=N;i++)
	{
		scanf("%c",&s);
		if(s=='I')
		t++;
		else if(s=='D')
		t--;
		ans=max(t,ans);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================


	ll N, M;
	cin >> N >> M;

	ll omote = 0;
	ll ura = 0;

	if (N >= 3 && M >= 3) {
		cout << (N - 2) * (M - 2);
	}
	else if (N * M == 1) {
		cout << 1;
	}
	else if (N == 1) {
		if (M == 2) {
			cout << 0;
		}
		else {
			cout << M - 2;
		}
	}
	else if (M == 1) {
		if (N == 2) {
			cout << 0;
		}
		else {
			cout << N - 2;
		}
	}
	else {
		cout << 0;
	}


}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  long long A, B;
  cin >> A >> B;
  
  if ((A + B) % 2 == 0)  {
    cout << abs((A + B) / 2) << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import numpy as np
N, D = list(map(int, input().split()))
X = [np.array(list(map(int, input().split()))) for _ in range(N)]

ans = 0
for i in range(N):
    a = X[i]
    for b in X[i+1:]:
        u = a - b
        if np.linalg.norm(u).is_integer():
            ans += 1

print(ans)

Measured memory_bytes: 12492
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define error(args...) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    int N;
    while(cin >> N) {
        vector<LL> a(N);
        REP(i, N) cin >> a[i];
        LL ans = LLONG_MAX;
        REP(iter, 2){
            LL result = 0;
            LL s = 0;
            REP(i, N) {
                s += a[i];
                bool plus = ((iter + i) % 2 == 0);
                if(plus) {
                    if(s <= 0) {
                        result += abs(1 - s);
                        // cerr << i << " " << s << " " << 1 << endl;
                        // cerr << result << endl;
                        s = 1;
                    }
                } else {
                    if(s >= 0) {
                        result += abs(s + 1);
                        // cerr << i << " " << s << " " << -1 << endl;
                        // cerr << result << endl;
                        s = -1;
                    }
                }
            }
            // cerr << "end: " << result << endl;
            ans = min(ans, result);
        }
        cout << ans << endl;
    }
    return 0;
}



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

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 1000000000
#define PI 3.14159265358979323846

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;

//==============================================
#define NIL -2000000050

struct node {
	int key;
	int left = NIL;
	int right = NIL;
};

node T[500050];

void insert(int z) {
	int y = NIL;
	int x = 0;

	if (z == 0) return;

	while (x != NIL) {
		y = x;
		if (T[z].key < T[x].key) {
			x = T[x].left;
		} else {
			x = T[x].right;
		}
	}

	if (T[z].key < T[y].key) {
		T[y].left = z;
	} else {
		T[y].right = z;
	}
}

void inorder(int x) {
	if (x == NIL) return;
	inorder(T[x].left);
	cout << " " << T[x].key;
	inorder(T[x].right);
}

void preorder(int x) {
	if (x == NIL) return;
	cout << " " << T[x].key;
	preorder(T[x].left);
	preorder(T[x].right);
}


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

	int n;
	cin >> n;

	string s;
	int v;
	REP(i, n) {
		cin >> s;

		if (s == "insert") {
			cin >> v;
			T[i].key = v;
			insert(i);
		} else {
			inorder(0);
			cout << "\n";
			preorder(0);
			cout << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 9060
#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<LL,LL> 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; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,1,-1,1,-1,-1,0};
int dy[]={0,1,1,-1,-1,1,0,-1};


int main(){
    int n,k;cin>>n>>k;
    vector<int> p(n);
    vector<double> e(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        e[i] = (p[i] + 1) / 2.;
    }
    vector<double> ec(n+1,0);
    for (int i = 0; i < n; i++) {
        ec[i+1] = ec[i] + e[i];
    }
    double ans = 0.0;
    for (int i = 0; i <= n-k; i++) {
        chmax(ans, ec[i+k] - ec[i]);
    }
    cout << setprecision(30) << fixed << ans << endl;
    return 0;
}


Measured memory_bytes: 4096
#include<stdio.h>

long long s[100000];

typedef struct{
	long long a;
	long id;
} stone;
stone a[100000];

int cmp(const void *a, const void *b){
	if(((stone*)a)->a==((stone*)b)->a){
		return ((stone*)a)->id-((stone*)b)->id;
	}
	return ((stone*)b)->a-((stone*)a)->a;
}

int main(int argc, char const *argv[]) {
	long n,i;
	long long max;
	scanf("%ld",&n);
	for(i=0;i<n;i++){
		scanf("%lld",&a[i].a);
		a[i].id=i;
	}
	qsort(a,n,sizeof(stone),cmp);
	max=a[0].a;
	for(i=0;i<n;i++){
		if(max!=a[i].a){
			s[a[0].id]+=i*(max-a[i].a);
			if(a[0].id>a[i].id) a[0].id=a[i].id;
			max=a[i].a;
		}
	}
	s[0]+=((long long)n)*max;
	for(i=0;i<n;i++){
		printf("%lld\n",s[i]);
	}
	return 0;
}

Measured memory_bytes: 3424
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;

int main(){
    int a,b; cin>>a>>b;
    Yes(a*b%2);
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<i64>();
    let m = input::<i64>();
    let ypi = {
        let mut temp = (0..m)
            .map(|i| {
                let p = input();
                let y = input();
                (y, p, i)
            })
            .collect::<Vec<(i64, i64, i64)>>();
        temp.sort();
        temp
    };

    let mut cnt_p = vec![0; n as usize];
    let mut ans = vec![(0, 0); m as usize];
    for i in 0..m {
        let (_, p, c) = ypi[i as usize];
        cnt_p[p as usize - 1] += 1;
        ans[i as usize] = (c, 1000000 * (p) + cnt_p[p as usize - 1]);
    }
    ans.sort();

    let out = std::io::stdout();
    let mut buf = std::io::BufWriter::new(out.lock());
    for a in ans {
        writeln!(buf, "{:012}", a.1).unwrap();
    }
}


Measured memory_bytes: 13820
my $s = <STDIN>;
my @Forcast = split(//,$s);
$s = <STDIN>;
my @obs = split(//,$s);


my $count = 0;
for(my $i=0;$i<$#Forcast;$i++){
  
  if( $Forcast[$i] eq $obs[$i]){
    $count++;
  }
}
print "$count";

Measured memory_bytes: 384
import sys
input = sys.stdin.readline

n = int(input())
ab = [tuple(map(int, input().split())) for _ in range(n)]

ab.sort(key=lambda x: x[1])

sum = 0
for cost, limit in ab:
    sum += cost
    if sum > limit:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 31840
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
ans = (n - 1) * n // 2
print(ans)

Measured memory_bytes: 60268
/*** Numeral System ***/

#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int num(string s){
	int i=0, ans=0;
	map<char, int> ctoi;
	ctoi['m']=1000;
	ctoi['c']=100;
	ctoi['x']=10;
	ctoi['i']=1;
	
	while(i<s.size()){
		int a=1;
		if(isdigit(s[i])){
			a=s[i]-'0';
			i++;
		}
		ans+=a*ctoi[s[i]]; //check(s[i]);
		i++;
	}
	
	return ans;
}

void print_mcxi(int val){
	int x=1000;
	map<int, char> itoc;
	itoc[1000]='m';
	itoc[100] ='c';
	itoc[10]  ='x';
	itoc[1]   ='i';
	
	while(x>0){
		if(val/x>1) cout << val/x << itoc[x];
		else if(val/x==1) cout << itoc[x];
		val%=x;
		x/=10;
		
	}
	cout << endl;
	return;
}

int main(){
	int n;
	
	cin >> n;
	REP(i, 0, n){
		int sum;
		string str1, str2;
		cin >> str1 >> str2;
		
		sum=num(str1)+num(str2);
		
		print_mcxi(sum);
		
	}
	
	return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int N;
	cin>>N;
	vec(A)
	fx(N){
		vecp(A)
	}
	sorts(A)
	ce(A.at(N-1)-A.at(0))
	
}

Measured memory_bytes: 256
n=int(input())

import math
def isPrime(num):
    if num < 2: return False
    elif num == 2: return True
    elif num % 2 == 0: return False
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False
    return True
def callIsPrime(input_num):
    numbers = []
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)
    return numbers

tmp=callIsPrime(10000)
result=[]
cnt=0
for item in tmp:
    if item%5==1:
        result.append(item)
        cnt+=1
    if cnt==n:
        break
#print(len(result))
print(" ".join(map(str,result)))

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

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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



int main(){
    bool flag=true;
    ll ans=0,sum=0;
    int n,count=0,mx=0;
    cin >>n;

    for (int i = 0; i < n; i++)
    {
        int a;
        cin>>a;
        while (a%2 == 0)
        {
            a/=2;
            ans++;
        }
    }
    



    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
using namespace std;

int main(){
	char a[5];
	scanf("%s",a);
	if(a[1]=='R')   printf("ABC");
	else    printf("ARC");
	return 0;
}


Measured memory_bytes: 3828
def prime_factorize(n):
    a = {}
    while n % 2 == 0:
        if 2 not in a:
            a[2] = 1
        else:
            a[2] += 1
        n //= 2
        # print('[A]n:{}, a:{}'.format(n, a))
    f = 3
    while f * f <= n:
        while n % f == 0:
            if f not in a:
                a[f] = 1
            else:
                a[f] += 1
            n //= f
        f += 2
        # print('[B]f:{}, n:{}, a:{}'.format(f, n, a))
    if n != 1:
        if f not in a:
            a[f] = 1
        else:
            a[f] += 1
        # print('[C]f:{}, n:{}, a:{}'.format(f, n, a))
    return a

x = int(input())
y = prime_factorize(x)

# print(y)

num = 0
for v in y.values():
    now_v = v
    i = 1
    while True:
        if now_v < i:
            break
        now_v -= i
        num += 1
        i += 1

print(num)

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl
#define err(x) cerr<<(x)<<endl
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 200010
#define lim9 1000000010

#define deg(rad) (((rad)/2/M_PI)*360)
#define mid(min, max) ((min + max) / 2)

int main() {
	in(k);
	string s;
	cin >> s;
	if (k >= s.length()) {
		out(s);
		return 0;
	} else {
		out(s.substr(0, k) + "...");
		return 0;
	}
}


Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    int n; cin >> n;
    for(int i = 0; i < n; i++){
        int a, b; cin >> a >> b;
        int ans = a % b;
        if(ans == 0) ans = b;
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <string>

typedef long long ll;

int main(int argc, char* argv[])
{
  ll x;
  std::cin >> x;

  ll mod_cnt = 0;
  if (x % 11 > 6) {
    mod_cnt = 2;
  } else if (x % 11 > 0) {
    mod_cnt = 1;
  } else {
    mod_cnt = 0;
  }

  std::cout << x / 11 * 2 + mod_cnt << std::endl;
  return 0;
}


Measured memory_bytes: 256