akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int x,y;
    cin>>x>>y;
    if(y%2!=0)
    {
        cout<<"No";
    }
    else
    {
        if(y>x*4 || y<x*2)
        {
            cout<<"No";
        }
        else
        {
            cout<<"Yes";
        }
    }
    
    // your code goes here
	return 0;
}


Measured memory_bytes: 3620
import sys
INPUT = sys.stdin.readline
#入力関数
def SORO_INT(): return int(INPUT())
def MULT_INT_LIST(): return list(map(int, INPUT().split()))
def MULT_INT_MAP(): return map(int, INPUT().split())
def SORO_STRING(): return INPUT()
def MULT_STRING(): return INPUT().split()

r=SORO_INT()
print(r**2)

Measured memory_bytes: 3060
import math
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n
def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                w = cmt + ': ' + str(x)
            else:
                w = str(x)
            print(w)
        return x

def prob():  # WA 2
    d = Debug()
    d.off()
    N, K = getIntList()
    d.dmp((N, K), 'N, K')
    A = getIntList()
    d.dmp((A), 'A')
    if K == 0:
        x = 0
    else:
        lg = int(math.log2(K+0.1))
        mask = 1 << lg
        x = 0
        d.dmp(x,'x')
        #mask >>= 1
        lessK = False  # x<Kか否か
        while mask > 0:
            cz, co = 0, 0
            for i in range(N):
                if A[i] & mask == 0:
                    cz += 1
                else:
                    co += 1
            if cz > co:
                if K & mask or lessK:
                    x += mask
            if (x & mask == 0) and mask & K:
                lessK = True
            mask >>= 1
            d.dmp((mask,x),'mask,x')
    d.dmp((x),'x')
    ans = 0
    for i in range(N):
        d.dmp((x ^ A[i]),'x ^ A[i]')
        ans += x ^ A[i]
    return ans


ans = prob()
print(ans)


Measured memory_bytes: 14748
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N, Y;
  cin >> N >> Y;
  for (int i = 0; i <= N; i++) {
    for (int p = 0; p <= N-i; p++) {
      int z = N-i-p;
      if (10000*i + 5000*p + 1000*z == Y) {
        printf("%lld %lld %lld\n", i, p, z);
        return;
      }
    }
  }

  cout << "-1 -1 -1" << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[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 (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


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

	string str;
	cin >> str;
	int cnt = 0;
	rep(i, str.size()) {
		if (str.at(i) == '?') {
			str.at(i) = 'D';
		}
	}
	cout << str;
	return 0;
}


Measured memory_bytes: 3728
N,M=map(int,input().split())
l=[list(map(int,input().split()))for i in range(M)]
min=0
max=1000000
for i in l:
    if i[0]>=min:
        min=i[0]
    if i[1]<=max:
        max=i[1]
if max-min>=0:
    print(max-min+1)
else:
    print(0)

Measured memory_bytes: 27336
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    char a, b;

    cin >> a >> b;

    if (a == 'H') {
        cout << b << endl;
    }
    else {
        if (b == 'H') {
            cout << 'D' << endl;
        }
        else {
            cout << 'H' << endl;
        }
    }
}


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

const int MOD = 1e9 + 7;

int n, cnt[30];
char S[100010];

int main() {
	scanf("%d%s", &n, S);
	
	for (int i = 0; i < n; i++) {
		++cnt[S[i] - 'a'];
	}
	long long ans = 1;
	for (int i = 0; i < 26; i++) {
		(ans *= cnt[i] + 1) %= MOD;
	}
	--ans;
	ans = (ans + MOD) % MOD;
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define rep(x) for(int i=0;i<x;i++)
#define reprev(x) for(int i=x-1;i>=0;i--)
#define repdef(x,n) for(int i=x;i<n;i++)
#define Debug(x) cout<<x<<"\n";
#define Debug2(x,y) cout<<x<<" "<<y<<"\n";
#define TEST(t) while(t--)
#define mod 1000000007
#define MAX 100005
int fast_exp(ll base,ll exp){
    if(exp==1){
        return base%mod;
    }
    if(exp&1){
        int ans=fast_exp(base,exp-1);
        return (base%mod*ans%mod)%mod;
    }else{
        int ans=fast_exp(base,exp/2);
        return (ans%mod*ans%mod)%mod;
    }
}
int fast_exp_itr(ll base,ll exp,ll p){
    ll ans=1;
    base=base%p;
    while(exp>0){
        if(exp&1){
            ans=((ans%p)*(base%p))%p;
        }
        exp>>=1;
        base=((base%p)*(base%p))%p;
    }
    return ans;
}
int euclid_gcd(int a,int b){
    if(b==0){
        return a;
    }
    return euclid_gcd(b,a%b);
}
int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    if(n==1){
    	printf("%0.10f\n",1.0);
    	return 0;
    }
    int odd=ceil((float)(n)/2);
    printf("%0.10f\n",(double)(odd)/n);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

template<typename T>
T euler_phi(T n){
    T res = n;
    for(T k=2; k*k<=n; ++k){
        if(n % k)continue;
        for(res=res/k*(k-1); n%k == 0; n/=k);
    }
    return 1 < n? res / n * (n - 1): res;
}

int main(){
    int n;
    cin >> n;
    cout << euler_phi(n) << '\n';
    return 0;
}

Measured memory_bytes: 1160
N = int(input())
a = list(map(int, input().split()))

num_dict = dict()
for a_i in a:
    if a_i in num_dict:
        num_dict[a_i] += 1
        continue
    num_dict[a_i] = 1

ans = 0
for num in num_dict:
    if num_dict[num] == num:
        continue
    if num_dict[num] < num:
        ans += num_dict[num]
        continue
    ans += num_dict[num]-num

print(ans)

Measured memory_bytes: 17780
import math
import sys
input = sys.stdin.readline


N,Y = map(int, input().split())
flag=0
for i in range(0,N+1):
    for j in range(0,N+1-i):
        if(Y-10000*i-5000*j)/1000 == N-i-j :
            a = i
            b = j
            c = N-i-j
            flag =1
            break
        if flag==1:
            break

if flag==1:
    print(a,b,c)

if flag!=1:
    print("-1 -1 -1")


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

int main(){

    int X = 0;
    cin >> X;

    int FVHYNcoin = 0;
    int FVYNcoin = 0;

    FVHYNcoin = X / 500;
    FVYNcoin = (X - FVHYNcoin * 500) / 5;

    int ans = FVHYNcoin * 1000 + FVYNcoin * 5;
    cout << ans << endl; 

    return 0;
}

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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (long long )(9e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii >

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){ 
    in >> q.F >> q.S; return in;
}
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}

void solve() {
  int k;cin >> k;
    string s;
    cin >> s;
    
    if(si(s) <= k){
        cout << s;
    } else{
        for(int i = 0; i < k; i++)
            cout << s[i];
        cout << "...";
    }
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(20);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif
   
    //cin >> t;
    
    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": "; 
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

struct Union_Find_Tree{
    vector<int> par, rank, num;
    //要素数n(0〜n-1)の初期化されたUnion-Find木を構築
    Union_Find_Tree(int N){
        par.assign(N, -1);
        rank.assign(N, 0);
        num.assign(N, 1);
    }
    //ノードxの根を取得
    int root(int x){
        if(par[x] < 0 || par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    //xとyの属する集合を併合
    void unite(int x, int y){
        x = root(x), y = root(y);
        if(x == y) return;
        elif(rank[x] < rank[y]) par[x] = y, num[y] += num[x];
        else{
            par[y] = x, num[x] += num[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    //xの属する集合の要素数を取得
    int size(int x){
        return num[root(x)];
    }
    //xとyが同じ集合に属するか判定
    bool same(int x, int y){
        return root(x) == root(y);
    }
    //初期化する
    void clear(){
        fill(par.begin(), par.end(), -1);
        fill(rank.begin(), rank.end(), 0);
        fill(num.begin(), num.end(), 1);
    }
};

const int MAX = 1e5;

int main(){
    ll N;
    cin >> N;
    //xs[i]:=x=iとなるもの
    vector<int> xs[MAX], ys[MAX];
    rep(i, N){
        int x, y; cin >> x >> y; x--, y--;
        xs[x].pb(y), ys[y].pb(x);
    }
    Union_Find_Tree uft(MAX);
    rep(i, MAX){
        if(ys[i].size() == 0) continue;
        rep(j, ys[i].size()-1){
            uft.unite(ys[i][j], ys[i][j+1]);
        }
    }
    ll ans = 0;
    set<int> s[MAX];
    rep(i, MAX){
        int j = uft.root(i);
        for(auto &e: xs[i]){
            s[j].insert(e);
        }
    }
    rep(i, MAX){
        ll a = s[i].size(), b = uft.size(i);
        ans += a*b;
    }
    cout << ans-N << endl;
}

Measured memory_bytes: 16256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

typedef long long lli;
typedef pair<lli, lli> P;


const lli INF = (1LL<<30);

int n;

bool compare_y(P a, P b){
  return a.second < b.second;
}

lli closest_pair(P* a, int n){
  if(n <= 1) return INF;
  int m = n / 2;
  lli x = a[m].first;
  lli d = min(closest_pair(a, m), closest_pair(a+m, n-m));
  inplace_merge(a, a+m, a+n, compare_y);
  vector<P> b;
  for(int i=0;i<n;i++){
    if((a[i].first - x) * (a[i].first - x) >= d) continue;
    for(int j=0;j<b.size();j++){
      lli dx = a[i].first - b[(int)b.size()-j-1].first;
      lli dy = a[i].second - b[(int)b.size()-j-1].second;
      if(dy*dy >= d) break;
      d = min(d, dx * dx + dy * dy);
    }
    b.push_back(a[i]);
  }
  return d;
}

main(){
  cin >> n;
  P* A = new P[n];
  for(int i=0;i<n;i++){
    cin >> A[i].first >> A[i].second;
  }
  sort(A, A+n);
  cout << closest_pair(A, n) << endl;
}  

Measured memory_bytes: 20480
#include <stdio.h>
#include <iostream>

int arr[210];
int main() {
  int num;
  scanf("%d", &num);
  for (int i = 0; i < num; i++) scanf("%d", (arr+i));
  int cnt = 0;
  for (int i = 0;;i++) {
    if (arr[i%num] % 2 == 0) arr[i%num] = arr[i%num] / 2;
    else {
      cnt = (i+1) / num;
      break;
    }
  }
  std::cout << cnt << '\n';
}


Measured memory_bytes: 256
#include<cstdio>

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

using namespace std;

int main(){
	int bit[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x27,0x7f,0x6f};

	for(int n;scanf("%d",&n),~n;){
		int stat=0;
		rep(i,n){
			int a;	scanf("%d",&a);
			int dif=stat^bit[a];
			stat=bit[a];

			rep(j,7)	printf("%d",(bool)(dif&(1<<(6-j))));
			putchar('\n');
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define io ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define ll long long
int main(){
	io;
	ll a, b, c, d;
	cin>>a>>b>>c>>d;
	while(1){
		c = c - b;
		if(c <= 0){
			cout<<"Yes";
			break;
		}
		a = a - d;
		if(a <= 0){
			cout<<"No";
			break;
		}
	}
	return 0;
}


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

int Solve(const int m, int n) {
    long long int MAX_YEAR = 7368792;
    vector<bool> year(MAX_YEAR, false);

    int idx = m;
    while (n--) {
        while (year[idx]) ++idx;
        for (int i = 1; i * idx < MAX_YEAR; ++i)
            year[i * idx] = true;
    }
    while (year[idx]) ++idx;

    return idx;
}

int main() {
    cin.tie(0);

    int m, n;
    while (cin >> m >> n, m)
        cout << Solve(m, n) << '\n';

    return 0;
}


Measured memory_bytes: 3884
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
 
class Program{
    static void Main(){
        int l = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split(' ')
                                    .Select(val => int.Parse(val))
                                    .ToArray();
        long ans = Divide(ref A, 0, l);
        Console.WriteLine(ans);
    }

    static long Divide(ref int[] A, int left, int right)
    {
        if(left + 1 < right)
        {
            int mid = (left + right) / 2;
            long v1 = Divide(ref A, left, mid);
            long v2 = Divide(ref A, mid, right);
            long v3 = Merge(ref A, left, mid, right);
            return v1 + v2 + v3;
        }
        else return 0L;
    }

    static long Merge(ref int[] A, int left, int mid, int right)
    {
        int llength = mid - left;
        int rlength = right - mid;
        int[] L = new int[llength + 1];
        int[] R = new int[rlength + 1];
        Array.Copy(A, left, L, 0, llength);
        Array.Copy(A, mid, R, 0, rlength);
        L[llength] = int.MaxValue;
        R[rlength] = int.MaxValue;
        //Console.Error.WriteLine("L: {0}", string.Join(" ", L));
        //Console.Error.WriteLine("R: {0}", string.Join(" ", R));
        int i = 0, j = 0, k;
        long cnt = 0;
        do
        {
            k = i + j;
            //Console.Error.WriteLine("i: {0}, j: {1}, k: {2}", i, j, k);
            if(L[i] > R[j])
            {
                //Console.Error.WriteLine("L{0} R{1}", L[i], R[j]);
                A[left + k] = R[j++];
                cnt += llength - i;
            }
            else A[left + k] = L[i++];
        } while (k < llength + rlength - 1);
        //Console.Error.WriteLine("cnt: {0}", cnt);
        return cnt;
    }
}

Measured memory_bytes: 36208
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int h = sc.NextInt();
        int m = sc.NextInt();
        int h2 = sc.NextInt();
        int m2 = sc.NextInt();
        int k = sc.NextInt();

        int mm1 = h * 60 + m;
        int mm2 = h2 * 60 + m2;

        Console.WriteLine(mm2 - mm1 - k);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27544
#include <iostream>
#include <vector>
#include <functional>
using namespace std;
using ll = long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;

int main()
{
    ll N, M;
    cin >> N >> M;
    if (N == 1 && M == 1)
        cout << 1 << endl;
    else if (N == 1)
    {
        cout << M - 2 << endl;
    }
    else if (M == 1)
    {
        cout << N - 2 << endl;
    }
    else
    {
        ll ans = N * M - 2 * (N - 1) - 2 * (M - 1);
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std;
    int main() {
       	int N;
       	cin>>N;
       	int d;
        vector<int> vec(N);
          	for(int i=0; i<N; i++){
           		cin>>d;
           		vec[i]=d;
           	}
           	sort(vec.begin(),vec.end());
          int a=(N/2)-1;
          int b=N/2;       
          int ans=vec[b]-vec[a];
           cout<<ans<<endl;
            }

Measured memory_bytes: 640
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

vector<int> primes = {2,  3,  5,  7,  11, 13, 17, 19, 23, 29, 31, 37, 41,
                      43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};

int f(int N, int p) {
  if (N < p) return 0;
  return N / p + f(N / p, p);
}

int main() {
  int N;
  while (cin >> N) {
    vector<ll> dp(76, 0);
    dp[1] = 1ll;
    for (int p : primes) {
      int e = f(N, p);
      vector<ll> ndp(76, 0);
      for (int k = 0; k <= e; k++) {
        for (int p = 1; p <= 75; p++) {
          if (p * (k + 1) > 75) break;
          ndp[p * (k + 1)] += dp[p];
        }
      }
      dp = ndp;
    }
    cout << dp[75] << endl;
  }
  return 0;
}


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

int main() {
    int a, b, C;
    double S, L, h, PI = acos(-1);

    cin >> a >> b >> C;
    S = a * b * sin(C * PI / 180) / 2;
    L = a + b + sqrt(pow(a,2) + pow(b,2) - 2 * a * b * cos(C * PI / 180));
    h = S * 2 / a;

    printf("%lf\n%lf\n%lf\n",S, L, h);

    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define len(x) (int)(x).size()
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define fast_io ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
typedef long long ll;
typedef long double ld;
using namespace std;

signed main(){
    int n;cin >> n;
    bool cant = 0;
    for(int i = 0 ; i < n; ++i){
        int x;cin >> x;
        if(x % 2 == 0){
            if(x % 3 && x % 5)cant = 1;
        }
    }
    if(cant)cout<<"DENIED";
    else cout<<"APPROVED";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String cards = s.next();
		while(!"-".equals(cards)){
			int num = s.nextInt();
			for(int i = 0;i < num;i++){
				int h = s.nextInt();
				String top = cards.substring(0,h);
				String under = cards.substring(h,cards.length());
				cards = under + top;
			}
			System.out.println(cards);
			cards = s.next();
		}
	}
	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 26532
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

int main () {
    
    int a, b, c; cin >> a >> b >> c;

    if(min(a, b) <=  c && c <= max(a,b)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    } 
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int N, M;
    read(N, M);
    vector<int> A(M);
    for(int i = 0; i < M; i++){
        read(A[i]);
    }
    for(int i = 0; i < M; i++){
        N -= A[i];
    }
    write(max(-1, N));
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 3668
import math

S = int(input())


X1 = 0
Y1 = 0
X2 = 10 ** 9
X3 = 1

Y3 = math.ceil(S / (10 ** 9))
Y2 = X2 * Y3 - S

print(X1, Y1, X2, Y2, X3, Y3)


Measured memory_bytes: 2940
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#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<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi   = vec<int>;
using vvi  = vec<vi>;
using vvvi = vec<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n;cin>>n;
  vi l(n);
  rep(i,n)cin>>l[i];
  sort(all(l));
  ll ret = 0;
  rep(i,n){
    rep(j,i+1,n){
      int a = l[i];
      int b = l[j];
      // we need a-b < c, b-a < c => abs(a-b)<c
      // we also need c<a+b
      auto it1 = upper_bound(l.begin()+j+1, l.end(), (int)abs(a-b));
      auto it2 = lower_bound(l.begin()+j+1, l.end(), a+b);
      ret += max(0,(int)(it2-it1));
      //dump(l[i],l[j],(int)(it2-it1));
      //if(it1!=l.end()) dump(*it1);
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3628
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
using namespace boost::multiprecision;  
using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

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

    int n,r;
    cin >> n >> r;

    if(n >= 10){
        cout << r << '\n';
    }else{
        cout << r + 100 * (10 - n) << '\n';
    }

    return 0;
}


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

using namespace std;
int main(){
  int n,q;
  cin>>n;
  cin>>q;

  string name[n];
  int work[n]={0},time=0,v[n]={0},c=0,g=0;

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

  while(1){
    for(int i=0;i<n;i++){
      if(v[i]==0){
        if(c==n-1){
          cout<<name[i]<<" "<<time+work[i]<<"\n";
          g=1;
          break;
        }
	      if(work[i]-q<=0){
	        time=time+work[i];
	        cout<<name[i]<<" "<<time<<"\n";
	        v[i]=1;
          c++;
	      }
	      else{
	        time=time+q;
	        work[i]=work[i]-q;
	      }
      }
    }
    if(c==n) break;
    if(g==1) break;
  }

  return 0;
}


Measured memory_bytes: 6176
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int factorial(int n){
    if(n == 1) return 1;
    return n * factorial(n-1);
}
 
int main() {
    //input
 
    int N;
    cin >> N;
    int C[N][2];
    rep(i,N){
        cin >> C[i][0] >> C[i][1];
    }
    double D[8][8];
    rep(i,N){
        rep(j,N){
            D[i][j] = sqrt(pow(abs(C[i][0]-C[j][0]),2) +pow(abs(C[i][1]-C[j][1]),2));
        }
    }
    double result = 0;
    vector<int> A;
    rep(i,N) A.emplace_back(i);
    do {
        for(int i=1;i<N;i++){
            result += D[A[i-1]][A[i]];
        }
    } while (std::next_permutation(A.begin(), A.end()));
 
    cout << setprecision(16) << result / factorial(N)  << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e3 + 10;

int dp[N][N];

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, m;
	cin >> n >> m;
	int a[n + 1], b[m + 1];
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for(int i = 1; i <= m; i++) {
		cin >> b[i];
	}
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			if(a[i] == b[j]) {
				dp[i][j] = (dp[i - 1][j - 1] + 1) % mod;
			}
			dp[i][j] = (dp[i][j] + dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + mod) % mod;
		}
	}
	cout << ((dp[n][m] + 1) % mod);

	return 0;
}

Measured memory_bytes: 31744
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.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long[] a = in.nextLongArray(3);
            long k = in.nextLong() % 2;

            if (k == 1) {
                long t0 = a[1] + a[2];
                long t1 = a[2] + a[0];
                long t2 = a[0] + a[1];

                a[0] = t0;
                a[1] = t1;
                a[2] = t2;
            }

            out.println(a[0] - a[1]);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(nextString());
        }

        public long[] nextLongArray(int n) {
            long[] res = new long[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21588
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Get a number from stdio and convert it
	//sc.Split(bufio.ScanWords)
	sc.Scan()

	//	num, e := strconv.Atoi(sc.Text())
	//	if e != nil {
	//		panic(e)
	//	}

	// Get some numbers from stdio and convert it
	sc.Scan()
	numString := strings.Split(sc.Text(), " ")

	dl := make([]int, len(numString))
	var err error

	for i := 0; i < len(dl); i++ {
		dl[i], err = strconv.Atoi(numString[i])
		if err != nil {
			panic(err)
		}
	}

	//	fmt.Println(dl)
	//	fmt.Println("num:", num)
	//	fmt.Println("dl:", dl)

	var sum int

	for i := 0; i < len(dl)-1; i++ {
		for j := i + 1; j < len(dl); j++ {
			sum += dl[i] * dl[j]
		}
	}

	fmt.Println(sum)
}

Measured memory_bytes: 640
n,k = gets.chomp.split(' ').map(&:to_i)
arr = gets.chomp.split(' ').map(&:to_i)
s = 0
k.times do
	m = arr.max
	s += m
	arr.each_with_index do |n, i|
		arr.delete_at(i) and break if n == arr.max
	end
end
puts s

Measured memory_bytes: 1788
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
using namespace std;

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

    int N;
    cin >> N;
    vector<int> x(N), y(N), h(N);
    tuple<ll, ll, ll> G = make_tuple(-1, -1, -1);
    REP(i, N) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] > 0)
            G = make_tuple(x[i], y[i], h[i]);
    }
    vector<tuple<ll, ll, ll>> ans;

    REP(i, 101) {
        REP(j, 101) {
            ll H   = get<2>(G) + abs(get<0>(G) - i) + abs(get<1>(G) - j);
            H      = max(H, 0LL);
            bool f = true;
            REP(k, N) {
                ll hb = H - abs(x[k] - i) - abs(y[k] - j);
                hb    = max(hb, 0LL);
                if (h[k] != hb)
                    f = false;
            }
            if (f == true) {
                ans.push_back(make_tuple(i, j, H));
            }
        }
    }

    if (ans.size() == 1) {
        cout << get<0>(ans[0]) << " " << get<1>(ans[0]) << " " << get<2>(ans[0])
             << endl;
    }

    return 0;
}

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

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

using namespace std;

int main() {
  int n;
  vector<int> r;

  while (true) {
    cin >> n;
    if (n == 0) break;
    int sum = 0;
    int max = -1;
    int min = 1001;
    REP(i, n) {
      int val;
      cin >> val;
      if (val > max) max = val;
      if (min > val) min = val;
      sum += val;
    }
    sum = sum - max - min;
    r.push_back((int)(sum / (n - 2)));
  }
  REP(i, r.size()) { cout << r[i] << endl; }
  return 0;
}



Measured memory_bytes: 3048
#include<iostream>

using namespace std;

int A[50];
int q;
int n;
bool solve(int i, int m)
{
	if (!m) return true;
	if (i >= n) return false;
	bool flag = solve(i+1, m) || solve(i+1, m-A[i]);
	return flag;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	cin >> q;
	while (q)
	{
		q--;
		int m;
		cin >> m;
		if (solve(0, m))
		{
			cout << "yes" << endl;
		}
		else
		{
			cout << "no" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
int main() {
 int N;
 cin>>N;
 vector<int>A(N);
 for(int i=0;i<N;i++){
     cin>>A[i];
 }
 for(int i=0;i<N;i++){
     if(A[i]%2==0){if(A[i]%5!=0&&A[i]%3!=0){cout<<"DENIED"<<endl;return 0;}
 }}
 cout<<"APPROVED"<<endl;
 return 0;}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

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

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    map<int, int> mp;
    REP(i, n){
        mp[a[i]]++;
    }

    bool flag = true;
    if(n%2 == 1 && mp[0] != 1) flag = false;
    for(int i = (n & 1 ? 2 : 1); i <= n/2*2; i += 2){
        if(mp[i] != 2) flag = false;
    }

    LL ans = 0;
    if(flag){
        ans = 1;
        REP(i, n/2) ans *= 2, ans %= MOD;
    }

    cout << ans << endl;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  cout << (N % 2 == 0 ? N : 2 * N) << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	vector<ll> a(x);
	vector<ll> b(y);
	vector<ll> c(z);
	vector<ll> d;
	for (int i = 0; i < x; i++){
		cin >> a[i];
	}
	for (int i = 0; i < y; i++){
		cin >> b[i];
	}
	for (int i = 0; i < z; i++){
		cin >> c[i];
	}
	sort(a.begin(), a.end(), greater<ll>());
	sort(b.begin(), b.end(), greater<ll>());
	sort(c.begin(), c.end(), greater<ll>());

	for (int i = 0; i < x; i++){
		for (int j = 0; j < y; j++){
			for (int l = 0; l < z; l++){
				if ((i+1)*(j+1)*(l+1) <= k) d.push_back(a[i]+b[j]+c[l]);
			}
		}
	}
	sort(d.begin(), d.end(), greater<ll>());
	for (int i = 0; i < k; i++){
		cout << d[i] << endl;
	}
	return 0;
 }



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

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

using namespace std;

int main() {
  while(1){
    string dir = "NESW";
    int64_t h,w,l;
    cin>>h>>w>>l;
    if(!h) break;
    vector<string> m(h+2,string(w+2,'#'));
    REP(i,h){
      string s;
      cin>>s;
      m[i+1] = "#"+s+"#";
    }
    h+=2; w+=2;
    int si,sj,sd;
    REP(i,h)REP(j,w)REP(k,4){
      if (m[i][j] == dir[k])
        tie(si,sj,sd) = make_tuple(i, j, k);
    }
    map<tuple<int,int,int>,int> olds;
    vector<tuple<int,int,int>> ov;
    int di[]={-1,0,1,0};
    int dj[]={0,1,0,-1};
    int cycle = 0;
    int offset = 0;
    while(1){
      olds[make_tuple(si,sj,sd)] = olds.size();
      ov.emplace_back(si,sj,sd);
      int ni=si+di[sd];
      int nj=sj+dj[sd];
      while(m[ni][nj] == '#'){
        ++sd;
        sd%=4;
        ni=si+di[sd];
        nj=sj+dj[sd];
      }
      si=ni;sj=nj;
      auto itr = olds.find(make_tuple(si,sj,sd));
      if(itr != end(olds)){
        ov.emplace_back(si,sj,sd);
        offset = itr->second;
        cycle = olds.size()+1 - offset;
        break;
      }
    }
    int li,lj,ld;
    if(l < offset){
      tie(li,lj,ld) = ov[l];
    }else{
      l -= offset;
      l %= cycle;
      tie(li,lj,ld) = ov[l+offset];
    }
    cout<<li<<' '<<lj<<' '<<dir[ld]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1640
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
5 10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
)");
#define cin input
#endif

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

	map<int, set<int>> e;
	REP (i, m)
	{
		int a, b;
		cin >> a >> b;
		e[--a].insert(--b);
	}

	ll r = 0;

	multiset<int> s;
	REP (i, n)
	{
		if (s.count(i))
		{
			++r;
			s.clear();
		}
		
		for (auto j : e[i])
			s.insert(j);
	}

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdio>

using namespace std;

vector<int> pre, in, post;
int n, pos;

int FindRoot(int key, int left, int right) {
    for (int i = left; i < right; ++i) {
        if (in[i] == key) {
            return i;
        }
    }

    return -1;
}

void ReBuild(int left, int right) {
    if (left >= right) {
        return;
    }

    int root = pre[pos++];
    int index = FindRoot(root, left, right);
    ReBuild(left, index);
    ReBuild(index + 1, right);
    post.push_back(root);
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        pre.push_back(x);
    }

    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        in.push_back(x);
    }

    ReBuild(0, n);

    for (int i = 0; i < post.size(); ++i) {
        if (i > 0) {
            cout << " ";
        }

        cout << post[i];
    }

    cout << endl;
    return 0;
}



Measured memory_bytes: 3224
from itertools import accumulate

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = [0] + list(accumulate(a))
sb = [0] + list(accumulate(b))

ans = 0
p = m
for i in range(n + 1):
    if sa[i] > k:
        break
    for j in range(p, -1, -1):
        if sa[i] + sb[j] <= k:
            p = j
            ans = max(ans, i + j)
            break
print(ans)


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

using namespace std;

int main() {
  string vowel("aiueo");
  char c;
  cin >> c;
  for (int i = 0; i < 5; ++i) {
    if (c == vowel[i]) {
      cout << "vowel" << endl;
      return 0;
    }
  }
  cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,t;int q,i,k,f;char c;
	cin>>s>>q;
	for(i=0;i<q;i++){
		cin>>k;
		if(k==1)swap(s,t);
		else{
			cin>>f>>c;
			if(f==1)t+=c;else s+=c;
		}
	}
	reverse(t.begin(),t.end());
	t+=s;
	cout<<t;
}


Measured memory_bytes: 1128
S=str(input())
ListNum=[]
ListNUm=[]
ListNUM=[]
for i in range(0,len(S),1):
  if i<len(S)-2:
    Num=100*int(S[i])+10*int(S[i+1])+int(S[i+2])
    NUm=Num-753
    NUM=NUm**2
    ListNum.append(Num)
    ListNUm.append(NUm)
    ListNUM.append(NUM)
posi=ListNUM.index(min(ListNUM))

if ListNUm[posi]<0:
  ListNUm[posi]=ListNUm[posi]*(-1)
print(ListNUm[posi])


Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N;
  cin >> N;
  map<pair<int, int>, int> mp;
  for (int i = 1; i <= N; i++) {
    string tmp = to_string(i);
    int first_keta = tmp[0] - '0';
    int last_keta = tmp.back() - '0';
    if (last_keta == 0) continue;
    pair<int, int> p_tmp = make_pair(first_keta, last_keta);
    if (mp.count(p_tmp)) {
      mp[p_tmp]++;
    } else {
      mp[p_tmp] = 1;
    }
  }
  debug(mp);
  int64 ans = 0;
  for (auto v : mp) {
    if (v.first.first == v.first.second) {
      ans += v.second;
      ans += v.second * (v.second - 1);
    } else {
      pair<int, int> rev = make_pair(v.first.second, v.first.first);
      if (mp.count(rev)) {
        ans += v.second * mp[rev];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  for(int i=0; i<n; i++){
    int xn;
    cin >> xn;
    x=max(x, xn);
  }
  for(int i=0; i<m; i++){
    int yn;
    cin >> yn;
    y=min(y, yn);
  }
  if(x<y)cout << "No War";
  else cout << "War";
  return 0;
}

Measured memory_bytes: 760