akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;
struct P{
int x,y;
};
int main(){
	int W,H,n;
	cin>>W>>H>>n;
	
	P now;
	cin>>now.x>>now.y;
	int ans=0;
	for(int i=1;i<n;i++){
		P tmp;
		cin>>tmp.x>>tmp.y;
		while(now.x!=tmp.x ||now.y!=tmp.y){
			ans++;
			if(now.x>tmp.x){
				if(now.y>tmp.y){
					now.x--;
					now.y--;
				}
				else now.x--;
			}
			else if(now.x==tmp.x){
				if(now.y>tmp.y)now.y--;
				else now.y++;
			}
			else if(now.x<tmp.x){
				if(now.y<tmp.y){
					now.x++;
					now.y++;
				}
				else now.x++;
			}
		}
	
	}
	cout<<ans<<endl;
}

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

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

    vector<int> A(H + 1);
    for (int i = 1; i <= H; i++)
    {
        cin >> A[i];
    }

    for (int i = 1; i <= H; i++)
    {
        cout << "node " << i << ": key = " << A[i] << ", ";
        if (i > 1)
        {
            cout << "parent key = " << A[i / 2] << ", ";
        }
        if (i * 2 <= H)
        {
            cout << "left key = " << A[i * 2] << ", ";
        }
        if (i * 2 + 1 <= H)
        {
            cout << "right key = " << A[i * 2 + 1] << ", ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int main(){
  cin >> n >> a >> b;
  int sum=0,total=0,c=0;
  for(int i=1;i<=n;i++){
    sum=0;
    c=i;
    while(c > 0){
      sum+=c%10;
      c/=10;
    }
    if(sum>=a && sum<=b) total+=i;
  }
  cout << total << endl;
}


Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0
for i in range(n-1,-1,-1):
    if i == 0:
        if a[i] != 0:
            print(-1)
            exit()
    else:
        if a[i-1] + 1 < a[i]:
            print(-1)
            exit()
        elif a[i-1] + 1 == a[i]:
            ans += 1
        else:
            ans += a[i]
print(ans)

Measured memory_bytes: 57432
import java.util.Scanner;

public class Main {

	public static void main(String aargs[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();
		dp = new Boolean[k + 1];
		System.out.println(canWin(k, a) ? "First" : "Second");

	}

	static Boolean dp[];

	public static boolean canWin(int k, int[] a) {

		if (dp[k] == null) {

			for (int i : a) {
				if (i == k)
					return dp[k] = true;
				else if (i < k)
					if (!canWin(k - i, a))
						return dp[k] = true;
			}
			dp[k] = false;
		}
		return dp[k];
	}

	private static int next(String str, int s1) {
		int j = s1 + 1;
		for (; j < str.length() && str.charAt(j) == str.charAt(s1); j++)
			;
		return j - s1;
	}
}

Measured memory_bytes: 31572
{-# LANGUAGE BangPatterns     #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiWayIf       #-}
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State
import           Control.Monad.Trans.State
import           Data.Array.IArray
import           Data.Array.ST
import           Data.Array.Unboxed        (UArray)
import qualified Data.Array.Unboxed        as U
import           Data.Bits
import           Data.ByteString.Char8     (ByteString)
import qualified Data.ByteString.Char8     as BS
import           Data.Char
import           Data.Graph
import           Data.Int                  (Int64)
import           Data.List
import           Data.Maybe
import           Data.Proxy
import           Data.Sequence             (Seq, (<|), (><), (|>))
import qualified Data.Sequence             as Seq
import qualified Data.Set                  as S
import           Data.STRef
import qualified Data.Vector               as V
import qualified Data.Vector.Unboxed       as VU
import           Numeric

main :: IO ()
main = do
  x <- readLn :: IO Int
  print $ if
    | x >= 400 && x < 600 -> 8
    | x >= 600 && x < 800 -> 7
    | x >= 800 && x < 1000 -> 6
    | x >= 1000 && x < 1200 -> 5
    | x >= 1200 && x < 1400 -> 4
    | x >= 1400 && x < 1600 -> 3
    | x >= 1600 && x < 1800 -> 2
    | x >= 1800 && x < 2000 -> 1


-- converter
unconsChar :: StateT BS.ByteString Maybe Char
unconsChar = StateT BS.uncons

unconsInt :: StateT BS.ByteString Maybe Int
unconsInt = StateT $ BS.readInt . BS.dropWhile isSpace

unconsInteger :: StateT BS.ByteString Maybe Integer
unconsInteger = StateT $ BS.readInteger . BS.dropWhile isSpace

-- for list
readLnAsListWith :: StateT BS.ByteString Maybe a -> IO [a]
readLnAsListWith st = unfoldr (runStateT st) <$> BS.getLine

-- for unboxed vector
readLnAsUVecNWith :: VU.Unbox a => Int -> StateT BS.ByteString Maybe a -> IO (VU.Vector a)
readLnAsUVecNWith !n !st = VU.unfoldrN n (runStateT st) <$> BS.getLine

-- for boxed vector
readLnAsVecNWith :: Int -> StateT BS.ByteString Maybe a -> IO (V.Vector a)
readLnAsVecNWith !n !st = V.unfoldrN n (runStateT st) <$> BS.getLine

getAsString :: IO [String]
getAsString = map BS.unpack . BS.words <$> BS.getLine

getAsCharArray1DWithLength :: IO (Int, UArray Int Char)
getAsCharArray1DWithLength = BS.getLine >>= \ !cs ->
  let !n = BS.length cs
      !ary = (U.listArray (1,n) $ unfoldr BS.uncons cs) :: UArray Int Char
  in return (n, ary)

-- n: number of lines
-- m: number of chars per a line
getAsCharArray2D :: Int -> Int -> IO (UArray (Int,Int) Char)
getAsCharArray2D !n !m = U.listArray ((1,1),(n,m)) . unfoldr BS.uncons . BS.concat <$> replicateM n BS.getLine


Measured memory_bytes: 3940
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N, M;
int a[100001];
int dp[100001];
map<int, int> m;

void solve()
{
    dp[0] = 1;
    int j = 0;
    FOR(i, 1, N+1){
        if(i >= 1 && m[i-1] != 1) dp[i] = (dp[i] + dp[i-1]) % MOD;
        if(i >= 2 && m[i-2] != 1) dp[i] = (dp[i] + dp[i-2]) % MOD;
    }
    cout << dp[N] << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    REP(i, M){
        cin >> a[i];
        m[a[i]] = 1;
    }
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef vector<P> vec;

double eps=1e-8;
double PI=acos(-1);

bool eq(double a,double b){return (b-a<eps&&a-b<eps);}
double dot(P a,P b){return real(b*conj(a));}
double cross(P a,P b){return imag(b*conj(a));}
P project(P a,P b,P c){b-=a;c-=a;return a+b*real(c/b);}
P reflect(P a,P b,P c){b-=a;c-=a;return a+conj(c/b)*b;}
int ccw(P a,P b,P c){
  b-=a,c-=a,a=c*conj(b);
  if(a.imag()>eps)return 1;//ccw
  if(a.imag()<-eps)return -1;//cw
  if(a.real()<-eps)return 2;//ob
  if(abs(b)+eps<abs(c))return -2;//of
  return 0;//os
}

//segment ab , point c
double dist(P a,P b,P c){
  if(dot(b-a,c-a)<0)return abs(c-a);
  if(dot(a-b,c-b)<0)return abs(c-b);
  return abs(cross(b-a,c-a))/abs(b-a);
}

bool isintersect(P a,P b,P c,P d){
  return ((ccw(a,b,c)*ccw(a,b,d)<=0)&&(ccw(c,d,a)*ccw(c,d,b)<=0));
}

//segment ab , segment cd
P intersect(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

double dist(P a,P b,P c,P d){
  if(isintersect(a,b,c,d))return 0;
  double ab=min(dist(a,b,c),dist(a,b,d));
  double cd=min(dist(c,d,a),dist(c,d,b));
  return min(ab,cd);
}

double calcArea(vec &t){
  double res=0;
  int n=t.size();
  for(int i=0;i<n;i++)res+=cross(t[i],t[(i+1==n?0:i+1)]);
  return abs(res/2.0);
}

double atan(P p){ return atan2(p.imag(),p.real()); }

double Arg(P a,P b,P c){
  b-=a,c-=a;
  return atan(c*conj(b));
}

int inPolygon(vec &t,P p){
  int n=t.size();
  double sum=0;
  for(int i=0;i<n;i++){
    P a=t[i],b=t[(i+1==n?0:i+1)];
    if( ccw(a,b,p) == 0 )return 1;
    sum+= Arg(p,a,b);
  }
  //  printf("%.8f\n",sum);
  if( abs(sum) < 0.001 )return 0;
  else  return 2;
}

int main(){
  int n;
  cin>>n;
  vec t;
  double x,y;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    t.push_back(P(x,y));
  }
  int q;
  cin>>q;
  while(q--){
    cin>>x>>y;
    cout<<inPolygon(t,P(x,y))<<endl;
  }

  return 0;
}

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

main() {
    int A,B,C,D; cin >> A >> B >> C >> D;
    cout << max(A*B,C*D) << endl;

    return 0;
}

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

int main(int argc, char* argv[]) {
  int n, b, f, r, v;
  cin >> n;
  int room[12][10];
  for(int i=0;i<12;i++){
    for(int j=0;j<10;j++){
      room[i][j] = 0;
    }
  }

  for(int i=0;i<n;i++){
    cin >> b >> f >> r >> v;
    room[(b-1)*3+(f-1)][r-1] += v;
  }

  for(int i=0;i<12;i++){
    if(i%3==0 && i!=0){
      cout << "####################" << endl;
    }
    for(int j=0;j<10;j++){
      cout << " " << room[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    int a, b;
    foreach (c; readln.chomp) {
        if (c == '0') {
            ++a;
        } else {
            ++b;
        }
    }
    writeln(min(a, b) * 2);
}

Measured memory_bytes: 2428
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string serch_word,sample_word;
           // while(true)
            {
                //??????????????????
                var read = Console.ReadLine();
                sample_word = read;
                read = Console.ReadLine();
                serch_word = read;

                sample_word += sample_word;

                if (0 <= sample_word.IndexOf(serch_word))
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");

                }

            }
            
        }
    }
}

Measured memory_bytes: 9804
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9;

int main(){
  int N,W,w[100],v[100];
  cin>>N>>W;
  for (int i(0);i<N;i++) cin>>w[i]>>v[i];
  ll dp[100001]={0}; //i番目までを使って重さw以下になるように選んだ時の価値の最大値
  for (int i(0);i<N;i++){
    for (int j(W);j>=0;j--){
      if (w[i]<=j) dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
    }
  }
  cout << dp[W] << endl;
}


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

int down(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}

int main(){
  int n;
  scanf("%d", &n);
  int a[n], b[n];
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
    b[i] = a[i];
  }
  qsort(b, n, sizeof(int), down);
  int ans;
  for(int i = 0; i < n; i++){
    if(a[i] == b[0]){
      ans = b[1];
    }else{
      ans = b[0];
    }
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 3120
import java.util.Arrays;

class Main {
    public static void main(String args[]) {
        java.util.Scanner sc = new java.util.Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String[] subsequence = new String[2*n];

        for(int i=0; i<n*2; i++){
            subsequence[i] = sc.next();
        }
        for(int i=0; i<n; i++){
            lcs(subsequence[i*2], subsequence[(i*2)+1]);      
        }
        // 0 1 2 3 4 5 
        
    }

    static private void lcs(String str1, String str2){
        int l1 = str1.length();
        int l2 = str2.length();
        int[][] dp= new int[l1+1][l2+1];
        Arrays.fill(dp[0], 0);
        for(int i=0; i<l1; i++) dp[i][0] = 0;

        for(int i=0; i<str1.length(); i++){
            for(int j=0; j<str2.length(); j++){
                if(str1.charAt(i) == str2.charAt(j)){
                    dp[i+1][j+1] = dp[i][j]+1;
                } else {
                    dp[i+1][j+1] = Math.max(dp[i][j+1], dp[i+1][j]);
                }
                
            }
        }
        System.out.println(dp[l1][l2]);
    }
}




Measured memory_bytes: 64716
n = int(input())
a = list(map(int, input().split()))

ans = 0
c = 0
while True:
    for i in range(n):
        if a[i] % 2 == 0:
            c += 1
    if c == n:
        for i in range(n):
            a[i] = a[i] // 2
        ans += 1
        c = 0
    else:
        print(ans)
        exit()


Measured memory_bytes: 9176
from collections import defaultdict
n, m = map(int, input().split())
cnt = defaultdict(int)
for _ in range(m):
    a, b = map(int, input().split())
    cnt[a] ^= 1
    cnt[b] ^= 1

if any(v for v in cnt.values()):
    print('NO')
else:
    print('YES')

Measured memory_bytes: 9448
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int t, p, r;
    while(cin >> t >> p >> r, t){
        vector<array<int, 3>> team(t);
        for (int i = 0; i < t; ++i) {
            team[i][2] = i;
        }
        vector<vector<int>> wa(t, vector<int>(p));
        while(r--){
            int a, b, c; string s;
            cin >> a >> b >> c >> s;
            a--; b--;
            if(s == "CORRECT"){
                team[a][0]--; team[a][1] += c+wa[a][b]*1200;
            }else {
                wa[a][b]++;
            }
        }
        sort(team.begin(),team.end());
        for (int i = 0; i < t; ++i) {
            printf("%d %d %d\n", team[i][2]+1, -team[i][0], team[i][1]);
        }
    }
    return 0;
}


Measured memory_bytes: 3232
n,x = map(int,input().split())
xl = list(map(int,input().split()))
a = [abs(i-x) for i in xl]
def gcd(x,y):
    if x<y:
        x,y = y,x
    if y==0:
        return x
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)
ans = a[0]
for i in a:
    ans = gcd(ans,i)
print(ans)

Measured memory_bytes: 14224
N, K = map(int, input().split())
sweet = [0 for i in range(N)]
for i in range(K):
  s = input()
  for j in map(int, input().split()):
    sweet[j-1] = 1
cnt = 0
for k in sweet:
  if k == 0:
    cnt += 1
print(cnt)


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

using namespace std;

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

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

  int minAbs = INT_MAX;
  for (int t = 0; t < n; t++) {
    int s1 = 0;
    for (int i = 0; i <= t; i++) {
      s1 += w[i];
    }

    int s2 = 0;
    for (int i = t + 1; i < n; i++) {
      s2 += w[i];
    }

    minAbs = min(minAbs, abs(s1 - s2));
  }

  cout << minAbs << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	cout << ((a+b<c)?"No":"Yes") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    int a[N], b[N-1];
    REP(i, N){
        cin >> a[i];
    }

    FOR(i, 1, N){
        b[i-1] = a[i] - a[i-1];
    }

    int res = 1;
    int temp1 = 0;
    int temp2 = 0;

    REP(i, N-1){
        if (b[i] > 0){
            temp2 += 1;
        }
        else if (b[i] < 0){
            temp2 += -1;
        }

        if (abs(temp1) > abs(temp2)){
            res += 1;
            temp1 = 0;
            temp2 = 0;
        }
        else{
            temp1 = temp2;
        }
        
    }

    cout << res << endl;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

import collections

ac = collections.Counter(a)
common = ac.most_common()

operation_count = 0
for num, num_count in common:
  if num < num_count:
    operation_count += num_count - num
  elif num_count < num:
    operation_count += num_count

print(operation_count)
    

Measured memory_bytes: 21620
#include <stdio.h>

int main()
{
  int cnt;
  unsigned long long int K,A,B;
  unsigned long long int i;
  unsigned long long int cookie=1;
  unsigned long long int yen=0;

  cnt = scanf("%lld %lld %lld", &K,&A,&B);

  if (A >= B) {
    printf("%lld", (K+1));
    return 0;
  }

  for (i=K; i>0; i--) {
    if (yen > 0) {
      cookie += (yen*B);
      yen = 0;
      continue;
    }
    if ((cookie >= A) && (i > 1)) {
      yen++;
      cookie -= A;
      continue;
    }
    cookie++;
  }

  if (cookie < (K+1)) {
    cookie = K+1;
  }

  printf("%lld", cookie);
  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;

void main() {
	auto ip = readln.split.to!(int[]), N = ip[0], L = ip[1];
	auto S = new string[](N);
	foreach(i; 0..N) 
		S[i] = readln.chomp;
	S.sort();
	string res;
	foreach(S_i; S) {
		res ~= S_i;
	}
	writeln(res);
}


Measured memory_bytes: 380
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AStillTBD solver = new AStillTBD();
        solver.solve(1, in, out);
        out.close();
    }

    static class AStillTBD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();

            String[] parts = s.split("/");
            int y = Integer.parseInt(parts[0]);
            int m = Integer.parseInt(parts[1]);
            int d = Integer.parseInt(parts[2]);

            long time = y * 10000 + m * 100 + d;

            out.println(time <= 2019 * 10000 + 4 * 100 + 30 ? "Heisei" : "TBD");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <vector>
#include <set>

using namespace std;

typedef long long ll;

vector<ll> Dziel(ll n)
{
    vector<ll> d;
    for (ll i = 1; i * i <= n; ++i)
    {
        if (n % i == 0)
            d.push_back(i);
        if (n % (n / i) == 0 && i * i != n)
            d.push_back(n / i);
    }
    return d;
}

bool Ok(ll n, ll k)
{
    if (k == 1)
        return false;
    while (n % k == 0)
        n /= k;
    if ((n - 1) % k == 0)
        return true;
    return false;
}

bool Ok2(ll n, ll k)
{
    if (k == 1)
        return false;
    if ((n - 1) % k == 0)
        return true;
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0);
    ll n;
    cin >> n;
    vector<ll> d1 = Dziel(n);
    vector<ll> d2 = Dziel(n - 1);
    set<ll> odp;
    for (int i = 0; i < d1.size(); ++i)
        if (Ok(n, d1[i]))
            odp.insert(d1[i]);
    for (int i = 0; i < d2.size(); ++i)
        if (Ok2(n, d2[i]))
            odp.insert(d2[i]);
    cout << odp.size();
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  vector<int> num(26);
  for(int i=0;i<S.size();i++){
    int A=S.at(i)-'a';
    num.at(A)++;
  }
  for(int i=0;i<26;i++){
    if(num.at(i)%2==1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
      

Measured memory_bytes: 3580
#include <stdio.h>

int main(){
    int n, x;
    int a, b, c, ans;
    while(1){
        scanf("%d%d", &n, &x);
        if(n == 0 && x == 0){break;}
        
        ans = 0;
        
        for(a = 1; a <= n; a++){
            for(b = a; b <= n; b++){
                for(c = b; c <= n; c++){
                    if(a == b || b == c || c == a){
                        continue;
                    }
                    if(x == a + b + c){
                 //       printf("%d,%d,%d\n",a,b,c);
                        ans++;
                    }
                }
            }    
        }
        
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
#define double long double
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

struct edge{ int to,cost; };

vector<edge> G1[100000],G2[100000];
int n;
int d1[100000],d2[100000];

void dijkstra(int s,int *d,bool flag){
	vector<edge> G[100000];
	for(int i = 0;i < n;i++){
		if(!flag) G[i] = G1[i];
		else G[i] = G2[i];
	}
	priority_queue<P,vector<P>,greater<P> > que;
	for(int i = 0;i < n;i++) d[i] = INF;
	d[s] = 0;
	que.push(P(0,s));
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0;i < G[v].size();i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}

signed main(){
	int m,s,t;
	cin >> n >> m >> s >> t; s--;t--;
	for(int i = 0;i < m;i++){
		int a,b,c,d;
		cin >> a >> b >> c >> d; a--;b--;
		G1[a].pb({b,c});
		G1[b].pb({a,c});
		G2[a].pb({b,d});
		G2[b].pb({a,d});
	}
	dijkstra(s,d1,false);
	dijkstra(t,d2,true);
	int ans[100001];
	ans[n] = INF;
	for(int i = n - 1;i >= 0;i--){
		ans[i] = min(ans[i + 1],d1[i] + d2[i]);
	}
	for(int i = 0;i < n;i++) cout << 1000000000000000 - ans[i] << endl;
	return 0;
}

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

typedef long long LL;

const int N = 2e5 + 10, M = 2010;
const LL mod = 1e9 + 7;

LL power(LL a, LL b)
{
	LL c = 1;
	for (; b; a = a * a % mod, b >>= 1)
		if (b & 1) c = c * a % mod;
	return c;
}

LL fac[M << 2], inv[M << 2];

void init(int n)
{
	fac[0] = 1;
	for (int i = 1; i <= n; ++ i)
		fac[i] = fac[i - 1] * i % mod;
	inv[n] = power(fac[n], mod - 2);
	for (int i = n - 1; i >= 0; -- i)
		inv[i] = inv[i + 1] * (i + 1) % mod;
}

LL C(int n, int m) { return fac[n] * inv[m] % mod * inv[n - m] % mod; }

int n;
int a[N], b[N], maxa, maxb;

LL f[M << 1][M << 1];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i)
	{
		scanf("%d %d", &a[i], &b[i]);
		maxa = max(maxa, a[i]);
		maxb = max(maxb, b[i]);
	}
	++ maxa, ++ maxb;
	init(maxa + maxb << 1);
	for (int i = 1; i <= n; ++ i)
		++ f[maxa - a[i]][maxb - b[i]];
	for (int i = 1; i <= maxa << 1; ++ i)
		for (int j = 1; j <= maxb << 1; ++ j)
			(f[i][j] += f[i - 1][j] + f[i][j - 1]) %= mod;
	LL ans = 0;
	for (int i = 1; i <= n; ++ i)
		(ans += f[maxa + a[i]][maxb + b[i]]) %= mod;
	for (int i = 1; i <= n; ++ i)
		(ans += mod - C(a[i] + b[i] << 1, a[i] << 1)) %= mod;
	printf("%lld\n", ans * power(2, mod - 2) % mod);
}

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

const int N = 2e5+10;
int p[N], s[N];

int find(int x){
	return x == p[x] ? x : p[x] = find(p[x]);
}

void _union(int x, int y){
	p[x] = y;
}
int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	int u, v;
	for(int i = 0; i <= n; i++){
		p[i] = i;
		s[i] = 1;
	}
	int res = 0;
	for(int i = 0; i < m; i++){
		scanf("%d%d", &u, &v);
		int ur = find(u);
		int vr = find(v);
		if(ur != vr){
			_union(ur, vr);
			s[vr] += s[ur];
			res = max(res, s[vr]);
		}
	}
	cout << max(1,res) << endl;
}


Measured memory_bytes: 5324
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll s=-1,g=1000000000000,a,ans,cnt,n,k,L,m;
vector<ll> u,v;
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a;
        v.push_back(a);
    }
    for(int i=0;i<n;i++){
        cin>>a;
        u.push_back(a);
    }
    sort(v.begin(),v.end());
    sort(u.begin(),u.end());
    reverse(v.begin(),v.end());
    while(g-s>1){
        m=(s+g)/2;
        cnt=0;
        for(int i=0;i<n;i++){
            L=m/u[i];
            cnt+=max(v[i]-L,0LL);
        }
        if(cnt<=k)g=m;
        else s=m;
    }
    cout<<g<<endl;
}


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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 100500;

ll ans;
int n, a[N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;
	
	cin >> n;

	for (int i = 1; i <= n + n; i++)
		cin >> a[i];

	sort(a + 1, a + n + n + 1);

	for (int i = 1; i <= n + n; i += 2)
		ans += a[i];

	cout << ans;
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 256
from sys import stdin

N, M, C = [int(x) for x in stdin.readline().rstrip().split()]
A = []
B = []
B = [int(x) for x in stdin.readline().rstrip().split()]
for i in range(0, N):
    A.append([int(x) for x in stdin.readline().rstrip().split()])


count = 0
for i in range(0, N):
    sum = 0
    for j in range(0,M):
        sum += A[i][j] * B [j]
    if sum + C > 0:
        count += 1

print(count)

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

int main() {
  string s, re = "Yes";
  cin >> s;
  if(s.size()%2 != 0){
      re = "No";
  } 
  for(int i = 0;i < s.size();i++){
    if(i%2 == 0){
        if(s.at(i) != 'h'){
            re = "No";
        }
    }
    else{
        if(s.at(i) != 'i'){
            re = "No";
        }
    }
  }
  cout << re << endl;
}

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

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

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

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

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};
int main()
{
  int n; cin >> n;
  mint ans = modpow(10, n);
  ans -= modpow(9, n);
  ans -= modpow(9, n);
  ans += modpow(8, n);
  cout << ans.x << endl;
}

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

using namespace std;

typedef pair<int, int> P;

int main() {
  string w;
  cin >> w;
  vector<int> alp(26, 0);
  for (int i = 0; i < w.size(); ++i) {
    alp[w[i] - 'a']++;
  }
  string res = "Yes";
  for (auto i : alp) if (i % 2 == 1) res = "No";
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t / 2;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}



int main() {
    long long a , b, ans = 0;
    cin >> a >> b;
    if (a > 0 && b > 0){
        cout << "Positive" << endl;
        return 0;
    }else if (a <= 0 && b >= 0){
        cout << "Zero" << endl;
    }else if((b - a) % 2 == 0){
        cout << "Negative" << endl;
    }else{
        cout << "Positive" << endl;
    }
}   

Measured memory_bytes: 256
#include<cstdio>
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        double x1,y1,x2,y2,x3,y3,x4,y4;
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        if((y2-y1)/(x2-x1)==(y4-y3)/(x4-x3)) printf("YES\n");
        else printf("NO\n");
    }
}

Measured memory_bytes: 1048
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

int n;
int64_t ac[3][100001];
int64_t dp[3][100001];

int64_t f(int l, int i) {
  if (i == n) return 0;
  if (l >= 0 && dp[l][i] != -1) return dp[l][i];
  int64_t best = 0;
  for (int a = 0; a < 3; ++a) {
    if (a == l) continue;
    best = std::max(best, ac[a][i] + f(a, i + 1));
  }
  if (l >= 0) dp[l][i] = best;
  return best;
}

int main() {
  std::memset(dp, -1, sizeof(dp));
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    std::cin >> ac[0][i] >> ac[1][i] >> ac[2][i];
  }
  std::cout << f(-1, 0) << '\n';
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll = long long;
 
int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double ha = (h*30 + 30*m/60)*2*M_PI/360;
    double ma = m*6*2*M_PI/360;
    double angle = max(abs(ha-ma),2*M_PI-abs(ha-ma));
    double ans = sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(angle));
    cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4092
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
	string s;cin>>s;
	string ret=s.substr(0,(int)s.size()-8);
	cout<<ret<<endl;
	return 0;
}



Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<i32>();
    let (a, b, x) = (line[0], line[1], line[2]);

    if a > x || b < x-a{
        println!("NO");
    }else{
        println!("YES");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

vector<int> G[100005];
int used[100005];

int main(){
    int n,m; cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b; cin >> a >> b;
        G[b].push_back(a);
        G[a].push_back(b);
    }
    queue<P> que; //いま、さっき
    que.push(P(1,1));
    while(!que.empty()){
        P p=que.front(); que.pop();
        if(used[p.first]) continue;
        used[p.first]=p.second;
        //cout << "hey " << p.first  << " " << p.second << endl;
        for(auto v:G[p.first]){
            if(used[v]==0) que.push(P(v,p.first));
        }
    }
    cout << "Yes" << endl;
    for(int i=2;i<=n;i++){
        cout << used[i] << endl;
    }
}

Measured memory_bytes: 10944
import java.util.Scanner;

/**
 * C - Next Prime
 * X 以上の素数のうち、最小のものを求めよ。
 */
public class Main {

    public static void main( String[] args ) {

        Scanner sc = new Scanner( System.in );
        // 入力値
        int x = sc.nextInt();

        while( !isPrime( x ) ) {
            x++;
        }
        System.out.println( x );

        sc.close();
    }

    // 素数判定
    public static boolean isPrime( int num ) {
        if ( num < 2 ) return false;
        else if ( num == 2 ) return true;
        else if ( num % 2 == 0 ) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.sqrt( num );
        for ( int i = 3; i <= sqrtNum; i += 2 ) {
            if (num % i == 0) {
                // 素数ではない
                return false;
            }
        }

        return true;
    }
}

Measured memory_bytes: 35548
/*Divyam Goyal - IIT-BHU*/
#include<bits/stdc++.h>
using namespace std;

#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define bitcount    __builtin_popcountll
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define ll long long
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define pb(x) push_back(x)
#define MOD 1000000007
#define MAX 100005

int f[30];

int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s;
	cin>>s;
	int n=s.size();
	ll ans=0;
	for(int i=n-1;i>=0;i--)
	{
		ans+=n-i-1-f[s[i]-'a'];
		f[s[i]-'a']++;
	}

	cout<<ans+1;





    return 0;


}

Measured memory_bytes: 640
#include <iostream>
#include <random>
using namespace std;
bool isvowel(char c);
int main()
{
  char c; cin >> c;
    if(isvowel(c))
        cout << "vowel";
    else
        cout << "consonant";
}

bool isvowel(char c)
{
    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
        return true;
    else
        return false;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  int k;
  string s;
  cin >> k >> s;
  
  if (k >= s.size()) {
    cout << s << endl;
  } else {
    cout << s.substr(0, k) + "..." << endl;
  }
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
int main(){
  string str;
  int l,a,b,i;  static int s;
  while(1){
  cin >> str;
  if(str[0]=='0')break;
  l=str.size();
  for(i=1,a=0,b=0;i<l;i++){
    if(str[i]=='A'){
      a++;
    }else{
      b++;
    }
  }
  if(a>b)a++;
  else if(b>a)b++;
  cout << a << " " << b << endl;
  }
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
	fast;
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //f//reopen("output.txt", "w", stdout);
    //#endif
    ll int a,b,c,d;
    cin>>a>>b>>c>>d;
    ll int i;
    for(i=1;i<=10000;i++)
    {
    	c=c-b;
    	if(c<=0)
    	{
    		cout<<"Yes";break;
    	}
    	a=a-d;
    	if(a<=0)
    	{
    		cout<<"No";break;
    	}
    }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, q;
    cin >> n >> m >> q;
    vector<vector<int>> vl(n+1, vector<int>(n+1));
    vector<vector<int>> s(n+1, vector<int>(n+1));  
    for(int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        vl[a][b]++;
    }
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            s[i][j] = s[i][j-1] + vl[i][j];
        }
    }
    for(int i = 0; i < q; i++)
    {
        int p, q;
        cin >> p >> q;
        int count = 0;
        for(int j = p; j <= q; j++)
        {
            count += s[j][q];
        }
        cout << count << endl;
    }
}


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

int main()
 {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if( A+B > C+D ){
   cout << "Left" <<endl;
  }
  else if ( A+B == C+D ){
   cout << "Balanced" <<endl;
  }
  else{
  cout << "Right" <<endl;
  }
 }

Measured memory_bytes: 256
Q = int(input())
Queries = [list(map(int, input().split())) for _ in range(Q)]

import heapq as hp
L = [-(-(10**9+1))] # 最小ヒープなので負を入れる
R = [10**9+1] # そのまま
hp.heapify(L)
hp.heapify(R)
odd = False
sum_b = 0
sum_l = 0
sum_r = 0

for q in Queries:
  if len(q)==1 and q[0]==2:
    print(*(-L[0], sum_b + abs(sum_l-sum_r)))
    
  else:
    _, a, b = q
    sum_b += b

    l = -hp.heappop(L)
    r = hp.heappop(R)
    
    X = sorted([l, r, a])
    if odd==False:
      sum_l -= l
      sum_r -= r
      hp.heappush(L,-X[0])
      hp.heappush(L,-X[1])
      hp.heappush(R,X[2])
      sum_l += X[0]
      sum_r += X[2]
      odd=True
    elif odd==True:
      sum_r -= r
      hp.heappush(L,-X[0])
      hp.heappush(R,X[1])
      hp.heappush(R,X[2])
      sum_l += X[0]
      sum_r += X[1] + X[2]
      odd=False


Measured memory_bytes: 56692
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath> 
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;

    if(A<=8 && B<=8){
        cout << "Yay!" << endl;
        return 0;
    }

    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
bbn=1000000007
	
#+++++
#knight
#https://atcoder.jp/contests/abc145/tasks/abc145_d


def kk(n,a_mod=1):
	ret=1
	for i in range(1, n+1):
		ret = (ret * i) % a_mod
	return ret
	
def pp(n,m,a_mod=1):
	ret=1
	for i in range(m):
		ret *= n - i
		ret = ret % a_mod
	return ret

def modinv(a,m):
	b=m
	u=1
	v=0
	
	while b > 0:
		t = a //b
		a = a - (t * b)
		a,b = b,a
		u = u - (t * v)
		u,v=v,u
	
	u = u % m
	if u < 0:
		u+=m
	return u
	
def cnv(a_total, a_sub,a_mod):
	ret = pp(a_total,a_sub,a_mod)
	ww = kk(a_sub,a_mod)
	ret *= modinv(ww,a_mod)
	ret %= a_mod
	return ret
	
	

def main():
	x,y = map(int, input().split())
	if (x+y)%3!=0:
		return 0
	
	if x > y:
		x,y=y,x
	
	if x*2 < y:
		return 0
	
	turn = (x+y)//3
	xp2=x-turn
	return cnv(turn, xp2, bbn)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    bool f=0;
    if(a==b and b==c) f=0;
    else if(a==b or b==c or a==c ) {f=1;}
    
    if(f) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
int main(){
	int x, max = 1,p;
	scanf("%d", &x);
	if (x != 1) {
		for (int i = 2; i < x; ++i) {
			p = 2;
			while (pow(i, p) <= x)
			{
				max = fmax(max, pow(i, p));
				++p;
			}
		}
	}
	else max = 1;
	printf("%d", max);
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcoder_b_086
{
    class _01
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]); 

            if((a * b) % 2 != 0)
            {
                Console.WriteLine("Odd");
            }else
            {
                Console.WriteLine("Even");
            }

        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
//#include <string.h>

int main(void){
  
  char s[12];
  
  scanf("%s", &s);
  //scanf("%d %d", &h, &w);
  
  if(s[5]=='0' && s[6]<='4') printf("Heisei");
  else printf("TBD");

  return 0;
}


Measured memory_bytes: 1696
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


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

	ll x = X % M;

	vector<ll> V;
	V.pb(x);
	set<ll> ST;
	ST.insert(x);
	int hajimari = 0;
	while (1) {
		ll tmp = V.back();
		tmp = tmp * tmp % M;
		if (ST.count(tmp)) {
			int k = 0;
			for (; k < V.size(); k++) {
				if (V[k] == tmp) {
					break;
				}
			}
			hajimari = k;
			break;
		}
		V.pb(tmp);
		ST.insert(tmp);
	}

	int K = V.size() - hajimari;
	ll kei = 0;
	for (int i = hajimari; i < V.size(); i++) kei += V[i];

	if (N <= hajimari) {
		ll kotae = X - x;
		rep(i, N) {
			kotae += V[i];
		}
		co(kotae);
		return 0;
	}

	ll kotae = X - x;
	rep(i, hajimari) {
		kotae += V[i];
	}
	N -= hajimari;

	ll shou = N / K;
	int amari = N % K;

	kotae += shou * kei;
	for (int i = hajimari; i < hajimari + amari; i++) kotae += V[i];
	
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 5956
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void)
{
	int a, b; cin >> a >> b;

	if (a == 2 && b == 2) cout << "Yes" << endl;
	else if ((a == 4 || a == 6 || a == 9 || a == 11) &&
		(b == 4 || b == 6 || b == 9 || b == 11))  cout << "Yes" << endl;
	else if ((a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12) &&
		(b == 1 || b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12)) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] words = sc.nextLine().split(" ");
		LinkedList<String> ans = new LinkedList<String>();
		for(String word: words) {
			word = word.replace(",", "").replace(".", "");
			if( 3<=word.length() && word.length() <= 6 ) ans.add(word);
		}
		for(;!ans.isEmpty();) {
			System.out.print( ans.remove() + (ans.isEmpty()? "\n": " ") );
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int N,M,Q,B[200010],C,D;
int A[200010];
std::string S;

int main(){
	char a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"<"<<endl;
	}
	else if(a>b){
		cout<<">"<<endl;
	}
	else{
		cout<<"="<<endl;
	}
	return 0;
}


Measured memory_bytes: 256