akhauriyash/Code-Regression huggingface dataset:
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var x = int.Parse(line[1]);
            if (n == 0 && x == 0) break;
            var count = 0;
            for (int i = 1; i <= n; i++)
                for (int j = i + 1; j <= n; j++)
                {
                    var w = x - i - j;
                    if (w > j && w <= n) count++;
                }
            Console.WriteLine(count);
        }
    }
}



Measured memory_bytes: 9244
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  string s, t;
  cin >> s >> t;
  int n = s.length();
  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(s[i] != t[i]){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3920
#include <stdio.h>

int main(){
  int X,Y,Z;
  scanf("%d %d %d",&X,&Y,&Z);
  int T;
  T=X;
  X=Y;
  Y=T;
  T=X;
  X=Z;
  Z=T;
  printf("%d %d %d\n",X,Y,Z);
  return 0;
}


Measured memory_bytes: 1688
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m, n) for(int i = m-1; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAX = 510000;
const int INF =2000000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
//gcd,lcmセット
ll gcd(ll a, ll b){
   if (a%b == 0) return b;
   else return gcd(b, a%b);
}
ll lcm(ll a, ll b){	
   return a*b/gcd(a, b);
}
int pow_kai(int a, int n){//aのn乗を計算します。
  int x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a;
    }
    a = a*a;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}
// a^n mod を計算する
long long modPow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// a^{-1} mod を計算する
ll modInv(ll a, ll mod) {
    return modPow(a, mod - 2, mod);
}

// combinationのテーブルを作る前処理
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;
    }
}
 
// 二項係数計算
 
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
//dfsではvector<vector<int>> g(n);で◎
int main(){
    //COMinit();
    //string a,b;
    ll n;
    cin>>n;
    ll t[10][10]={0};
    ll cnt=0;
    for(ll k=1;k<=n;k++){
        int e=k%10;
        int f=k;
        while(f>9) f/=10;
        t[f][e]++;
    }
    /*REP(j,10){
        REP(i,10){
            cout<<t[j][i]<<" ";
        }
        cout<<endl;
    }*/
    for(int i=1;i<10;i++)for(int j=1;j<10;j++) cnt+=t[i][j]*t[j][i];
//答え出力パート
    cout<<cnt
    <<endl;
}

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

long long int pow2(long long int x) {
    return x * x;
}

int main() {
    int n;
    std::vector<int> v;
    std::cin >> n;
    int num_out_of_order = 0;

    bool prev_set = false;
    int prev = 0;
    int index1 = 0;
    int index2 = 0;

    for (int i = 0; i < n; i++)
    {
        int temp;
        std::cin >> temp;
        v.push_back(temp);
        if (!prev_set)
        {
            prev = temp;
            prev_set = true;
        } else {
            if(temp < prev) {
                num_out_of_order++;
                if(num_out_of_order == 1) {
                    index1 = i - 1;
                }
                else if (num_out_of_order == 2)
                {
                    index2 = i;
                }
            }
            if(num_out_of_order > 2) {
                break;
            }
        }
        prev = temp;
    }

    if(num_out_of_order > 2) {
        std::cout << "NO" << std::endl;
        return 0;
    }
    else if (num_out_of_order == 1) {
        int temp = v[index1];
        v[index1] = v[index1+1];
        v[index1+1] = temp;
    }
    else if (num_out_of_order == 0)  {
        std::cout << "YES" << std::endl;
        return 0;
    }
    else
    {
        int temp = v[index1];
        v[index1] = v[index2];
        v[index2] = temp;
    }
     bool success = true;
    for (int i = 1; i < v.size(); i++)
    {
        if (v[i] < v[i-1]) {
            success = false;
        }
    }
    if(success) {
        std::cout << "YES" << std::endl;

    } else
    {
        std::cout << "NO" << std::endl;
    }
    
}

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

 
const int MAX_ROW = 60; // 2^60 >= 10e18
const int MAX_N = 200005;
int to[MAX_ROW][MAX_N];
    
int main() {
    /* Doubling
    e.g. Teleportations between Towns 
        1 -> 4 -> 2 -> 3 -> 5 -> 2 -> ...
    
    N: number of steps moved
        fill in m by multiplying 2 (2^N)
    m | 1 | 2 | 3 | 4 | 5
    1 | 4 | 3 | 5 | 2 | 2
    2 | 2 | 5 | 2 | 3 | 3 (can be compute based on previous row)
    4 | 5 | 3 | 5 | 2 | 2
    8 | ...

    How to use the table above
    e.g. K = 123
        123 = 64 + 32 + 16 + 8 + 2 + 1 (Binary)
        to find the destinations after 123 teleportations,
        can refer to table in the order: 64, 32, 16, 8, 2, 1

    Time | Space Complexity: O(N log K)
        number of times of reference = number of bit K has
        number of towns = N
        Time | Memory to fill up reference table = N log K
    */

    int n; ll k;
    cin >> n >> k;
   
    for (int i = 0; i < n; ++i) {
        cin >> to[0][i]; // first step
        to[0][i]--; // move index from 1 to 0
    };

    // compute reference table
    for (int i = 0; i < MAX_ROW - 1; ++i) {
        for (int j = 0; j < n; ++j) {
            to[i+1][j] = to[i][to[i][j]]; // teleport 2 times based on the previous row
        }
    }

    int v{0}; // starting town
    // looping in binary (1 <- 2 <- 4 <- 8 <- ...) 
    for (int i = MAX_ROW - 1; i >= 0; --i) {
        ll l = 1ll<<i; // 1ll to make sure shift is done on long long instead of int
        if (l <= k) {
            v = to[i][v];
            k -= l;
        }

    }

    cout << (v + 1) << endl;

    return 0;
}

Measured memory_bytes: 50468
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(), a.end());
    cout << a.at(a.size()-1) - a.at(0) << endl;
}


Measured memory_bytes: 256
from collections import deque

H, W = [int(_) for _ in input().split()]
C = [int(_) - 1 for _ in input().split()]
D = [int(_) - 1 for _ in input().split()]

S = [input() for _ in range(H)]
V = [[-1 for w in range(W)] for h in range(H)]

V[C[0]][C[1]] = 0

pool = deque()
pool.append(tuple([0, C[0], C[1]]))
while(pool):
    c, y, x = pool.popleft()
    if c != V[y][x]:
        continue
    for dx in [-2, -1, 0, 1, 2]:
        for dy in [-2, -1, 0, 1, 2]:
            if y + dy < 0 or H <= y + dy:
                continue
            if x + dx < 0 or W <= x + dx:
                continue
            if S[y+dy][x+dx] == "#":
                continue
            if (dx, dy) in [(-1,0),(1,0),(0,-1),(0,1)]:
                if V[y+dy][x+dx] == -1 or V[y+dy][x+dx] > V[y][x]:
                    V[y+dy][x+dx] = V[y][x]
                    pool.appendleft((c, y+dy, x+dx))
            elif V[y+dy][x+dx] == -1 or V[y+dy][x+dx] > V[y][x] + 1:
                V[y+dy][x+dx] = V[y][x] + 1
                pool.append((c+1, y+dy, x+dx))
print(V[D[0]][D[1]])


Measured memory_bytes: 109536
import itertools
n = int(input())
a = [input() for i in range(n)]
dict = {"M":0, "A":0, "R":0, "C":0, "H":0}
ans = 0
march = list(itertools.combinations("MARCH",3))
for c in a:
    if(c[0] in "MARCH"):
        dict[c[0]] += 1
for c in march:
    ans += dict[c[0]] * dict[c[1]] * dict[c[2]]
print(ans)

Measured memory_bytes: 9776
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define AL 26
int main(){
  int d,i,j,tmp=0;
  ll c[26],s[365][26];
  
  cin >> d;
  rep(i,AL) cin >> c[i];
  rep(i,d){
    rep(j,AL) cin >> s[i][j];
  }
  rep(i,d){
    tmp=0;
    rep(j,AL){
      if(s[i][tmp]*pow(c[tmp],2)<s[i][j]*pow(c[j],2)){
        tmp = j;
      }
    }
    cout << tmp+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

const int maxN = 100005;

class TaskC {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		int n , m;
		cin >> n >> m;
		vector<int> h(n);
		for(int i = 0; i < n; i++){
			cin >> h[i];
		}
		vector<vector<int>> graph(n, vector<int>());
		for(int j = 0; j < m; j++){
			int x, y;
			cin >> x >> y;
			x--; y--;
			graph[x].push_back(y);
			graph[y].push_back(x);
		}
		int ans = 0;
		for(int i = 0; i < n; i++){
			bool good = true;
			for(int nxt : graph[i]){
				if(h[i] <= h[nxt]){
					good = false;
				}
			}
			ans += good;
		}
		cout << ans << endl;

	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskC solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 8728
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}





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

  string S,T; cin >> S >> T;

  rep(i,S.size()){
    if(i+T.size() > S.size()){
      cout << "UNRESTORABLE" << endl;
      return 0;
    }
    ll s = S.size()-1-i;


    bool flag = true;
    rep(j,T.size()){
      if(S[s-j] == '?') continue;
      if(S[s-j] != T[T.size()-1-j]) {
	flag = false;
	break;
      }
    }

    if(flag){
      rep(j,T.size())
	S[s-j] = T[T.size()-1-j];
      rep(i,S.size())
	if(S[i] == '?') S[i] = 'a';
      cout << S << endl;
      return 0;
    }
  }

  
    




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


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

import           Data.Char
import qualified Data.ByteString.Char8 as B
import           Control.Applicative

main :: IO ()
main = do
  s <- B.getLine
  putStrLn $ if solve s then "YES" else "NO"

solve :: B.ByteString -> Bool
solve = any ((==) "keyence") . (liftA2 B.append <$> B.inits <*> B.tails)


Measured memory_bytes: 892
d, g = gets.chomp.split(' ').map(&:to_i)
list = d.times.map { gets.chomp.split(' ').map(&:to_i) }

ans_steps = 1_000

0.upto(2 ** d - 1).each do |i|
  solve_flgs = i.to_s(2).rjust(d, '0')

  sum = 0
  steps = 0
  rest = []
  solve_flgs.chars.each.with_index(0) do |j, k|
    cnt, bonus = list[k]
    if j == '1'
      sum += (k + 1) * 100 * cnt + bonus
      steps += cnt
    else
      rest = [k, cnt]
    end
  end
  if sum < g
    next if rest.empty?
    rest_base = (rest[0] + 1) * 100
    rest_sum_max = rest_base * rest[1]
    next if sum + rest_sum_max < g

    min_step = rest[1]
    rest[1].downto(1).each do |l|
      if sum + rest_base * l >= g
        min_step = l
      else
        break
      end
    end
    steps += min_step
  end
  ans_steps = steps if steps < ans_steps
end

puts ans_steps


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

using P=pair<int,int>;

int main()
{
   string s,t; cin>>s>>t;
   const int N=s.size();
   const int M=t.size();

   vector<vector<int>> dp(N+1,vector<int>(M+1,-1));
   vector<vector<P>> pre(N+1,vector<P>(M+1));
   for(int i=0;i<=N;i++) dp[i][0]=0;
   for(int j=0;j<=M;j++) dp[0][j]=0;
   for(int i=0;i<N;i++) for(int j=0;j<M;j++){
      if(s[i]==t[j]){
         dp[i+1][j+1]=dp[i][j]+1;
         pre[i+1][j+1]=P(i,j);
      }else{
         if(dp[i+1][j]>=dp[i][j+1]){
            dp[i+1][j+1]=dp[i+1][j];
            pre[i+1][j+1]=P(i+1,j);
         }else{
            dp[i+1][j+1]=dp[i][j+1];
            pre[i+1][j+1]=P(i,j+1);
         }
      }
   }
   string ans;
   int i=N,j=M;
   while(i>0 and j>0){
      if(pre[i][j]==P(i-1,j-1)) ans=s[i-1]+ans;
      tie(i,j)=pre[i][j];
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 105984
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H,W;
    cin>>H>>W;
    char S[W][H];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>S[j][i];
        }
    }
    for(int nowy=0;nowy<H;nowy++){
        for(int nowx=0;nowx<W;nowx++){
            if(S[nowx][nowy]=='.'){
                char c='0';
                if(nowx!=0&&nowy!=0){
                    if(S[nowx-1][nowy-1]=='#'){c++;}
                }
                if(nowy!=0){
                    if(S[nowx][nowy-1]=='#'){c++;}
                }
                if(nowx!=W-1&&nowy!=0){
                    if(S[nowx+1][nowy-1]=='#'){c++;}
                }
                if(nowx!=0){
                    if(S[nowx-1][nowy]=='#'){c++;}
                }
                if(nowx!=W-1){
                    if(S[nowx+1][nowy]=='#'){c++;}
                }
                if(nowx!=0&&nowy!=H-1){
                    if(S[nowx-1][nowy+1]=='#'){c++;}
                }
                if(nowy!=H-1){
                    if(S[nowx][nowy+1]=='#'){c++;}
                }
                if(nowx!=W-1&&nowy!=H-1){
                    if(S[nowx+1][nowy+1]=='#'){c++;}
                }
                S[nowx][nowy]=c;
            }
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout<<S[j][i];
        }
        puts("");
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int K = sc.nextInt();
    int X = sc.nextInt();
    sc.close();
    if (500 * K >= X) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


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

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

    int cnt = 0;
    bool even = true;
    for (int i = 0; i < s.size(); i++)
    {
        for (int j = 0; j < s.size(); j++)
        {
            if (s[i] == s[j])
                cnt++;
        }
        if (cnt % 2 == 1)
            even = false;

        cnt = 0;
    }
    if (even)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a_list = list(map(int,input().split()))
color = [0]*9
for a in a_list:
  t = a//400
  if t < 8:
    color[t] += 1
  else:
    color[8] += 1
mi = 0
pro = color.pop(-1)
for c in color:
  if c > 0:
    mi += 1
print(max(1,mi),mi+pro)

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

int main(){
    string s;
    cin >> s;
    if (count(s.begin(), s.end(), 'a') == 1
    && count(s.begin(), s.end(), 'b') == 1
    && count(s.begin(), s.end(), 'c') == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <ctype.h>

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

int main(int argc, const char * argv[])
{
    std::string temp = "", ret = "";
    std::vector<std::string> vec;
    while (cin >> temp)
    {
        vec.push_back(temp);
    }
    for (size_t i = 0; i < vec.size(); ++i)
    {
        ret += toupper(vec[i][0]);
    }
    cout << ret;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    A=int(input())
    B=int(input())
    C=int(input())
    D=int(input())
    print(min(A,B)+min(C,D))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n,x = MI()

def mycalc(n,x):
    M = 4*(2**n) - 3
    m = (M//2) + 1
    if n==0:
        return 1
    if x==1:
        return 0
    elif x>=2 and x<m:
        return mycalc(n-1,x-1)
    elif x==m:
        return mycalc(n-1,x-2) + 1
    elif x>m and x<M:
        return mycalc(n-1,x-m) + ( 2**(n+1) - 2 )//2 + 1
    elif x==M:
        return 2**(n+1) - 1
    else:
        print("E")
ans = mycalc(n,x)
print(ans)

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

using namespace std;

int main(void) {
	long long a, b, c;
	cin >> a >> b >> c;
	if(c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b)) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   string s;
   cin >> s;
   if(n&1){
      cout << "No\n";
      return 0;
   }
   if(s.substr(0,n/2)==s.substr(n/2,n/2)){
      cout << "Yes\n";
   }else{
      cout << "No\n";
   }
   return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	vector<pair<int,int>> v;
	vector<pair<int,int>> vv;
	for(int i=0;i<n;i++){
		if(i%2==0){
			v.push_back({a[i],i});
			vv.push_back({b[i],i});
		}
		else{
			v.push_back({b[i],i});
			vv.push_back({a[i],i});
		}
	}
	sort(v.begin(),v.end());
	sort(vv.begin(),vv.end());
	int ans=1e9;
	for(int i=0;i<(1<<n);i++){
		if(__builtin_popcount(i)!=n/2)continue;
		bool ok=1;
		int now=0;
		vector<int> q;
		vector<int> used(n,0);
		for(int j=0;j<n;j++){
			if(j%2==0){
				for(int k=0;k<n;k++){
					if(used[v[k].second]==0&&!((i>>v[k].second)&1)){
						if(v[k].first<now)ok=0;
						if(!ok)break;
						now=v[k].first;
						used[v[k].second]=1;
						q.push_back(v[k].second);
						break;
					}
				}
			}
			else{
				for(int k=0;k<n;k++){
					if(used[vv[k].second]==0&&(i>>vv[k].second)&1){
						if(vv[k].first<now)ok=0;
						if(!ok)break;
						now=vv[k].first;
						used[vv[k].second]=1;
						q.push_back(vv[k].second);
						break;
					}
				}
			}
			if(!ok)break;
		}
		if(ok&&q.size()==n){
			int cnt=0;
			for(int j=0;j<n;j++){
				for(int k=j+1;k<n;k++){
					if(q[j]>q[k])cnt++;
				}
			}
			ans=min(ans,cnt);
		}
	}
	if(ans==1e9){
		cout << -1 << endl;
	}
	else{
		cout << ans << endl;
	}
}

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

const int MOD=1000000007;
//~ const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int a[200000];
ll L[200000];

int main(){
	int n;cin>>n;
	rep(i,n+1)scanf("%d",&a[i]);
	if(n==0){
		if(a[0]==1)puts("1");
		else puts("-1");
		return 0;
	}
	L[0]=1;
	rep(i,n+1){
		L[i+1]=max(0LL,min(INFL,(L[i]-a[i])*2));
	}
	ll cnt=0;
	ll ans=0;
	for(int i=n;i>=0;i--){
		if((cnt+1)/2+a[i]>L[i]){
			puts("-1");return 0;
		}
		cnt=min(L[i],cnt+a[i]);
		ans+=cnt;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4940
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = iterator.map(|s| s.parse::<usize>().unwrap()).collect();

    let q = partition(&mut a, 0, n - 1);

    let mut ans = String::new();
    for i in 0..n {
        if i == q {
            ans += &format!("[{}] ", a[i]);
        } else {
            ans += &format!("{} ", a[i]);
        }
    }
    return ans.trim().to_string();
}

fn partition(a: &mut Vec<usize>, p: usize, r: usize) -> usize {
    let x = a[r];
    let mut i: isize = p as isize - 1;
    for j in p..r {
        if a[j] <= x {
            i += 1;
            a.swap(i as usize, j)
        }
    }
    a.swap(i as usize + 1, r);
    i as usize + 1
}



Measured memory_bytes: 7052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
                     
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
const ll mod = 1e9+7;
ll mult(ll a,ll b){return ((a%mod)*(b%mod))%mod;}
ll add(ll a,ll b){return ((a%mod)+(b%mod))%mod;}
ll sub(ll a,ll b){return ((a%mod)-(b%mod)+mod)%mod;} 
int n;
vector<int> h, a;
vector<ll> dp;

vector<ll> tree(1000000);
vector<ll> lazy(4000005);
void update(ll tl,ll tr, ll tind, ll nval, ll arrind){
    if(tr==tl){
        tree[tind] = nval;
        return;
    }
    ll m = tl + (tr - tl)/2;
    if(arrind<=m)
        update(tl,m,tind*2,nval,arrind);
    else
        update(m+1,tr,tind*2+1,nval,arrind);

    tree[tind] = max(tree[tind*2], tree[tind*2+1]);

}

ll range_query(ll tl, ll tr, ll tind, ll l, ll r){
    if(l>tr || r<tl){
        return 0;
    }
    else if(l<=tl && r>=tr){
        return tree[tind];
    }
    else{
        ll m = tl + (tr-tl)/2;
        return max(range_query(tl,m,tind*2,l,r), range_query(m+1,tr,tind*2+1,l,r));
    }
}
ll build(ll tl,ll tr, ll i){
    if(tl == tr){
        return tree[i] = 0;
    }
    ll m = tl + (tr-tl)/2;
    return tree[i] = max(build(tl,m,2*i), build(m+1,tr,2*i+1));
}
int solve(){
    cin>>n;
    h.resize(n), a.resize(n), dp.resize(n);
    for(int i=0;i<n;++i){
        cin>>h[i];
    }
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    dp.resize(n + 1);
    build(1, n, 1);
    ll ans = 0;
    for(int i=0;i<n;++i){
        // find maximum beauty for height in range (1, h[i]-1)
        ll maxi = range_query(1, n, 1, 1, h[i]-1);
        dp[i] = a[i]+ maxi;
        ans = max(ans, dp[i]);
        update(1, n, 1, dp[i], h[i]);
        // update segment tree for height = h[i];
    }
    cout<<ans;
    return 0;
}
int main(){
    fast;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}

Measured memory_bytes: 47028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;

#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)
 
const ll MOD=1e9+7;

//足し算してmodをとる
ll ad(ll x,ll y=0){
    return (x+y)%MOD;
}

//mod _mult 
ll mlt(ll x,ll y=1){
    return (x*y)%MOD;
}

 //xのy条
ll pwr(ll x,ll y){
    ll pw[32]={},w=1;
    pw[0]=x;
    //先にたくさんの2^p乗を計算しておく
    for(int i=0;i<31;++i) pw[i+1]=mlt(pw[i],pw[i]);
    //掛け算する
    for(int i=0;i<32;++i){
        w=mlt(w,1+(y%2)*(pw[i]-1));
        y/=2;
    }
    return w;
}

 //フェルマーの小定理に夜と、　x^(mod-2)=-1
ll inv(ll x){
    return pwr(x,MOD-2);
}

 //factorial
ll fc[200010]={1};
ll fct(ll x){
    if(fc[x]==0) fc[x]=mlt(x,fct(x-1));
    return fc[x];
}

 //inverse_factorial
ll ifc[200010]={1};
ll ifct(ll x){
    if(ifc[x]==0) ifc[x]=inv(fct(x));
    return ifc[x];
}
 
ll comb(ll n,ll r){
    if(n<0 || r<0 || n<r) return 0;
    return mlt(fct(n),mlt(ifct(r),ifct(n-r)));
}
 
int main(){
    ll n,a,b,c,d,f;
    cin>>n>>a>>b>>c>>d;
    ll dp[1010][1010]={};
    fct(1010);
    ifct(1010);
    ifr(i,1010){
        ifc[i]=mlt(i+1,ifc[i+1]);
    }
    dp[b+1][n]=1;
    for(ll i=b;i>=a;i--){
        //cout << i << endl;
        fr(j,n+1){
            dp[i][j]=ad(dp[i][j],dp[i+1][j]);
            f=1;
            Fr(k,c-1) f=mlt(f,comb(j+k*i,i));
            for(ll k=c;k<=d;k++){
                if(j+i*k>n) break;
                f=mlt(f,comb(j+k*i,i));
                dp[i][j]=ad(dp[i][j],mlt(dp[i+1][j+i*k],mlt(f,ifct(k))));
            }
        }
    }
    /*for(int i=2;i<4;i++){
        fr(j,8) cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    cout<<dp[a][0]<<endl;
}

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

int main(){
	while(1){
		int n, x;
		cin >> n >> x;
		if(n==0 && x==0) break;
		int cnt=0;
		for(int i=1;i<n-1;i++){
        	for(int j=i+1;j<n;j++){
        		for(int k=j+1;k<n+1;k++){
            		if(i+j+k==x) cnt++;
				}
			}
		}
		cout << cnt << endl;
    
	}
	return 0;
}

Measured memory_bytes: 1160
#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;
  cin >> N;
  vector<long> X(N);
  rep (i, N) cin >> X[i];
  vector<long> foo = X;
  sort(foo.begin(), foo.end());
  long mid = N / 2 - 1;
  rep (i, N) {
    if (foo[mid] >= X[i]) cout << foo[mid+1] << endl;
    else cout << foo[mid] << endl;
  }
}

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


Measured memory_bytes: 5376
#include <bits/stdc++.h>
// #pragma GCC optimization ("O3,unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
using namespace std;

#define _ << ": " <<
#define watch1(var1) (cerr << #var1 _ var1 << '\n')
#define watch2(var1, var2) cerr << #var1 _ var1 << ", " << #var2 _ var2 << '\n';
#define watch3(var1, var2, var3) cerr << #var1 _ var1 << ", " << #var2 _ var2 << ", " << #var3 _ var3 << '\n';
#define wloop(size, arr) cerr << #arr << ": "; for (int i = 0; i < size; i++) cerr << arr[i] << " \n"[i+1 == size];

template<typename... Args>
void read(Args&... args) { ((cin >> args), ...); }

template<typename... Args>
void show(Args... args) { ((cout << args << " "), ...); }

#define ints(a...) int a; read(a)
#define longs(a...) int64_t a; read(a)

const int MAX = 5e5 + 10;
vector<int64_t> fact(MAX), ifact(MAX);
const int MOD = 1e9 + 7;

int64_t pow_n(int64_t a, int p, const int mod = MOD) {
    int64_t ans = 1;
    a %= mod;
    while(p) {
        if(p & 1) ans = ans * a % mod;
        a = a * a % mod;
        p >>= 1;
    }
    return ans;
}

int add(int64_t a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
    return a;
}

int sub(int a, int b) {
    a = a-b;
    if (a < 0) a += MOD;
    return a;
}

int mul(int64_t a, int b) {
    return a * b % MOD;
}

int64_t inv(int b) {
    return pow_n(b, MOD - 2);
}

void precal() {
    fact[0] = fact[1] = 1;
    for (int i = 2; i < MAX; i++)
        fact[i] = fact[i - 1] * i % MOD;
    
    ifact[MAX - 1] = inv(fact[MAX - 1]);
    for (int i = MAX - 2; ~i; i--) 
        ifact[i] = ifact[i + 1] * (i + 1) % MOD;
}

int ncr(int n, int r) {
    if (r > n) return 0;
    return mul(mul(fact[n], ifact[r]), ifact[n - r]);
}

int64_t sq(int64_t x) {
    return x * x % MOD;
}

void solve() {
    precal();
    longs(n, m);
    int64_t sum = 0;
    for (int k = 0; k <= n; k++) {
        int64_t c1 = ncr(n, k);
        int64_t p1 = mul(ncr(m, k), fact[k]);
        int64_t p2 = sq(mul(ncr(m - k, n - k), fact[n - k]));
        if (k%2 == 0) sum = add(sum, mul(mul(c1, p1), p2));
        else sum = sub(sum, mul(mul(c1, p1), p2));
    }
    cout << sum;
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1; 
    // cin >> T;
    while (T--) solve();
    return 0;
}

Measured memory_bytes: 11040
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  int N, X, W;
  cin >> N >> X >> W;
  int a[N];
  for(int i = 0; i < N; i++ ) cin >> a[i];

  if(N == 1){
    cout << abs(a[0] - W) << endl;
  } else {
    cout << max(abs(a[N - 1] - a[N - 2]), abs(a[N - 1] - W));
  }

  return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=c && c<=b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


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

#define int long long



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


Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}

typedef long long int ll;
#define int ll
#define endl '\n'
const ll mod =1e9+7;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
const ll inf = 1e18+123;
const int maxn = 200001;
int vis[101];
int32_t main()
{

   IOS
    int n,k;
    cin>>n>>k;
    for(int i = 0;i<n;i++){
      int d;
      cin>>d;
      for(int j = 0;j<d;j++){
        int x;
        cin>>x;
        vis[x] = 1;
      }
    } 
    int ans = 0;
    for(int i =1;i<=n;i++)
    {
      ans+=(vis[i] == 0);
    }
    cout<<ans<<endl;
} 


Measured memory_bytes: 3648
#include<iostream>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<bitset>
#include<functional>
#include<iterator>
#include<complex>
#include<fstream>
#include<random>
#include<ctype.h>
#include<stdio.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using PII = pair<ll, ll>;
using piii = pair<pii, pii>;
using Pi = pair<int, pii>;
using Graph = vector<vector<int>>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
bool check(int x, int y) {
	if (0 <= x && x<55 && 0 <= y && y<55)return true;
	else return false;
}
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;

//iの逆元mod inf
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const double PI = 3.14159265358979323846;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll 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] % INF) % INF;
}
double Euclidean_distance(double x1, double y1, double x2, double y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

//素因数分解
map<int, int>prime_factor(int n) {
	map<int, int>res;
	for (int i = 2; i*i <= n; ++i) {
		while (n%i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1)res[n] = 1;
	return res;
}


ll powmod(ll a, ll k, ll mod) {
	ll ap = a, ans = 1;
	while (k) {
		if (k & 1) {
			ans *= ap;
			ans %= mod;
		}
		ap = ap * ap;
		ap %= mod;
		k >>= 1;
	}
	return ans;
}
ll invi(ll a, ll mod) {
	return powmod(a, mod - 2, mod);
}
#define PI 3.14159265358979323846  // 円周率
//逆元Aを足したときのmodで割った余りは
//+=invi(A)
//Yで割ることはY^(10^9+7)-2を掛けることは同値
///////////////////////////////////////

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


Measured memory_bytes: 4500
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb puah_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

int main(){
    string s; cin >> s;
    int n = s.size();
    int nc = 0, wc = 0, sc = 0, ec = 0;
    REP(i, 0, n){
        if(s[i] == 'N'){
            nc++;
        }else if(s[i] == 'W'){
            wc++;
        }else if(s[i] == 'S'){
            sc++;
        }else{
            ec++;
        }
    }
    if((min(wc, ec) == 0 && max(wc, ec) != 0) || (min(nc, sc) == 0 && max(nc, sc) != 0)){
        cout << "No" << endl;
        return 0;
    }/*else if(wc == 0 && wc == 0){
        if(nc % sc == 0 || sc % nc == 0){
            cout << "Yes" << endl;
            return 0;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }else if(nc == 0 && sc == 0){
        if(wc % ec == 0 || ec % wc == 0){
            cout << "Yes" << endl;
            return 0;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    if((wc % ec == 0 || ec % wc == 0) && (nc % sc == 0 || sc % nc == 0)){
        cout << "Yes" << endl;
        return 0;
    }*/
    cout << "Yes" << endl;
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int main(){
    fcin;

    int n, m;
    cin >> n >> m;

    vector<int> ac(n + 1, 0);
    vector<int> wa(n + 1, 0);
    for(int i = 0; i < m; i++){
        int id;
        string judge;
        cin >> id >> judge;

        if(judge == "AC") ac[id] = 1;
        if(!ac[id] and judge == "WA") wa[id]++;
    }

    int acc = 0;
    int wac = 0;

    for(int i = 1; i <= n; i++) acc += ac[i];
    for(int i = 1; i <= n; i++) if(ac[i]) wac += wa[i];

    cout << acc << " " << wac << endl;
    return 0;
}



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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n, m;
    cin >> n >> m;
    vector<i64> cnt(n);
    for (i64 i = 0; i < m; i++) {
        i64 a, b;
        cin >> a >> b, a--, b--;
        cnt[a]++, cnt[b]++;
    }

    i64 f = 0;
    for (auto& e : cnt) f += e % 2;
    cout << (f <= 1 ? "YES" : "NO") << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
ll dp[2][310][310];

void solve() {
	cin >> N >> M;
	dp[0][N - 1][1] = 1;
	
	int now = 0, nex = 1;
	rep(i, 0, M) {
		memset(dp[nex], 0, sizeof(dp[nex]));
		rep(j, 0, N + 1) {
			rep(k, 0, N + 1) {
				if(!dp[now][j][k]) continue;
				if(j != 0) ADD(dp[nex][j - 1][k], dp[now][j][k] * j % mod);
				if(N - j - k > 0) ADD(dp[nex][j][k], dp[now][j][k] * (N - j - k) % mod);
				ADD(dp[nex][j][N - j], dp[now][j][k] * k % mod);
			}
		}
		swap(now, nex);
	}
	cout << dp[now][0][N] << "\n";;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    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;
    }
}
 
 
#define comuse Comuse()
 
ll combi(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;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b,x,y,n;
  	ci(x>>y>>n);
  a=0;
  b=0;
  FOR(i,0,n){
    ll l,m,N;
    	ci(l>>m>>N);
    if(N==1){
      chmax(a,l);
    }
    else if(N==2){
      chmin(x,l);
    }
    else if(N==3){
      chmax(b,m);
    }
    else{
      chmin(y,m);
    }
  }
  ll z=0;
  ll X=max(z,x-a);
  ll Y=max(z,y-b);
  co(X*Y)
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.stream.Stream;
 
public class Main {

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      String[] lines = br.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      int m = Integer.parseInt(lines[1]);
      int l = Integer.parseInt(lines[2]);
      long[][] mA = new long[n][m];
      long[][] mB = new long[m][l];
      long[][] mC = new long[n][l];

      for(int i = 0; i < n; i++ ) {
        lines = br.readLine().split(" ");
        mA[i] = Stream.of(lines)
                      .mapToLong(Long::parseLong)
                      .toArray();
      }
      for( int i = 0; i < m; i++ ) {
        lines = br.readLine().split(" ");
        mB[i] = Stream.of(lines)
                      .mapToLong(Long::parseLong)
                      .toArray();
      }

      for( int i = 0; i < n; i++ ) {
        for( int j = 0; j < l; j++ ){
          for( int k = 0; k < m; k++ )
          mC[i][j] += mA[i][k] * mB[k][j];
        }
      }

      System.out.println(
        Stream.of(mC)
              .map( a -> ArrayToString(a) )
              .collect(Collectors.joining("\n"))
      );
    }
  }
  public static String ArrayToString(long[] a) {
      if (a == null)
          return "null";
      int iMax = a.length - 1;
      if (iMax == -1)
          return "[]";

      StringBuilder b = new StringBuilder();
      for (int i = 0; ; i++) {
          b.append(a[i]);
          if (i == iMax)
              return b.toString();
          b.append(" ");
      }
  }
}


Measured memory_bytes: 38052