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

using std::vector;

double get_optimal_value(int capacity, vector<int> weights, vector<int> values) {
  double value = 0.0;

      // write your code here


  return value;
}

int main() {
  int a,b;
  std::cin >> a >> b;
  std::cout<<a*b<<"\n";

  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
#define NUM 1000000007
typedef long long int lli;

int main(){
    int n, d, x;
    cin >> n >> d >> x;
    int ans = x;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        ans += (d - 1) / a + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
ll mpower(ll a,ll b,ll c){
  int z;
  if(b==0){
    z=1;
    z%=c;
    return z;
  }
  if(b==1){
    z=a;
    z%=c;
    return z;
  }
  else{
    return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
  }
}
bool IsPrime(ll num){
  if(num<2) return false;
  else if(num==2) return true;
  else if(num%2==0) return false;
  double sqrtNum=sqrt(num);
  for(ll i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
  return true;
}

int main(){
  ll a,b;
  cin>>a>>b;
  ll c=gcd(a,b);
  if(c==1){
    cout<<1<<endl;
    return 0;
  }
  int ans=1;
  if(c%2==0){
    ans++;
    while(c%2==0){
      c/=2;
    }
  }
  for(int i=0;i<20;i++){
    for(ll j=3;j*j<=c;j+=2){
      if(IsPrime(j)==true&&c%j==0){
        ans++;
        while(c%j==0){
          c/=j;
        }
      }
    }
  }
  if(c>1){
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char tmp[2000];
int main() {
	//freopen("in","r",stdin);
	while(cin>>tmp) {
		if(tmp[0]=='0') break;
		long long sum = 0;
		for(int i=0;i<strlen(tmp);i++) {
			sum += (tmp[i]-'0');
		}
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
using namespace std;

int main() {
	int n, a[200000], stair;
	long long ans;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	stair=n-1-a[n-1];
	if (n == 1 && a[0] != 0) {
		cout << -1 << endl;
		return 0;
	}
	ans = a[n - 1];
	for (int i = n - 2; i >= 0; i--) {
		if (i - a[i] > stair||i-a[i]<0) {
			cout << -1 << endl;
			return 0;
		}
		else if (i - a[i] == stair)continue;
		else {
			ans += a[i];
			stair = i - a[i];
		}
	}
	cout << ans << endl;
	return 0;
}

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

const int N = 1e5+5 , inf = 0x3f3f3f3f;

int n , k , h[N] , dp[N];

int main(){
  cin >> n >> k;
  for(int i = 2 ; i < N ; i++) dp[i] = inf;
  for(int i = 1 ; i <= n ; i++) cin >> h[i];
  for(int i = 1 ; i < n ; i++)
    for(int j = 1 ; j <= k ; j++)
    dp[min(i+j,n)] = min(dp[min(i+j,n)],dp[i]+abs(h[i]-h[min(i+j,n)]));
  cout << dp[n] << "\n";
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		int tot = 0, min = 100;
		for(int i = 0; i < n; i++){
			int a = l+i;
			tot += a;
			if(Math.abs(a) < Math.abs(min)) min = a;
		}
		System.out.println(tot-min);
	}

}


Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
    int a, b;
    int ab = 0;
    cin >> a >> b;
    if(b < 10){
        ab = a*10 + b;
    }else if(b >= 10 && b < 100){
        ab = a*100 + b;
    }else {
        ab = a*1000 + b;
    }
    for(int i = 1; i <= 1000; i++){
        if(i * i == ab){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

using namespace std;

const int N = 1e5 + 10;

int n, x[N], l, q, le, ri, a, b, f[N][35];

long long sum;

void init ()
{
	scanf ( "%d" , &n);
	for (int i = 1; i <= n; ++ i)
		scanf ( "%d" , &x[i]);
	scanf ( "%d%d" , &l, &q);
}

void work ()
{
	for (int i = 1; i <= n; ++ i)
	{
		le = i + 1, ri = n;
		for (; le <= ri; )
		{
			int mid = (le + ri) >> 1;
			if (x[mid] <= l + x[i])
				le = mid + 1;
			else ri = mid - 1;
		}
		if (x[i] + l >= x[n])
			f[i][0] = n;
		else f[i][0] = le - 1;
	}
	for (int i = 1; i <= 31; ++ i)
		for (int j = 1; j <= n; ++ j)
			f[j][i] = f[ f[j][i - 1] ][i - 1];
}

void prin ()
{
	for (int i = 1; i <= q; ++ i)
	{
		scanf ( "%d%d", &a, &b);
		if (b < a) swap (a, b);
		sum = 0;
		for (int j = 31; j >= 0; -- j)
			if (f[a][j] < b)
			{
				sum += (1 << j);
				a = f[a][j];
			}
		printf ( "%lld\n" , sum + 1);
	}
}

int main ()
{
	init ();
	work ();
	prin ();
	return 0;
}

Measured memory_bytes: 14848
#include<iostream>

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main()
{
    int n;  cin >> n;
    int a[n + 1];   rep(i, n + 1) cin >> a[i];
    int b[n];   rep(i, n) cin >> b[i];
    long long ans = 0;
    int kill;

    for(int i = 0; i < n; i++){
        kill = min(a[i], b[i]);
        b[i] -= kill;
        ans += kill;

        if(b[i] > 0){
            kill = min(a[i + 1], b[i]);
            a[i + 1] -= kill;
            ans += kill;
        }
    }

    cout << ans << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	int a,b,c,d;
	cin >> a >> b>> c >>d;
	if (b < c) cout << 0;
	else if(a < c ) cout << min(b,d)-c;
	else cout << max(min(b,d)-a,0);

	return 0;
}

Measured memory_bytes: 256
A = [list(map(int,input().split())) for _ in [0]*3]
N = int(input())
B = [int(input()) for _ in [0]*N]

bingo = [[False]*3 for _ in [0]*3]
for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                bingo[i][j] = True

ans = False
for i in range(3):
    tmp = True
    for j in range(3):
        tmp = tmp and bingo[i][j]
    ans = ans or tmp

for j in range(3):
    tmp = True
    for i in range(3):
        tmp = tmp and bingo[i][j]
    ans = ans or tmp
tmp = bingo[0][0] and bingo[1][1] and bingo[2][2]
ans = ans or tmp
tmp = bingo[0][2] and bingo[1][1] and bingo[2][0]
ans = ans or tmp
print("Yes" if ans else "No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n;
  cin>>n;
  ll a[n+1];
  a[0]=2,a[1]=1;
  for(int i=2;i<=n;i++){
    a[i]=a[i-1]+a[i-2];
  }
  cout<<a[n];
}


Measured memory_bytes: 256
import Data.Text
check :: Double -> String -> Double
check a b = if b == "JPY"
               then a
               else a * 380000

main = do
  head <- getLine
  s <- getContents
  let cont = Prelude.map Prelude.words $ Prelude.map unpack (splitOn (pack "\n") (pack s))
  let fil = Prelude.filter (Prelude.not . Prelude.null) cont
  let ans = Prelude.sum $ Prelude.map (\x -> check (read (x !! 0) :: Double) (x !! 1)) fil
  print ans



Measured memory_bytes: 636
fun main(args: Array<String>) {
    val (a, b, c, d) = readLine()!!.split(" ").map(String::toInt)
    val output = if (a + b > c + d) {
        "Left"
    } else if (a + b == c + d) {
        "Balanced"
    } else {
        "Right"
    }
    println(output)
}


Measured memory_bytes: 37880
#include<iostream>

using namespace std;

bool isPrime( int x )
{
	if( 2 == x ) { return true; }
	if( 0 == x%2 ) { return false; }
	
	for( int i=3; i*i<=x; i+=2 ) {
		if( 0 == x%i ) { return false; }
	}
	return true;
}

int main( )
{	
    int n;
    
    cin>>n;
    
    int cnt = 0, num;
    while( n-- ) {
    	cin>>num;
    	cnt += isPrime( num );
    }
    cout<<cnt<<endl;
	
	return 0;
}

Measured memory_bytes: 1160
n = int(input())
a = list(map(int,input().split()))
b = list(a)
b.sort()
l = [b[n//2-1],b[n//2]]
r = [b[n//2],b[n//2-1]]
for i in range(n):
    if a[i] <= l[0]:
        print(l[1])
    else:
        print(r[1])

Measured memory_bytes: 30552
// solv_D.cpp : 

#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

typedef unsigned long long ll;

int main()
{
    int N;
    string S;
    vector <int> R, G, B;
    int i, j, k;

    cin >> N;
    cin >> S;

    int nR, nG, nB;
    ll sum;
    nR = 0;
    nG = 0;
    nB = 0;
    for (i = 0; i < N; i++) {
        if (S[i] == 'R') {
            nR++;
        }
        else if (S[i] == 'G') {
            nG++;
        }
        else {
            nB++;
        }
    }

    sum = ll(nR) * ll(nG) * ll(nB);

    for (i = 0; i < N-2; i++) {
        for (j = i+1; j < N-1; j++) {
            if (S[i] == S[j]) continue;
            k = j + (j - i);
            if (k < N) {
                if (S[i] != S[k] && S[j] != S[k]) {
                    sum--;
                }
            }
            else {
                break;
            }
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long ans  = 0;
        int c = 0;
        for (int i = 0 ; i < s.length() ; i++) {
            if (s.substring(i, i + 1).equals("B")) {
                c++;
            } else {
                ans += c;
            }
        }

        System.out.println(ans);

    }

}


Measured memory_bytes: 37944
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N, dp[410][410], sum[410], A[410];

// [l, r)
int solve(int l, int r) {
    int &val = dp[l][r];
    if(val >= 0) return val;
    if(r - l == 1) return val = 0;

    val = INF;
    for(int i=l+1; i<r; i++) {
        // [l, r) -> [l, i) and [i, r)
        int cost = 0;
        cost += sum[i] - sum[l];
        cost += sum[r] - sum[i];
        chmin(val, solve(l, i) + solve(i, r) + cost);
    }
    return val;
}

signed main() {
    cin >> N;
    for(int i=0; i<N; i++) {
        cin >> A[i];
        sum[i+1] += sum[i] + A[i];
    }

    fill(dp[0], dp[N+1], -1);
    cout << solve(0, N) << endl;
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define nl cout<<'\n';
int main()
{
    int n,x=0,mx=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0; i<n; i++)
    {
        if(s[i]=='I')
            x++;
        else
            x--;
        mx=max(x,mx);
    }
    cout<<mx;
    nl;
    return 0;
}


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

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();

    int X, Y;
    cin >> X >> Y;
    if ((2 * X - Y) % 3 != 0 || (2 * Y - X) % 3 != 0) {
      cout << 0 << endl;
    }
    else {
      int N, M;
      N = (2 * X - Y) / 3;
      M = (2 * Y - X) / 3;
      cout << COM(N + M, N) << endl;
    }
}

Measured memory_bytes: 23680
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> dp(n + 1, 1 << 30);
	dp[0] = 0;
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1] + 1;
		for (int j = 6; j <= i; j *= 6) {
			dp[i] = min(dp[i - j] + 1, dp[i]);
		}
		for (int j = 9; j <= i; j *= 9) {
			dp[i] = min(dp[i - j] + 1, dp[i]);
		}
	}
	cout << dp[n] << endl;
	return 0;	
}

Measured memory_bytes: 640
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		int a = s.charAt(0) - '0';
		int b = s.charAt(1) - '0';
		int c = s.charAt(2) - '0';
		int d = s.charAt(3) - '0';
		
		// 計算
		String op1 = "";
		String op2 = "";
		String op3 = "";
		for(int i = 0; i < 8; i++){
		    int sum = a;
		    if(((i>>0)&1) == 0){
		        op1 = "+";
		        sum += b;
		    }else{
		        op1 = "-";
		        sum -= b;
		    }
		    if(((i>>1)&1) == 0){
		        op2 = "+";
		        sum += c;
		    }else{
		        op2 = "-";
		        sum -= c;
		    }
		    if(((i>>2)&1) == 0){
		        op3 = "+";
		        sum += d;
		    }else{
		        op3 = "-";
		        sum -= d;
		    }
		    if(sum == 7) break;
		}
		
		// 出力
		System.out.println(a + op1 + b + op2 + c + op3 + d + "=7");
	}
}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,k;
    cin>>n>>k;
    vector<ld> p(n+1),a(n+1);
    ld ans=0;
    repi(i,1,n+1){
        cin>>p[i];
        a[i]=((1+p[i])*p[i]/2)/p[i]+a[i-1];
    }
    repi(i,k,n+1){
        ans=max(ans,a[i]-a[i-k]);
    }
    cout<<fixed<<setprecision(9)<<ans;
}

Measured memory_bytes: 9508
import math
a,b,h,m = list(map(int,input().split()))

#角度 
hsita = 30 * h + 0.5*m
msita = 6 * m

#位置
hx = math.cos(math.radians(hsita)) * a
hy = math.sin(math.radians(hsita)) * a
mx = math.cos(math.radians(msita)) * b
my = math.sin(math.radians(msita)) * b

#3heiho
ans = math.sqrt(((hx - mx) ** 2) + ((hy-my)**2))

print(ans)

Measured memory_bytes: 9348
N = int(input())

tbl = [0]*(N+1)
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            a = x*x + y*y + z*z + x*y + y*z + z*x
            if a > N:
                continue
            tbl[a] += 1

for i in range(1, N+1):
    print(tbl[i])


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

using namespace std;

int main(){
    int n,ans;
    cin >> n;
    int x[n];
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    ans=INT_MAX;
    for(int i=0;i<=100;i++){
        int sum=0;
        for(int j=0;j<n;j++){
            sum+=(i-x[j])*(i-x[j]);
        }
        if(ans>sum){
            ans=sum;
        }
    }
   
   
    cout << ans << endl;
    

    
    return 0;
}

Measured memory_bytes: 256
tbl = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

num = int(input())

for count in range(num):
    b, f, r, v = map(int, input().split()) 
    tbl[b-1][f-1][r-1]= tbl[b-1][f-1][r-1] + v
    if tbl[b-1][f-1][r-1] > 9:
        tbl[b-1][f-1][r-1] = 9
    if tbl[b-1][f-1][r-1] < 0:
        tbl[b-1][f-1][r-1] = 0

for i, row in enumerate(tbl):
    for j, elem in enumerate(row):
        for n, test in enumerate(elem):
            print(" ", end = "")
            print(tbl[i][j][n], end = "")
        print()
    if i != 3:
        print('####################')




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

int main()
{
  int n;
  for(;cin>>n;)
    {
      int a,b,c,d;
      cin>>a>>b>>c>>d;
      int ans=999;
      a--;b--;c--;d--;
      for(int k=1;k<=n;k++)
	    ans=min(ans,abs(a/k-b/k)+abs(a%k-b%k)+abs(c/k-d/k)+abs(c%k-d%k));
      cout<<ans<<endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, q;
  cin >> a >> b >> q;
  vll v1(a), v2(b);
  for (int i = 0; i < a; i++)
    cin >> v1[i];
  for (int i = 0; i < b; i++)
    cin >> v2[i];
  v1.push_back(-10000000000000000LL);
  v2.push_back(-10000000000000000LL);
  v1.push_back(10000000000000000LL);
  v2.push_back(10000000000000000LL);
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  for (int i = 0; i < q; i++) {
    ll x;
    cin >> x;
    auto i1 = lower_bound(v1.begin(), v1.end(), x);
    ll r1 = *i1;
    i1--;
    ll l1 = *i1;
    auto i2 = lower_bound(v2.begin(), v2.end(), x);
    ll r2 = *i2;
    i2--;
    ll l2 = *i2;
    if (r1 == x)
      cout << min(r2 - x, x - l2) << endl;
    else if (r2 == x)
      cout << min(r1 - x, x - l1) << endl;
    else
      cout << min(min((x - l1) * 2 + r2 - x, (x - l2) * 2 + r1 - x),
                  min(min((r1 - x) * 2 + (x - l2), (r2 - x) * 2 + (x - l1)),
                      min(max(r2, r1) - x, x - min(l2, l1))))
           << endl;
  }
  return 0;
}


Measured memory_bytes: 2912
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <stdio.h>

using namespace std;

int sa, sb, d;

vector<string> &split(const string &s, char delim, vector<string> &elems) {
    stringstream ss(s);
    string item;
    while(getline(ss, item, delim)) {
        elems.push_back(item);
    }
    return elems;
}


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    return split(s, delim, elems);
}

int toint(string s) {
    istringstream ss(s);
    int ans;
    ss >> ans;
    return ans;
}

int main(void) {
    string s;
    int rec = 0, loz = 0;
    while(getline(cin, s)) {
        vector<string> v = split(s, ',');
        sa = toint(v[0]);
        sb = toint(v[1]);
        d = toint(v[2]);

        if(sa == sb) loz++;
        if(sa * sa + sb * sb == d * d) rec++;
    }
    cout << rec << endl << loz << endl;
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

using R = long double;
constexpr R pi = acos((R)-1), eps = 1e-10;

int sgn(R a) { return (a > eps) - (a < -eps); }
int sgn(R a, R b) { return sgn(a - b); }
using P = complex<R>;
istream& operator>>(istream& i, P& p) { R x, y; i >> x >> y; p = P(x, y); return i; }
ostream& operator<<(ostream& o, P p) { return o << fixed << setprecision(15) << real(p) << ' ' << imag(p); }
bool cmp(P p, P q) { return 2 * sgn(real(p), real(q)) + sgn(imag(p), imag(q)) < 0; }
bool eql(P p, P q) { return !cmp(p, q) and !cmp(q, p); }
R dot(P p, P q) { return real(conj(p) * q); }
R crs(P p, P q) { return imag(conj(p) * q); }
int ccw(P p, P q) {
  int s = sgn(crs(p, q));
  if (s) return s;
  if (dot(p, q) < 0) return -2;
  if (dot(p, q - p) > 0) return 2;
  return 0;
}
int ccw(P o, P p, P q) { return ccw(p - o, q - o); }
struct L {
  P s, t;
  P vec() const { return t - s; }
  R abs() const { return std::abs(vec()); }
  R arg() const { return std::arg(vec()); }
};
int ccw(L l, P p) { return ccw(l.s, l.t, p); }

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int q; cin >> q;
  while (q--) {
    L l, m;
    cin >> l.s >> l.t >> m.s >> m.t;
    if (sgn(crs(l.vec(), m.vec()), 0) == 0) cout << 2 << '\n';
    else if (sgn(dot(l.vec(), m.vec()), 0) == 0) cout << 1 << '\n';
    else cout << 0 << '\n';
  }
}


Measured memory_bytes: 3324
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    6月で水色になるぞ〜!!!
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{one, zero, One, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'a' as u8;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize,
        a: [i64; n],
        b: [i64; n]
    }

    if a.iter().sum::<i64>() < b.iter().sum::<i64>() {
        println!("-1");
        return;
    }

    let mut pos = Vec::new();
    let mut neg = Vec::new();

    for k in (0..n).filter(|x| a[*x] != b[*x]).map(|x| a[x] - b[x]) {
        if k > 0 {
            pos.push(k);
        }
        if k < 0 {
            neg.push(k);
        }
    }

    pos.sort();
    pos.reverse();
    neg.sort();

    let mut pl = 0;
    let mut ng = 0;
    let mut stock = 0;

    loop {
        if ng >= neg.len() {
            break;
        } else {
            if stock >= -neg[ng] {
                stock -= -neg[ng];
                ng += 1;
            } else {
                stock += pos[pl];
                pl += 1;
                stock -= -neg[ng];
                ng += 1;
            }
        }
    }

    // dbg!(pl, ng);
    println!("{}", pl + ng);
}


Measured memory_bytes: 6536
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	cin >> s;
	if (s[3] == s[2] && s[4] == s[5] && s[0] != s[1]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <set>
#include <stack>
#include <string.h>
#include <map>
#include <bitset>

using namespace std;

const int maxn=1e4+5;

int n;
pair < int, int > l[maxn];
set < pair < int, int > > s;
int boja[maxn*2];
int sad;
stack < pair < int, int > > red;
int mid;
bitset < maxn*2 > bio;

void dfs(pair < int, int > x){
//	printf("dalje: %d %d\n", x.first, x.second);
	pair < int, int > p=x;
	if(p.second<n){
		p={l[p.second].second, p.second+n};
	}
	else{
		p={l[p.second-n].first, p.second-n};
	}
	s.erase(p);
	bio[x.second]=1;
	p={x.first-mid+1, 0};
	set < pair < int, int > >::iterator it=s.lower_bound(p);
	while(it!=s.end() && (*it).first<x.first+mid){
		p=*it;
		if(p.second<n){
			p={l[p.second].second, p.second+n};
		}
		else{
			p={l[p.second-n].first, p.second-n};
		}
		if(!bio[p.second] && x.second-n!=p.second && x.second!=p.second-n){
			s.erase(it);
			dfs(p);
		}
		it=s.upper_bound(*it);
	}
	red.push(x);
}

void dfs1(pair < int, int > x){
	s.erase(x);
	boja[x.second]=sad;
	pair < int, int > p=x;
	if(p.second<n){
		p={l[p.second].second, p.second+n};
	}
	else{
		p={l[p.second-n].first, p.second-n};
	}
	pair < int, int > z={p.first-mid+1, 0};
	set < pair < int, int > >::iterator it=s.lower_bound(z);
	while(it!=s.end() && (*it).first<p.first+mid){
/*		if(mid==7630){
			cout << "pod " << p.first << " je " << (*it).first << endl;
		}*/
		if(p.second!=(*it).second){
			dfs1(*it);
		}
		it=s.upper_bound(*it);
	}
}

bool provjeri(){
	for(int i=0; i<n; i++){
		s.insert({l[i].first, i});
		s.insert({l[i].second, i+n});
	}
	pair < int, int > x;
	for(int i=0; i<n*2; i++){
		if(!bio[i]){
			if(i<n){
//				printf("sirim %d\n", l[i].first);
				dfs({l[i].first, i});
			}
			else{
//				printf("sirim %d\n", l[i].second);
				dfs({l[i-n].second, i});
			}
		}
	}
	for(int i=0; i<n; i++){
		s.insert({l[i].first, i});
		s.insert({l[i].second, i+n});
	}
	sad=1;
//	cout << red.size() << endl;
//	printf("red: ");
 	while(!red.empty()){
 //		printf("%d ", red.top().first);
		if(s.find(red.top())!=s.end()){
//			printf("ide se %d %d\n" , red.top().first, red.top().second);
			dfs1(red.top());
			sad++;
		}
		red.pop();
	}
//	printf("\n");
	bool p=1;
	for(int i=0; i<n; i++){
		if(boja[i]==boja[i+n]){
//			cout << "aha " << boja[i] << endl;
			p=0;
			break;
		}
	}
	bio.reset();
	memset(boja, 0,  sizeof(boja));
	return p;
}

int binary(){
	int lo=0, hi=1e9;
	while(lo<hi){
//		printf("na %d\n", mid);
		mid=(lo+hi)/2+1;
//		cout << mid << endl;
		if(provjeri()){
			lo=mid;
		}
		else{
			hi=mid-1;
		}
	}
	return lo;
}

int main(){
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%d%d", &l[i].first, &l[i].second);
	}
	printf("%d\n", binary());
	return 0;
}


Measured memory_bytes: 2816
from collections import deque
import sys
input = sys.stdin.readline
H,W = map(int,input().split())
lst=[[] for f in range(H)]
for i in range(H):
 lst[i] = [d for d in input()]
stack = deque([[0,0]])
muki=[[1,0],[-1,0],[0,1],[0,-1]]
check=[[0 for e in range(W)] for f in range(H)] #チェック済みリスト
check[0][0]=1
t=0
while stack != deque([]) :
 a=stack.popleft()
 for i in muki:
  b0=a[0]+i[0]
  b1=a[1]+i[1]
  if b0<=H-1 and b0>=0 and b1<=W-1 and  b1>=0:
   if check[b0][b1]==0 and lst[b0][b1]==".":
    check[b0][b1]=check[a[0]][a[1]]+1
    stack.append([b0,b1])
if check[H-1][W-1]==0:
 print(-1)
else:
 ct=0
 for i in range(H):
  for j in range(W):
   if lst[i][j]==".":
    ct+=1
 print(ct-check[H-1][W-1])


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

vector<int> to[2505];
vector<int> rto[2505];
bool reachableFrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v){
	if(reachableFrom1[v])return;
	reachableFrom1[v] = true;
	for(int u:to[v]){
		dfs(u);
	}
}
void rdfs(int v){
	if(reachableToN[v])return;
	reachableToN[v] = true;
	for(int u:rto[v]){
		rdfs(u);
	}
}	
int main(void){
	int n,m,p,ans;
	vector<tuple<int,int,int>> edges;
	cin >> n >> m >> p;
	for(int i=0;i<m;i++){
		int a,b,c;
		cin >> a >> b >> c;
		a--;b--;
		c-=p;
		c = -c;
		edges.emplace_back(a,b,c);
		to[a].push_back(b);//aからbにいける
		rto[b].push_back(a);//bにはaからいける
	}
	dfs(0);
	rdfs(n-1);
	for(int i=0;i<n;i++)ok[i] = reachableFrom1[i]&reachableToN[i];
	
	//bellman-ford
	vector<int> d(n,inf);
	d[0] = 0;
	bool upd = true;
	int step = 0;
	while(upd){
		upd = false;
		for(int i=0;i<m;i++){
			int a,b,c;
			tie(a,b,c) = edges[i];
			if(!ok[a])continue;
			if(!ok[b])continue;
			int newD = d[a]+c;
			if(newD< d[b]){
				upd = true;
				d[b] = newD;
			}
		}
		step++;
		if(step > n){
			puts("-1");
		return 0;
		}
	}
	ans = max(0,-d[n-1]);
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
typedef unsigned long long int ll;
int main()
{
ll n;
cin>>n;
ll v[n]={0};
for(ll i=1;i<n;i++)
{
ll j;
cin>>j;
v[j-1]++;
}
for(ll i=0;i<n;i++)
{
cout<<v[i]<<"\n";
}
return 0;
}

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

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

  int V = X / 500;
  X -= V * 500;

  int v = X / 5;
  X -= v * 5;

  cout << (V * 1000) + (v * 5) << endl;
}

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

def f1(i):
    lst = []
    while i > 0:
        lst.append(i%10)
        i //= 10
    lst.reverse()
    return lst

b = f1(a)
c = 0
for i in range(4):
    if b[i]==2:
        c += 1
    else:
        c = c

print(c)
    


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define ppb push_back
typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;
typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;
typedef vector<vector<int>> vvi; typedef vector<vbool> vvb;

const ll N = 100010;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, r; cin >> n >> r;
	r += 100*(10-min(10, n));
	cout << r << nl;
	
	#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int x;
    cin>>x;
    for(int i=0,tmp=100;;i++,tmp*=1.01)
        if(tmp>=x)
            cout<<i<<endl,exit(0);
}

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

Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> w(n+1);
    int sum = 0;
    rep(i,n){
        cin >> w[i];
        sum += w[i];
    }
    int s = w[0];
    long long int res = 1000000;

    rep(i,n-1){
        if(abs(s - (sum - s) < res)){
            res = abs(s - (sum-s));
        }
        s += w[i+1];
    }
    cout << res;

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int H[] = new int[N];
		for(int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
		}
		int ans = 0;
		int temp = 0;
		int now = H[0];
		for(int i = 1; i < N; i++) {
			if(H[i] <= H[i - 1]) {
				now = H[i];
				temp++;
			} else {
				now = H[i];
				ans = Math.max(ans, temp);
				temp = 0;
			}
		}
		ans = Math.max(ans, temp);
		System.out.println(ans);
	}
}


Measured memory_bytes: 50664
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vvin=vector<vector<int>>;
using vll=vector<long long>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;
vin dy={0,1,0,-1};
vin dx={1,0,-1,0};

int main(){
    int x;cin>>x;
    x-=400;
    int tmp=x/200;
    cout<<8-tmp<<endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
using namespace std;

using ll=long long int;


int main() {

	int d;
	cin >> d;

	cout << "Christmas";

	for (int i = 0; i < 25 - d; i++) {
		cout << " Eve";
	}

	cout << endl;

	return 0;
}





Measured memory_bytes: 256
# D - AtCoder Express 2

N, M, Q = map(int, input().split())
G = [[0] * (N+1) for _ in range(N+1)]

for _ in range(M):
    L, R = map(int, input().split())
    G[L][R] += 1

for i in range(N+1):
    for j in range(N):
        G[i][j+1] += G[i][j]

for _ in range(Q):
    p, q = map(int, input().split())
    ans = 0
    for i in range(p, q+1):
        ans += G[i][q] - G[i][p-1]
    print(ans)

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


using namespace std;

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

    double ave = (a + b) / 2.0;
    cout << static_cast<int>(ceil(ave)) << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);

    solve();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <stack>

using namespace std;

typedef long long ll;

const int N = 2e5 + 500;

int L[N], R[N], n, p[N];
stack < int > S;

int main(){
	scanf("%d", &n);
	for(int i = 0;i < n;i++)
		scanf("%d", p + i);
	for(int i = 0;i < n;i++){
		for(;!S.empty() && p[S.top()] > p[i];S.pop());
		if(S.empty())
			L[i] = 0;
		else
			L[i] = S.top() + 1;
		S.push(i);
	}
	for(;!S.empty();S.pop());
	for(int i = n - 1;i >= 0;i--){
		for(;!S.empty() && p[S.top()] > p[i];S.pop());
		if(S.empty())
			R[i] = n - 1;
		else
			R[i] = S.top() - 1;
		S.push(i);
	}
	ll sol = 0;
	for(int i = 0;i < n;i++){
		sol += (ll)(i - L[i] + 1) * (ll)(R[i] - i + 1) * (ll)p[i];
	}
	printf("%lld\n", sol);
}


Measured memory_bytes: 3456
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    string S;
    ll K;
    cin >> S >> K;
    char ans = '1';
    if(K > 100) {
        REP(i, S.length()) if(S[i] != '1'){
             ans = S[i];
             break;
         }
    } else {
        REP(i, S.length()) {
            if(i + 1 == K){
                ans = S[i];
                break;
            }
            if(S[i] != '1') {
                ans = S[i];
                break;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

main(){

int x,y,z,temp;

scanf("%d %d %d",&x,&y,&z);

if(x>y){
temp=x;
x=y;
y=temp;
}

if(y>z){
temp=y;
y=z;
z=temp;
}

if(x>y){
temp=x;
x=y;
y=temp;
}


printf("%d %d %d\n",x,y,z);

return 0;
}

Measured memory_bytes: 592
import bisect
M = 10**12
a, b, q = [int(x) for x in input().split()]
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
for i in range(q):
  x = int(input())
  lst = []
  i_s = bisect.bisect_left(s, x)
  i_t = bisect.bisect_left(t, x)
  if i_s == 0:
    sl, sr = -M, s[i_s]
  elif i_s == a:
    sl, sr = s[i_s-1], M
  else:
    sl, sr = s[i_s-1], s[i_s]
  if i_t == 0:
    tl, tr = -M, t[i_t]
  elif i_t == b:
    tl, tr = t[i_t-1], M
  else:
    tl, tr = t[i_t-1], t[i_t]
  d = M
  for ss in [sl, sr]:
    for tt in [tl, tr]:
      d1 = abs(ss - x) + abs(ss - tt)
      d2 = abs(tt - x) + abs(ss - tt)
      d = min(d, d1, d2)
  print(d)
  

Measured memory_bytes: 12092
#include <iostream>
#include <cstdlib>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(void)
{
    int64_t N;
    cin >> N;

    cout << N+N*N+N*N*N;
    
    return 0;
}


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

int main(){ 
  string S;
  cin >> S;
  
  if (S == "AAA" || S == "BBB") cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N, P;
  cin >> N >> P;
  vector<long> A(N);
  rep (i, N) cin >> A[i];
  vector<long> even(N+1, 0);
  vector<long> odd(N+1, 0);
  even[0] = 1;
  rep (i, N) {
    if (A[i] % 2 == 0) {
      even[i+1] = even[i] * 2;
      odd[i+1] = odd[i] * 2;
    } else {
      even[i+1] = even[i] + odd[i];
      odd[i+1] = odd[i]  + even[i];
    }
  }
  if (P == 0) cout << even[N] << endl;
  else cout << odd[N] << endl;
} 

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
import numpy as np

n = int(input())
P = [int(i) for i in  input().split()]

cnt = 0
for i in np.arange(1,n-1):
    tmp_l = [P[i-1],P[i],P[i+1]]
    tmp_l.sort()
    if tmp_l[1] == P[i]:
        cnt+=1

print(cnt)

Measured memory_bytes: 12448
#coding: utf-8
N, M, K = map(int, input().split())
mod = 998244353

def cmb(n, k, mod, fac, ifac):    
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod

def make_tables(mod, n):
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)
 
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac

f = [0 for _ in range(N)]
for i in range(N):
    if i == 0:
        f[i] = M
    else:
        f[i] = (f[i-1] * (M-1)) % mod
if K == 0:
    print(f[N-1])
else:
    fac, ifac = make_tables(mod, N)
    ans = 0
    c = 1
    for i in range(K+1):
        ans += f[N-1-i] * c
        ans %= mod
        c = cmb(N-1, i+1, mod, fac, ifac)
    print(ans % mod)



Measured memory_bytes: 40700
#include <stdio.h>
#define N 8

int row[N], col[N], dpos[2*N-1], dneg[2*N-1], X[N][N];

void initialize();
void printboard();
void recursive(int);

int main(){
  int k, r, c;
  int i, j;
  
  initialize();
  for(i=0; i<N; i++){
    for(j=0; j<N; j++)X[i][j] = 0;
  }

  scanf("%d",&k);
  for(i=0; i<k; i++){
    scanf("%d%d",&r,&c);
    X[r][c] = 1;
  }

  recursive(0);
  return 0;
}

void initialize(){
  int i;
  for(i=0; i<N; i++){
    row[i] = 1;
    col[i] = 1;
  }
  for(i=0; i<2*N-1; i++){
    dpos[i] = 1;
    dneg[i] = 1;
  }
}

void Printboard(){
  int i, j;
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(X[i][j]){
	if(row[i] != j)return;
      }
    }
  }
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(row[i] == j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;
  if(i == N){
    Printboard();
    return;
  }
  for(j=0; j<N; j++){
    if(-1 == col[j] || -1 == dpos[i+j] || -1 == dneg[i-j+N-1])continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = -1;
    recursive(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = 1;
  }
}



Measured memory_bytes: 2108
from collections import defaultdict

N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]
if N == 1:
  print(1)
else:
  d = defaultdict(int)
  for i in range(N):
    xi,yi = xy[i]
    for j in range(N):
      if i==j:
        continue
      else:
        xj,yj = xy[j]
      d[(xj-xi,yj-yi)] += 1
  max_v = max(d.values())
  print(N-max_v)



Measured memory_bytes: 3828
sx,sy,tx,ty = map(int,input().split())

ans = ""
ans += "U"*(ty-sy)
ans += "R"*(tx+1-sx)
ans += "D"*(ty-sy+1)
ans += "L"*(tx+1-sx)
ans += "UL"
ans += "U"*(ty+1-sy)
ans += "R"*(tx-sx+1)
ans += "D"*(ty+1-sy)
ans += "L"*(tx-sx)

print(ans)


Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	// Code for B - Exchange
	var A, B, K int
	fmt.Scanf("%d %d %d", &A, &B, &K)

	for i := 0; i < K; i++ {
		if i%2 == 0 {
			if A%2 != 0 {
				A--
			}
			B = B + A/2
			A = A / 2
		} else {
			if B%2 != 0 {
				B--
			}
			A = A + B/2
			B = B / 2
		}
	}

	fmt.Println(A, B)
}


Measured memory_bytes: 1832
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main(){

	int n, m, x;
	int acount=0, bcount=0;
	cin >> n >> m >>x;
	int a[m];
	for(int i = 0; i < m; i++){
		cin >> a[i];
	}
	int b[n+1];
	for(int i = 0; i < n+1; i++){
		b[i] = 0;
	}
	for(int i = 0; i < m; i++){
		b[a[i]+1] = 1; //bのa[i]に1を
	}
	//1か0が入った
	for(int i = 0; i < x+1; i++){
		if( b[i] == 1 ){
			bcount++;
		}
	}
	for(int i = x+1; i < n+1; i++){
		if( b[i] == 1 ){
			acount++;
		}
	}
	cout << min(bcount,acount) <<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int nn = sc.nextInt();
		
		int xx = (int)Math.floor((nn+1)/1.08);
		
		if((int)(xx * 1.08) == nn ){
			System.out.print(xx);
		}else{
			System.out.print(":(");
		}
	}
}

Measured memory_bytes: 21844
//        VIVEK UPADHYAY
//        MANIT, BHOPAL(M.P)
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<endl
#define ok cout<<"ok\n" ;
typedef long long ll;
const int MAXN = 1e5 + 10 ;
const int MAX = 1e7 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 ;

int main(){
    
    string s,t ;
    cin >> s>> t ;
    string str="" ;
    for(int i=0;i<t.length();i++){
        str+=t[i] ;
        string v = t.substr(i+1),n;
        
        n=v+str;
        if(n==s){
            cout<<"Yes\n" ;
            return 0;
        }
    }
    cout<<"No\n" ;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define mod 1000000007
const double pi = 3.14159265358979323846;
typedef long long ll;
using namespace std;

const int M = (int)(2e6 + 239);

int getnum(string a)
{
    int i,p=0;
    rep0(i,a.size())
    {
        p*=10;
        p+=a[i]-'0';
    }
    return p;
}

int main()
{
    fast

    ll a,b;
    cin>>a>>b;
    if(a<b)
    {
        cout<<min(a,abs(a-b))<<endl;
    }
    else if(a==b)
    {
        cout<<0<<endl;
    }
    else
    {
        if(a%b==0)
        {
            cout<<0<<endl;
        }
        else
        {
            ll temp=a%b;
            ll temp1=abs(temp-b);
            cout<<min(temp,temp1)<<endl;
        }
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
#define all(x) (x).begin(),(x).end()


int main() {
  string s;
  cin >> s;

  bool flag = true;
  if(s[0] != 'A') flag = false;
  int index, cnt = 0;
  for(int i = 2; i < s.length() - 1; i++){
    if(s[i] == 'C'){
      cnt++;
      index = i;
    }
  }
  if(cnt != 1) flag = false;
  for(int i = 1; i < s.length(); i++){
    if(i == index) continue;
    if(s[i] >= 'A' && s[i] <= 'Z'){
      flag = false;
    }
  }
  if(flag) cout << "AC" << ln;
  else cout << "WA" << ln;
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int H,W,K;
const int MaxH=10;
const int MaxW=1000;
int main(){
	cin>>H>>W>>K;
	vector<string>S(H);
	rep(i,H)cin>>S[i];
	int ans=INF;
	rep(mask,1<<(H-1)){
		int nm=__builtin_popcount(mask)+1;
		int tmp=__builtin_popcount(mask);
		vector<int>cnt(nm);
		bool suc=false;
		rep(j,W){
			int now=0;
			rep(i,H){
				if(S[i][j]=='1')cnt[now]++;
				if(mask>>i&1)now++;
			}
			if(*max_element(all(cnt))>K){
				if(suc){
					tmp=INF;break;
				}
				tmp++;
				for(auto &x:cnt)x=0;
				j--;
				suc=true;
				continue;
			}
			suc=false;
		}
		chkmin(ans,tmp);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
while 1:
    ans=0
    N,X=map(int,input().split())
    if N==0 and X==0:
        break
    for i in range(1,N+1):
        for j in range(1,N+1):
            k=X-i-j
            if i<j and j<k and i+j+k==X and k<=N:
                ans+=1
    print(ans)


Measured memory_bytes: 5592