akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
  var N, Y int
  fmt.Scan(&N, &Y)
  for x := 0; x <= N; x++ {
    for y := 0; y <= N - x; y++ {
      z := N - (x + y)
      if 10000 * x + 5000 * y + 1000 * z == Y {
        fmt.Println(x, y, z)
        return
      }
    }
  }
  fmt.Println(-1, -1, -1)
}

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

int main() {
  int r;
  cin >> r;
  double ans = r*2*acos(-1);
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 3744
using System.Collections.Generic;
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var brue = new Dictionary<string, int>();
        var red = new Dictionary<string, int>();
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine().Trim();
            if (brue.ContainsKey(s)) brue[s]++;
            else brue[s] = 1;
        }
        var m = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < m; i++)
        {
            var s = Console.ReadLine().Trim();
            if (red.ContainsKey(s)) red[s]++;
            else red[s] = 1;
        }
        var res = 0; var resmax = 0;
        foreach (var x in brue.OrderByDescending(y => y.Value))
        {
            if (!red.ContainsKey(x.Key)) res = x.Value;
            else res = x.Value - red[x.Key];
            resmax = Math.Max(resmax, res);
        }
        Console.WriteLine(resmax);
    }
}

Measured memory_bytes: 11348
n=gets.to_i
a=$<.read.chomp.split.map{|i|i.split("")}
b=a.transpose
r=[]
n.times do |i|
  c=0
  if b[i].include?(?#)
    n.times do |j|
      if a[i][j]==?.
        c+=1
      end
    end
  else
    if a[i].include?(?#)
      c=a[i].count(?.)+1
    else
      c=10**9
    end
  end
  r<< c
end
if r.min==10**9
  p -1
else
  p r.min+n-b.count{|i|i==[?#]*n}
end

Measured memory_bytes: 27012
#include <stdio.h>
int main(){
	int i;
	char x[20];
	for(i=0;i<20;i++){
		scanf("%c",&x[i]);
	}
	x[5]=' ';
	x[13]=' ';
	for(i=0;i<20;i++){
		printf("%c",x[i]);
	}
	
	return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<map>
#include<cmath>
#include<sstream>
#include<cstring>
#include<algorithm>
#include<string>
#define LL long long
using namespace std;
LL n,s,b;
bool check(LL n, LL b)
{
    long long res = 0;
    while(n > 0)
    {
        res += n%b;
        n/=b;
    }
    return res == s;
}
int main()
{
    //int n,s,b;
    cin >> n >> s;
    LL temp = (LL)sqrt(n)+1;
    for(LL i = 2; i <= temp; i ++)
    {
        if(check(n,i))
        {
            cout << i << endl;
            return 0;
        }
    }
    if(s == n)
    {
        cout << n+1 << endl;
        return 0;
    }
    if(s > n)
    {
        cout << "-1" << endl;
        return 0;
    }
    LL temp1 = n - s, temp2 = temp1/temp + 1;
    for(int i = temp2; i >= 1; i --)
    {
        if(!(temp1%i) && s - i <= temp1/i && s >= i && i<= temp1/i)
        {
            cout << temp1/i + 1 << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}


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

using namespace std;

const int maxn = 300100;
const int base = 998244353;

int n,m,sum_a,sum_b,sum_up,sum_down,ans,inv[maxn],L[maxn],R[maxn],a[5][maxn],fac[maxn],tot;

int pw(int a,int n) {
    if (n==0) return 1;
    if (n==1) return a;
    int tg = pw(a,n/2);
    tg = (1ll*tg*tg) % base;
    if (n%2==0) return tg;
    return (1ll*tg*a) % base;
}

void init() {
    inv[0]=1;
    fac[0]=1;
    for (int i=1;i<=maxn;i++) fac[i] = (1ll*fac[i-1]*i) % base;
    for (int i=1;i<=maxn;i++) inv[i] = pw(fac[i],base-2);
}

int C(int k,int n) {
    if (k > n) return 0;
    return 1ll*fac[n] * inv[k] % base * inv[n-k] % base;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
  //  freopen("in.txt","r",stdin);
    cin>>n>>m;
    init();
    for (int i=1;i<=4;i++) {
        for (int j=1;j<=((i<=2)?n:m);j++) {
            char ch;
            cin>>ch;
            a[i][j] = ch - '0';
        }
    }
  ans =0;
   // cout<<C(1,3)<<endl;
   // cout<<inv[2]<<endl;
    tot=0;
    for (int times =1;times<=2;times++) {
        sum_a = sum_b = sum_up = sum_down = 0;
        for (int i=1;i<=n;i++) {
            sum_a += a[1][i];
            sum_b += a[2][i];
        }
        tot += sum_a + sum_b;
        for (int i=1;i<=m;i++) {
            if (a[3][i]+a[4][i]==0) {
                L[i] =0;
            } else {
                if (sum_a ==0 & sum_up >0) L[i]=0;
                else L[i] =((sum_a == 0) ? 1 : C(sum_a-1,sum_a + sum_up - 1));
            }
            sum_up += a[3][i] + a[4][i];
        }
        for (int i=m;i>=1;i--) {
            if (a[3][i]+a[4][i]==0) {
                R[i] =0;
            } else {
                if (sum_b ==0 & sum_down >0) R[i]=0;
                else R[i] =((sum_b == 0) ? 1 : C(sum_b-1,sum_b + sum_down - 1));
            }
            sum_down += a[3][i] + a[4][i];
        }
        int sum=0;
        for (int i=1;i<=m;i++) {
            //cout<<L[i]<<" "<<R[i]<<endl;
            sum = (sum + L[i]) % base;
            sum = (1ll* sum * max(1,a[3][i]+a[4][i])) % base;
            ans = (ans + 1ll*sum*R[i]%base) % base;
        }

        swap(n,m);
        swap(a[1],a[3]);
        swap(a[2],a[4]);
    }
    if (tot==0) ans =1;
    cout<<ans<<endl;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
int main (){
    int N,ans=0,sum=0;
    cin >> N;
    vector<int> v(2*N);
    for(int i=0;i<2*N;i++){
        cin >> v.at(i);
    }
    for(int j=0;j<N;j++){
        for(int k=0;k<N;k++){
            if(k<j){
                sum += v.at(k);
            }
            else if (k == j){
                sum += v.at(k);
                sum += v.at(N+k);
            }
            else{
                sum += v.at(N+k);
            }
        }
        ans = max(ans,sum);
        sum =0;
    }
    cout << ans << endl;
}
    


Measured memory_bytes: 256
N = int(raw_input())

def solve(N):
    if N % 2 == 1:
        return 0
    else:
        ans = 0
        # every n/(2 * 5^1) -> +1
        # every n/(2 * 5^2) -> +1
        # every n/(2 * 5^3) -> +1
        exp = 1
        while 2 * 5**exp <= N:
            num_div = N / (2 * 5**exp)
            ans += num_div
            exp += 1
        return ans

print solve(N)


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
int phi(int n){
	long long res=1;
	for(int i=2;i*i<=n;i++){
		if(n%i==0)res*=i-1,n/=i;
		while(n%i==0)res*=i,n/=i;
	}
	if(n>1)res*=n-1;
	return res;
}
int main(){
	int n;cin>>n;
	cout<<phi(n)<<endl;
	return 0;
}


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

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

  ll vmax = n * 1000;

  vector<ll> w(n + 1), v(n + 1);
  for (ll i = 0; i < n; i++) cin >> w[i + 1] >> v[i + 1];

  // dp[items until this index][total value] = min weight
  vector<vector<ll>> dp(n + 1, vector<ll>(vmax * 2 + 1, __INT_MAX__));
  dp[0][0] = 0;

  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < vmax; j++) {
      ll next_i = i + 1;
      ll next_j1 = j;
      ll next_j2 = j + v[next_i];

      dp[next_i][next_j1] = min(dp[next_i][next_j1], dp[i][j]);
      dp[next_i][next_j2] = min(dp[next_i][next_j2], dp[i][j] + w[next_i]);
    }
  }

  ll ans;
  for (ll j = vmax; j >= 0; j--) {
    if (dp[n][j] <= wmax) {
      ans = j;
      break;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 159744
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;
ll N,A,B,C,D;
ll fac[1005];
ll rfac[1005];
ll dp[1005][1005];
ll pow (ll x, ll a) {
  ll res = 1;
  while(a > 0) {
    if(a & 1) res = res * x % mod;
    x = x * x % mod;
    a >>= 1;
  }
  return res % mod;
}



ll rpow(ll x) {
  return pow(x,mod-2);
}

ll P(ll n, ll r) {
  return fac[n] * rpow(fac[n-r]) % mod;
}

int main() {
  cin >> N >> A >> B >> C >> D;
  fac[0] = 1;
  for(ll i = 1; i <= N; i++) {
    fac[i] = fac[i-1] * i % mod;
  }

  dp[A-1][0] = 1;
  for(ll i = A; i <= B; i++) {
    for(ll j = 0; j <= N; j++) dp[i][j] = dp[i-1][j]; //i人のグループを一つも作らない場合の操作
    for(ll k = C; k <= D; k++) {
      for(ll j = i * k; j <= N; j++) {
	dp[i][j] = (dp[i][j] + (dp[i-1][j-i*k] * (P(j,i*k) * rpow(pow(fac[i],k) * fac[k] % mod) % mod) % mod)) % mod;

      }
    }
  }
  cout << dp[B][N] << endl;
		       
  
}
  
  


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


int main(){
  int N,K;
  cin >> N >> K;
  vector<int>h(N);
  for(int i=0;i<N;i++){
    cin >> h.at(i);
  }
  int cnt=0;
  for(int i=0;i<N;i++){
    if(h.at(i)>=K){
      cnt++;
    }
  }
  cout << cnt << endl;
      
    
  
}
      


Measured memory_bytes: 768
/*
	ex4_3
	ruuu0048
*/
#include <stdio.h>

int sigma(int max_num); //1から引数までの数の和を返す関数
int answer(int west_height,int east_height); //答えである雪の深さを返す関数

int main(void){

    int west_height,east_height; //西と東の塔の見えるところの高さの変数を宣言

    scanf("%d %d",&west_height,&east_height); //それぞれ入力

    printf("%d\n",answer(west_height,east_height));//答えを出力

    return 0; 
}

int sigma(int max_num){
    int total = 0; //足しあわせていく変数を宣言

    while(max_num > 0){ //max_numが0になったらループが終わる
        total += max_num; //足していく
        max_num -= 1; //足したら1減らす
    }
    return total;

};

int answer(int west_height,int east_height){
    
    int real_east_height,snow_height; //東側の塔全体の高さと積雪の高さの変数を宣言

    real_east_height = sigma(east_height - west_height); //東側の塔全体の高さを計算

    snow_height = real_east_height - east_height; //積雪の高さを計算

    return snow_height;

};


Measured memory_bytes: 128
import           Data.Char                      ( isSpace )
import qualified Data.Vector.Unboxed           as V
import qualified Data.ByteString.Char8         as C

main = do
    n <- readLn :: IO Int
    a <- V.unfoldr (C.readInt . C.dropWhile isSpace) <$> C.getLine
    let zeros   = V.replicate n 0 :: V.Vector Int
        ones    = V.replicate n 1
        indices = V.map pred a
        ans     = V.accumulate_ (+) zeros indices ones
    V.forM_ ans print


Measured memory_bytes: 9884
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < s.size(); i++) {
		s[i] = 'A' + (s[i] - 'A' + n) % 26;
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main(){
	ios::sync_with_stdio(false);
	int n;string s;
	cin>>n>>s;
	int num=0;
	long long ans=1;
	for(int i=1;i<=n;++i) ans=ans*i%mod;
	for(int i=0;i<2*n;++i){
		if((s[i]=='W')^num&1) ans=ans*num%mod,num--;
		else num++;
	}
	printf("%lld\n",num?0:ans);
}

Measured memory_bytes: 720
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N, M = MI()
    edge = [[] for _ in range(N)]
    used_edge = set()

    # ダイクストラ
    def dijkstra(start, edge):
        costs=[inf]*N
        costs[start]=0
        queue = [(0, start, (-1,-1))]  # 第一要素が優先的に評価されるので 第３要素にpre(前の頂点)が入る
        hash = {}
        while queue:
            c, from_, e = heappop(queue)
            hash[from_]=1
            if costs[from_] >= c:
                costs[from_] = c
                used_edge.add(e)
            for cost,node in edge[from_]:
                if node in hash:
                    continue
                e = tuple(sorted([from_,node]))
                heappush(queue, (c + cost, node,e))



    for _ in range(M):
        a, b, c = MI_()
        c += 1
        edge[a].append((c, b))
        edge[b].append((c, a))
        
    for start in range(N):
        dijkstra(start, edge)
    
    num_used_edge = len(used_edge)-1
    print(M-num_used_edge)
    
if __name__ == '__main__':
    main()

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

const int INF = 1e9;

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

	int count = 0;
	map<int, int> mp;
	for (int i = 0; i < 3; i++) {
		int a;
		cin >> a;
		if (mp[a])
			count++;
		mp[a] = 1;
	}
	if (count == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
bool B[8]={0};
void check(long N)
{
    if(N<=399)
        B[0]=1;
    else if(N<=799)
        B[1]=1;
    else if(N<=1199)
        B[2]=1;
    else if(N<=1599)
        B[3]=1;
    else if(N<=1999)
        B[4]=1;
    else if(N<=2399)
        B[5]=1;
    else if(N<=2799)
        B[6]=1;
    else if(N<=3199)
        B[7]=1;
}
int main()
{
    //ifstream cin("input.in");
   // ofstream cout("output2.out");
    ios::sync_with_stdio(0);cin.tie(0);
    long N,A[1009];
    cin>>N;
    for(long i=0;i<N;i++)
        cin>>A[i];
    sort(A,A+N);
    long i=0;
    for(;i<N;i++)
        if(A[i]<3200)
            check(A[i]);
        else break;
    long M=0;
    for(long i=0;i<8;i++){
        //cout<<B[i]<<" ";
        M+=B[i];
    }
    //cout<<"\n";
    long C=(M+(N-i));
    if(M==0 && N!=0)
        M=1;
    cout<<M<<" "<<C;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
int N, K, Q;
int A[MAX], cnt[MAX];

int main(void) {
    cin >> N >> K >> Q;
    REP(i, Q) {
        cin >> A[i];
        cnt[--A[i]]++;
    }

    REP(i, N) {
        if (K <=  Q - cnt[i]) puts("No");
        else puts("Yes");
    }
}


Measured memory_bytes: 1408
//https://atcoder.jp/contests/abc142/tasks/abc142_a
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N; cin>>N;
    double n=N;
    double ans;
    if(N%2==0){
        //ぐう
        ans = 0.5;
    }else{
        double tmp=N/2;
        ans=(tmp+1.0)/n;
    }
    cout<<fixed<<std::setprecision(10)<<ans<<endl;
    return 0;
}

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

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

    int a,b;
    cin >> a >> b;

    if(a < b) {
        rep(i,b) cout << a;
    } else if(a > b){
        rep(i,a) cout << b;
    } else {
        rep(i,a) cout << a;
    }
}


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

int main(){
  int r;
  cin >> r;
  if(r < 1200){
    cout << "ABC" << endl;
  }else if(r < 2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }

  return 0;
}


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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define rall(v) rbegin(v),rend(v)
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
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
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
  nimble;
  int tt=1;//cin>>tt;
  while(tt--){
    ll h;
    cin>>h;
    map<ll,int> mp;
    ll an=1;
    ll x=1;
    while(h>1){
      h/=2;
      x+=x;
      an+=x;
    }
    cout<<an<<nl;
  }
  return 0;
}


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

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

    static class DWaterBottle {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            double a = in.nextInt(), b = in.nextInt(), x = in.nextInt();

            double extraHeight = b - (x / a / a);
            double tanOfAnswer = extraHeight / (a / 2);

            if (extraHeight >= b / 2) {
                tanOfAnswer = b * b / (x / a) / 2;
            }

            double answer = Math.atan(tanOfAnswer);
            answer = Math.toDegrees(answer);

            out.println(Util.formatDouble(answer));
        }

    }

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

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

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

    static class Util {
        public static String formatDouble(double x) {
            return String.format("%.15f", x);
        }

    }
}



Measured memory_bytes: 22740
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
inline int read()
{
	int x = 0 , f = 1; char ch = getchar();
	while(ch < '0' || ch > '9')	{if(ch == '-')	f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 8005 , M = 205 , mod = 998244353 , G = 3 , Ginv = (mod + 1) / 3;
int n , m;
ll f[N][M] , A[N << 2] , B[N << 2] , fac[N] , inv[N];
int r[N << 2];
inline ll ksm(ll a,int b)
{
	ll res = 1;
	while(b)
	{
		if(b & 1) res = res * a % mod;
		a = a * a % mod; b >>= 1;
	}
	return res;
}
namespace Poly
{
	inline void NTT(int lim,ll *a,int type)
	{
		for(int i = 0;i < lim;i ++) r[i] = (r[i >> 1] >> 1) | (i & 1 ? lim >> 1 : 0);
		for(int i = 0;i < lim;i ++) if(i < r[i]) swap(a[i],a[r[i]]);
		for(int k = 1;k < lim;k <<= 1)
		{
			ll Wn = ksm(type == 1 ? G : Ginv,(mod - 1) / (k << 1));
			for(int i = 0;i < lim;i += k << 1)
			{
				ll w = 1;
				for(int j = 0;j < k;j ++ , w = w * Wn % mod)
				{
					ll x = a[i + j] , y = w * a[i + j + k] % mod;
					a[i + j] = (x + y) % mod; a[i + j + k] = (x - y + mod) % mod;
				}
			}
		}
		if(type == 1) return;
		ll inv = ksm(lim,mod - 2);
		for(int i = 0;i < lim;i ++) a[i] = a[i] * inv % mod;
	}
	inline void MUL(int n,ll *a,int m,ll *b)
	{
		int lim = 1;
		while(lim <= (n + m)) lim <<= 1;
		NTT(lim,a,1); NTT(lim,b,1);
		for(int i = 0;i < lim;i ++) a[i] = a[i] * b[i] % mod;
		NTT(lim,a,-1);
	}
}
inline void init(int n)
{
	fac[0] = inv[0] = 1;
	for(int i = 1;i <= n;i ++) fac[i] = fac[i - 1] * i % mod;
	inv[n] = ksm(fac[n],mod - 2);
	for(int i = n - 1;i >= 1;i --) inv[i] = inv[i + 1] * (i + 1) % mod;
}
inline void solve(int j)
{
	memset(A,0,sizeof A);
	memset(B,0,sizeof B);
	using namespace Poly;
	for(int i = 1;i <= n;i ++) A[i] = inv[i + 2];
	for(int i = 0;i <= n;i ++) B[i] = f[i][j - 1] * inv[i] % mod;
	MUL(n + 1,A,n + 1,B);
	for(int i = 0;i <= n;i ++) f[i][j] = f[i][j - 1] * (1 + i + i * (i - 1) / 2) % mod;
	for(int i = 1;i <= n;i ++) f[i][j] = (f[i][j] + A[i] * fac[i + 2]) % mod;
}
inline ll C(int n,int m) { return fac[n] * inv[m] % mod * inv[n - m] % mod;}
int main()
{
	n = read(); m = read(); ll ans = 0;
	init(n + 2); f[0][0] = 1;
	for(int i = 1;i <= m;i ++) solve(i);
	for(int i = 0;i <= n;i ++) ans = (ans + C(n,i) * f[i][m]) % mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 13696
#include <iostream>
#include <algorithm>
#include <stdlib.h>
using namespace std;
int main(int argc, char const *argv[])
{
    int n, m;
    int a,k,ac=0;
    int answer[30]={};
    cin >> n >> m;
    for(int i=0;i<n;i++){
        cin>>k;
        for (int j = 0; j < k; j++)
        {
            cin>>a;
            answer[a-1]++;
        }

    }
    for (int i = 0; i < m; i++)
    {
        if (answer[i] == n)
        {
            ac++;
        }
    }

    cout << ac;

    /* code */
    return 0;
}


Measured memory_bytes: 256
from typing import Dict, List

N, M = [int(x) for x in input().split()]

class UnionFind:
    def __init__(self, num_node: int):
        self.__parent_index = [x for x in range(num_node)]
        self.__tree_rank = [1] * num_node

    def __is_root(self, index: int) -> bool:
        return self.__parent_index[index] == index

    def root(self, index: int) -> int:
        """Find root index."""
        while not self.__is_root(index):
            index = self.__parent_index[index] = self.root(self.__parent_index[index])
        return index

    def unite(self, x: int, y: int) -> bool:
        """Unite two trees."""
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return False

        if self.__tree_rank[x] < self.__tree_rank[y]:
            x, y = y, x

        self.__tree_rank[x] += self.__tree_rank[y]
        self.__parent_index[y] = x

        return True

    def groups(self) -> Dict[int, List[int]]:
        __groups: Dict[int, List[int]] = {}
        for node, parent in enumerate(self.__parent_index):
            __root = self.root(parent)
            if __groups.get(__root) is None:
                __groups[__root] = [node]
            else:
                __groups[__root].append(node)

        return __groups

uni = UnionFind(N)
for i in range(M):
    a, b = [int(x) - 1 for x in input().split()]
    uni.unite(a, b)

print(len(uni.groups()) - 1)


Measured memory_bytes: 26088
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
	ll a,b;
	cin>>a>>b;
	string ra="",rb="";
	for(int i=0;i<b;i++) ra+=to_string(a);
	for(int i=0;i<a;i++) rb+=to_string(b);
	cout<<min(ra,rb);
	return 0;
}

Measured memory_bytes: 256
x = int(input())
y = [int(i) for i in input().split()]
students = []
for (i, v) in enumerate(y):
  seat = i + 1
  students.append([v, seat])
s_dict = dict(students)
result = []
for i in range(x):
  num = i + 1
  result.append(s_dict[num])
print(*result)

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

struct Node{
    int val;
    Node* parent;
    Node* left;
    Node* right;
};
Node* nil;

class Tree{
    Node* root;
    void preorder(Node* p){
        if (p == nil) return;
        cout << " " << p->val;
        preorder(p->left);
        preorder(p->right);
    }
    void inorder(Node* p){
        if (p == nil) return;
        inorder(p->left);
        cout << " " << p->val;
        inorder(p->right);
    }
    Node* next_node(Node* z){
        if (z->left == nil) return z;
        return next_node(z->left);
    }
    void delete_node(Node* z){
        Node* z_c = nil;
        if (z->left != nil && z->right != nil) {
            Node* n = next_node(z->right);
            z->val = n->val;
            z = n;
        }
        if (z->left != nil) {
            z_c = z->left;
        }
        if (z->right != nil) {
            z_c = z->right;
        }
        if (z == root) {
            root = z_c;
            return;
        }
        if (z->parent->left == z) {
            z->parent->left = z_c;
        } else {
            z->parent->right = z_c;
        }
        if (z_c != nil) {
            z_c->parent = z->parent;
        }
    }

    Node* find_node(int k){
        Node* p = root;
        while (p != nil) {
            if (k == p->val) return p;
            if (k < p->val) {
                p = p->left;
            } else {
                p = p->right;
            }
        }
        return nil;
    }
public:
    Tree(){
        root = nil;
    }
    void insert(int k){
        Node* n = new Node;
        n->val   = k;
        n->left  = nil;
        n->right = nil;
        if (root == nil) {
            root = n;
            n->parent = nil;
            return;
        }
        Node* pos = root;
        Node* pos_p;
        while (pos != nil) {
            pos_p = pos;
            if (k < pos->val) {
                pos = pos->left;
                continue;
            }
            pos = pos->right;
        }
        n->parent = pos_p;
        if (k < pos_p->val) {
            pos_p->left = n;
        } else {
            pos_p->right = n;
        }
    }
    void print(){
        inorder(root);
        cout << endl;
        preorder(root);
        cout << endl;
    }
    bool find(int k){
        Node* z = find_node(k);
        if (z == nil) {
            return false;
        } else {
            return true;
        }
    }
    void del(int k){
        Node* z = find_node(k);
        delete_node(z);
    }
};

int main(){
    int n;
    cin >> n;
    Tree T;
    for (int i = 0; i < n; i++) {
        string str;
        cin >> str;
        if (str == "print") {
            T.print();
            continue;
        }
        int k;
        cin >> k;
        if (str == "insert") {
            T.insert(k);
            continue;
        }
        if (str == "find") {
            if (T.find(k)) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
            continue;
        }
        if (str == "delete") {
            T.del(k);
        }
    }
    return 0;
}

Measured memory_bytes: 21752
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

long gd(long x,long y){
    return y ? gd(y,x % y) : x;
}

void main(){

    while(true){
	long x,y,z;
	long x1,y1,z1;
	long l,m,n;
	auto s = readln().split().to!(long[]);
	if(s[0] == 0 && s[1] == 0 && s[2] == 0 && s[3] == 0 && s[4] == 0 && s[5] == 0 ) break;
	x1 = s[0];
	l = s[1];
	y1 = s[2];
	m = s[3];
	z1 = s[4];
	n = s[5];
	x = x1 % l;
	y = y1 % m;
	z = z1 % n;
	long ans;
	long a,b,c;
	a = 1;
	b = 1;
	c = 1;
	while(x != 1){
	    x = (x1 * x) % l;
	    a++;
	}
	while(y != 1){
	    y = (y1 * y) % m;
	    b++;
	}
	while(z != 1){
	    z = (z1 * z) % n;
	    c++;
	}
	ans =  (a * b) / gd(a,b);
	ans = (ans * c) / gd(ans,c);
	writeln(ans);
    }
}

Measured memory_bytes: 2400
Max = 100000000
N, M, X = map(int, input().split())
A = []
for j in range(N):
	A.append(list(map(int, input().split())))

R = 2**N
ans = Max
for i in range(R):
	cost = 0
	check = M*[0]
	#print(check)
	for j in range(N):
		if (i>>j)&1:
			cost += A[j][0]
			for k in range(M):
				check[k] += A[j][k+1]

	judge = 1
	for j in range(M):
		if  check[j] < X:
			judge = 0
			break
	if judge==1:
		ans = min(ans, cost)

if ans < Max:
	print(ans)
else:
	print(-1)

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

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
typedef pair<ll,ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}


int main(){
    init();

    int a,b,c;  cin >> a >> b >> c;
    if(a == b + c || b == a + c || c == a + b)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int l,cnt=0,tot=0,res,tmp,first[30];
struct edge{int u,v,w,next;}e[65];
inline void add(int u,int v,int w){e[++tot].u=u,e[tot].v=v,e[tot].w=w,e[tot].next=first[u],first[u]=tot;}
int main(){
    cin>>l,tmp=l,res=l;
    while(tmp)tmp>>=1,++cnt;
    for(int i=1;i<cnt;++i)add(i,i+1,0),add(i,i+1,(1<<(i-1)));
    res-=1<<(cnt-1);
    tmp=1<<(cnt-1);
    for(int i=0;i<=20;++i)if(((res>>i)&1))add(i+1,cnt,tmp),tmp+=1<<i;
    cout<<cnt<<' '<<tot<<'\n';
    for(int i=1;i<=tot;++i)cout<<e[i].u<<' '<<e[i].v<<' '<<e[i].w<<'\n';
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(5 * 10**5)
input=sys.stdin.readline

N, Q = list(map(int, input().split()))

M = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = list(map(int, input().split()))
    M[a-1].append(b-1)
    M[b-1].append(a-1)

ans = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    ans[p-1] += x

Q = [0]

while Q:
    current = Q.pop()

    for i in M[current]:
        ans[i] += ans[current]
        M[i].remove(current)
    
    Q += M[current]

print(' '.join(map(str, ans)))


Measured memory_bytes: 71772
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;
const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
struct edge { ll to, cost; };

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

int main() {
	ll n, x;
	cin >> n >> x;
	cout << 3 * (n - gcd(n, x)) << endl;
	}

Measured memory_bytes: 384
#include<stdio.h>
 #include<stdbool.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

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

void initialize(){
  int i;
  for(i=0;i<N;i++){
    row[i]=FREE,col[i]=FREE;
  }
}

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++){
      printf((row[i]==j)?"Q":".");
    }
    printf("\n");
  }
}

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

     row[i]=j;
     col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;

     recursive(i+1);

     row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
   }
 }

 int main(){
   initialize();
   int i,j;
   for(i=0;i<N;i++){
     for(j=0;j<N;j++)X[i][j]=false;
   }
   int k;
   scanf("%d",&k);
   for(i=0;i<k;i++){
     int r,c;
     scanf("%d%d",&r,&c);
     X[r][c]=true;
   }

   recursive(0);
   return 0;
 }
 

Measured memory_bytes: 588
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <climits>
using namespace std;
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repb(i,r,l) for(int i=r;i>l;i--)
#define ll long long
#define ull unsigned long long
#define ve vector
#define umap unordered_map
#define iter iterator
void solve() {
    int n, m;
    cin>>n>>m;
    for(int i=0;i<n+2;i++) {
        for(int j=0;j<m+2;j++) {
            if(j==0 || j==m+1) cout<<"#";
            else if(i==0 || i==n+1) cout<<"#";
            else {
                char x; cin>>x; cout<<x;
            }
        }
        cout<<endl;
    }
}

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

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, w, y, z) lower_bound(y.begin(), y.end(), z) - lower_bound(x.begin(), x.end(), w)

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);

  rep(i, 0, N) {
    cin >> A[i];
  }
  rep(i, 0, N) {
    cin >> B[i];
  }

  int ans = 0;
  int T = 1;
  rep(k, 0, 30) {
    int mod = 2 * T;
    vector<int> Amod(N);
    vector<int> Bmod(N);
    rep(i, 0, N) {
      Amod[i] = A[i] % mod;
      Bmod[i] = B[i] % mod;
    }
    sort(All(Amod));

    ll counter = 0;
    rep(i, 0, N) {
      int bi = Bmod[i];
      int l1 = lbidx(Amod, T - bi);
      int r1 = lbidx(Amod, 2 * T - bi);
      int l2 = lbidx(Amod, 3 * T - bi);
      int r2 = lbidx(Amod, 4 * T - bi);
      counter += (r1 - l1) + (r2 - l2);
    }
    if (counter % 2 == 1) ans += T;
    T *= 2;
  }

  cout << ans << endl;
};


Measured memory_bytes: 3432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;
const ll Mod=1e9+7;


vector<ll> inv,fact,invfact;
void Mod_build(int n=101010){
	fact.resize(n+1);
	inv.resize(n+1);
	invfact.resize(n+1);
	fact[0]=inv[0]=invfact[0]=1;
	inv[1]=1;
	for(ll i=0;i<n;i++){
		fact[i+1]=fact[i]*(i+1)%Mod;
		if(i>0)inv[i+1]=Mod-inv[Mod%(i+1)]*(Mod/(i+1))%Mod;
		invfact[i+1]=invfact[i]*inv[i+1]%Mod;
	}
}
ll perm(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return fact[n]*invfact[n-k]%Mod;
}
ll comb(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return (fact[n]*invfact[n-k]%Mod)*invfact[k]%Mod;
}
ll powMod(ll n,ll k){
	k%=Mod-1;
	if(k<0)k+=Mod-1;
	ll ret=1;
	while(k){
		if(k&1)ret=ret*n%Mod;
		n=n*n%Mod;
		k>>=1;
	}
	return ret;
}

int main(){
  int i,j,l;
  ll n,k;
  cin>>n>>k;
  ll a[k+1];
  for(i=1;i<=k;i++) cin>>a[i];
  Mod_build();
  VVI s(21,VI(1010,0));
  s[0][0]=1;

  for(i=1;i<=k;i++){
      for(j=0;j<=n;j++){
          ll u=comb(n,a[i]);
          s[i][j]=u*s[i-1][j]%mod;
          for(l=1;l<=j;l++){
              ll p=comb(n-l,a[i]-l)*comb(j,l)%mod;
              s[i][j]+=p*s[i-1][j-l];
              s[i][j]%=mod;
          }
      }
  }
  cout<<s[k][n]<<endl;
  for(i=0;i<5;i++){
     // cout<<i<<" "<<s[1][i]<<endl;
  } 
  return 0;
}


Measured memory_bytes: 2816
class SegmentTree
  
  def initialize
    @N=2**17
    @Z=0
    @seg=Array.new(2*@N-1){@Z}
  end
  
  def add(i, x)
    i+=@N-1
    @seg[i]+=x
    while i.nonzero?
      i=(i-1)/2
      @seg[i]=@seg[2*i+1]+@seg[2*i+2]
    end
  end
  
  def sum(a, b, i=0, l=0, r=@N)
    if b<=l or r<=a
      @Z
    elsif a<=l and r<=b
      @seg[i]
    else
      m=(r+l)/2
      vl=sum(a, b, 2*i+1, l, m)
      vr=sum(a, b, 2*i+2, m, r)
      vl+vr
    end
  end
  
end

st=SegmentTree.new
n, q=gets.split.map(&:to_i)
q.times do
  c, a, b=gets.split.map(&:to_i)
  case c
  when 0
    st.add(a, b)
  when 1
    puts st.sum(a, b+1)
  end
end

Measured memory_bytes: 10912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
ll n,k;
bool calc(ll x,vector<ll> &vec){
  
  ll num=0;
  
  for(int i=0;i<n;i++){
    int left=i,right=n;
    
    if(vec[i]>=0) {
      while(left+1<right){
        int mid=(left+right)/2;
        if(vec[i]*vec[mid]<=x) left=mid;
        else right=mid;
      }
      num+=left-i;
    }
    
    else if(vec[i]<0){
      while(left+1<right){
        int mid=(left+right)/2;
        if(vec[i]*vec[mid]<=x) right=mid;
        else left=mid;
      }
      num+=n-right;
    }
    
  }
  
  return num<k;
}

int main(){
  cin >> n >> k;
  vector<ll> vec(n);
  for(int i=0;i<n;i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  ll ok = INF+1,ng = -INF-1;
  while(ok>ng+1){
    ll mid = (ok+ng)/2;
    if(calc(mid,vec)) ng=mid;
    else ok=mid;
  }
  cout << ok << endl;
}

Measured memory_bytes: 1792
import sys
n,q=map(int,input().split())
s=[0]*-~n
w=m=0
for e in sys.stdin:
 a,v=map(int,e.split())
 s[a]+=v
 if v<0 and a==w:m=max(s);w=s.index(m)
 elif s[a]>m:w,m=a,s[a]
 elif s[a]==m:w=min(w,a)
 print(w,m)


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

// Defination {{{
#define PI pair<int, int>
#define mk make_pair
#define reg register
#define ll long long
#define rep(i, a, b) for(reg int i = a; i <= b; ++i)
#define per(i, a, b) for(reg int i = a; i >= b; --i)
#define pb push_back
// }}}

using namespace std;

int min(reg int a, reg int b) { return a < b ? a : b; }
int max(reg int a, reg int b) { return a > b ? a : b; }

template<typename T> void read(T &x) {
    x = 0; reg char ch = getchar(); reg int f = 1;
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
    x *= f;
}

int m, d;

int main() {
    read(m), read(d);
    int ans = 0;
    rep (i, 1, m) {
        rep (j, 22, d) {
            if (j % 10 < 2) continue;
            if ((j % 10) * (j / 10) == i) {
                ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0; 
}


/*
 _____  ____    _____
|__  / |  _ \  |__  /
  / /  | |_) |   / / 
 / /_  |  _ <   / /_ 
/____| |_| \_\ /____|
  
 _____________________________________ 
< A.cpp is created by zrz who is weak >
 ------------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
*/


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

const int INF = 1e9+1;
int n, a, dp[100001];

int main() {    
    ios::sync_with_stdio(false);
    cin >> n;

    fill(dp, dp+n, INF);

    int l = 1;
    for (int i=0; i<n; ++i) {
        cin >> a;
        int k = lower_bound(dp, dp+l, a) - dp;
        dp[k] = a;
        l = max(l, k+1);
    }

    cout << l << endl;
    return 0;
}

Measured memory_bytes: 3584
_, *lines = open(0).readlines()
H = [[[0]*10 for i in range(3)] for j in range(4)]
for line in lines:
    b, f, r, v = map(int, line.split())
    H[b-1][f-1][r-1] += v
for i, h in enumerate(H):
    if i:
        print("#"*20)
    for r in h:
        print("",*r)


Measured memory_bytes: 5628
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    b = tuple(map(int, input().split()))
    a = [0] * n
    a[0], a[n-1] = b[0], b[n-2]
    for i in range(1, n-1):
        a[i] = min(b[i-1], b[i])
    print(sum(a))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int M,T,P,R;
int m[2000],t[2000],p[2000],j[2000];
struct team{
	int n,s,t,w[2000];
};

bool comp(const team &t1,const team &t2){
	if(t1.t==t2.t && t1.s==t2.s)return t1.n>t2.n;
	if(t1.s==t2.s)return t1.t<t2.t;
	return t1.s>t2.s;
};

team dat[2001];

int main(void){
	while(1){
		scanf("%d%d%d%d",&M,&T,&P,&R);
		if(M+T+R+P==0)break;
		memset(dat,0,sizeof(dat));
		for(int i=0;i<T;i++)dat[i].n=i+1;
		for(int i=0;i<R;i++){
			scanf("%d%d%d%d",&m[i],&t[i],&p[i],&j[i]);
			if(j[i]!=0){
				dat[t[i]-1].w[p[i]]++;
			}else{
				dat[t[i]-1].s++;
				dat[t[i]-1].t+=m[i]+dat[t[i]-1].w[p[i]]*20;
			}
		}
		sort(dat,dat+T,comp);
		printf("%d",dat[0].n);
		for(int i=1;i<T;i++){
			if(dat[i-1].s==dat[i].s && dat[i-1].t==dat[i].t)printf("=");
			else printf(",");
			printf("%d",dat[i].n);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 16924
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

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

Measured memory_bytes: 256
use proconio::{input, fastout};
use itertools_num::ItertoolsNum;

macro_rules! echo {
  ($val:expr) => {
    println!("{}", $val);
  }
}

#[fastout]
fn main() {
  input!{
    n: usize,
    aa: [usize; n]
  };

  let mut aa = aa;
  aa.sort();
  let cumsum = aa.iter().cumsum().collect::<Vec<usize>>();
  let mut pos = 0;
  for i in 1..n {
    if cumsum[i-1] * 2 < (cumsum[i] - cumsum[i-1]) {
      pos = i;
    }
  }
  echo!(n-pos);
}


Measured memory_bytes: 4548
using System;
class aoj1_10_D{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    String[] vecx = Console.ReadLine().Split(' ');
    String[] vecy = Console.ReadLine().Split(' ');
    double sum,max=0,temp;
    for(int i=1; i<=3; i++){
      sum = 0;
      for(int j=0; j<n; j++){
        sum += Math.Pow((double)Math.Abs(double.Parse(vecx[j])-double.Parse(vecy[j])),(double)i);
      }
      Console.WriteLine("{0:F6}", (double)Math.Pow(sum, (1.0)/(double)i));
    }
    for(int i=0; i<n; i++){
       temp = (double)Math.Abs(int.Parse(vecx[i])-int.Parse(vecy[i]));
       if(max<temp){
         max = temp;
       }
    }
    Console.WriteLine("{0:F6}", max);
  }
}



Measured memory_bytes: 18080
import math
n=int(input())
p=[0]*101
dp=[0]*101
for i in range(2,n+1):
  for j in range(2,i+1):
    while i%j==0:
      i//=j
      p[j]+=1
for i in range(101):
  if p[i]!=0:
    dp[p[i]]+=1
ans=sum(dp[74:])+sum(dp[24:])*(sum(dp[2:])-1)+sum(dp[14:])*(sum(dp[4:])-1)+sum(dp[4:])*(sum(dp[4:])-1)//2*(sum(dp[2:])-2)
print(ans)

Measured memory_bytes: 63492
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
#include <cstdio>

using namespace std;

int main(){
    int n, ans = 0;
    cin >> n;
    vector<int> B;
    vector<int> A;
    for(int i=0; i<n-1; i++){
        int b;
        cin >> b;
        B.push_back(b);
    }
    A.push_back(B[0]);
    for(int i=0; i<n-2; i++){
        int min_two = min(B[i], B[i+1]);
        A.push_back(min_two);
    }
    A.push_back(B[n-2]);
    for(int i=0; i<A.size(); i++){
        ans += A[i];
    }
    cout << ans << endl;
    return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
using namespace std;

int d;
int c[26];
int s[365][26];

int t[365];

int score(){
	int last[26] = {0};
	int evl = 0;

	for( int i = 1; i <= d; i++ ){
		last[t[i-1]-1] = i;
		evl += s[i-1][t[i-1]-1];
		for( int j = 0; j < 26; j++ ){
			evl -= c[j]*(i - last[j]);
		}
		//cout << i << " score:" << evl << endl;
	}
	cout << "score:" << evl << endl;

	return evl;
}

int main(){
	cin >> d;
	for( int i = 0; i < 26; i++ ){
		cin >> c[i];
	}
	for( int i = 0; i < d; i++ ){
		for( int j = 0; j < 26; j++ ){
			cin >> s[i][j];
		}
	}

	int gre;

	for( int i = 0; i < d; i++ ){
		gre = 0;
		for( int j = 0; j < 26; j++ ){
			gre = max( gre, s[i][j] );
			if( gre == s[i][j] ){
				t[i] = j + 1;
			}
		}
	}

//	for( int i = 0; i < 365; i++ ){

//	}

	for( int i = 0; i < d; i++ ){
		cout << t[i] << endl;
	}

//	score();

	return 0;
}


Measured memory_bytes: 3672
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int64_t> vs(n);
    for (auto& v : vs)
    {
        cin >> v;
    }
    sort(vs.begin(), vs.end());
    cout << (vs.back() - vs[0]) << endl;
}

Measured memory_bytes: 256