akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
  private static int solve(int n, int[] ps) {
    int min = Integer.MAX_VALUE;
    int count = 0;
    for (int p : ps) {
      if (p < min) {
        min = p;
        count++;
      }
    }
    return count;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int[] ps = reader.nextInt(n);
    out.println(solve(n, ps));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 46752
def main():
	a,b,c,d = map(int,input().split())

	#about c
	ans_c_a = (a-1)//c
	ans_c_b = b//c
	# print(ans_c_b)
	ans_c = ans_c_b - ans_c_a
	# print("ans_c = {}".format(ans_c))

	#about d
	ans_d_a = (a-1)//d
	ans_d_b = b//d
	ans_d = ans_d_b - ans_d_a
	# print("ans_d = {}".format(ans_d))

	#aboud c*d
	import fractions
	saisyou = (c * d) // fractions.gcd(c,d)
	# print(saisyou)
	ans_saisyou_a = (a-1)//saisyou
	ans_saisyou_b = b//saisyou
	ans_saisyou = ans_saisyou_b - ans_saisyou_a
	# print("ans_saisyou = {}".format(ans_saisyou))

	print(int( b-a+1 - (ans_c + ans_d - ans_saisyou) ))


if __name__ == '__main__':
	main()

Measured memory_bytes: 63980
# 出目がaの時にk点以上出すために必要な 連続の表の回数
def coin(a,k):
    point = a
    c=0
    while point<k:
        point  *= 2
        c += 1
    return c
def main():
    n,k=map(int,input().split())
    print(sum([1/(n*2**coin(i,k)) if i<=k else 1/n for i in range(1,n+1)]))    
main()

Measured memory_bytes: 6296
key= list('abcdefghijklmnopqrstuvwxyz')
value=[[] for i in range(26)]
d = dict(zip(key,value))
import bisect    
s = input()
s = list(s)
n = len(s)
ans = 0
for i in range(len(s)):
    d[s[i]].append(i+1)
st = set(s)
t = input()
t = list(t)
b = 0
for i in range(len(t)):
    if t[i] in st:
        p = bisect.bisect(d[t[i]],b) 
        if p < len(d[t[i]]):
            b = d[t[i]][p]
        else:
            b = d[t[i]][0]
            ans += n
    else:
        ans = -1
        break
if ans != -1:
    ans += b
print(ans)

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s; cin >> s;
	cout << 700 + count(s.begin(), s.end(), 'o') * 100 << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){

    string str1,str2;
    int n,count = 0;
    int i,j;

    cin >> n >> str1 >> str2;
    const char* ch1 = str1.c_str();
    const char* ch2 = str2.c_str();

    i = max(0,n - (int)str1.size());

    while(i < str1.size()){
        j = 0;
        while(i + j < str1.size() && ch1[i+j] == ch2[j])j++;
        if(i + j == str1.size()){
            break;
        }
        i++;
    }

    cout << str1.size() * 2 - j;

    return 0;
}


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

int main() {
	int N;
	cin >> N;
	if(N==3){
	    cout << "17 28 125" << endl;
	    return 0;
	}
	vector<int> ans(N);
	int i;
	for(i=0; (i+1)*4<N; ++i){
	    ans[i*4]=i*6+2;
	    ans[i*4+1]=i*6+3;
	    ans[i*4+2]=i*6+4;
	    ans[i*4+3]=i*6+6;
	}
	if(i%2==1){
	    ans[i*4]=i*6+3;
	    if(N%2==0){
	        ans[i*4+1]=i*6+6;
	    }
	    if(N%4==3){
	        ans[i*4+1]=i*6+2;
	        ans[i*4+2]=i*6+4;
	    }
	    if(N%4==0){
	        ans[i*4+2]=i*6+2;
	        ans[i*4+3]=i*6+4;
	    }
	}else{
	    if(N%2==1){
	        ans[i*4]=i*6+6;
	        if(N%4==3){
	            ans[i*4+1]=i*6+2;
	            ans[i*4+2]=i*6+4;
	        }
	    }
	    else{
	        ans[i*4]=i*6+2;
	        ans[i*4+1]=i*6+4;
	        if(N%4==0){
	            ans[i*4+2]=i*6+3;
	            ans[i*4+3]=i*6+9;
	        }
	    }
	}
	cout << ans[0];
	for(int i=1; i<N; ++i) cout << ' ' << ans[i];
	cout << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);
		double x=0,y=0,angle=90;
		while(true){
            String[] str=s.next().split(",");
            int a=Integer.parseInt(str[0]);
            int b=Integer.parseInt(str[1]);
            if(a==0&&b==0)break;
            x+=a*Math.cos(Math.toRadians(angle));
            y+=a*Math.sin(Math.toRadians(angle));
            angle-=b;
		}
		System.out.println((int)x);
		System.out.println((int)y);
	}	
}
//by Tuvshee 12.05.2012
//Treasure Hunt

Measured memory_bytes: 12000
A = 'a'.ord
T = 't'.ord

def print_result(data, shift)
  print(data.map do |datum|
    datum.each_char.map do |c|
      (c == '.') ? '.' : ((c.ord - A - shift) % 26 + A).chr
    end.join
  end.join(' '))
  print "\n"
end

readlines.each do |line|
  data = line.split
  candidates_of_the = data.select {|datum| datum.size == 3 }
  candidates_of_thxx = data.select {|datum| datum.size == 4 }
  tt = candidates_of_the.find do |candidate|
    (candidate[0].ord - candidate[1].ord) % 26 == 12 && (candidate[1].ord - candidate[2].ord) % 26 == 3
  end
  if tt
    print_result(data, (tt[0].ord - T) % 26)
    next
  end
  tt = candidates_of_thxx.find do |candidate|
    ((candidate[0].ord - candidate[1].ord) % 26 == 12 &&
      (candidate[1].ord - candidate[2].ord) % 26 == 7 &&
      (candidate[3].ord - candidate[2].ord) % 26 == 19) ||
    ((candidate[0].ord - candidate[1].ord) % 26 == 12 &&
      (candidate[2].ord - candidate[1].ord) % 26 == 1 &&
      (candidate[3].ord - candidate[2].ord) % 26 == 10)
  end
  if tt
    print_result(data, (tt[0].ord - T) % 26)
    next
  end
end



Measured memory_bytes: 6896
#include<stdio.h>

int main(){
	int i,j;
	int mt[10];
	int max[3]={0,0,0};
	
	for(i=0;i<10;i++){
		scanf("%d",&mt[i]);
		if(mt[i]>max[0]){
			max[2]=max[1];
			max[1]=max[0];
			max[0]=mt[i];
		}else
		if(mt[i]>max[1]){
			max[2]=max[1];
			max[1]=mt[i];
		}else
		if(mt[i]>max[2]){
			max[2]=mt[i];
		}
	}
	for(j=0;j<3;j++){
		printf("%d\n",max[j]);
	}
	
	return 0;
}

Measured memory_bytes: 600
from collections import defaultdict, deque
import sys


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


n, k = LI()
s = S()
c = s[k - 1].lower()
print(s[:k - 1] + c + s[k:])


Measured memory_bytes: 3316
#include "bits/stdc++.h"
#define _CRT_SECURE_NO_WARNINGS
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define Pi pair<int,int>
#define IINF 1e9
#define LINF 1e18
#define vi vector<int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 0, 1,0,-1 };
int dy[] = { 1, 0,-1,0 };
void solve() {
	ll n;
	cin >> n;
	vector<pair<ll,ll> > v;
	set<ll> s;
	rep(i, n) {
		ll a;
		cin >> a;
		v.push_back(make_pair(a,i));
	}
	ll sum = 0;
	sort(v.begin(), v.end());
	s.insert(-1); s.insert(n);
	rep(i, n) {
		ll middle = v[i].second;
		auto it = s.lower_bound(middle);
		ll right = *it;
		it--;
		ll left = *it;
		sum += v[i].first*(middle - left)*(right - middle);
		s.insert(middle);
	}
	P(sum);
}

int main() {
	solve();
	return 0;
}

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

int main() 
{
    int n;
    cin>>n;
    vector<int> a(n), dp(n,0);
    for(int i = 0; i<n; i++)
        cin>>a[i];
    
    dp[1] = abs(a[1] - a[0]);
    for(int i = 2; i<n; i++)
    {
        dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]),  dp[i-2] + abs(a[i] - a[i-2]));
    }
	cout<<dp[n-1]<<"\n";
	return 0;
}


Measured memory_bytes: 4068
from functools import lru_cache

MOD = pow(10, 9) + 7

H, W = map(int, input().split())
A = [input() for _ in range(H)]
dp = [ [0 for j in range(W + 1)] for i in range(H + 1)]

for w in range(1, W + 1):
    for h in range(1, H + 1):
        if w == 1 and h == 1:
            dp[1][1] = 1
            continue
 
        if A[h-1][w-1] == '.':
            dp[h][w] = (dp[h-1][w] + dp[h][w-1]) % MOD
            continue
        if A[h-1][w-1] == '#':
            dp[h][w]  = 0



print(dp[H][W])


Measured memory_bytes: 54108
N = int(input())
 
ans = 0
num_A = 0
num_B = 0
num_BA = 0
for _ in range(N):
  s = input()
  ans += s.count('AB')
  num_A += s.endswith('A')
  num_B += s.startswith('B')
  num_BA += s.startswith('B') * s.endswith('A')

con = min(num_A, num_B)
con -= (num_A == num_B == num_BA != 0)
ans += con
print(ans)

Measured memory_bytes: 3064
{-# LANGUAGE OverloadedStrings #-}

module Main where

import qualified Data.Text as T
import qualified Data.Text.IO as T

main :: IO()
main = do
  input <- T.getLine
  T.putStrLn . solve $ input

solve :: T.Text -> T.Text
solve = (\(a, b) -> if a > b
                    then "B"
                    else "A")
  . toAbsPair
  . T.words

toAbsPair :: [T.Text] -> (Int, Int)
toAbsPair (x:y:z) = toAbss . toInts $ (x, y, head z)
toAbsPair _ = error ""

toInts :: (T.Text, T.Text, T.Text) -> (Int, Int, Int)
toInts (xs, as, bs) = (read $ T.unpack xs, read $ T.unpack as, read $ T.unpack bs)

toAbss :: (Int, Int, Int) -> (Int, Int)
toAbss (x, a, b) = (abs (x - a), abs (x - b))


Measured memory_bytes: 508
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;
int main(void){
    int N,M,C; cin >> N >> M >> C;
    vector<int> b(M);
    vector< vector<int> > a(N, vector<int>(M));
    int i = 0;
    int ans = 0;
    int j = 0;
    while(j < M) {
        cin >> b[j];
        j++;
    }
    while (i < N) {
        int tmp = 0;
        int j = 0;
        while(j < M) {
            int tmp2 = 0;
            cin >> tmp2;
            tmp += tmp2 * b[j];
            j++;
        }
        if (tmp > -C) ans++;
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
t = [int(input()) for i in range(5)]
r = [x%10 for x in t]
if all(x==0 for x in r):
  print(sum(t))
else:
  y = min(set(r)-{0})
  print(sum(x if x%10==0 else 10*(1+x//10) for x in t) -10+y)

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

#define pii pair<int, int>
#define mp make_pair

const int maxN = 2e5 + 10, mod = 998244353;

int n;
int f[maxN + 1], sum[maxN + 1];
int st[maxN + 1][22], lg[maxN + 1];

pii num[maxN + 1];

inline int ADD(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }

inline int SUB(int x, int y) { return x - y < 0 ? x - y + mod : x - y; }

inline int query(int l, int r)
{
	int k = lg[r - l + 1];
	return max(st[l][k], st[r - (1 << k) + 1][k]);
}

inline int find(int x, int num)
{
	int l = 1, r = x - 1, ans = x;
	while(l <= r)
	{
		int mid = (l + r) >> 1;
		if(query(mid, x - 1) <= num) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	return ans;
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d %d", &num[i].first, &num[i].second);

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

	for(int i = 2; i <= n; i++) lg[i] = lg[i >> 1] + 1;

	for(int i = 1; i <= n; i++) st[i][0] = num[i].first + num[i].second;
	for(int j = 1; (1 << j) <= n; j++)
		for(int i = 1; i + (1 << j) - 1 <= n; i++)
			st[i][j] = max(st[i][j - 1], st[i + (1 << j - 1)][j - 1]);

	sum[0] = f[0] = 1;
	for(int i = 1; i <= n; i++)
	{
		int x = find(i, num[i].first);
		if(x == 1) f[i] = sum[i - 1];
		else f[i] = SUB(sum[i - 1], sum[x - 2]);
		sum[i] = ADD(sum[i - 1], f[i]);
	}

	printf("%d", sum[n]);
	return 0;
}


Measured memory_bytes: 21376
def main():
    N = int(input())
    L = list(map(int, input().split()))
    ans = 0
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            for k in range(j + 1, N):
                if L[i] == L[j] or L[i] == L[k] or L[j] == L[k]:
                    continue
                if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9208
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;

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

    int x,y; cin >> x >> y;

    bool possible = false;

    for(int i=0; i<x+1; i++){
        int j = x-i;
        if(i*4+j*2==y) possible = true;
    }

    if(possible) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  N %= 10;
  
  if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9){
    cout << "hon" << endl;
  } else if (N == 3) {
    cout << "bon" << endl;
  } else {
    cout << "pon" << endl;
  }
}


Measured memory_bytes: 3600
import sys
input = sys.stdin.readline
from operator import itemgetter

N = int(input())
LR = [list(map(int, input().split())) for _ in range(N)]
LR.sort(key=itemgetter(0))

dp = [[[0, 0], [0, 0]] for _ in range(N)]

L0, R0 = LR[0]
L1, R1 = LR[1]
dp[1][0][0] = L0
dp[1][0][1] = R0
dp[1][1][0] = L1
dp[1][1][1] = R1
L, R = max(L0, L1), min(R0, R1)
for i in range(1, N-1):
    l, r = LR[i+1]
    a0 = max(min(dp[i][0][1], r) - max(dp[i][0][0], l)+1, 0) + max(dp[i][1][1] - dp[i][1][0] + 1, 0)
    a1 = max(min(dp[i][1][1], r) - max(dp[i][1][0], l)+1, 0) + max(dp[i][0][1] - dp[i][0][0] + 1, 0)
    a2 = max(R-L+1, 0) + r-l+1
    a = max(a0, a1, a2)
    if a == a2:
        dp[i+1][0][0] = l
        dp[i+1][0][1] = r
        dp[i+1][1][0] = L
        dp[i+1][1][1] = R
    elif a == a0:
        dp[i+1][0][0] = max(dp[i][0][0], l)
        dp[i+1][0][1] = min(dp[i][0][1], r)
        dp[i+1][1][0] = dp[i][1][0]
        dp[i+1][1][1] = dp[i][1][1]
    elif a == a1:
        dp[i+1][0][0] = dp[i][0][0]
        dp[i+1][0][1] = dp[i][0][1]
        dp[i+1][1][0] = max(dp[i][1][0], l)
        dp[i+1][1][1] = min(dp[i][1][1], r)
    L, R = max(L, l), min(R, r)

ans = max(dp[N-1][0][1]-dp[N-1][0][0]+1, 0) + max(dp[N-1][1][1] - dp[N-1][1][0] + 1, 0)
print(ans)

Measured memory_bytes: 50548
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int n; cin>>n;
  vector<int> a(n),b(32);
  rep(i,0,n){
    cin>>a[i];
    int x=a[i];
    rep(j,0,32){
      b[j]+=x%2;
      x/=2;
    }
  }
  rep(i,0,n){
    vector<int> bb(32);
    rep(j,0,32) bb[j]=b[j];
    int x=a[i];
    ll c=0,r=1;
    rep(j,0,32){
      bb[j]-=x%2;
      x/=2;
    }
    rep(j,0,32){
      c+=r*(bb[j]%2);
      r*=2;
    }
    cout<<c;
    if(i!=n-1) cout<<" ";
  }
  co("");
    
  return 0;
}

Measured memory_bytes: 3920
/*input
3
10 10
20 20
30 30
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
using namespace std;
#define N  100005
void solve()
{
	lld n;
	cin >> n;
	lld a[n],b[n];
	vpi v;
	rep(i,0,n)
	{
		cin >> a[i] >> b[i] ;
		v.pb({a[i]+b[i],i});
	}
	sort(all(v)); 
	reverse(all(v));
	lld ans[n+1];
	rep(i,0,n)
	{
		ans[i]=0;
	}
	lld val=0;
	rep(i,0,n)
	{
		ans[v[i].S]=(i+1)%2;
	}
	rep(i,0,n)
	{
		if(ans[i]==1)
		{
			val+=a[i];
		}
		else
		{
			val-=b[i];
		}
	}
	cout << val << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 4336
from functools import lru_cache
h, w, d = map(int, input().split())
pos = [[] for j in range(h*w)]
for a in range(h):
    s = list(map(int, input().split()))
    for g in range(w):
        pos[s[g] -1] = [s[g], a+1, g+1]
q = int(input())

time = [0 for h in range(h*w)]
for l in range(h*w - d):
    if not time[l + d]:
        time[l+d] = time[l] + (abs(pos[l+d][1] - pos[l][1]) + abs(pos[l+d][2] - pos[l][2]))


@lru_cache(maxsize=None)
def ask(st, en):
    return time[en-1] - time[st-1]


for rr in range(q):
    dd, ff = map(int, input().split())
    print(ask(dd, ff))


Measured memory_bytes: 51896
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int N;
ll A[200000], B[200000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
    }
    if(N%2 == 0){
        sort(A, A+N);
        sort(B, B+N);
        int l = N/2-1;
        int r = N/2;
        cout << B[r]+B[l]-A[l]-A[r]+1 << endl;
    }else{
        sort(A, A+N);
        sort(B, B+N);
        int m = (N-1)/2;
        cout << B[m]-A[m]+1 << endl;
    }   
}

Measured memory_bytes: 6788
sen = input()
n = int(input())
for i in range(n):
    cmd = input().split()
    sta = int(cmd[1])
    end = int(cmd[2])
    if cmd[0] == 'replace':
        sen = sen[0:sta] + cmd[3] + sen[end+1:]
    elif cmd[0] == 'reverse':
        rev = sen[sta:end+1]
        rev = rev[::-1]
        # print(rev)
        sen = sen[0:sta] + rev +sen[end+1:]
    elif cmd[0] == 'print':
        print(sen[sta:end+1])
    # print('sen : '+sen)

Measured memory_bytes: 7700
#include<iostream>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int e=100*n+ 1800*m;
  int ans=1;
  for(int i=1;i<=m;i++)	ans*=2;
  ans=ans*e;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
A_1=list(map(int,input().split()))
A_2=list(map(int,input().split()))
A_3=list(map(int,input().split()))
N=int(input())
b=[(int(input())) for _ in range(N)]
Z_1=[0,0,0]
Z_2=[0,0,0]
Z_3=[0,0,0]

for i in range(3):
    for j in range(N):
        if A_1[i]==b[j]:
            Z_1[i]=1
        elif A_2[i]==b[j]:
            Z_2[i]=1 
        elif A_3[i]==b[j]:
            Z_3[i]=1

if Z_1[0] == Z_1[1] == Z_1[2] == 1:
    print("Yes")
elif Z_2[0] == Z_2[1] == Z_2[2] == 1:
    print("Yes")
elif Z_3[0] == Z_3[1] == Z_3[2] == 1:
    print("Yes")
elif Z_1[0] == Z_2[0] == Z_3[0] == 1:
    print("Yes")
elif Z_1[1] == Z_2[1] == Z_3[1] == 1:
    print("Yes")
elif Z_1[2] == Z_2[2] == Z_3[2] == 1:
    print("Yes")
elif Z_1[0] == Z_2[1] == Z_3[2] == 1:
    print("Yes")
elif Z_1[2] == Z_2[1] == Z_3[0] == 1:
    print("Yes")
else:
    print("No")


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

int main(){
  string S,T;
  cin >> S >> T;
  int A=S.size();
  T=T.substr(0,A);
  if(S==T){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3596
#include <stdio.h>
int head = 0,tail = 0;

typedef struct{
  int time;
  char job[20];
}Data;

Data a[100000];

Data DEQUEUE(void)
{
  if(head==100000)
    {
      head=0;
      return a[100000];
    }
  else
    {
      head++;
      return a[ head - 1 ];
    }
}

void ENQUEUE(Data j)
{
  if(tail==100000)
    {
      tail=0;
      a[tail]=j;
    }
  else
    {
      tail++;
      a[tail]=j;
    }
  return ;
}

int main(){
  int q,n,i,total = 0,count = 0;
  Data temp;
  Data c[100000];

  scanf("%d%d",&n,&q);

  for(i=0;i<n;i++)
    {
      scanf("%s%d",a[i].job,&a[i].time);
    }

  tail = n - 1;
  while(1)
    {
      if(a[head].time <= q)
	{
	  temp = DEQUEUE();
	  total = total + temp.time;
	  temp.time = total;
	  c[count] = temp;
	  count++;
	}
      else
	{
	  total = total + q;
	  temp = DEQUEUE();
	  temp.time = temp.time - q;
	  ENQUEUE(temp);
	}
      if(head == tail+1) break;
    }
  for(i=0;i<n;i++)
    {
      printf("%s %d\n",c[i].job,c[i].time);
    }
  return 0;
}





Measured memory_bytes: 5244
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n,m,e,t,i,j;
    string a,b,c;
    cin>>n>>m>>e>>t;
    if(n+m>e+t){
        cout<<"Left"<<endl;
    }else if(n+m<e+t){
        cout<<"Right"<<endl;
    }else{
        cout<<"Balanced"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		long y = scan.nextLong();
		scan.close();
		long smaller = Math.min(x, y);
		long bigger = Math.max(x, y);
		System.out.println(GreatestCommonDivisor(bigger, smaller));
	}

	static long GreatestCommonDivisor(long x, long y){
		long mod = Math.floorMod(x, y);
		if(mod == 0){
			return y;
		}else{
			x = Math.max(y, mod);
			y = Math.min(y, mod);
			return GreatestCommonDivisor(x, y);
		}
	}
}

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

void solve(long long D, long long N){
    int start = pow(100, D);
    if (N == 100) cout << start * N + 1 * start << '\n';
    else cout << start * N << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long D;
    scanf("%lld",&D);
    long long N;
    scanf("%lld",&N);
    solve(D, N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define double long double
#define mod 1000000007
#define w(t) \
   int t;    \
   cin >> t; \
   while (t--)
#define f(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define pob pop_back
#define mk make_pair
#define ARMY                         \
   ios_base::sync_with_stdio(false); \
   cin.tie(NULL);                    \
   cout.tie(NULL);
using namespace std;
vector<string> v;
int dp[3001][3001];
int len(string &s, string &t,int i,int j)
{
    if(i>=s.length() or j>=t.length())
      return 0;
      if(dp[i][j]!=-1)
        return dp[i][j];
      if(s[i]==t[j])
        { return dp[i][j]=1+len(s,t,i+1,j+1);}
     else
      {
         return dp[i][j]=max(len(s,t,i+1,j),len(s,t,i,j+1));
      }
}
string LCS(string &s,string &t,int le)
{   string ans;
   int i=0,j=0;
   while(le>0)
    {
       if(s[i]==t[j])
        {
           ans.push_back(s[i]);
           le--;
           i++;
           j++;
          
        }
        else
        {
           if(dp[i+1][j]>dp[i][j+1])
              i++;
            else
            {
               j++;
            }
            
        }        
    }
    return ans;
}
string solve(string s, string t)
{
   memset(dp,-1,sizeof dp);
   int le = len(s, t,0,0);
   return LCS(s,t,le);
}
int32_t main()
{
   ARMY
     
   
      string s,t;
      cin>>s>>t;
      cout << solve(s,t);
   
}

Measured memory_bytes: 74384
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

typedef struct{
  char suit;
  int value;
} Card;

Card L[MAX/2 + 2],R[MAX/2 +2];

void merge(Card *A,int n,int left,int mid,int right){
  int i,j,k,n1,n2;
  n1 = mid-left;
  n2 = right-mid;
  for(i=0;i<n1;i++) L[i] = A[left+i];
  for(i=0;i<n2;i++) R[i] = A[mid +i];
  L[n1].value = SENTINEL;
  R[n2].value = SENTINEL;
  i = 0;
  j = 0;
  for(k = left;k < right;k++){
    if(L[i].value <= R[j].value) A[k] = L[i++];
    else A[k] = R[j++];
  }
}

void mergeSort(Card *A,int n,int left,int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(Card *A,int n,int p,int r){
  int i,j;
  Card t,x;
  x = A[r];
  i = p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i+1]; A[i+1] = A[r]; A[r] = t;
  return i+1;
}

void quickSort(Card *A,int n,int p,int r){
  int q;
  if(p < r){
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main(){
  int n,i,v;
  Card A[MAX],B[MAX];
  char S[10];
  int stable=1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }
  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);
  for(i=0;i<n;i++){
    if(A[i].suit != B[i].suit) stable=0;
  }
  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) printf("%c %d\n",B[i].suit,B[i].value);
  return 0;
}

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

using namespace std;

int main()
{
    int a = 0;
    for (int i = 0; i < 5; i++){
        int p;
        scanf("%d", &p);
        a += max(8, p / 5);
    }
    printf("%d\n", a);
    
    return (0);
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    int n, T;
    cin >> n >> T;
    int res = 1001;
    rep0(i,n){
        int c, t;
        cin >> c >> t;
        if(T>=t&&res>c){
            res=c;
        }
    }
    if(res== 1001){
        cout << "TLE" << endl;
    }else{
    cout << res << endl;
    }
}


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

int main(){
    int num[100];
    int n;

    while(cin >> n, n){
        int count = 0;
        fill(num, num+100, 0);
        for(int i=0; i < n; i++, count++){
            int input;
            cin >> input;
            num[i] = input;
        }

        for(int i=0; i < count; i++){
            if(i == 0) cout << num[i];
            else if(i == count-1){
                if(num[i-1] == num[i]-1) cout << "-" << num[i];
                else cout << " " << num[i];
            }
            else if(num[i-1] == num[i]-1 && num[i] != num[i+1]-1) cout << "-" << num[i];
            else if(num[i-1] != num[i]-1) cout << " " << num[i];
        }
        cout << endl;
    }
}

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

if "##" in S[A:C-1] or "##" in S[B:D-1]:
    print("No")
    exit()
elif C>D and "..." not in S[B-2:D+1]:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define pii pair<ll,ll>
#define ff first
#define ss second
#define mxx 100005
#define endl "\n"
const ll mod=1e9+7;

int main()
{
    ll n,m;
    cin>>n>>m;

    vector<ll>v[n+5];
    for(int i=0; i<m; i++)
    {
        ll a,b;
        cin>>a>>b;
        v[a].pb(b);
    }

    ll ans=0,mn=1e9;
    for(int i=1; i<=n; i++)
    {
        if(i==mn)
        {
            ans++;
            mn=1e9;
        }
        if(v[i].size())
        {
            for(auto it:v[i])
                mn=min(mn,it);
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 5760
N, K = map(int, input().split())
D = list(map(int, input().split()))

#使うことのできるリストの作成
d = []
for i in range(10):
    if i in D:
        pass
    else:
        d += [i]

def check(i): #数値iがdのリストだけで書くことができるかを判定
    I = str(i) #文字列に変換
    # print (I)
    n = len(I) #桁数の取得
    for j in range(n): #全桁で確認
        # print (I[j])
        if int(I[j]) in d: #大丈夫ならスルー
            pass
        else: #一つでも不適ならFalseを返す
            return False
    return True

# print (check(2000))

for i in range(N, 10**5 + 1): #小さい数から全探索
    if i >= N: #大きさを確認
        if check(i): #dの中だけで書けるかをチェック
            print (i) #書くことができるなら出力して終了
            exit()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll n, q;
    cin >> n;
    vector<ll> a(n, 0), num(100001, 0);
    ll sum = 0;
    rep1(i, n){
        cin >> a[i];
        num[a[i]] += 1;
        sum += a[i];
    }
    cin >> q;
    vector<ll> b(q, 0), c(q, 0);
    ll num_b = 0;
    rep1(i, q) cin >> b[i] >> c[i];
    rep1(i, q){
        num_b = num[b[i]];
        num[b[i]] = 0;
        num[c[i]] += num_b;
        sum = sum + (c[i]-b[i])*num_b;
        cout << sum << endl;
    }
}

Measured memory_bytes: 6408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v1 = vector<T>;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    auto calc_rad = [](double degree) {
        return degree * (PI / 180.0);
    };
    double short_degree = 6 * M;
    H = 60 * H + M;
    double long_degree = 0.5 * H;
    double short_x = B * cos(calc_rad(short_degree));
    double short_y = B * sin(calc_rad(short_degree));
    double long_x = A * cos(calc_rad(long_degree));
    double long_y = A * sin(calc_rad(long_degree));
    double difX = long_x - short_x, difY = long_y - short_y;
    double ans = sqrt(difX * difX + difY * difY);
    cout << fixed << setprecision(10) << ans << endl;
}

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

int n, m, k;
int main()
{
    while(~scanf("%d%d%d", &n, &m, &k))
    {
        int a, b, x, y, ans = 0;
        scanf("%d%d", &a, &b);
        for(int i = 1; i < k; i++)
        {
            scanf("%d%d", &x, &y);
            int q = abs(x - a), p = abs(y - b);
            if((x > a && y > b) || (x < a && y < b)) ans += max(p, q);
            else ans += p + q;
            a = x, b = y;
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1188
#include <cstdio>
#include <queue>
#include <vector>

using namespace std;

bool Check(int n,int m,int l){
	if(n == m && m == l && l == n){ return false; }
	priority_queue<int> q;
	q.push(n);
	q.push(m);
	q.push(l);
	int a,b,c;
	c = q.top();
	q.pop();
	b = q.top();
	q.pop();
	a = q.top();
	q.pop();
	if(a * a + b * b == c * c){
		return true;
	}else{
		return false;
	}
}

int main(){
	int n;
	int a,b,c;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		if(Check(a,b,c)){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

ll step(ll diff, vector<ll> &memo);

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> a(M + 2);
    vector<ll> memo(N + 10, -1);
    a.at(0) = -1;
    a.at(M + 1) = N + 1;
    rep(i, 0, M)
    {
        cin >> a.at(i + 1);
        if ((i != 0) && (a.at(i + 1) - a.at(i) == 1))
        {
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    rep(i, 1, M + 2)
    {
        ans *= step(a.at(i) - a.at(i - 1) - 1, memo);
        ans %= MOD;
    }
    cout << ans << endl;
}

ll step(ll diff, vector<ll> &memo)
{
    if (diff == 0)
    {
        return memo.at(diff) = 0;
    }
    else if (diff == 1)
    {
        return memo.at(diff) = 1;
    }
    else if (memo.at(diff) != -1)
    {
        return memo.at(diff);
    }
    return memo.at(diff) = (step(diff - 1, memo) + step(diff - 2, memo)) % MOD;
}

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

using namespace std;

using dbl = long double;
using Pi = pair<int, int>;

const dbl eps = 1e-15;
#define lt(a, b) ((a)-(b) < -eps)
#define eq(a, b) (fabs((a)-(b)) < eps)

int W, H;
char mas[505][505];
Pi S, G;
vector<Pi> Bs;

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

bool in(int y, int x) {
  return 0<=y&&y<H&&0<=x&&x<W;
}

vector<vector<dbl> > bfs(const vector<Pi>& s) {
  //cout<<"!!!!!"<<endl;
  queue<Pi> que;
  vector<vector<dbl> > dist(H, vector<dbl>(W, -1));
  for(Pi p : s) {
    que.emplace(p);
    dist[p.first][p.second] = 0;
  }
  while(!que.empty()) {
    int y, x;
    tie(y, x) = que.front(); que.pop();
    //cout<<mas[y][x]<<" "<<y<<" "<<x<<endl;    
    for(int i = 0; i < 4; ++i) {
      int ny = y+dy[i], nx = x+dx[i];
      if(!in(ny, nx) || mas[ny][nx] == '#' || mas[ny][nx] == '*') continue;
      if(dist[ny][nx] == -1) {
	dist[ny][nx] = dist[y][x]+1;
	que.emplace(ny, nx);
      }
    }
  }
  return dist;
}

vector<vector<dbl> > db;
vector<vector<dbl> > dg;

bool check(dbl mb) {
  dbl sum = 0;
  int num = 0;
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      if(mas[i][j] == '.') {
	if(dg[i][j] == -1 && db[i][j] == -1) continue;//assert(false);
	else if(dg[i][j] == -1) sum += db[i][j]+mb;
	else if(db[i][j] == -1) sum += dg[i][j];
	else sum += min(dg[i][j], db[i][j]+mb);
	++num;
      }
    }
  }
  assert(num > 0);
  sum /= num;
  return sum >= mb;
}

int main() {
  cin >> W >> H;
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      cin >> mas[i][j];
      if(mas[i][j] == 's') S = Pi(i, j), mas[i][j] = '.';
      else if(mas[i][j] == 'g') G = Pi(i, j);
      else if(mas[i][j] == '*') Bs.emplace_back(i, j);
    }
  }

  db = bfs(Bs);
  dg = bfs({G});

  dbl ans = dg[S.first][S.second];
  //cout<<ans<<endl;
  /*
  bool flag = false;  
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      if(mas[i][j] == '.' && dg[i][j] == -1 && db[i][j] == -1) flag = true;
    }
  }
  */
  if(ans == -1) ans = DBL_MAX/2;
  else if(db[S.first][S.second] == -1) {
  //else if(flag) {
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
  }

  dbl lb = 0, ub = 1e20;
  for(int i = 0; i < 200; ++i) {
    dbl mb = (lb+ub)/2;
    if(check(mb)) lb = mb;
    else ub = mb;
  }

  ans = min(ans, db[S.first][S.second]+lb);

  cout << fixed << setprecision(12) << ans << endl;  
  
  return 0;
}



Measured memory_bytes: 10968
#include<iostream>
#include<string>
using namespace std;
typedef long long int ll;

string S;
ll K;

int main(){
	cin >> S >> K;
	if(K <= S.length()){
		for(int i = 0; i < K; i++){
			if(S[i] != '1'){
				cout << S[i] << endl;
				return 0;
			}
		}
		cout << '1' << endl;
		return 0;
	}else{
		for(int i = 0; i < S.length(); i++){
			if(S[i] != '1'){
				cout << S[i] << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m,i,j,a[100001],sum=1;
int main()
{
	cin>>n;
	for(i=1;i*i<n;i++)
	{
		ll k=n-1;
		if(k%i==0)
		{
			if(i*i!=k)
			{
				sum++;
			}
			if(i!=1)
			{
				sum++;
			}
		}
	}
	for(i=2;i*i<=n;i++)
	{
		ll k=n;
		while(k%i==0)
		{
			k/=i;
		}
		if(k!=n&&k%i==1)
		{
			sum++;
		}
	}
	cout<<sum<<"\n";
	return 0;
}

Measured memory_bytes: 256
// by Balloons
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
 
using namespace std;
 
typedef long long LL;
 
const int inf = 1 << 30;
const int maxn=4005;
 
int n,d;
vector<int>g[maxn]; 
int vis[maxn],dis[maxn];
int ex[maxn],ey[maxn];
 
void dfs(int x){
	vis[x]=1;
	for(int i=0;i<g[x].size();i++){
		int u=g[x][i];
		if(vis[u])continue;
		dis[u]=dis[x]+1;
		dfs(u);
	}
}
 
int main(){
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n-1;i++){
		scanf("%d%d",&ex[i],&ey[i]);
		g[ex[i]].push_back(ey[i]);g[ey[i]].push_back(ex[i]);
	}
	if(d&1){
		int ans=inf;
		for(int i=1;i<=n-1;i++){
			memset(vis,0,sizeof vis);memset(dis,0,sizeof dis);
			int u=ex[i],v=ey[i];
			vis[v]=1;
			dfs(u);
			
			vis[v]=0;
			dfs(v);
			
			int res=0;
			for(int j=1;j<=n;j++)
				if(dis[j]>(d-1)/2)++ res;
				
			ans=min(ans,res);
		}
		printf("%d\n",ans);
	}else{
		int ans=inf;
		for(int i=1;i<=n;i++){
			int x=i;
			memset(vis,0,sizeof vis);
			dis[x]=0;
			dfs(x);
//			for(int j=1;j<=n;j++)printf("%d ",dis[j]);puts("");
			
			int res=0;
			for(int j=1;j<=n;j++)
				if(dis[j]>d/2)++ res;
 
			ans=min(ans,res);
		}
		printf("%d\n",ans);
	}
 
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
//typedef complex<long double> com;
 
//const ll mod = 1e9+7;
 
void setIO(string name) {
    ios_base::sync_with_stdio(0); cin.tie(0);
    freopen((name+".in").c_str(),"r",stdin);
    freopen((name+".out").c_str(),"w",stdout);
}
 
//setIO("sleepy");


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//setIO("shortcut");
	vector <ll> arr(3);
	cin >> arr[0] >> arr[1] >> arr[2];
	sort(arr.begin(),arr.end());
	if (arr[0] == arr[1] && arr[0] != arr[2]){
		cout << "Yes" << endl;
	} else if (arr[1] == arr[2] && arr[0] != arr[2]){
		cout << "Yes" << endl;
	} else {
		cout << "No"<< endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define F first
#define S second
#define mp make_pair
int main()
{
	int n;
  cin>>n;
  	map<pair<ll,ll>,ll> count;
      for(ll k=1;k<=n;k++)
      {
        string s=to_string(k);
        count[make_pair( *s.begin() - '0',s.back() -'0' )]++;
      }
      ll ans=0;
      for(auto&i:count)
                        {
                        //cout<<i.F.F<<" "<<i.F.S<<" "<<i.S<<" "<<ans<<endl;
                          if(i.F.F==i.F.S)
                          {
                            ans+= i.S * i.S;
                          }
                          else if(count.find(mp(i.F.S,i.F.F))!=count.end())
               				ans+= i.S*count[mp(i.F.S,i.F.F)];        
                        }
              
             cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair



int main() {
    int N;
    ll D;
    cin >> N >> D;
    vector<ll> X(N), Y(N);
    REP(i, N) cin >> X[i] >> Y[i];
    int cnt = 0;
    REP(i, N) if (X[i] * X[i] + Y[i] * Y[i] <= D * D) cnt++;
    PRINT(cnt);
    return 0;
}

Measured memory_bytes: 6424
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
        int[] points = new int[n];
        for (int i = 0; i < q; i++) {
          points[sc.nextInt() - 1] += 1;
          
        }
        for (int i = 0; i < n; i++) {
          System.out.println(q - points[i] < k ? "Yes" : "No");
        }
	}
}


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

int gcd(int X, int Y) {
  if (Y == 0) return X;
  return gcd(Y, X % Y);
}

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<int> V(N);
  for (int i = 0; i < N; i++) {
    cin >> V.at(i);
  }

  vector<int> L(N);
  L.at(0) = V.at(0);
  L.at(1) = gcd(V.at(0), V.at(1));
  for (int i = 2; i < N; i++) {
    L.at(i) = gcd(L.at(i - 1), V.at(i));
  }

  vector<int> R(N);
  R.at(N - 1) = V.at(N - 1);
  R.at(N - 2) = gcd(V.at(N - 2), V.at(N - 1));
  for (int i = N - 3; i >= 0; i--) {
    R.at(i) = gcd(R.at(i + 1), V.at(i));
  }

  int ans = R.at(1);

  for (int i = 1; i < N - 1; i++) {
    ans = max(ans, gcd(L.at(i - 1), R.at(i + 1)));
  }

  cout << max(ans, L.at(N - 2)) << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector> 
#include <string> 
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	int string_length;
  	int string_cnt;
  	string input;
  	vector<string> str; /* sort対象 */
  
  	cin >> string_cnt >> string_length;
	for (int i=0; i<string_cnt; i++) {
      	cin >> input;
      	str.push_back(input);
    }
  	sort(str.begin(), str.end());
  
	for (int i=0; i<string_cnt; i++)
		cout << str[i];
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

string s,t;

int main(){
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.rbegin(),t.rend());
	if(s<t) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
s = list(map(int, input().split('/')))
if s[0] <= 2019:
  if s[1] <= 4:
    if s[2] <= 30:
      print('Heisei')
    else:
      print('TBD')
  else:
    print('TBD')
else:
  print('TBD')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

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

const ll INF=1LL << 60;
ll dp[110][100005];
ll weight[110],value[110];

int main() {
  int n,w;cin >> n >> w;
  rep(i,n)cin >> weight[i] >> value[i];
  //配るDP
  rep(i,n){
    for(int sumw=0;sumw<=w;sumw++){
      if(sumw-weight[i]>=0)chmax(dp[i+1][sumw],dp[i][sumw-weight[i]]+value[i]);
      chmax(dp[i+1][sumw],dp[i][sumw]);
    }
  }
  cout << dp[n][w];
}

Measured memory_bytes: 79360