akhauriyash/Code-Regression huggingface dataset:
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)


def to_frac(A,B):
    g = math.gcd(A,B)
    A = A//g
    B = B//g
    if A<0:
        A *= -1
        B *= -1

    return (A,B)
N = I()
cnt = {}
pair = {}
bothzero = 0
for i in range(N):
    A,B = MI()
    if A==0 and B==0:
        bothzero += 1
    elif B==0:
        pair[0]=pair.get(0,0)+1
    elif A == 0:
        cnt[0]=cnt.get(0,0)+1
    elif A/B>0:
        frac = to_frac(A,B)
        cnt[frac]=cnt.get(frac,0)+1
    else:
        frac = to_frac(-B,A)
        pair[frac]=pair.get(frac,0)+1
res = N-bothzero
ans = 1
for v in cnt:
    if pair.get(v,0)==0:
        continue
    res -= (cnt[v]+pair[v])
    ans = ans*((pow(2,cnt[v],MOD)+pow(2,pair[v],MOD)-1)%MOD)
    ans = ans%MOD
ans = (ans*pow(2,res,MOD)-1)%MOD
ans = (ans+bothzero)%MOD
print(ans)


Measured memory_bytes: 48548
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

ll N;
vector<ll> A(200010), B(200010);
int main(){
  cin >> N;
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  ll ans = 0;
  for(int k = 1; k <= 29; k++){
    //k桁目
    ll cnt = 0;
    vector<ll> a(N), b(N);
    rep(i, N){
      a[i] = A[i] % (1 << k), b[i] = B[i] % (1 << k);
    }
    sort(b.begin(), b.end());
    for(int i = 0; i < N; i++){
      //2^(k-1) - a[i] <= b < 2 * 2^(k-1) - a[i]
      //3 * 2^(k-1) ^ a[i] <= b
      ll m1, m2, m3, m4;
      m1 = upper_bound(b.begin(), b.end(), (1<<(k-1)) - a[i] - 1) - b.begin();
      m2 = upper_bound(b.begin(), b.end(), 2 * (1<<(k-1)) - a[i] - 1) - b.begin();
      m3 = upper_bound(b.begin(), b.end(), 3 * (1<<(k-1)) - a[i] - 1) - b.begin();
      cnt += m2 - m1;
      cnt += N - m3;
    }
    if(cnt % 2) ans += (1<<(k-1));
  }
  cout << ans << endl;
}


Measured memory_bytes: 6548
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int A, B, T; cin >> A >> B >> T;
	cout << T/A*B << endl;
	return 0;
}

Measured memory_bytes: 256
/* ファイル名：ITP1_4_A.c	*/
/* 内容：２つの整数 a と b を読み込んで、以下の値を計算する	*/
/* 		・a / b (整数での商)								*/
/* 		・a % b (剰余)										*/
/* 		・a / b (実数での商)								*/

/* include	*/
#include <stdio.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名:main	*/
/* 処理内容:２つの整数 a と b を読み込んで、以下の値を計算する	*/
/* 			・a / b (整数での商)								*/
/* 			・a % b (剰余)										*/
/* 			・a / b (実数での商)								*/

int main( void )
{
	/* 内部変数定義	*/
	/* 入力	*/
	int a;		/* 入力される変数a	*/
	int b;		/* 入力される変数b	*/
	/* 出力	*/
	int d;		/* 整数での商	*/
	int r;		/* 剰余			*/
	double f;	/* 実数での商	*/
	
	scanf("%d %d",&a,&b);	/* a と b を取得	*/
	
	/* 整数での商を計算	*/
	d = a / b;
	/* 剰余を計算		*/
	r = a % b;
	/* 実数での商を計算	*/
	f = (double)a / (double)b;
	
	printf("%d %d %f\n",d,r,f);	/* 計算結果を出力*/
	
	return 0;
}



Measured memory_bytes: 2040
<?php
list($n, $l) = ints();
$a = ints();
for ($i = 0; $i < $n - 1; ++$i) {
    if ($a[$i] + $a[$i + 1] < $l) continue;

    echo 'Possible', PHP_EOL;
    for ($j = 1; $j <= $i; ++$j) echo $j, PHP_EOL;
    for ($j = $n - 1; $j > $i; --$j) echo $j, PHP_EOL;
    exit;
}
echo 'Impossible', PHP_EOL;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 27048
#include <iostream>
#include <algorithm>
#include <stdint.h>
using namespace std;

int main() {

	int N;
	cin >> N;

	int ans = 0;

	int a[2000] = { 0, };

	for (int j = 0; j < N; j++) {
		cin >> a[j];
	}
	sort(a, a + N);
	for (int x = 0; x < N; x++) {
		for (int y = 0; y < x; y++) {
			int tmp = lower_bound(a, a + N, a[x] + a[y]) - a;
			ans += max(0, tmp - x - 1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import collections

def answer(ds, ts):
    dsDic = collections.Counter(ds)
    tsDic = collections.Counter(ts)
    for k, v in tsDic.items():
        if dsDic.get(k) is None: return 'NO'
        if tsDic[k] > dsDic[k]:
            return 'NO'
    return 'YES'

n = int(input())
ds = list(map(int, input().split()))
m = int(input())
ts = list(map(int, input().split()))
print(answer(ds, ts))

Measured memory_bytes: 127572
#include <bits/stdc++.h>
using namespace std;
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;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if(400 <= n && n <= 599) {
        cout << 8 << endl;
    } else if(600 <= n && n <= 799) {
        cout << 7 << endl;
    } else if(800 <= n && n <= 999) {
        cout << 6 << endl;
    } else if(1000 <= n && n <= 1199) {
        cout << 5 << endl;
    } else if(1200 <= n && n <= 1399) {
        cout << 4 << endl;
    } else if(1400 <= n && n <= 1599) {
        cout << 3 << endl;
    } else if(1600 <= n && n <= 1799) {
        cout << 2 << endl;
    } else if(1800 <= n && n <= 1999) {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
using namespace std;
typedef long long LL;
const int N = 1e5+7;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = acos(0.0) * 2;
char a[N];
int b[27];
char c[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int main() {
    while(~scanf("%s",a)) {
        int flag = 0;
        memset(b,0,sizeof(b));
        int len = strlen(a);
        for(int i = 0;i<len;i++)b[a[i]-'a'] = 1;
        for(int i = 0;i<26;i++) {
            if(b[i] == 0) {
                printf("%c\n",c[i]);
                flag = 1;
                break;
            }
        }
        if(flag == 0)printf("None\n");
    }
    return 0;
}


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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll a,b,c; cin>>a>>b>>c;
  cout << b+min(c,a+b+1) << endl;

  return 0;
}


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

typedef long long ll;
#define rep(i, n) for(ll i=0; i<n; i++)
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define sz(v) ll(v.size)


void solve(long long A, long long P){
    cout << (A * 3 + P) / 2 << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long P;
    scanf("%lld",&P);
    solve(A, P);
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from heapq import heappush, heappop

qn = int(input())

low = []
high = []
ans = 0
num = 0

for i in range(qn):
    q = [int(i) for i in input().split()]
    if q[0] == 1:
        # update
        ans += q[2]
        a = q[1]
        heappush(low, -a)
        heappush(high, a)
        if -low[0] > high[0]:
            low0 = heappop(low)
            high0 = heappop(high)
            heappush(low, -high0)
            heappush(high, -low0)
            ans += -low0 - high0
    if q[0] == 2:
        print(-low[0], ans)


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

int main() {
  int n; cin >> n;
  int ans = 0;
  for(int a = 1;a <= n; a++){
    for(int b = 1;b <= n; b++){
      for(int c = 1;c <= n; c++){
        ans += __gcd(a,__gcd(b,c));
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 3624
import math
def primes(x):
    if x < 2: return []
    primes = [i for i in range(x)]
    primes[1] = 0
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0
    return [prime for prime in primes if prime != 0]

n = int(input())
p=primes(10000)
pc = []
for v in p:
    if (v-1)%5==0:
        pc.append(v)
        if len(pc)==n:
            break
print(' '.join(map(str, pc)))


Measured memory_bytes: 3444
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n, a[100010], b[100010];
int main() {
	cin >> n;
	ll cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> b[i] >> a[i];
	}
	for (int i = n - 1; i >= 0; i--) {
		if ((b[i] + cnt) % a[i])cnt += a[i] * ((b[i] + cnt) / a[i] + 1) - (b[i] + cnt);
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)

const int INF = 1 << 24;

typedef unsigned long long ull;

int N, res = 0;
std::string expected;

bool can(int i, int j, const std::string& s){
    int counter = 0;
    
    while(i < s.size()){
        if(s[i] != expected[counter]){
            return false;
        }

        if(++counter == expected.size()){
            return true;
        }

        i += j;
    }

    return false;
}

int make(const std::string& s){
        REP(i, s.size()){
            FOR(j, 1, s.size()){
                if(can(i, j, s)){
                    return 1;
                }
            }
        }

        return 0;
}

int main(){
    std::cin >> N;
    std::cin >> expected;

    REP(i, N){
        std::string s;
        std::cin >> s;
        
        // if(make(s)){
        //     std::cout << i << std::endl;
        //     res += 1;
        // }
        res += make(s);
    }

    std::cout << res << std::endl;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

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

  ll ans=0;
  for(ll i=1;i<=n;i++){
    ans+=(i+(n/i*i))*(n/i)/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3636
N = int(input())
A = list(map(int, input().split()))

ans = 0
A_test = sorted(list(set(A)))

if N % 2 == 1:
    judge = [i for i in range(0,N,2)]
    if (A_test == judge) and (A.count(0) == 1):
        ans = 2**(N//2)
else:
    judge = [i for i in range(1,N,2)]
    if A_test == judge:
        ans = 2**(N//2)

ans = ans % (10**9 + 7)
print(ans)


Measured memory_bytes: 20472
#include<iostream>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<algorithm>
    #include<string>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    using namespace std;
    #define INF 10000000;
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define rrep(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
    #define vec(n) vector<int> vec(n)
    #define vvec(m,n) vector<vector<int>> vec(m,vector(n))

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

      int m = pow(n,0.5);
      long res;
      rrep(i,1,m+1){
        if(n%i == 0)res = n/i;
      }

      string s;
      s = to_string(res);
      int size = s.size();
      cout << size <<endl;
    }


Measured memory_bytes: 256
N,X=map(int,input().split())
l=[2**(i+2)-3 for i in range(N+1)]#レベルLバーガー層数
p=[2**(i+1)-1 for i in range(N+1)]#レベルL パティ数
def f(n,x):
    if n==0:
        return 1
    elif x==1:
        return 0
    elif 1<x<=l[n-1]+1:
        return f(n-1,x-1)
    elif x==l[n-1]+2:
        return p[n-1]+1
    elif l[n-1]+2<x<l[n]:
        return p[n-1]+1+f(n-1,x-l[n-1]-2)
    elif x==l[n]:
        return p[n]
print(f(N,X))

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

int main() {
  string s;
  cin >> s;
  int si = s.size();
  // cout << si;
  int con = 0;
  for (int i = 0; i < si / 2; i++) {
    if (s[i] != s[si - 1 - i]) {
      con++;
      // cout << s[i] << s[si - 1 - i];
    }
  }
  cout << con;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;

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

    if(N%(2*D+1)==0){
        cout<<N/(2*D+1)<<endl;
    }
    else{
        cout<<N/(2*D+1)+1<<endl;
    }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
#define int long long

int d[200][200];
int R[200];
int dp[1<<8][8];
signed main() {
	int n,m,r;scanf("%lld%lld%lld",&n,&m,&r);
	memset(d,0x3f,sizeof(d));
	rep(i,n)d[i][i]=0;
	rep(i,r){
		scanf("%lld",&R[i]);R[i]--;
	}
	rep(i,m){
		int a,b,c;scanf("%lld%lld%lld",&a,&b,&c);a--;b--;
		d[a][b]=d[b][a]=c;
	}
	rep(k,n)rep(i,n)rep(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	memset(dp,0x3f,sizeof(dp));
	rep(i,r){
		dp[1<<i][i]=0;
	}
	rep(i,1<<r){
		rep(k,r){
			rep(j,r){
				if(i>>j&1)continue;
				dp[i|1<<j][j]=min(dp[i|1<<j][j],dp[i][k]+d[R[k]][R[j]]);
			}
		}
	}
	int Min=INFL;
	rep(i,r){
		Min=min(Min,dp[(1<<r)-1][i]);
	}
	cout<<Min<<endl;
}


Measured memory_bytes: 512
/* Binary tree 1 */
#include <stdio.h>
#include <stdlib.h>

struct node{
  
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
  
};

typedef struct node * Node;

#define NIL NULL

Node root;


/* 二分探索木Tに対してkeyがkのノードを挿入する関数 */
void insert(int k)
{
  Node y = NIL;
  Node x = root;
  Node z;

  /* 挿入するノードzを作成 */
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  /* zを挿入する場所を求める */
  while( x != NIL )
    {
      y = x;     /* 親を設定 */

      if( z->key < x->key )
	x = x->left;       /* 左の子に移動 */
      else
	x = x->right;      /* 右の子に移動 */
    }

  z->parent = y;           /* zの親を設定 */

  if( y == NIL )
    root = z;              /* Tが空の場合 */
  else if( z->key < y->key )
    y->left = z;           /* 左の子として挿入する場合 */
  else
    y->right = z;          /* 右の子として挿入する場合 */
}


/* 二分探索木Tを中間順巡回によって出力する関数 */
void inorder(Node u)
{
  if( u == NIL )
    return;

  inorder(u->left);       /* 左の子に進む */
  printf(" %d", u->key);
  inorder(u->right);      /* 右の子に進む */
}


/* 二分探索木Tを先行順巡回によって出力する関数 */
void preorder(Node u)
{
  if( u == NIL )
    return;
  
  printf(" %d", u->key);
  preorder(u->left);       /* 左の子に進む */
  preorder(u->right);      /* 右の子に進む */
}

/* ノードxをルートノードとする二分探索木中でkeyの値が最小のものを探す関数
   戻り値  keyの値が最小のノードのアドレス */
Node treeMinimum(Node x)
{
  while( x->left != NIL )
    x = x->left;

  return x;
}


/* 二分探索木中でxの次に大きいノードを求める関数
   戻り値  求めたノードのアドレス  */
Node treeSuccessor(Node x)
{  
  /* ケース１ */
  if( x->right != NIL )
    return treeMinimum(x->right);

  /* ケース２ */
  while( x != NIL && x->parent->right == x )
      x = x->parent;
  return x;
}


/* 二分探索木Tからノードzを削除する関数 */
void treeDelete(Node z)
{
  Node y; // node to be deleted
  Node x; // child of y

  if( z->left == NIL || z->right == NIL )
    y = z;
  else
    y = treeSuccessor(z);

  if( y->left != NIL )
    x = y->left;
  else
    x = y->right;

  if( x != NIL )
    x->parent = y->parent;
  
  if( y->parent == NIL )
    root = x;
  else if( y->parent->left == y )
    y->parent->left = x;
  else
    y->parent->right = x;
  
  if( z != y )
    z->key = y->key;
}


/* 二分探索木T中にkeyがkという値のノードが含まれるかどうか調べる関数
   戻り値  存在 そのノードのアドレス  存在しない NIL  */
Node find(Node x, int k)
{
  
  while( x != NIL )
    {
      /* keyの値がkのノードが存在した場合 */
      if( x->key == k )
	return x;

      if( k < x->key )
	x = x->left;      /* 左の子に移動 */
      else
	x = x->right;     /* 右の子に移動 */
      
    }

  return NIL;   /* 存在しなかった場合 */
}

int main()
{
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

    if( com[0] == 'f' )
      {
	scanf("%d", &x);

	if( find(root,x) != NIL )
	  printf("yes\n");
	else
	  printf("no\n");
      }
    else if ( com[0] == 'i' )
      {
	scanf("%d", &x);
	insert(x);
      }
    else if ( com[0] == 'p' )
      {
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
      }
    else if ( com[0] == 'd' )
      {
	scanf("%d", &x);
	treeDelete( find(root,x) );
      }
    
  }

  return 0;
}



Measured memory_bytes: 20472
#include<bits/stdc++.h>
#define maxn 1000005
using namespace std;
int n,ans;
char s[maxn],t[maxn];
queue<int>q;
int main()
{
	scanf("%d%s%s",&n,s,t);
	for(int i=0;i<n;i++) if(s[i]!=t[i]) {ans=-1;break;}
	if(ans!=-1) return puts("0"),0;
	for(int up=n-1,down=n-1;down>=0;down--){
		if(t[down]==t[down-1]) continue;
		while(up>down||(up>=0&&s[up]!=t[down])) up--;
		if(up<0) {ans=-1;break;}
		while(!q.empty()&&q.front()-q.size()>=down) q.pop();
		if(up!=down) q.push(up);
		ans=max(ans,(int)q.size()+1);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 6400
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int main(void) {
    const int AMAX = 200000;
    int n, k;
    cin >> n >> k;

    vector<int> a(AMAX + 1);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a[x]++;
    }

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

    int p = -1;
    for(int i = 0; i <= AMAX; i++){
        if(a[i] != 0){
            p = i;
            break;
        }
    }

    int del = max(0UL, (a.size() - p) - k);

    long cnt = 0;
    for(int i = 0; i < del; i++){
        cnt += a[p + i];
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1656
a,b=map(int,input().split())
list1 = []
list2 = []
if (a/0.08).is_integer():
    c1 = int(a/0.08)
else:
    c1=int(a/0.08)+1
if ((a+1)/0.08).is_integer():
    c2 = int((a+1)/0.08)
else:
    c2=int((a+1)/0.08)+1

for i in range(c1,c2):
    list1.append(i)

if (b/0.10).is_integer():
    c3 = int(b/0.10)
else:
    c3=int(b/0.10)+1
if ((b+1)/0.10).is_integer():
    c4 = int((b+1)/0.10)
else:
    c4=int((b+1)/0.10)+1
for i in range(c3,c4):
    list2.append(i)

l3 = set(list1) & set(list2)
l3 = list(l3)
if len(l3) > 0:
    print(min(l3))
else:
    print(-1)

Measured memory_bytes: 3064
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

print(2*n*math.pi)



Measured memory_bytes: 67448
N, M, C = map(int, input().split())
Bi = list(map(int, input().split()))
Ai = [list(map(int, input().split())) for _ in range(N)]

count = 0
for a in Ai:
    s = C
    for i in range(M):
        s += a[i] * Bi[i]
    if s > 0:
        count += 1
print(count)

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

using namespace std;
using LL = long long;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    if (s.back() == '2' || s.back() == '4' || s.back() == '5' || s.back() == '7' || s.back() == '9')
        cout << "hon" << endl;
    else if (s.back() == '0' || s.back() == '1' ||s.back() == '6' ||s.back() == '8')
        cout << "pon" << endl;
    else cout << "bon" << endl;
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s="ACL";
    int n=sc.nextInt();
    for(int i=0;i<n-1;i++){
      System.out.print(s);
    }
    System.out.println(s);
  }
}

Measured memory_bytes: 35784
using System;

public class SortingThreeNumbers {
  static int Main(string[] args)
  {
    string inputData = Console.ReadLine();
    string[] inputDataArray = inputData.Split();
    int a = int.Parse(inputDataArray[0]);
    int b = int.Parse(inputDataArray[1]);
    int c = int.Parse(inputDataArray[2]);

    int tmp = 0;

    if(c < a) {
        tmp = c;
        c = a;
        a = tmp;
    }

    if(b < a) {
      tmp = a;
      a = b;
      b = tmp;
    }

    if(c < b) {
      tmp = b;
      b = c;
      c = tmp;
    }

    Console.WriteLine("{0} {1} {2}", a, b, c);
    return 0;
  }
}



Measured memory_bytes: 9196
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto s = readln.chomp;
  auto cnt = s.count!(a=>a=='o');
  auto d = 15 - s.length;
  if (cnt + d >= 8) {
    writeln("YES");
  } else {
    writeln("NO");
  }
}


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

int main()
{   int N,K;
int64_t s=0;
    cin>>N>>K;
    int H[N];
    int i;
    for(i=0;i<N;i++)
        cin>>H[i];
        sort(H,H+N);
    N=N-K;
    if(N>0) for(i=0;i<N;i++)
        s+=H[i];
    cout<<s;

    return 0;
}

Measured memory_bytes: 1024
N = int(input())
H = list(map(int, input().split()))
before = H[0]
flag = True
magic = False
for i in range(1, N):
    now = H[i]
    if now >= before+1:
        before = now-1
        magic = True
    elif now == before:
        before = now
        magic = True
    elif now == before - 1 and magic == False:
        before = now
        magic = True
    else:
        flag = False
        break
    #print(before)
if flag:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 15020
#include<stdio.h>
int main(void){
  int N, M, C;
  scanf("%d %d %d", &N, &M, &C);
  
  int B[M];
  int A[N][M];
  int i, j;
  int sum = 0, cnt = 0;
  for(i = 0; i < M; i++){
    scanf("%d", &B[i]);
  }
  for(i = 0; i < N; i++){
    for(j = 0; j < M; j++){
      scanf("%d", &A[i][j]);
      sum += A[i][j] * B[j];
    }
    sum += C;
    if(sum > 0){
      cnt++;
    }
    sum = 0;
  }
  
  printf("%d\n", cnt);
}

Measured memory_bytes: 128
// #include<iostream>
// using namespace std;
//
// int max(int A[],int array_size){
//   int max=1;
//   for(int i=0;i<array_size;i++){
//     if(A[i]<=A[i+1])max=A[i+1];
//     else max=max;
//   }
//   return(max);
// }
// int min(int A[],int array_size){
//   int min=1;
//   for(int i=0;i<=array_size;i++){
//     if(A[i]>=A[i+1])min=A[i+1];
//     else min=min;
//   }
//   return(min);
// }
// int main(){
//   int n,m,X,Y,b=0,max_x,min_y;
//   cin>>n>>m>>X>>Y;
//   string s={"War","No War"};
//   int x[n],y[m];
//   for(int i=0;i<n;i++)cin>>x[i];
//   for(int i=0;i<m;i++)cin>>y[i];
//   max_x=max(x,n);
//   min_y=min(y,m);
//   b=(max_x<min_y&&X<Y)?0:1;
//   cout<<s[b]<<endl;
//   return 0;
// }


#include<iostream>
#include<vector>
using namespace std;

bool is_war(const vector<int>& x, const vector<int>& y){
  for(int Z=-100; Z<= 100; Z++){
    bool is_ok=true;
    for(int i=0;i<x.size();i++){
      if(x[i]>=Z)is_ok=false;
    }
    for(int i=0;i<y.size();i++){
      if(y[i]<Z)is_ok=false;
    }
    if(is_ok)return false;
  }
  return true;
}
int main(){
  int N,M;cin>>N>>M;
  vector<int>x(N+1),y(M+1);
  cin>>x[0]>>y[0];
  for(int i=0;i<N;i++){
    cin>>x[i+1];
  }
  for(int i=0;i<M;i++){
    cin>>y[i+1];
  }
  if(is_war(x,y)){
    cout<<"War"<<endl;
  }else{
    cout<<"No War"<<endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
const int N=1e5+10;
int n,m,f[300][300],R,ans,r[N],tmp[N];
bool vis[N];
void dfs(int t)
{
	int i,sum=0;
	if (t>R)
	{
		sum=0;
		for (i=2;i<=R;i++)
		  sum+=f[r[tmp[i]]][r[tmp[i-1]]];
		ans=min(sum,ans);
	}
	else
	  for (i=1;i<=R;i++)
	    if (!vis[i])
	      vis[i]=true,tmp[t]=i,dfs(t+1),vis[i]=false;
}
int main()
{
	int i,j,k,a,b,c,l;
	scanf("%d%d%d",&n,&m,&R);
	memset(f,127/3,sizeof(f));
	ans=1e9;
	for (i=1;i<=R;i++)
	  scanf("%d",&r[i]);
	for (i=1;i<=m;i++)
	  scanf("%d%d%d",&a,&b,&c),f[a][b]=f[b][a]=c;
	  for (k=1;k<=n;k++)
	    for (i=1;i<=n;i++)
	      for (j=1;j<=n;j++)
	        f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
	dfs(1);
	printf("%d",ans);
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>//小数点以下表示
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n,d;
    cin>>n>>d;
    double x[n][d];
    rep(i,n){
        rep(j,d){
            cin>>x[i][j];
        }
    }
    int count=0;
    rep(i,n-1){
        for(int j=i+1;j<n;j++){
            double Sum=0.0;
            rep(k,d){
                Sum+=pow((x[i][k]-x[j][k]),2);
            }
            Sum=sqrt(Sum);
            if(Sum==ceil(Sum)){
                count++;
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
loop do
  n = gets.chomp.to_i
  row_count = gets.chomp.to_i

  break if n == 0 && row_count == 0
  
  graph = Hash.new { |h, k| h[k] = [] }

  row_count.times do
    pair = gets.chomp.split(' ')
    graph[pair[0]] << pair[1]
    graph[pair[1]] << pair[0]
  end

  friends = graph['1']
  foaf = friends.map { |f| graph[f].delete_if { |of| of == '1' } }.flatten.uniq

  puts (friends | foaf).size
end

Measured memory_bytes: 9536
import java.util.*;
import java.util.regex.*;

public class Main {
	
	public static void main(String... args) {
		System.out.println(sum(sort(scanInt(), scanInt(), scanInt()), scanInt()));
	}
	
	private static int sum(int[] nums, int K) {
		int m = nums[nums.length - 1];
		int[] nnn = Arrays.copyOfRange(nums, 0, nums.length - 1);
		int t = m;
		for (int i = 0; i < K; ++i) {
			t *= 2;
		}
		for (int n : nnn) {
			t += n;
		}
		return t;
	}
	
	private static int[] sort(int... a) {
		Arrays.sort(a);
		return a;
	}
	
	private static final Scanner SC = new Scanner(System.in);

	private static int scanInt() {
		return SC.nextInt();
	}

	private static  String scanString() {
		return SC.next();
	}
}


Measured memory_bytes: 20948
#include <iostream>
#include <vector>
#include <bits/stdc++.h>

#define MOD 1000000007

using namespace std;

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

    vector<int>oks(n+1, 1);
    for (int i = 0; i < m; ++i) {
        cin >> a;
        oks[a] = 0;
    }

    vector<long long int>dp(n+1);
    dp[0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j <= min(n, i + 2); ++j) {
            if (oks[j]) {
                dp[j] += dp[i];
                dp[j] %= MOD;
            }
        }
    }

    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int a[3],b[3];
int n;
int main()
{
	cin>>a[0]>>a[1]>>a[2]>>n;
	sort(a,a+3);
	int ans=0;
	int df=-1,di=-1;
	if(a[0]==a[1])
	{
		df=2;di=1;
	}
	else
	{
		if(a[0]==a[2])
		{
			df=1;di=2;
		}
		else
		if(a[1]==a[2])
		df=0,di=1;
	}
	if(df==-1)
	{
		for(int i=n/a[0];i>=0;i--)
			for(int j=(n-i*a[0])/a[1];j>=0;j--)
				for(int k=(n-i*a[0]-j*a[1])/a[2];k>=0;k--)
				{
					if(i*a[0]+j*a[1]+k*a[2]==n)
					ans++;
				}	
	}
	
	else
	{
		for(int i=n/a[df];i>=0;i--)
		{
			if((n-i*a[df])%a[di]!=0)
			continue;
			ans+=(n-i*a[df])/a[di]+1;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    char[] ss = s.toCharArray();
    char[] tt = t.toCharArray();
    Arrays.sort(ss);
    Arrays.sort(tt);
    for (int i=0; i<tt.length / 2; i++) {
      char tmp = tt[i];
      tt[i] = tt[tt.length-1-i];
      tt[tt.length-1-i] = tmp;
    }
    int check =0,y =0, w=0;
    for (int i=0; i<Math.min(ss.length,tt.length); i++) {
      if (ss[i] < tt[i]) {
        y++;
        break;
      }
      if (ss[i] > tt[i]) {
        w++;
        break;
      }
    }
    if (y != 0) {
      System.out.println("Yes");
    } else if (w != 0) {
      System.out.println("No");
    } else if (ss.length < tt.length) {
      System.out.println("Yes");      
    } else {
      System.out.println("No");
    }
  }
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, m, x, y;
	cin >> n >> m >> x >> y;

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

	vector<int> b(m);
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}

	sort(begin(a), end(a));
	sort(begin(b), end(b));

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (a[i] >= b[j]) {
				cout << "War" << endl;
				return 0;
			}
		}
	}

	int z = a[n - 1] + 1;
	cout << (x < z && z <= y ? "No War" : "War") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll N, A; cin >> N >> A;
	ll ans = N;
	for (int t = 1; t < 100; t++) {
		ll lb = -1, ub = N;
		while (ub - lb > 1) {
			ll mid = (lb + ub) / 2, n = N;
			double z = 1;
			rep(i, t + 1) {
				ll d = mid / (t + 1) + (i < mid % (t + 1));
				z *= d;
			}
			if (z >= N) ub = mid;
			else lb = mid;
		}
		ans = min(ans, ub + t * A);
	}
	cout << ans << endl;
	return 0;
	if (N > 1000000) return 0;
	vector<int> v;
	for (int i = 1; i * i <= N; i++) {
		v.pb(i);
		v.pb((N + i - 1) / i);
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	while (v.back() > N) v.pop_back();
	int M = v.size();
	vector<ll> dp(M, LLONG_MAX);
	dp[0] = 1;
	for (int k = 1; k < M; k++) {
		int x = v[k];
		dp[k] = x;
		for (int _k = 0; _k < k; _k++) {
			int y = v[_k];
			int d = (x + y - 1) / y;
			dp[k] = min(dp[k], dp[_k] + d + A);
		}
	}
	cout << dp.back() << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt(),a[]=new int[200],i,j,t,s=0;
		for(i=0;i<2*n;i++) a[i]=stdIn.nextInt();
		for(i=0;i<2*n-1;i++) {
			for(j=2*n-1;j>i;j--) {
				if(a[j-1]>a[j]) {
					t=a[j-1];
					a[j-1]=a[j];
					a[j]=t;
				}
			}
		}
		for(i=0;i<n*2;i+=2) {
			if(a[i]>a[i+1]) s+=a[i+1];
			else s+=a[i];
		}
		System.out.print(s);
	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr), cout.tie(nullptr)
#define endl '\n'
using namespace std;

int n;

void solve(){   
    cin >> n;
    vector<int> heights(n);
    vector<int> dp(n, INT_MAX); 
    for(int& it : heights)
        cin >> it;
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < i + 3 && j < n; ++j){
            dp[j] = min(dp[j], dp[i] + abs(heights[i] - heights[j]));
        }
    }
    cout << dp[n - 1] << endl;
}
 
signed main() {
	fastio;
	// int t; cin >> t;
 
	// while(t--)
		solve();
 
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;
 
int N;
int x, y;
string s;
 
const int MAX_C = 8010;
bool dp_x[MAX_C][MAX_C*2];
bool dp_y[MAX_C][MAX_C*2];
 
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin >> s;
    cin >> x >> y;
    N = s.length();
 
    vector<int> X, Y;
    // preprocessing
    int t = 1;
    int cnt = 0;
    rep(i, N) {
        if (s[i] == 'T') {
            if (t == 1) X.push_back(cnt);
            else Y.push_back(cnt);
            cnt = 0;
            t = 1 - t;
        }
        else {
            cnt++;
            if (i == N - 1) {
                if (t == 1) X.push_back(cnt);
                else Y.push_back(cnt);
            }
        }
    }
 
    int nx = (int)X.size();
    int ny = (int)Y.size();
    dp_x[0][8000] = true;
    dp_y[0][8000] = true;

    bool flag = 0;
    if (X[0] == 0) flag = 1;
 
    rep(i, nx) {
        rep(j, MAX_C * 2) {
            if (dp_x[i][j]) {
                if (j + X[i] < MAX_C * 2) dp_x[i+1][j + X[i]] = 1;
                if (j - X[i] >= 0 && flag) dp_x[i+1][j - X[i]] = 1;
            }
        }
        if (!flag) flag = 1;
    }
    rep(i, ny) {
        rep(j, MAX_C * 2) {
            if (dp_y[i][j]) {
                if (j + Y[i] < MAX_C * 2) dp_y[i+1][j + Y[i]] = 1;
                if (j - Y[i] >= 0) dp_y[i+1][j - Y[i]] = 1;
            }
        }
    }
 
    if (dp_x[nx][x+8000] && dp_y[ny][y+8000]) cout << "Yes" << endl;
    else cout << "No" << endl;
 
    return 0;
}

Measured memory_bytes: 125824
n = int(input())
T_point = 0
H_point = 0
for i in range(n):
    T_card, H_card = input().split()
    if T_card > H_card:
        T_point += 3
    elif H_card > T_card:
        H_point += 3
    else:
        T_point += 1
        H_point += 1
print(T_point, H_point)

Measured memory_bytes: 7660
N=int(input())
a=list(map(int,input().split()))
b=int(sum(a)/len(a))
c=sum(a)
d=sum(map(lambda x:x**2,a))
e=min(d+N*b*b-2*c*b,d+N*(b+1)*(b+1)-2*c*(b+1))
print(e)



Measured memory_bytes: 3064
#include <algorithm>
#include <functional>
#include <iostream>
#include <set>
#include<iomanip>
#include<queue>
#include <cstdint>
#include <string>


using namespace std;

int main() {
	int n;
	cin>>n;
	int prime[101];
	for(int i=0;i<101;i++){
		prime[i]=0;
	}
	for(int i=1;i<=n;i++){
		int copy_i=i;
		int k=2;
		while(true){
			if(copy_i==1){
				break;
			}else{
				if(copy_i%k==0){
					copy_i=copy_i/k;
					prime[k]++;
				}else{
					k++;
				}
			}
		}
	}

	int over74 = 0;
	int over24=0;
	int over2=0;
	int over14=0;
	int over4=0;
	for(int i=2;i<=n;i++){
		if(prime[i]>=2){
			over2++;
		}
		if(prime[i]>=4){
			over4++;
		}
		if(prime[i]>=14){
			over14++;
		}
		if(prime[i]>=24){
			over24++;
		}
		if(prime[i]>=74){
			over74++;
		}
	}
	int ans = over74+(over24*(over2-1))+(over14*(over4-1))+(over4*(over4-1)*(over2-2))/2;
	cout<<ans<<endl;



	return 0;

}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;



int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		if(a%2==0){
			if(a%3==0||a%5==0){
				continue;
			}
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

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

    ll H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    ll s = H1*60 + M1;
    ll e = H2*60 + M2;

    cout << e-s-K << endl;
}


Measured memory_bytes: 3652
while True:
    m,f,r = map(int,input().split())
    if m == f == r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif 65 <= m + f < 80:
        print("B")
    elif 50 <= m + f < 65:
        print("C")
    elif 30 <= m + f < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")



Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std ;
int main () {
int  a,b,c ;
cin>>a>>b>>c  ;
if(a!=b&&a!=c) {
    cout<<a ;
}
else if(b!=a&&b!=c) {
    cout<<b ;
}
else if (c!=a&&c!=b) {
    cout<< c ;
}

}


Measured memory_bytes: 256
// abc098_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    string S;
    cin >> S;

    vector<int> L(N), R(N);
    REPN(i, 1, N){
        L[i] = L[i-1] + (S[i-1] == 'W' ? 1 : 0);
    }
    REP_REV(i, N-1){
        R[i] = R[i+1] + (S[i+1] == 'E' ? 1 : 0);
    }
    int ans = INF;
    REP(i, N){
        ans = min(ans, L[i] + R[i]);
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 2964
N = int(input())
A_upper = list(map(int, input().split()))
A_lower = list(map(int, input().split()))

max_A_sum = 0

for i in range(N):
    A_sum = sum(A_upper[:i+1]) + sum(A_lower[i:])
    if A_sum > max_A_sum:
        max_A_sum = A_sum

print(max_A_sum)



Measured memory_bytes: 2940
m,d = map(int, input().split())

ans = 0
for i in range(1,m+1):
    for d1 in range(2,10):
        if i % d1 == 0:
            d10 = i // d1
            if 2 <= d10 <= 9 and 10 * d10 + d1 <= d: ans += 1
print(ans)

Measured memory_bytes: 2940
import numpy as np

bingo = []
for _ in range(3):
    array = list(map(int,input().split()))
    bingo.append(array)
bingo = np.array(bingo)
n = int(input())
bs = []
for _ in range(n):
    bs.append(int(input()))

for i in bs:
    bingo = np.where(bingo == i, 101, bingo)

h = False
if bingo[0][0] == bingo[1][1] == bingo[2][2] or bingo[0][2] == bingo[1][1] == bingo[2][0]:
    h = True
if h == False:
    for i in range(3):
        if bingo[i][0] == bingo[i][1] == bingo[i][2]:
            h = True
            break
    for j in range(3):
        if bingo[0][j] == bingo[1][j] == bingo[2][j]:
            h = True
            break

print('Yes') if h == True else print('No')

Measured memory_bytes: 27140
// cand <genesis?>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const ll base = 7;
const ll N = 3e5 + 9;
const ll inf = 1000100009;
typedef pair<ll,ll> LL;

ll n,a[N],b[N],i;
map<ll,ll> cnt;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("test.INP", "r", stdin);
    //cout<<cal(104) - cal(103)<<"\n";
    cin>>n;
    for (i=1;i<=n;i++){
        cin>>a[i];
        b[i] = a[i] + i;
    }
    ll ans = 0;
    for (i=1;i<=n;i++){
        ll p = i - a[i];
        if (p > 0) ans += cnt[p];
        cnt[i + a[i]]++;
    }
    cout<<ans;
}


Measured memory_bytes: 20556
#include <iostream>
#include <vector>
using namespace std;
#define MOD 1000000007

int main()
{
    int n, k;
    cin >> n >> k;
    vector<long long> total(n+1);
    for(int i = 0; i <= n; ++i)
    {
        total[i] += i;
        if(i > 0) total[i] += total[i-1];
    }

    long long ans = 0;
    for(int i = k; i <= n+1; ++i)
    {
        if(i>n)
        {
            ans += 1;
            ans %= MOD;
            continue;
        }
        long long r = total[n] - total[n-i];
        long long l = total[i-1];
        ans += r-l+1;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4840