akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int n;
map <int,int> occ;
priority_queue <int> pq;
int main()
{
	scan(n);
	while(n--)
	{
		int input;
		scan(input);
		occ[input]++;
		if((occ[input]&1)==0)
			pq.push(input);
	}
	if(pq.size()>=2)
	{
		int temp=pq.top();pq.pop();
		cout<<(LL) temp*pq.top()<<endl;
	}
	else
		cout<<"0"<<endl;
}

Measured memory_bytes: 4992
while True:

    try:
        a,b,c,d,e,f = (float(x) for x in input().split())
        x = (c * e - b * f) / (a * e - b * d)
        y = (c * d - a * f) / (b * d - a * e)
        
        if x == 0: x = 0
        if y == 0: y = 0
        print(format(x, ".3f"), format(y, ".3f"))

    except EOFError:
        break


Measured memory_bytes: 5592
import std.stdio, std.algorithm, std.string, std.conv, std.array;

int read_num() {return readln.chomp.to!(int);}

void main() {
  while(true) {
    int[] line = readln.chomp.split(" ").map!(to!(int)).array;
    int times = line[0];
    int len = line[1];
    int[] arr;

    if (times == 0 && len == 0) break;
  
    foreach(t; 0..times)
      arr ~= read_num;

    int max, sum;
    int next = 0;
    foreach(x; arr[0..len])
      max += x;
    sum = max;
    
    foreach(int i, x; arr[len..times]) {
      sum += x;
      sum -= arr[i];
      if (sum > max) max = sum;
    }
    writeln(max);
  }
}

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

vector<ll> fct, invfct;

ll mod_pow(ll n, ll p, ll mod){
    // 繰り返し二乗法で (n^p) % mod を求める
    if(p==0) return 1;
    ll res = mod_pow(n*n%mod, p/2, mod);
    if(p%2==1) res = res * n % mod;
    return res;
}

ll calc(ll x, ll n, ll mod){
    if(x==0 || x + n - 1 >= mod){
        // (2-a) の場合
        return 0;
    }else{
        // (2-b) の場合
        return fct[x+n-1]*invfct[x-1] % mod;
    }
}

int main(){
    int Q;  cin >> Q;
    ll mod = 1000003;

    // mod-1 までの階乗を求める。
    fct = vector<ll>(mod,1);
    for(int i=1; i<mod; i++){
        fct[i] = fct[i-1] * i % mod;
    }

    // mod-1 までの階乗の逆数を求める。
    invfct = vector<ll>(mod,1);
    invfct[mod-1] = mod_pow(mod-1, mod-2, mod);
    for(int i=mod-2; i>=1; i--){
        invfct[i] = invfct[i+1]*(i+1) % mod;
    }
    
    while(Q--){
        ll x, d, n;  cin >> x >> d >> n;
        if(d==0){
            // (1) の場合。 x^n を計算する。
            cout << mod_pow(x, n, mod) << endl;
        }else if(d==1){
            // (2) の場合。
            cout << calc(x, n, mod) << endl;
        }else{
            // (3) の場合。
            // x を x/d の mod で置き換えて(2)の計算をし、最後に d^n を掛ける。
            x = x * mod_pow(d, mod-2, mod) % mod;
            cout << mod_pow(d, n, mod)*calc(x, n, mod) % mod << endl;
        }
    }
}


Measured memory_bytes: 16512
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
map<lint,int> me;
vector<lint> so;
bool go[1001001];
lint mo=1000000007;
lint extgcd(lint a, lint b, lint &x, lint &y) {
  lint g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
lint invMod(lint a, lint m) {
  lint x, y;
  if (extgcd(a, m, x, y) == 1) return (x + m) % m;return 0;
}
lint zyo(lint x,lint y){
    lint ret=1,a=x;
    while(y>0){
    	if(y%2==1) ret=(ret*a)%mo;
    	a=(a*a)%mo;y/=2;
    }
    return ret;
}
int main()
{
	memset(go,false,sizeof(go));
	REP(i,2,1001000){
		if(go[i]) continue;
		so.pb(i);
		for(int j=i+i;j<1001000;j+=i) go[j]=true;
	}
	lint sum=0,a;
	int n;cin>>n;
	rep(i,n){
		cin>>a;sum+=invMod(a,mo);sum%=mo;
		rep(j,(int)so.size()){
			if(so[j]*so[j]>a) break;
			int x=0;
			while(a%so[j]==0){
				a/=so[j];x++;
			}
			me[so[j]]=max(me[so[j]],x);
		}
		if(a>1) me[a]=max(me[a],1);
	}
	//cout<<sum<<endl;
	map<lint,int>::iterator it=me.begin();
	while(it!=me.end()){
		//cout<<zyo((*it).fi,(*it).se)<<endl;
		sum*=zyo((*it).fi,(*it).se);sum%=mo;
		it++;
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 2424
import java.util.Scanner;

public class Main {
    Scanner sc = new Scanner(System.in);
    int INF = Integer.MAX_VALUE / 2;

    void solve() {
        int N = sc.nextInt();

        int[][] mat = new int[N][N];
        boolean all_dot = true;
        for (int i = 0; i < N; ++i) {
            String line = sc.next();
            for (int j = 0; j < N; ++j) {
                if (line.charAt(j) == '#') {
                    mat[i][j] = 1;
                    all_dot = false;
                } else {
                    mat[i][j] = 0;
                }
            }
        }

        if (all_dot) {
            System.out.println(-1);
            return;
        }

        int not_filled_column = N; // 埋まっていない列
        for (int i = 0; i < N; ++i) {
            boolean flag = true;
            for (int j = 0; j < N; ++j) {
                if (mat[j][i] == 0) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                not_filled_column--;
            }
        }

        int ans = INF;
        for (int i = 0; i < N; ++i) {
            boolean all_dots_column_i = true;
            for (int j = 0; j < N; ++j) {
                if (mat[j][i] == 1) all_dots_column_i = false;
            }

            int dots = 0;
            for (int j = 0; j < N; ++j) {
                if (mat[i][j] == 0) {
                    dots++;
                }
            }
            int cand = dots + not_filled_column;
            if (all_dots_column_i) cand++;
            if (ans > cand) {
                ans = cand;
            }

        }

        if (ans == INF) {
            System.out.println(-1);
            return;
        }
        System.out.println(ans);


    }

    public static void main(String[] args) {
        new Main().solve();
    }
}


Measured memory_bytes: 28116
#include <iostream>

using namespace std;

bool table[21][21];

int main()
{
    int n;
    while (cin >> n, n) {
        // prepare
        fill_n((bool *)table, 21*21, false);
        for (int i = 0; i < n; i++) {
            int x, y;
            cin >> x >> y;
            table[y][x] = true;
        }

        // search
        int m;
        cin >> m;
        int x = 10, y = 10;
        for (int i = 0; i < m; i++) {
            char d;
            int l;
            cin >> d >> l;
            int dx, dy;
            switch(d){
                case 'N':
                    dx = 0;
                    dy = 1;
                break;
                case 'E':
                    dx = 1;
                    dy = 0;
                break;
                case 'W':
                    dx = -1;
                    dy = 0;
                break;
                case 'S':
                    dx = 0;
                    dy = -1;
                break;
            }
            for (int i = 1; i <= l; i++) {
                x += dx;
                y += dy;
                table[y][x] = false;
            }
        }

        // output
        bool yes = true;
        for (int j = 0; j < 21; j++) {
            for (int i = 0; i < 21; i++) {
                yes = yes && !table[j][i];
            }
        }
        if (yes) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3080
#include <stdio.h>
int main()
{
    char a[10];
    int z = 0;
    
    
    
    for(int i=0;i>=0;i++)
    {
        scanf("%s\n" ,&a[i]);
        
        if(a[i] == '+')
        {
            z++;
        }
        else
        {
            z--;
        }
        
        
        
        if(a[i] == '\0')
        {
            z++;
            break;
        }
        
    }
    
    printf("%d\n" ,z);
    
}


Measured memory_bytes: 128
s = input()
t = input()
ans = 0
num0, num1 = len(s), len(t)

for i in range(num0-num1+1):
    count = 0
    for j in range(i, num1+i):
        if s[j] == t[j-i]:
            count += 1
    ans = max(count, ans)
print(len(t)-ans)




Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int a = N / 1000;
  int b = (N - a * 1000) / 100;
  int c = (N - a * 1000 - b * 100) / 10;  
  int d = (N - a * 1000 - b * 100 - c * 10);
  
  if ((a == b) && (b == c) || (b == c) && (c == d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(long long i = 0;i < n;++i)
#define FOR(i,a,b) for(long long i = a;i < b;++i)
using namespace std;
using ll = long long;
using point = pair< int,int >;

int data[3][101];

int main(){
    int d,n;
    scanf("%d%d", &d, &n);
    if (d == 0) {
        if (n == 100) puts("101");
        else printf("%d\n", n);
    } else if (d == 1) {
        if (n == 100) puts("10100");
        else printf("%d\n", n * 100);
    } else {
        if (n == 100) puts("1010000");
        else printf("%d\n", n * 10000);
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;

int main(int argc, char *argv[])
{
    int n;
    std::cin >> n;

    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    /*
    std::vector<int> b;
    for (int i = 0; i < n; i++) {
        int temp = a[i]; 
        b.push_back(a[i]);
        std::reverse(b.begin(), b.end());
    }
    
    for (int i = 0; i < b.size(); i++) {
        std::cout << b[i] << " ";
    }
    */

    std::vector<int> b(n);
    for (int i = 0; i < n; i++) {
        if (n % 2 == 0) {
            if (i % 2 == 0) {
                b[n/2+i/2] = a[i];
            } else {
                b[n/2-1-i/2] = a[i];
            }
        } else {
            if (i == 0) {
                b[n/2] = a[i];
            } else if (i % 2 == 0) {
                b[n/2-i/2] = a[i];
            } else {
                b[n/2+1+i/2] = a[i];
            }
        }
    }

    for (int i = 0; i < b.size(); i++) {
        std::cout << b[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

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

    int a[12] = {1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049};
    vector<int> dp(N + 1, INF);
    dp[0] = 0;

    rep(i, N + 1) {
        if (dp[i] != INF) {
            rep(j, 12) {
                if (i + a[j] <= N)
                    dp[i + a[j]] = min(dp[i + a[j]], dp[i] + 1);
            }
        }
    }

    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 640
import math
n = int(input())
root_n = math.ceil(math.sqrt(n))
f = []
for i in range(1,root_n+1):
  if n % i == 0:
    f_pair = max(len(str(int(i))),len(str(int(n/i))))
    f.append(f_pair)
mini = min(f)
print(mini)


Measured memory_bytes: 3060
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
# import numpy as np
from fractions import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7


def inp(): return int(sys.stdin.readline())


def inp_list(): return list(map(int, sys.stdin.readline().split()))


def lcm(x, y): return (x * y) // gcd(x, y)


N = inp()
# a = np.zeros((N, 3), dtype=int)
a = [0] * N

for i in range(N):
    a[i] = inp_list()

# dp[i + 1][j]: i日目までの活動で、i日目に活動 j (0: A, 1: B, 2:C) を選んだときの i + 1 日目の幸福の最大値
# dp = np.zeros((N + 1, 3), dtype=int)
dp = [[0] * 3 for _ in range(N + 1)]
for i in range(N):
    for j in range(3): # i 日目の活動
        for k in range(3): # i + 1 日目の活動
            if j == k: continue
            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k])

ans = 0
for i in range(3):
    ans = max(ans, dp[N][i]) # N 日目を終了したときの幸福度 => dp[N][] (N + 1 番目)

# print(a)
# print(dp)
print(ans)


Measured memory_bytes: 91336
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if (500 * a) + (100 * b) + (50 * c) == X:
                cnt += 1

print(cnt)


Measured memory_bytes: 2940
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <limits>
#include <vector>
#include<functional>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define print_double(val,a) cout << fixed << setprecision(a) << val << endl;
ll mod = 1e9 + 7;
int par[100010];
int rank1[100010];

vector<pair<int, int>>G[100005];
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		rank1[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) { return x; }
	return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) { return; }
	if (rank1[x] < rank1[y]) { par[x] = y; }
	else {
		par[y] = x; if (rank1[x] == rank1[y]) { rank1[x]++; }
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int>p(n);
	vector<int>x(m);
	vector<int>y(m);
	for (int i = 0; i < n; i++) {
		cin >> p[i]; p[i]--;
	}
	for (int i = 0; i < m; i++) {
		cin >> x[i] >> y[i];
	}
	init(n);
	rep(i, m) { unite(x[i] - 1, y[i] - 1); }
	rep(i, n) {
		G[find(i)].push_back(pair<int,int>(p[i], i));
	}
	int ans = 0;
	rep(i, n) {
		vector<int>v1, v2;
		rep(j, G[i].size()) {
			v1.push_back(G[i][j].first);
			v2.push_back(G[i][j].second);
		}
		Sort(v1);
		Sort(v2);
		rep(j, v1.size()) {
			if (binary_search(v2.begin(), v2.end(), v1[j]))ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7680
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void)
{
    int N;
    long long int *A;
    long long int ans = 1;
    double dA;
    double dans;
    char temp[30];
    char temp2[30];
    int c;
    scanf("%d", &N);
    A = (long long int *)malloc(sizeof(long long int) * N);
    for (c = 0; c < N; ++c)
    {
        scanf("%lld", A + c);
        if (A[c] == 0)
        {
            printf("0");
            return 0;
        }
    }
    for (c = 0; c < N; ++c)
    {
        sprintf(temp, "%lld", A[c]);
        sprintf(temp2, "%lld", ans);
        sscanf(temp, "%lf", &dA);
        sscanf(temp2, "%lf", &dans);
        if (log10(dA * dans) > 19)
        {
            printf("-1");
            return 0;
        }
        ans *= A[c];
        if (ans > (long long)1e+18)
        {
            printf("-1");
            return 0;
        }
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 3332
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
void out(vector <lli>& v) {
	for (lli i :  v) {
		cout << i << " ";
	}
	cout << endl;
}
void solve() {
	lli n, k;
	cin >> n >> k;
	vi v(n);
	for (lli i = 0; i < n; i++) {
		cin >> v[i];
		v[i]--;
	}
	vector <lli> x;
	map <lli, lli> visited;
	lli curr = 0;
	while (k > 0) {
		k--;
		if (visited[curr] > 2) {
			k++;
			break;
		}
		visited[curr]++;
		if (visited[curr] == 2)
			x.push_back(curr);
		curr = v[curr];
	}

	//out(x);
	if (k == 0) {
		cout << curr + 1 << endl;
	} else {
		//cout << k << " " << x.size() << endl;
		cout << x[k % x.size()] + 1 << endl;
	}

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

Measured memory_bytes: 14796
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace atcoder;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int64_t n;
    std::cin >> n;
    n *= 2;
    
    std::vector<int64_t> p;
    int64_t x = n;
    for (int64_t i = 2; i * i <= x; ++i) {
        if (x % i == 0) {
            int64_t v = 1;
            while (x % i == 0) {
                x /= i;
                v *= i;
            }
            p.push_back(v);
        }
    }
    if (x > 1)
        p.push_back(x);
    
    int64_t ans = n;
    
    std::function<void(int, int64_t)> dfs = [&](int x, int64_t a) {
        if (x == int(p.size())) {
            int64_t b = n / a;
            int64_t y = a - inv_mod(b, a);
            ans = std::min(ans, b * y);
            return;
        }
        dfs(x + 1, a);
        dfs(x + 1, a * p[x]);
    };
    dfs(0, 1);
    
    std::cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 3692
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

#include<unistd.h>
template <int size>
struct Buffer{
    int idx = 0;
    char buf[size];
    Buffer(){
        read(0, buf, size);
    }
    int next(){
        int ret = 0;
        while(!isdigit(buf[idx])){ idx++; }
        while(isdigit(buf[idx])){ ret = ret * 10 + buf[idx++] - '0'; }
        return ret;
    }
};
struct FastInput {
    Buffer<1 << 22> buf;
    template <class T>
    FastInput& operator >> (T& num) { num = buf.next(); return *this; }
    void tie(int){ }
    template <class S, class T>
    friend FastInput& operator >> (FastInput& in, pair<S, T>& p){ return in >> p.first >> p.second; }
    template <class T>
    friend FastInput& operator >> (FastInput& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
};
FastInput fin;
#define cin fin

enum { SIZE = 1 << 20 };
char buf[SIZE];
int accs[512][512];
pair<int, int> pqs[100000];
int main(){
    int n, m, q;
    cin >> n >> m >> q;
    for(int i = 0; i < m; i++){
        int l, r;
        cin >> l >> r;
        accs[0][r]++;
        accs[l + 1][r]--;
    }
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            accs[i + 1][j] += accs[i][j];
            accs[i][j] += accs[i][j - 1];
        }
    }
    int idx = SIZE;
    for(int i = 0; i < q; i++){
        cin >> pqs[i].first >> pqs[i].second;
    }
    for(int i = q - 1; i >= 0; i--){
        int p = pqs[i].first, q = pqs[i].second;
        buf[--idx] = '\n';
        div_t num2;
        num2.quot = accs[p][q];
        do{
            num2 = div(num2.quot, 10);
            buf[--idx] = num2.rem + '0';
        }while(num2.quot);
    }
    write(1, buf + idx, SIZE - idx);
}


Measured memory_bytes: 6784
// Problem Code: abc160_a

#include <bits/stdc++.h>

using namespace std;

string A(string& S) {
	return (S[2] == S[3] && S[4] == S[5]) ? "Yes" : "No";
}

int main() {
	string S;
	cin >> S;
	cout << A(S);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>

int main(void){
    int flag = false;
    char a[101];
    scanf("%s", a);
    for (int i = 0; i < 99; i++){
        if (a[i] != 'L' && a[i] != 'R' && a[i] != 'U' && a[i] != 'D'){
            break;
        }
        if (a[i] == 'L'){
            flag = true;
            break;
        }
        i++;
        if (a[i] == 'R'){
            flag = true;
            break;
        }
    }
    if (flag){
        puts("No");
    } else {
        puts("Yes");
    }

}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, M; cin >> N >> M;

    ll K; cin >> K;
    ll A[N], B[M]; F0R(i, N) cin >> A[i];
    F0R(i, M) cin >> B[i];

    ll as = 0; F0R(i, N) as += A[i];
    ll bs = 0;
    int bp = 0;
    int ans = 0;
    F0Rd(i, N+1) {
        if (i < N) as -= A[i];
        if (as <= K) {
            while (bp < M && as + bs + B[bp] <= K) {
                 bs += B[bp]; bp++;
            }
            ckmax(ans, i + bp);
        }
//        cout << as << " " << bs << " " << bp << nl;
    }
    cout << ans << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 6708
n = int(input())
a = [0]*10**4
ans = 0
for i in range(1, 101):
  for j in range(1, min(i+1,101)):
    for k in range(1, min(j+1, 101)):
       if (i+j+k)**2-i*j-j*k-k*i <= 10**4:
          p = (i+j+k)**2-i*j-j*k-k*i
          if i==j==k:
             a[p-1] +=1
          elif i != j and j != k:
             a[p-1] +=6
          else:
             a[p-1] +=3
for q in a[:n]:
  print(q)
    

Measured memory_bytes: 9460
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
   int n;
   cin >> n;
   printf("%.8f\n",double(n/2+n%2)/n);
   
   
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  int a[n][10];
  REP(i,n){
    REP(j,10){
      int b;
      cin >> b;
      a[i][j] = b;
    }
  }
  int flag[n] = {0};
  REP(i,n){
    stack <int> b;
    stack <int> c;
    b.push(a[i][0]);
    for(int j = 1;j < 10;j++){
      if(b.top() < a[i][j]){
	b.push(a[i][j]);
      }
      else{
	if(c.empty()){
	  c.push(a[i][j]);
	}
	else if(c.top() < a[i][j]){
	  c.push(a[i][j]);
	}
	else{
	  flag[i] = 1;
	}
      }
    }
  }

  REP(i,n){
    if(flag[i] == 1){
      cout << "NO" << endl;
    }
    else{
      cout << "YES" << endl;
    }
  }

}

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

typedef long long ll;

int n,k;
int p[5005],c[5005],ir[5005],rc,rl[5005],vis[5005];
stack<int> st;
ll rs[5005],ans=-1e9;

void dfs(int x){
    vis[x]=1;
    st.push(x);
    if(!vis[p[x]]){
        dfs(p[x]);
    }else{
        rc++;
        while(st.top()!=p[x]){
            ir[st.top()]=rc;
            rl[rc]++;
            rs[rc]+=c[st.top()];
            st.pop();
        }
        ir[p[x]]=rc;
        rl[rc]++;
        rs[rc]+=c[p[x]];
        st.pop();
    }
}

bool u[5005][10005];
ll dp[5005][10005];
int dial;

ll calc(int x,int y){dial++;
    if(y==0)return 0;
    if(ir[x]){
        ll pre=0;
        if(y>rl[ir[x]]){
            pre+=max(0ll,(y-rl[ir[x]])/rl[ir[x]]*rs[ir[x]]);
            y-=(y-rl[ir[x]])/rl[ir[x]]*rl[ir[x]];
        }
        if(u[x][y])return dp[x][y];
        u[x][y]=1;
        return dp[x][y]=max(0ll,calc(p[x],y-1))+c[x]+pre;
    }else{
        return max(0ll,calc(p[x],y-1))+c[x];
    }
}

int main(){

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

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>p[i];
    }
    for(int i=1;i<=n;i++){
        cin>>c[i];
    }
    for(int i=1;i<=n;i++)if(!vis[i])dfs(i);
    for(int i=1;i<=n;i++){
        ans=max(ans,calc(i,k));
    }
    cout<<ans<<endl;
    cerr<<"TOT: "<<dial<<endl;

    return 0;
}

Measured memory_bytes: 443804
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;

int a,b;
char field[16][16];

class Info{
public:
	int x,y;
};

int bfs(void){
	queue<Info> q;
	Info tmp = {0,0};
	int dx[4] = {0,1}, dy[4] = {1,0};
	int ans = 0;

	q.push(tmp);
	while(!q.empty()){
		tmp = q.front(); q.pop();

		if(tmp.x==a-1 && tmp.y==b-1){
			ans++;
			continue;
		}

		for(int i=0;i<2;i++){
			int nx = tmp.x + dx[i];
			int ny = tmp.y + dy[i];

			if(0<=nx && nx<a && 0<=ny && ny<b && field[ny][nx]){
				Info tmp2 = {nx,ny};
				q.push(tmp2);
			}
		}
	}

	return ans;
}

int main(void){
	int i,j,n,x,y;

	while(cin>>a>>b && (a || b)){
		cin>>n;
		memset(field,1,sizeof(field));

		while(n--){
			cin>>x>>y;
			field[y-1][x-1] = 0;
		}

		cout<<bfs()<<endl;
	}

	return 0;
}

Measured memory_bytes: 7164
#include<stdio.h>

int money=100000;

int count5p(int);
int kill1000(void);

int main(){
  int n, i;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    money+=count5p(money);
    money=kill1000();
  }

  printf("%d\n",money);
  
  return 0;
}

int count5p(int money){
  return money/100*5;
}

int kill1000(void){
  if(money-money/1000*1000>0) return money/1000*1000+1000;
  else return money/1000*1000;
}



Measured memory_bytes: 2076
#include <stdio.h>

inline static int gl(void){
    int x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

inline static void pl(unsigned short s){
    char str[5];
    int pos=4;
    if(s==0){
        putchar_unlocked('0');
        return;
    }
    do{
        str[pos]=s%10+48;
        s/=10;
        pos--;
    }while(s!=0);
    for(pos++; pos<5; pos++){
        putchar_unlocked(str[pos]);
    }
}

typedef struct{
    int y;
    int x;
} pos_t;

char a[512];
unsigned short out[4*512*512];

int main(void){
    int h=gl(), w=gl();
    char haveCoin = 0;
    int pos = 0;
    short old_y, old_x;
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            int t = getchar_unlocked() - 48;
            getchar_unlocked();
            a[j] = t;
        }
        if(i%2==1){
            for(int j=1; j<=w; j++){
                if(haveCoin){
                    out[4*pos+0]=old_y;
                    out[4*pos+1]=old_x;
                    out[4*pos+2]=i;
                    out[4*pos+3]=j;
                    pos++;
                }
                haveCoin ^= a[j]&1;
                old_y = i;
                old_x = j;
            }
        }else{
            for(int j=w; j>0; j--){
                if(haveCoin){
                    out[4*pos+0]=old_y;
                    out[4*pos+1]=old_x;
                    out[4*pos+2]=i;
                    out[4*pos+3]=j;
                    pos++;
                }
                haveCoin ^= a[j]&1;
                old_y = i;
                old_x = j;
            }
        }
    }
    printf("%d\n", pos);
    for(int i=0; i<pos; i++){
        pl(out[4*i+0]); putchar_unlocked(' ');
        pl(out[4*i+1]); putchar_unlocked(' ');
        pl(out[4*i+2]); putchar_unlocked(' ');
        pl(out[4*i+3]); putchar_unlocked('\n');
    }
    return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define M 100007
using namespace std;
int w[M];
int n,k;
bool ok(int min_val){
	int i;
	int cars = 0;
	for(i = 0; i < n;){
		if(w[i]==min_val){
			cars++;
			i++;
		} else{
			int tmp = w[i];
			int k;
			for(k = i+1;k<n;k++){
				if(tmp+w[k]<=min_val) {
					tmp+=w[k];
				}else{
					break;
				}
			}
			i = k;
			cars++;
		}
	}
	
	if(cars>k) return false;
	return true;
}
int main(){
	cin >> n >> k;
	int i;
	int max_val = INT_MIN;
	int sum = 0;
	for(i = 0; i < n; i++){
		cin >> w[i];
		if(w[i]>max_val){
			max_val = w[i];
		}
		sum += w[i];
	}
	
	int min_val = max_val;
	int head = min_val;
	int end = sum;
	
	
	int mid = (head+end)/2;
	
	while(head<end){
		int a = ok(mid);
		int b = ok(mid+1);
		if(a == 1 && b==1){
			end = mid;
		}
		if(a == 0 && b==0){
			head= mid+1;
		}
		if(a==0 && b==1){
			min_val = mid+1;
			break;
		}
		mid = (head+end)/2;
	}
		
	
	cout << min_val << endl;
	return 0;
	
	
}


Measured memory_bytes: 3484
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N , K ; cin >> N >> K;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];

  vector<ll> score;
  map<ll,ll> m;
  ll tmp = 1;

  /*
  ll minans = 1;
  if(K < 1e6){
    rep(i,K){
      minans = a[minans - 1];
    }
    cout << minans << endl;
    return 0;
  }
  */
  ll ka = K;
  while(1){
    ka --;
    tmp = a[tmp - 1];
    if(ka == 0){
      cout << tmp << endl;
      return 0;
    }
    // tmpは新たな数字
    score.pb(tmp);
    m[tmp]++;
    if(m[tmp] > 1) break;
  }
  // scoreができている
  ll rank = score[score.size() - 1];
  score.pop_back();
  // cout << rank << endl;
  ll start = 0;
  rep(i,score.size()){
    if(score[i] == rank) start = i;
  }
  // cout << start << " " << score.size() << endl;

  ll cir = score.size() - start;

  // startは操作後の回数を保存している 1-index
  // startが1のとき残り操作は
  ll mar = (K - start) % cir;
  // cout << mar << endl;
  if(mar == 0) cout << score.back() << endl;
  else cout << score[start + mar - 1] << endl;
}


Measured memory_bytes: 15980
#include <iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<numeric>
using namespace std;
int main() {
	long long  a = 0, b = 0, x = 0, max = 0;
	long long  n = 0, ans = 0, k = 0;
	long long left = 0, right = 0;
	string s, t, u,now;
	vector<double> z(3,0), zz,count,countc;
	vector<string>ss;
	vector<long long int>::iterator position;
	bool q = false;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s;
		ss.push_back(s);
		
	}
	sort(ss.begin(), ss.end());
	int i = 0;
	for (auto x : ss) {
		if (k != 0) {
			if (count.at(k - 1) >= max)max = count.at(k - 1);
		}
		if (ss.at(i) != now) {
			k++;
			now = ss.at(i);
			count.push_back(1);
		}
		else {
			count.at(k - 1)++;
		}
		if (k != 0) {
			if (count.at(k - 1) >= max)max = count.at(k - 1);
		}
		i++;
	}
	ss.erase(unique(ss.begin(), ss.end()), ss.end());
	now = "";
	i = 0;
	for (; i < k; i++) {
		if (count.at(i) == max) {
			cout << ss.at(i) << endl; 
			now = count.at(i);
		}
		
	}
	
}

Measured memory_bytes: 15984
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5;
int a[maxn][3];
int dp[maxn][3];

int main()
{
    int n;
    cin >> n;
      dp[0][0]=0;
        dp[0][1]=0;
        dp[0][2]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<3;j++)
        {
          cin >> a[i-1][j];
        }

        dp[i][0]=a[i-1][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i-1][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i-1][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout << max(dp[n][0],max(dp[n][1],dp[n][2]));
    return 0;
}


Measured memory_bytes: 2560
n = int(input())
a_list = list(map(int, input().split()))
ans = 1
for i in a_list:
  ans *= i
  if ans > 1000000000000000000:
    break

if ans > 1000000000000000000 and 0 not in a_list:
              print("-1")
elif 0 in a_list:
              print(0)
else:
              print(ans)

Measured memory_bytes: 21660
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    m,d = LI()
    ans = 0
    for i in range(1,m+1):
        for j in range(1,d+1):
            d1 = j%10
            d2 = j//10
            if d1 >= 2 and d2 >= 2 and d1*d2 == i:
                ans += 1
    print(ans)
    return

#B
def B():
    def add(i):
        while i <= m:
            bit[i] += 1
            i += i&-i

    def sum(i):
        res = 0
        while i > 0:
            res += bit[i]
            i -= i&-i
        return res

    n,k = LI()
    m = 2000
    a = LI()
    bit = [0]*(m+1)
    ans = 0
    for i in range(n):
        ans += (i-sum(a[i]))*k
        add(a[i])
    inv = pow(2,mod-2,mod)
    for i in range(n):
        ans += sum(a[i]-1)*k*(k-1)*inv%mod
    print(ans%mod)
    return

#C
def C():
    n = I()
    s = S()
    if "W" in (s[0],s[-1]):
        print(0)
        return

    return

#D
def D():
    n = I()
    m = n.bit_length()
    v = [[0]*n for i in range(n)]
    for i in range(n):
        for j in range(n):
            k = i^j
            for l in range(m):
                if k&(1<<l):
                    v[i][j] = l+1
                    break
    for i in range(n-1):
        print(*v[i][i+1:])
    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 49116
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int cpw = b + 7 * a;
            int ws = c / cpw;
            int rc = c - cpw * ws;
            int ds = rc / a;
            int rm = rc - a * ds;
            if (rm > 0) {
                ds++;
            }
            int days = ws * 7 + ds;
            if (b > 0 && ds > 7) {
                int wd = (ws + 1) * 7;
                if (days > wd) {
                    days = wd;
                }
            }
            System.out.println(String.format("%d", days));
        }
    }
}



Measured memory_bytes: 26416
# abc_111_a

def transform (bango):
    if bango == "1":
        return "9"
    elif bango == "9":
        return "1"
    else:
        return bango

def solve(string):
    return "".join(list(map(transform, string)))

if __name__ == "__main__":
    string = input("")
    print (solve(string))


Measured memory_bytes: 2940
H, W = map(int, input().split())
a = [list(input().split(" ")) for _ in range(H)]
dp = [[-1] * (W + 1) for _ in range(H + 1)]

#print(a)

def f(y, x):
    if dp[y][x] != -1:
        return dp[y][x]
    res = 0
    if x == W:
        res = f(y + 1, x)
    elif y == H:
        res = f(y, x + 1)
    else:
        res = f(y, x + 1) + f(y + 1, x)
    dp[y][x] = res
    return res


dp[H][W] = 1
for i in reversed(range(1, H + 1)):
    for j in reversed(range(1, W + 1)):
        #print(i, j)
        if a[i-1][0][j-1] == '#':
            dp[i][j] = 0
        else:
            f(i, j)
print(dp[1][1]%1000000007)


Measured memory_bytes: 260952
N, K  = map(int, input().split())
M = 10 ** 9 + 7

C = [[0 for j in range(N+3)] for i in range(N+3)]
C[1][1] = 1

for i in range(2, N+2):
    for j in range(1, i+2):
        C[i][j] = C[i-1][j] + C[i-1][j-1]

for i in range(1, K+1):
    print(C[N-K+2][i+1] * C[K][i] %  M)


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

int main(){
	ll a;
	cin >> a;
	ll ans = a + a*a + a*a*a;
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
def absdiff(a, b):
    return abs(b - a)


def solve(s):
    n, *a = map(int, s.split())
    l, r, ans = 1, 3, sum(a)
    sll, slr, srl, srr = a[0], 0, sum(a[1:3]), sum(a[3:])
    for c in range(1, n - 1):
        slr += a[c]
        srl -= a[c]
        r = max(c, r)
        while l < c and absdiff(sll + a[l], slr - a[l]) < absdiff(sll, slr):
            sll, slr, l = sll + a[l], slr - a[l], l + 1
        while r < len(a) and absdiff(srl + a[r], srr - a[r]) < absdiff(srl, srr):
            srl, srr, r = srl + a[r], srr - a[r], r + 1
        _max, _min = max(sll, slr, srl, srr), min(sll, slr, srl, srr)
        ans = min(ans, absdiff(_min, _max))
    return ans


print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 25708
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  string S;cin>>S;
  deque<int> st;
  rep(i,S.size()){
   if(S[i]=='0')st.push_back(0);
   else if(S[i]=='1')st.push_back(1);
   else if(!st.empty())st.pop_back();
  }
  while(!st.empty()){
    cout<<st.front();
    st.pop_front();
  }
  cout<<endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007
const long long INF = 1LL<<60;


int main(){	
	ll N;
	cin >> N;
	ll ans = N;
	for(ll i = 1; i*i <= N; ++i){
		if(N % i != 0) continue;
		ll j = N / i;
		ans = min(ans, i-1 + j-1);
	}
	cout << ans << endl;
 }

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y;
    cin >> X >> Y;
    int ans = 0;
    rep(i, 2) {
        if (X == 1) ans += 300000;
        if (X == 2) ans += 200000;
        if (X == 3) ans += 100000;
        swap(X, Y);
    }
    if (X == 1 && Y == 1) ans += 400000;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  cin>>a.at(0);
  int g=a.at(0);
  int l=a.at(0);
  for(int i=1;i<n;i++){
    cin>>a.at(i);
    g=max(g,a.at(i));
    l=min(l,a.at(i));
  }
  int m=(g-l)*(g-l)*n;
  for(int x=l;x<=g;x++){
    int c=0;
    for(int i=0;i<n;i++)
      c+=(a.at(i)-x)*(a.at(i)-x);
    m=min(m,c);
  }
  cout<<m<<endl;
}

Measured memory_bytes: 256
N = int(input())
MARCH = [[],[],[],[],[]]
ans = 0

for _ in range(N):
    Si = input()
    if Si[0] == "M":
        MARCH[0].append(Si)
    if Si[0] == "A":
        MARCH[1].append(Si)
    if Si[0] == "R":
        MARCH[2].append(Si)
    if Si[0] == "C":
        MARCH[3].append(Si)
    if Si[0] == "H":
        MARCH[4].append(Si)

for i in range(0, 5-2):
    for j in range(i+1, 5-1):
        for k in range(j+1, 5):
            ans += len(MARCH[i]) * len(MARCH[j]) *len(MARCH[k])

print(ans)


Measured memory_bytes: 10356
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n,k;
    cin>>n>>k;
    list<ll>a;
    for(int i=0;i<n;i++){
        ll t;
        cin>>t;
        a.push_back(t);
    }
    a.sort();
    while(k&&!a.empty()){
        k--;
        a.pop_back();
    }
    ll c=0;
    for(ll x : a) c+=x;
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 6528
<?php
$N = intval(fgets(STDIN));
for($i = 0; $i < $N; $i++){
    $map[] = array_map("intval", explode(" ", trim(fgets(STDIN))));
}
$dp[-1] = [0,0,0];
for($i = 0; $i < $N; $i++){
    for($j = 0; $j < 3; $j++){
        $dp[$i][$j] = 0;
        for($k = 0; $k < 3; $k++){
            if($j<>$k){
                $dp[$i][$j] = max($dp[$i][$j], $dp[$i-1][$k] + $map[$i][$j]);
            }
        }
    }
}
echo max($dp[$N-1]);


Measured memory_bytes: 86516
/*Author : Kartik Bansal
 *Date : 07/09/19
 *Time : 16:14 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define tc int t ;cin>>t ;while(t--)
#define pb push_back
#define FOR(i,n) for(int i =0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin() , v.end()
#define sort(v) sort(all(v))
#define vi  vector<int>
#define vll  vector<long long >
#define inf INT_MAX
#define minf INT_MIN



int32_t main()
{
  ios::sync_with_stdio(0) ;
  cin.tie(0) ; cout.tie(0) ;
  int n , su = 0 ;
  cin>>n ;
  vi v(n) ;
  FOR(i,n)
       {
              cin>>v[i] ;
              su+=v[i] ;
       }
int k ;
cin>>k ;
while(k--)
{
       int a,b ;
       cin>>a>>b ;
       int ans = su - v[a-1] + b ;
       cout<<ans <<"\n" ;

}
  return 0 ;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void call(int n) {
    int i = 1, x;
    
    for (i; i <= n; i++) {
        x = i;
        if (x % 3 == 0) {
            cout << " " << i;
        }
        else {
            for (x; x != 0; x /= 10) {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
            }
        }
    }
    cout << endl;
}

int main() {
    int x;

    cin >> x;

    call(x);

	return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define re register
#define ui unsigned int
#define ull unsigned long long
const ui mod=998244353;
unordered_map<ull,ui>mp[110];
ui dfs(re ui n,re ull S)
{
	if(!n)return 1;
	unordered_map<ull,ui>::iterator it=mp[n].find(S);
	if(it!=mp[n].end())return it->second;
	re ui sum=dfs(n-1,S>>1)*((S&1)+1)%mod;
	for(re ui i=1;i*2<=n;i++)
	{
		re ull SS=S>>i,S1=S&((1llu<<i)-1);
		for(re ui j=2;i*j<=n;j++)
		{
			S1&=SS;SS>>=i;sum=(sum+(ull)dfs(i,S1)*dfs(n-i*j,SS))%mod;
		}
	}
	return mp[n][S]=sum;
}
char ss[100100];
ull cp[110][110];
ui f[110];
int main()
{
	re ui n;
	scanf("%s",ss+1);
	n=strlen(ss+1);
	for(re ui i=1;i<=n;i++)ss[i]-='0';
	f[n+1]=1;
	for(re ui i=1;i<=n;i++)
	{
		for(re ui j=i;j<=n;j++)cp[i][j]=(cp[i][j-1]<<1)|ss[j];
	}
	for(re ui i=n;i;i--)
	{
		f[i]=f[i+1]*(ss[i]+1)%mod;
		for(re ui j=1;i+2*j<=n+1;j++)
		{
			re ull S=cp[i][i+j-1];
			for(re ui k=2;i+j*k<=n+1;k++)
			{
				S&=cp[i+j*(k-1)][i+j*k-1];
				f[i]=(f[i]+(ull)f[i+j*k]*dfs(j,S))%mod;
			}
		}
	}
	printf("%u\n",f[1]);
}

Measured memory_bytes: 2304
#include <iostream>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long ll;
map<string, ll> mp;
#define rep(i, n) for(int i = 0; i < (n); ++i)

int main(){
  ll n, ans = 0;
  cin >> n;

  rep(i, n){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    ans += mp[s];
    mp[s]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 11136