akhauriyash/Code-Regression huggingface dataset:
/**
    Sweet!
**/
#include <bits/stdc++.h>

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define pp pop_back()
#define ll long long
#define ld long double
#define OK puts("OK");
#define sz(s) (int)s.size()
#define sq(s) s*1ll*s
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 3e2+10;
const int inf = 1e9+7;
const ll linf = 1e18+9;

int n, m, ans;
int a[N][N];
int u[N], cnt[N], g[N];
set <pair <int, int> > st;

int main() {
    cin >> n >> m;
    ans = n;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            cin >> a[i][j];
        }
        cnt[i] = 1;
        u[a[i][1]]++;
    }
    for (int i = 1; i <= m; i++) {
        int mx = 0, mi = 0;
        for (int j = 1; j <= m; j++)
            if(!g[j] && u[j] > mx)
                mx = u[j], mi = j;
        g[mi] = 1;
        ans = min(ans, mx);
        for (int j = 1; j <= n; j++)
            if(a[j][cnt[j]] == mi) {
                cnt[j]++;
                while(g[a[j][cnt[j]]])
                    cnt[j]++;
                u[a[j][cnt[j]]]++;
            }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
import * as fs from 'fs'

const reader = (data: string) =>
  data
    .split('\n')
    .join(' ')
    .split(' ')
    .map(t => parseInt(t, 10))

function Main(input) {
  const [N, ...xy] = reader(input)
  const x = xy.filter((_, ind) => ind % 2 !== 0)
  const y = xy.filter((_, ind) => ind % 2 === 0)
  let answer = 0

  for (let i = 0; i < N - 1; i++) {
    for (let j = i + 1; j < N; j++) {
      answer += Math.sqrt(Math.pow(x[i] - x[j], 2) + Math.pow(y[i] - y[j], 2))
    }
  }

  console.log((answer * 2) / N)
}

Main(fs.readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
use std::io;
use std::str::FromStr;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    let nums = buf.split_whitespace().map(|n| i32::from_str(n).unwrap());

    let mut ans = 0;
    for num in nums {
        ans += num;
    }

    println!("{}", if ans >= 22 { "bust" } else { "win" });
}


Measured memory_bytes: 2080
import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = null;
        try {
            sc = new Scanner(System.in);
            while (sc.hasNextInt()) {
                int targetThing = sc.nextInt();
                int weight = 512;

                Deque<Integer> result = new LinkedList<Integer>();

                while (targetThing > 0) {
                    if (targetThing < weight) {
                        weight /= 2;
                    } else {
                        targetThing -= weight;
                        result.push(weight);
                    }
                }
                print(result);
            }
        } finally {
            sc.close();
        }
    }

    public static void print(Deque<Integer> deque) {
        StringBuilder sb = new StringBuilder();
        for (int num : deque) {
            sb.append(num).append(" ");
        }
        sb.deleteCharAt(sb.length() - 1);

        System.out.println(sb);
    }
}

Measured memory_bytes: 26280
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def list_lcm(number_list):
    lcm_number = 1
    for j in number_list:
        lcm_number = lcm(lcm_number, j)

    return lcm_number


def list_gcd(number_list):
    gcd_number = number_list[0]
    for i in number_list:
        gcd_number = gcd(gcd_number, i)

    return gcd_number


if __name__ == '__main__':
    n, x = map(int, input().split())
    x_list = list(map(int, input().split()))
    x_list.append(x)
    x_min = min(x_list)
    for i in range(len(x_list)):
        x_list[i] -= x_min
    print(list_gcd(x_list))


Measured memory_bytes: 14484
<?php
/*
    Problem URL : http://arc074.contest.atcoder.jp/tasks/arc074_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d %d", $H, $W);

$ans = min($H, $W);

if ($H % 3 == 0 || $W % 3 == 0) {
    echo "0\n";
    exit;
} else {
    for ($y = 1; $y < $H; $y++) {
        $a1 = $y * $W;
        if ($W % 2 == 0) {
            $a2 = $a3 = ($H - $y) * ($W / 2);
        } else {
            $a2 = ($H - $y) * floor($W / 2);
            $a3 = ($H - $y) * ceil($W / 2);
        }
        $mmin = min($a1, $a2, $a3);
        $mmax = max($a1, $a2, $a3);
        $ans = min($ans, $mmax - $mmin);
    }
    $tmp = $H;
    $H = $W;
    $W = $tmp;
    for ($y = 1; $y < $H; $y++) {
        $a1 = $y * $W;
        if ($W % 2 == 0) {
            $a2 = $a3 = ($H - $y) * ($W / 2);
        } else {
            $a2 = ($H - $y) * floor($W / 2);
            $a3 = ($H - $y) * ceil($W / 2);
        }
        $mmin = min($a1, $a2, $a3);
        $mmax = max($a1, $a2, $a3);
        $ans = min($ans, $mmax - $mmin);
    }
}

echo $ans . PHP_EOL;


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

int main() {
    vector<int> x(3);
    int K;
    cin >> x[0] >> x[1] >> x[2] >> K;
    vector<vector <ll> > a(3);

    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < x[i]; j++)
        {
            ll l;
            cin >> l;
            a[i].push_back(l);
        }
    }
    
    vector<ll> tmp(x[0] * x[1]);
    int k = 0;

    for(int i = 0; i < x[0]; i++)
    {
        for(int j = 0; j < x[1]; j++)
        {
            tmp[k] = a[0][i] + a[1][j];
            k++;
        }
        
    }

    sort(tmp.begin(), tmp.end(), greater<ll>());

    int n = min(K, x[0] * x[1]);
    

    vector<ll> ans(n * x[2]);
    k = 0;

    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < x[2]; j++)
        {
            ans[k] = tmp[i] + a[2][j];
            k++;
        }
        
    }

    sort(ans.begin(), ans.end(), greater<ll>());

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

Measured memory_bytes: 31616
// ClassyNumbers
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll dp[ 10005 ][ 105 ][ 2 ];
string s;
ll d;

ll Solve(ll pos, ll sum, bool tight){
	if(pos == s.length())
		return sum == 0;
	if(dp[pos][sum][tight] != -1)
		return dp[pos][sum][tight];

	ll ans = 0;
	
	ll end = ((tight)?(s[pos]-'0'):9);
	for(ll i = 0; i<=end ;i++){
		ans =  (ans +Solve(pos+1,(sum+i)%d,tight&(i == end)))%mod;
	}
	return dp[pos][sum][tight] = ans;
}


int main(){
	
	cin>>s;
	cin>>d;
	memset(dp,-1,sizeof(dp));

	cout<<(Solve(0,0,1)-1+mod)%mod<<endl;

	return 0;
}

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()
#define sz(x) x.size()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

void solve()
{
    ll n,x,t;
    cin>>n>>x>>t;
    cout<<(((n+x-1)/x)*t)<<"\n";
}

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

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

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)
#define EREP(i,n,m) for(int i=n;i<=m;i++)
#define erep(i,n) EREP(i,0,n)

typedef pair<int,int> P;
//typedef long long ll;

unsigned int dp[101][101];

int main(void){
	int n; cin>>n;
	vector<P> v(n);
	rep(i,n) cin>>v[i].first>>v[i].second;

	erep(i,n){
		erep(j,n) dp[i][j] = INT_MAX;
		dp[i][i] = 0;
	}

	REP(i,1,n){ //ツ閉敖づ個個按津ィ
		EREP(j,0,n-i){ //ツ開ツ始ツ暗環置ツづ個個按津ィ
			REP(k,j,j+i){ //ツ静伉断ツ暗環置ツづ個個按津ィ
				int cost = v[j].first * v[k].second * v[k+1].first * v[j+i].second;
				dp[j][j+i] = min(dp[j][j+i],cost+dp[j][k]+dp[k+1][j+i]);
			}
		}
	}

	cout<<dp[0][n-1]<<endl;

	return 0;
}

Measured memory_bytes: 0
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define which(flag,msg1,msg2) cout<<((flag)? msg1:msg2);

#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
template <class T> map<T,int> 
count_same_elements(const vector<T>& v){map<T,int>cmap; for_each(v.begin(),v.end(),[&cmap](auto x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}
// 約数列挙
template <class T>
vector< T > divisor(T n) {
    vector< T > ret;
    for(T i = 1; i * i <= n; i++) {
        if(n % i == 0) {
        ret.push_back(i);
        if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int n;
vector<string> memo;
void input(){
    cin>>n;
    scan_vector(n,memo);
}
void src(){
    Yes(count_same_elements(memo).size()==memo.size() and
    all_of(adjacent_map(memo,(function<int(string,string)>)[](auto x,auto y){return y.back()==x.front();})))

}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	char X;
	char res;
	for (int i = 0; i < N; i++) {
		cin >> X;
		if (i == 0) {
			res = X;
		}
		else {
			if (res == 'T') {
				res = X;
			}
			else {
				res = 'T';
			}
		}

	}
	cout << res << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--)
#define p(s) cout<<(s)<<endl
#define DEBUG(x,y) cout<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl;
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll mod=1e9+7;

map<int,int> m;
int main(){
	int N;
	cin>>N;
	priority_queue<ll> pq;
	//int A[100010];
	REP(i,0,N){
		int a;
		cin>>a;
		//if(m[a]>=4) continue;
		m[a]++;
		if(m[a]%2==0){
			pq.push(a);
		}
	}
	ll ans=0;
	if(pq.empty()) ans*=0;
	else {
		ans=pq.top();
		pq.pop();
	}
	if(pq.empty()) ans*=0;
	else {
		ans*=pq.top();
	}
	p(ans);
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N, M;
  cin >> N >> M;
  vector<int> q(M);
  int w = 0;
  for(int i = 0; i < M; i++) {
    cin >> q.at(i);
    w += q.at(i);
  }
  if(N >= w) {
    cout << N - w << endl;
  }
  else {
    cout << "-1" << endl;
  }
}

Measured memory_bytes: 3644
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    int N;
    int[] l, r;
    void Solve() {
        //input
        N = io.Int;
        l = new int[N];
        r = new int[N];
        for (int i = 0; i < N;++i){
            l[i] = io.Int;
            r[i] = io.Int;
        }
        //cal
        int ans = 0;
        for (int i = 0; i < N;++i)
            ans += r[i] - l[i] + 1;
        //res
        Console.WriteLine(ans);
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}
class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef vector<int> vi;
    typedef vector<long long> vll;
    typedef vector<pair<int , int>> vpii;
    typedef pair<int , int> pii;
    typedef pair<long long  , long long> pll;
    typedef pair<double , double> pdd;
    #define eb emplace_back;
    #define mp make_pair;
     
    int main(){
        int n;
        cin>>n;
        double a , b , c;
        a = b = c = (int)(n/3) +(double)(n%3)/3;
        cout<<fixed<<setprecision(12)<<a*b*c;

        return 0;
    }

Measured memory_bytes: 384
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		String ans = "";
		while(n>0) {
			if(n%26==1) {
				ans = 'a'+ans;
				n=n/26;
				
			}
			else if(n%26==2) {
				ans='b'+ans;
				n=n/26;
				
			}
			else if(n%26==3) {
				ans='c'+ans;
				n=n/26;
				
			}
			else if(n%26==4) {
				ans='d'+ans;
				n=n/26;
				
			}
			else if(n%26==5) {
				ans='e'+ans;
				n=n/26;
				
			}
			else if(n%26==6) {
				ans='f'+ans;
				n=n/26;
				
			}
			else if(n%26==7) {
				ans='g'+ans;
				n=n/26;
				
			}
			else if(n%26==8) {
				ans='h'+ans;
				n=n/26;
				
			}
			else if(n%26==9) {
				ans='i'+ans;
				n=n/26;
				
			}
			else if(n%26==10) {
				ans='j'+ans;
				n=n/26;
				
			}
			else if(n%26==11) {
				ans='k'+ans;
				n=n/26;
				
			}
			else if(n%26==12) {
				ans='l'+ans;
				n=n/26;
				
			}
			else if(n%26==13) {
				ans='m'+ans;
				n=n/26;
				
			}
			else if(n%26==14) {
				ans='n'+ans;
				n=n/26;
				
			}
			else if(n%26==15) {
				ans='o'+ans;
				n=n/26;
				
			}
			else if(n%26==16) {
				ans='p'+ans;
				n=n/26;
				
			}
			else if(n%26==17) {
				ans='q'+ans;
				n=n/26;
				
			}
			else if(n%26==18) {
				ans='r'+ans;
				n=n/26;
				
			}
			else if(n%26==19) {
				ans='s'+ans;
				n=n/26;
				
			}
			else if(n%26==20) {
				ans='t'+ans;
				n=n/26;
				
			}
			else if(n%26==21) {
				ans='u'+ans;
				n=n/26;
				
			}
			else if(n%26==22) {
				ans='v'+ans;
				n=n/26;
				
			}
			else if(n%26==23) {
				ans='w'+ans;
				n=n/26;
				
			}
			else if(n%26==24) {
				ans='x'+ans;
				n=n/26;
				
			}
			else if(n%26==25) {
				ans='y'+ans;
				n=n/26;
				
			}
			else if(n%26==0) {
				ans='z'+ans;
				n=n/26-1;
				
			}
		}
		System.out.println(ans);
	 }
}

Measured memory_bytes: 38644
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<EntryPoint>]
let main _ =
    let s = read string
    let len = min s.Length 4
    let s = s.Substring(0, len)

    if s = "YAKI" then "Yes"
    else "No"
    |> printfn "%s"

    0 // return an integer exit code


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

int main() {
  int N, K;
  std::cin >> N >> K;
  std::vector<int> a(N);
  for (int i = 0; i < N; ++i)
    std::cin >> a[i];

  std::vector<bool> dp(2 * K + 7, false);
  for (int k = 0; k <= K; ++k)
    for (int i = 0; i < N; ++i)
      if (!dp[k])
        dp[k + a[i]] = true;

  std::cout << (dp[K] ? "First" : "Second") << std::endl;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N, M;
vi A;
vector<pair<int, int>> CB;

int main() {
    cin >> N >> M;
    A.resize(N);
    rep(i, N) cin >> A[i];
    CB.reserve(M);
    rep(i, M) {
        int _b, _c;
        cin >> _b >> _c;
        CB.emplace_back(_c, _b);
    }

    sort(all(A));
    sort(all(CB), greater<pair<int, int>>());

    ll increase = 0;
    int i_CB = 0;
    rep(i_A, N) {
        if (CB[i_CB].first > A[i_A] && CB[i_CB].second > 0) {
            increase += CB[i_CB].first - A[i_A];
            if (CB[i_CB].second > 1) CB[i_CB].second--;
            else i_CB++;
        }
        else break;
        if (i_CB >= M) break;
    }

    ll ans = accumulate(all(A), (ll)0) + increase;
    write(ans);
}

Measured memory_bytes: 1408
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	ll a;
	string b;
	cin >> a >> b;
	ll c = 0;
	REP(i, b.size()) if(i != 1) c = c * 10 + (b[i] - '0'); 
	ans = a * c;
	string h = to_string(a*c);
	if(h.size() > 2) h = h.substr(0, h.size() - 2);
	else h = "0";
	cout << h << endl;
}

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

char M(char ch){
   return ( 'A' <= ch && ch <= 'Z' ) ? ch - 'A' + 'a' : ch;
}

int main(){
  int count=0;
  string W ,str;
  cin>>W;
  while(1){
    cin>>str;
    if(str=="END_OF_TEXT")
    break;
    for(int i=0;i<str.size();i++){
      str[i]=M(str[i]);
    }
    if(str==W){
      count++;
    }
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>p(N+2);
  for(int i=1;i<=N;i++)
    cin>>p.at(i);
  p.at(0)=-1; p.at(N+1)=-1;
  int sum=0;
  vector<int>A={};
  for(int i=1;i<=N+1;i++){
  if(p.at(i)==i)
    sum++;
    else{
     A.push_back(sum); sum=0;
    }
    }int ans=0;
  for(auto x:A){
  ans+=(1+x)/2;
  }cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1276
# -*- coding: utf-8 -*-
def reduce(N):
    from math import sqrt, ceil
    from copy import deepcopy
    h_reductions = []
    for i in range(ceil(sqrt(N))):
        if N % (i+1) == 0:
            h_reductions.append(i+1)

    reductions = deepcopy(h_reductions)

    if h_reductions[-1]**2 != N:
        for i in range(len(h_reductions)):
            reductions.append(int(N/h_reductions[-1*i - 1]))
    else:
        for i in range(len(h_reductions)-1):
            reductions.append(int(N/h_reductions[-1*i - 2]))
    return reductions

N = int(input())

reductions = reduce(N)

print(len(str(int(reductions[len(reductions)//2]))))


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, 0, n) {
        cin >> a[i];
    }

    vector<vector<int>> div(n + 1);
    REP(i, 1, n + 1) {
        for (int j = i + i; j < n + 1; j += i) {
            div[j].push_back(i);
        }
    }
    vector<int> ans(n, 0);
    vector<int> sum(n, 0);
    for (int i = n - 1; i >= 0; i--) {
        dump(sum[i], a[i]);
        if (sum[i] != a[i]) {
            sum[i] = a[i];
            ans[i] = 1;
            for (int d : div[i + 1]) {
                sum[d - 1] = (sum[d - 1] + 1) % 2;
            }
        }
    }
    if (sum[0] == a[0]) {
        int cnt = 0;
        REP(i, 0, n) {
            cnt += ans[i];
        }
        cout << cnt << endl;
        REP(i, 0, n) {
            if (ans[i] == 1) {
                cout << i + 1 << endl;
            }
        }

    } else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 24576
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
	int n;
	int max=-1;
	int hb=0;
	char a[101];
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]=='I') hb++;
		if(a[i]=='D') hb--;
		if(hb>max) max=hb;
	}
	if(max==-1)
	max=0;
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

struct Slide_Max {
	std::deque<int> deq;
	std::vector<i64> v;
	int k, i;
	i64 ret;
	
	Slide_Max(int k) : k(k) {
		deq.clear();
		v.clear();
		ret = 0;
		i = 0;
	}
	
	i64 push(i64 x) {
		v.push_back(x);
		while(!deq.empty() and v[deq.back()] <= v[i]) {
			deq.pop_back();
		}
		deq.push_back(i);
		
		ret = v[deq.front()];
		if(deq.front() == i - k + 1) deq.pop_front();
		
		i++;
		return ret;
	}
	
	i64 get() { return (v.size() ? ret : -1); };
};
	
int main(){
	int n, m, k; cin >> n >> m >> k; std::vector<i64> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	
	Slide_Max sm[k + 1](m); sm[0].push(0);
	std::vector<std::vector<i64>> dp(n + 1, std::vector<i64>(k + 1, 0));
	for(int i = 0; i < n; i++) {
		for(i64 j = k - 1; j >= 0; j--) {
			if(sm[j].get() == -1) continue;
			i64 ma = sm[j].get();
			
			dp[i + 1][j + 1] = ma + a[i] * (j + 1);
			sm[j + 1].push(dp[i + 1][j + 1]);
		}
	}
	
	i64 ma = 0;
	for(int i = 0; i <= n; i++) ma = std::max(ma, dp[i][k]);
	cout << ma << endl;
	return 0;
}


Measured memory_bytes: 481176
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

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

    string s;
    cin >> s;

    vector<int> r;
    r.push_back(n);
    for (int i = n; i > 0;) {
        int b = 0;
        for (int j = max(i - m, 0); j < i; j++) {
            if (s[j] == '0') {
                r.push_back(j);
                i = j;
                b = 1;
                break;
            }
        }
        if (!b) {
            cout << -1 << endl;
            exit(0);
        }
    }

    int k = r.size() - 1;
    for (int i = k; i > 0; i--) {
        cout << r[i - 1] - r[i] << " \n"[i == 1];
    }

    //N/M回 最短手数だけならうしろで待つ意味はない 貪欲に前へ行けば手数はわかる
    //逆からそれをやればその回数までに最低限到達しないといけない場所がわかる そのラインでいちばん手前へ ていうかそれが実現できる

    return 0;
}

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

int main()
{
	int x,y,z;
	cin >> x >> y >>z;
	swap(x,y);
	swap(x,z);
	printf("%d %d %d",x,y,z);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
int func(int n,int k)
{
  if(n==1) return 0;
  return (func(n-1,k)+k)%n;
}
int main(int argc,char const* argv[])
{
  int n,m,k;
  while(1)
    {
      cin >> n >> k >> m;
      if(!n) break;
      cout << (func(n-1,k)+m)%n+1 << endl;
    }
  return 0;
}



Measured memory_bytes: 3336
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    ll n,m; cin >> n >> m;
    ll cnt = 0;
    vpl ans;
    ll l = 1, r = n;
    vl list(n,0);
    while(cnt < m){
        while((r-l)*2 == n || list[r-l] || list[n-r+l]){
            r--;
            continue;
        }
        list[r-l]++;
        list[n-r+l]++;
        print2(l,r);
        l++; r--;
        cnt++;
    }
}

Measured memory_bytes: 4580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Deque<Integer> ad1 = new ArrayDeque<>();
        Deque<int[]> ad2 = new ArrayDeque<>();
        char[] list = br.readLine().toCharArray();

        int sum = 0;
        for (int i = 0; i < list.length; i++) {
            if (list[i] == '\\') {
                ad1.push(i);
            } else if (list[i] == '/') {
                if (!ad1.isEmpty()) {
                    int j = ad1.pop();
                    int area = i - j;
                    sum += area;
                    while (!ad2.isEmpty() && ad2.peek()[0] > j) {
                        area += ad2.pop()[1];
                    }
                    int[] val = { j, area };
                    ad2.push(val);
                }
            }
        }
        System.out.println(sum);
        System.out.print(ad2.size());
        while(!ad2.isEmpty()){
            System.out.print(" " + ad2.pollLast()[1]);
        }
        System.out.println();
    }

    static boolean isNumber(String num) {
        return Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find();
    }

    static int[] createListInt(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    }

    static long[] createListLong(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        long[] list = new long[n];
        while (n-- > 0) {
            list[n] = Long.parseLong(lines[n]);
        }
        return list;
    }

    static int ip(String s) {
        return Integer.parseInt(s);
    }

    static long lp(String s) {
        return Long.parseLong(s);
    }
}

Measured memory_bytes: 26532
#include <bits/stdc++.h>
using namespace std;
int gcm(int, int,int);
int main() {
	int n;


	cin >> n;
	vector<int>a(n-1);
	for(int i=0;i<n-1;i++){
		cin >> a[i];
	}
	vector<int>b(n);
	for(int i=0;i<n-1;i++){
		b[a[i]-1]++;
	}
	for(int i=0;i<n;i++){
		cout << b[i] <<endl;
	}
	return 0;
}


Measured memory_bytes: 4840
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

#define N 100000

int A[N];
int n,k;

int K_search(int P){
    int TR[N]={0};
    int tr = 0;
    int count = 0;
    
    for (int i = 0; i < n; i++) {
        if (TR[tr]+A[i]<=P) {
            TR[tr] += A[i];
            count++;
        }else if(tr+1<k && A[i]<=P){
            tr++;
            TR[tr] += A[i];
            count++;
        }else{
            break;
        }
    }
    return count;
}

int solve(){
    int Right=0,Left=0;
    for (int i = 0; i < n; i++) {
        Right += A[i];
    }
    int mid;
    
    
    while ( Right-Left > 1 ) {
        mid = (Right+Left)/2;
        
        int v = K_search(mid);
        if (v >= n) {
            Right = mid;
        }else{
            Left = mid;
        }
    }
    return Right;
}


int main(){
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        scanf("%d",&A[i]);
    }
    
    cout << solve() << endl;
    
    return 0;
}

Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
using matrix = vector<vector<uint>>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    int N;
    cin >> N;
    ll sum = 0;
    for (int i = 1; i <= N; ++i)
        if (i % 5 && i % 3)
            sum += i;

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3652
s=input().split()
i=int(s[0])
j=int(s[1])
k=int(s[2])
a=[]
for l in range(k):
  if i+l<=j:
    a.append(str(i+l))
  else:
    break
b=int(a[-1])
if b>=j-k and b<j:
  for l in range(1,j-b+1):
    if b+l<=j:
      a.append(str(b+l))
elif b<j-k:
  for l in range(k-1,-1,-1):
    if j-l<=j:
      a.append(str(j-l))
print(*a)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  int cnt[50] = {};
  int k, a;
  int ans = 0;
  
  cin >> n >> m;

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

  for(int i = 1;i <= m;i++){
	if(cnt[i] == n){
	  ans ++;
	}
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;

long long MIN(long long a, long long b){
    if(a<b) return a ;
    return b ;
}

int main() {
	
long long n,k ;    
cin >> n >> k ;
long long h[n] ;

for(int i=0;i<n;i++) cin >> h[i] ;

sort(h,h+n) ;

long long tmp = 1000000000 ;
for(int i=0;i<(n-k+1);i++){
  tmp = MIN(h[i+k-1]-h[i],tmp) ;
} 

cout << tmp << endl ;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;

typedef long long ll;

vector<int> g[3];
set<int> s;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string a;
	cin >> a;
	for (int i = 0; i < n; i++)
	{
		if( a[i] == 'R' ) g[0].push_back(i);
		else if( a[i] == 'G' ) g[1].push_back(i);
		else g[2].push_back(i);   
	}
	for (int i = 0; i < g[2].size(); i++)
	{
		s.insert(g[2][i]);
	}
	ll ans = 0;
	for (int i = 0; i < g[0].size(); i++)
	{
		for (int j = 0; j < g[1].size(); j++)
		{
			int gap = abs(g[0][i]-g[1][j]);
			int t1 = min(g[0][i],g[1][j]) - gap;
			int t2 = max(g[0][i],g[1][j]) + gap;
			int temp = g[2].size();
			if( gap % 2 == 0 )
			{
				int t3 = ( g[0][i] + g[1][j] ) / 2;
				if( s.find(t3) != s.end() ) temp --;
			}
			if( s.find(t1) != s.end() ) temp --;
			if( s.find(t2) != s.end() ) temp --;
			ans += temp;
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3716
#include<iostream>
#include<cstdio>
#define ll long long
#define mod 1000000007
#define inv 500000004
using namespace std;
ll ans=0,cnt[5010],tim[5010];
int n,k;
int a[5010];
int main(){
	scanf("%d%d",&n,&k);
	for(register int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		cnt[a[i]]++;
	}
	for(register int i=1;i<=n;i++){
		ll res1=0,res2=0;
		for(register int j=a[i]+1;j<=2000;j++){
			res1+=tim[j];
			res2+=cnt[j];
			res1%=mod;
			res2%=mod;
		}
		ans=(ans+(res1*k%mod)+(res2*k%mod*(1ll*k-1)%mod*1ll*inv%mod))%mod;
		tim[a[i]]++;
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 256
n,k=map(int,input().split())
s=list(input())
if s[k-1]=="A":
    s[k-1]="a"
if s[k-1]=="B":
    s[k-1]="b"
if s[k-1]=="C":
    s[k-1]="c"
print("".join(s))


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	long long h;
	cin >> h;

	int cnt = -1;
	while (h) {
		h >>= 1;
		cnt++;
	}
	long long ans = 1;
	rep(i,cnt) {
		ans = ans * 2 + 1;
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
import sys


class AlgSegmentTreeMin:
    def __init__(self, n, default_value):
        self.Nelem = n
        self.default_value = default_value
        self.size = 1 << (n.bit_length())
        self.data = [self.default_value] * (2 * self.size)

    def update(self, i, x):
        i += self.size
        self.data[i] = x
        i >>= 1
        while i:
            x = self.data[i + i]
            y = self.data[i + i + 1]
            self.data[i] = min(x, y)
            i >>= 1

    def get_value(self, left, right):
        left += self.size
        right += self.size + 1
        x = self.default_value
        while left < right:
            if left & 1:
                y = self.data[left]
                x = min(x, y)
                left += 1
            if right & 1:
                right -= 1
                y = self.data[right]
                x = min(x, y)
            left >>= 1
            right >>= 1
        return x


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    stree = AlgSegmentTreeMin(n, 10 ** 15)
    lrc = [list(map(int, readline().split())) for _ in range(m)]
    lrc.sort()
    stree.update(0, 0)
    for l, r, c in lrc:
        l -= 1
        r -= 1
        now = stree.get_value(r, r)
        if now > c:
            tm = stree.get_value(l, r)
            if tm + c < now:
                stree.update(r, tm + c)
    mt = stree.get_value(n-1, n)
    print(mt if mt != stree.default_value else -1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 88028
n, y = [int(x) for x in input().split()]

def search():
    for b in range(0, n+1):
        for a in range(0, n+1):
            c = n - a - b
            total = 10000*a + 5000*b + 1000*c
            if (y == total and n == a + b + c and c >= 0):
                return (a, b, c)
    return (-1,-1,-1)
print("%d %d %d" % search())


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

//nに含まれる1の数を求める
int element_count(int n){
	n = (0x55555555 & n) + (0x55555555 & (n >> 1));
	n = (0x33333333 & n) + (0x33333333 & (n >> 2));
	n = (0x0f0f0f0f & n) + (0x0f0f0f0f & (n >> 4));
	n = (0x00ff00ff & n) + (0x00ff00ff & (n >> 8));
	n = (0x0000ffff & n) + (0x0000ffff & (n >> 16));
	return n;
}

int *solve(int A, int B, int N){
//	printf("solve(%d, %d, %d)\n", A, B, N);
	int *ans = (int *)malloc(sizeof(int) * (1 << N));
	if(N == 1){
		ans[0] = A;
		ans[1] = B;
	}
	else{
		int i;
		int b = (1 << (N - 1));
		int s = (A & b), t = (s ^ b);
//		printf("(b, s, t) = (%d, %d, %d)\n", b, s, t);
		if((A & b) == (B & b)){
			int *res1 = solve(A & (b - 1), B & (b - 1), N - 1);
			int *res2 = solve(res1[0], res1[1], N - 1);
			ans[0] = res1[0] + s;
			for(i = 1; i <= (1 << (N - 1)); i++){
				ans[i] = res2[i - 1] + t;
			}
			for(i = (1 << (N - 1)) + 1; i < (1 << N); i++){
				ans[i] = res1[i - (1 << (N - 1))] + s;
			}
		}
		else{
			int C;
			if(element_count(A & (b - 1)) % 2 == 0){
				C = 1;
			}
			else{
				C = 0;
			}
//			printf("C = %d\n", C);
			int *res1 = solve(A & (b - 1), C, N - 1);
			int *res2 = solve(C, B & (b - 1), N - 1);
			for(i = 0; i < (1 << (N - 1)); i++){
				ans[i] = res1[i] + s;
			}
			for(i = (1 << (N - 1)); i < (1 << N); i++){
				ans[i] = res2[i - (1 << (N - 1))] + t;
			}
		}
	}
	return ans;
}

int main(){
	int N, A, B, i;
	scanf("%d%d%d", &N, &A, &B);
	if(element_count(A) % 2 == element_count(B) % 2){
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	int *ans = solve(A, B, N);
	for(i = 0; i < (1 << N); i++){
		printf("%d ", ans[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 12288
#include<iostream>
using namespace std;
 
int main()
{
  int h, w, n;
  cin >> h;
  cin >> w;
  cin >> n;
  
  int bigger = h > w ? h : w;
  
  int count = n / bigger;
  if(n % bigger != 0)
  {
    count += 1;
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  //input
  int n;
  cin >> n;
  vector<P> task(n);  //締め切り，作業時間
  REP(i,n){
    int a, b;
    cin >> a >> b;
    task[i] = make_pair(b,a);
  }
  //締切の早い順にsort
  sort(ALL(task));
  //タスクの合計が，締め切りを超えていたらだめ
  ll sum = 0;
  REP(i,n){
    sum += task[i].second;
    if(sum > task[i].first){
      cout << "No" << endl;
      return 0;
    }

  }

  //全てokなら出力する．
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 4848
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  ll D;	cin>>D;	D*=D;
  int ans = 0;
  REP(i,N) {
    ll X, Y; cin>>X>>Y;
    ll tmp = X*X + Y*Y;
    if(tmp <= D) ans++;
  }
  cout << ans << endl;

  return 0;
}




Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<ll, ll>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const double INF = 1E+9;

pair<double, double> pos (pair<pair<double, double>, char> p, double t) {
    char dir = p.second;
    pair<double, double> res = p.first;
    if (dir=='R') res.first += t;
    if (dir=='L') res.first -= t;
    if (dir=='U') res.second += t;
    if (dir=='D') res.second -= t;
    return res;
}

int main(){
    ll n;
    cin >> n;
    vector<pair<pair<double, double>, char>> p(n);
    rep(i, n) cin >> p[i].first.first >> p[i].first.second >> p[i].second;
    double ans = 0.0;
    double l = 0; double r = 1E+9;
    rep(ti, 100) {
        vector<double> x(3);
        x[1] = (l+r)/2.0;
        x[0] = (l+x[1])/2.0;
        x[2] = (x[1]+r)/2.0;
        vector<double> area(3);
        vector<double> xmin(3, INF);
        vector<double> xmax(3, -INF);
        vector<double> ymin(3, INF);
        vector<double> ymax(3, -INF);
        rep(i, 3) {
            rep(j, n) {
                pair<double, double> now = pos(p[j], x[i]);
                chmin(xmin[i], now.first);
                chmax(xmax[i], now.first);
                chmin(ymin[i], now.second);
                chmax(ymax[i], now.second);
            }
            area[i] = (xmax[i]-xmin[i]) * (ymax[i]-ymin[i]);
        }
        if (area[1]<area[0] && area[1]<area[2]) {
            l = x[0]; r = x[2]; ans = area[1];
            continue;
        }
        if (area[0]<area[1]) {
            r = x[1]; ans = area[0]; 
            continue;
        }
        l = x[1];
        ans = area[2];
    }
    
    printf("%.10f\n", ans);
    return 0;
}


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

using namespace std;

int main()
{
    int x,y;
    cin>>x>>y;
    if((x==1 || x==3 ||x==5 || x==7||x==8 || x==10 ||x==12)&&
            (y==1 || y==3 ||y==5 || y==7||y==8 || y==10 ||y==12))
        cout<<"Yes"<<endl;
    else if((x==4 || x==6 ||x==9 || x==11)&&(y==4 || y==6 ||y==9 || y==11))
        cout<<"Yes"<<endl;
    else if(x==2 && y==2)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define fast ios::sync_with_stdio(0),cin.tie(0);
int main(){
    fast
    ll n,W;
    cin>>n>>W;
    ll w[n],v[n];
    for(ll i=0;i<n;i++) cin>>w[i]>>v[i];
    ll dp[W+1]={},ans=0;
    for(ll i=0;i<n;i++){
        for(ll j=W;j>=0;j--){
            if(j+w[i]<=W){
                dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
                ans=max(ans,dp[j+w[i]]);
            }
        }
    }
    cout<<ans;
    //for(ll i=0;i<=W;i++) cout<<dp[i]<<' ';
}

Measured memory_bytes: 1024
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

ll f(ll n){
    if(n==0)return INF;
    ll ret=0;
    while(n%2==0){
        n/=2;
        ret++;
    }
    return ret;
}

char rf(int n){
    if(n<26)return ('A'+n);
    else return ('a'+(n-26));
}

bool solve(){
    ll n,c,k;cin>>n>>c>>k;
    vector<ll>t(n);
    rep(i,n)cin>>t[i];
    sort(all(t));
    ll ans=0;
    ll time=-INF;
    ll nowcount=0;
    rep(i,t.size()){
        if(t[i]>time+k or nowcount==c){
            //go
            ans++;
            nowcount=1;
            time=t[i];
        }else nowcount++;
        // cout<<time<<" "<<ans<<endl;
    }
    cout<<ans<<endl;
    return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e7;  
using  p = pair<int,int>;
using  v = vector<int>;

int main(){
  int n;
  cin >> n;
  auto a = vector<int>(n,0);
  for (int i = 0; i < n; i++)
  {
     cin >> a[i];
     a[i]--;
  }
  
  int next = 0;
  int i=1;
  auto used = vector<int>(n,0);
  while(1){
     used[next]=1;
     next = a[next];
     if(used[next]==1){
        cout << -1;
        break;
     }

     if(next==1){
        cout << i;
        break;
     }
     i++;
  }
  

}
  
  

Measured memory_bytes: 1024