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

int combine(int a, int b) {
    int times = 1;
    while (times <= b)
        times *= 10;
    return a*times + b;
}

bool square(long long n){
    long long squareRootN=(long long)round((sqrt(n)));
    
    if(squareRootN*squareRootN == n) {
        return true;
    }
    else {
        return false;
    }
}
int main()
{
    int a, b;
    cin >> a >> b;
    
    int c = combine(a, b);
    
    bool tru = square(c);
    if(tru == 1)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
        int i=0;
        char s[10001000];

        scanf("%s",s);
        if(s[0]==' ')   return 0;

        while(s[i]!='\0') {    
                 printf("%c",s[i]);  i=i+2;
                 }
        printf("\n");
                return 0;
}

Measured memory_bytes: 2304
from collections import defaultdict

def main():
    num = int(input())
    data = list(map(int, input().split()))
    dic = defaultdict(int)

    for ele in data:
        dic[ele] += 1

    ans = 0
    for i, v in dic.items():
        if v >= i:
            ans += v - i
        else:
            ans += v

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 68648
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e4 + 7;
int dp[MAXN];
int main()
{
    int H, n; scanf("%d%d", &H, &n);
    for (int i = 1; i <= H + 10000; i++) dp[i] = 1e9;
    int ans = 1e9;
    for (int i = 1, a, b; i <= n; i++)
    {
        scanf("%d%d", &a, &b);
        for (int j = a; j <= H + 10000; j++) dp[j] = min(dp[j], dp[j - a] + b);
        for (int j = H; j <= H + 10000; j++) ans = min(ans, dp[j]);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<complex>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define vout rep(i, v.size()) cout << v[i] << " "; cout << endl;
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    cout << n;
    vector<int> v;
    rrep(i, 2, sqrt(n) + 1) {
        while (n % i == 0) {
            v.push_back(i);
            n /= i;
        }
    }
    if (n != 1) v.push_back(n);
    cout << ":";
    rep(i, v.size()) cout << " " << v[i];
    cout << endl;
}



Measured memory_bytes: 3232
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===

def disLR(a, idx):
    small = a[max(0, idx - 1)]
    large = a[min(len(a) - 1, idx)]
    return small, large


def main():
    a, b, q = ns()
    s = [ni() for _ in range(a)]
    t = [ni() for _ in range(b)]

    for _ in range(q):
        ans = INF

        x = ni()
        tmpans = [0] * 4

        idxs = bisect.bisect_left(s, x)
        sml, lrg = disLR(s, idxs)
        tmpans[0] += abs(x - sml)
        tmpans[1] += abs(x - lrg)
        idxsml = bisect.bisect_left(t, sml)
        tmpans[0] += min([abs(sml - i) for i in disLR(t, idxsml)])
        idxlrg = bisect.bisect_left(t, lrg)
        tmpans[1] += min([abs(lrg - i) for i in disLR(t, idxlrg)])

        idxt = bisect.bisect_left(t, x)
        sml, lrg = disLR(t, idxt)
        tmpans[2] += abs(x - sml)
        tmpans[3] += abs(x - lrg)
        idxsml = bisect.bisect_left(s, sml)
        tmpans[2] += min([abs(sml - i) for i in disLR(s, idxsml)])
        idxlrg = bisect.bisect_left(s, lrg)
        tmpans[3] += min([abs(lrg - i) for i in disLR(s, idxlrg)])
        ans = min(ans, min(tmpans))
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19184
def main():
    import sys
    input = sys.stdin.readline

    H, W = map(int, input().split())
    S = [list(input().split()[0]) for i in range(H)]

    from collections import deque

    dist = [0]*(H*W)
    for s in range(H*W):
        search_list = deque([s])
        visited_set = set([])
        d = [0] * (H*W)
        while search_list:
            now = search_list.popleft()
            visited_set.add(now)
            h = now // W
            w = now % W
            if S[h][w] == '#':
                continue
            for i, j in [[0, 1], [1, 0], [0, -1], [-1, 0]]:
                new_h = h+i
                new_w = w+j
                new_s = new_h * W + new_w
                if new_h in [-1, H] or new_w in [-1, W]:
                    continue
                elif new_s in search_list:
                    continue
                elif new_s in visited_set:
                    continue
                elif S[new_h][new_w] == '#':
                    continue
                else:
                    d[new_s] = d[now]+1
                    search_list.append(new_s)
        dist[s] = max(d)
    print(max(dist))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include<stdio.h>

typedef long long ll;
int up(const void * a ,const void * b){
  if(*(ll *)a > *(ll *)b){
    return 1;
  }
  else if(*(ll *)a < *(ll *)b){
    return -1;
  }
  
  else{
    return 0;
  }
  
}

int main(void){
  ll n , m;
  scanf("%lld %lld",&n ,&m);

  ll a[n+1];
  a[0] = 0;
  for(int i = 1;i <= n;i ++){
    scanf("%lld",&a[i]);
    a[i] += a[i-1];
    a[i] %= m;
  }
  
  qsort(a,n+1,sizeof(ll),up);
  
  /*for(int i = 0;i < n;i ++){
    printf("%lld\n",a[i]);
  }*/

  ll count = 0 , ans = 0;
  for(int  i = 0;i <= n;i ++){
    count ++;
    if(i == n || a[i] != a[i+1]){
      ans += count*(count-1)/2;
      count = 0;
    }
  }

  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 3096
def answer(arr):
    a = 0 # 4의배수
    b = 0 # 4의 배수가 아닌 짝수
    c = 0 # 4의 배수가 아닌 서로소(1 포함)
    
    for i in range(len(arr)):
        if arr[i]%4 == 0: a += 1
        elif arr[i]%2 == 0: b += 1
        else: c += 1
    
    if b > 0 : a -= 1
    if c - a > 1: return "No"
    else: return "Yes"

n = input()
arr = list(map(int, input().split()))
print(answer(arr))

Measured memory_bytes: 62704
#include<stdio.h>

int main(){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x-r<0||x+r>W||y-r<0||y+r>H)
    printf("No\n");
  else 
    printf("Yes\n");
 
  

    return 0;
}

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

int main(){
    string S;
    cin>>S;
    string sample="CODEFESTIVAL2016";
    int count=0;
    for(int i=0;i<sample.size();i++){
        if(sample.at(i)!=S.at(i))count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int N;
int main(void){
    cin >> N;
    int c = 0;
    for(int i=1;i<=N;i++){
        if((i>=1 and i<=9) or (i>=100 and i<=999) or (i>=10000 and i<=99999)) c++;
    }
    cout << c << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;

//////////////////////////////////////////////////////////////////////

int main(void) {
	int k, n; cin >> k >> n;
	if (n == 1) {
		int x; cin >> x;
		cout << max(0, x - 1) << endl;
		return 0;
	}
	priority_queue<int> q;
	rep(n) {
		int x; cin >> x;
		q.push(x);
	}
	while (!(q.size() == 1)) {
		int a = q.top(); q.pop();
		int b = q.top(); q.pop();
		q.push(a - b);
	}

	int ans = q.top();
	cout << max(0,ans - 1) << endl;

	return 0;
}

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

int main() {
    int N;
    while (cin >> N, N) {
        int W, H;
        cin >> W >> H;
        vector<vector<int>> v(W+1, vector<int>(H+1));
        for (int i = 0; i < N; i++) {
            int x, y;
            cin >> x >> y;
            x--, y--;
            v[x][y]++;
        }

        for (int i = 0; i <= W; i++) {
            for (int j = 0; j <= H; j++) {
                int t = 0, l = 0, tl = 0;
                if (i) t = v[i-1][j];
                if (j) l = v[i][j-1];
                if (i && j) tl = v[i-1][j-1];

                v[i][j] += t + l - tl;
            }
        }
        int S, T;
        cin >> S >> T;

        int ans = 0;
        for (int i = 0; i <= W - S; i++) {
            for (int j = 0; j <= H - T; j++) {
                int t = 0, l = 0, tl = 0;
                if (j) l = v[i+S-1][j-1];
                if (i) t = v[i-1][j+T-1];
                if (i && j) tl = v[i-1][j-1];

                ans = max(ans, v[i+S-1][j+T-1] - l - t + tl);
            }
        }

        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3124
#include <iostream>
using std::cout;
using std::endl;
using std::cin;

int main() {
	int t = 0;
	for (int i = 0;i != 4;++i) {
		int s;
		cin >> s;
		t += s;
	}
	cout << t/60 << "\n" << t%60 << endl;
}

Measured memory_bytes: 3056
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,i,arr[20001],j=0,a;
 cin>>n;
 
 for(i=1;i<=sqrt(n);i++)
{
    if(n%i==0)
        {arr[j]=i;
        j++;
        
        arr[j]=n/i;
        j++;
               }
}

sort(arr,arr+j);

cout<<arr[j/2]+arr[j/2-1]-2<<endl;
return 0;
}


Measured memory_bytes: 384
N, A, B = map(int, input().split())
x = B - A
if x % 2 == 0:
    print(x//2)
else:
    # 左に持って行って寄せる
    l = (A-1) + 1 + (B-A-1)//2
    # 右に持って行って寄せる
    r = (N-B) + 1 + (B-A-1)//2
    print(min(r, l))


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

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

const double PI = 3.14159265358979323846;
const int mod = 1e9+7;
// int 1e9+7 double 1e-12 long long 1e18

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  ll a, b;
  cin >> a >> b;
  if (a * b == 15){
    cout << "*" << endl;
  }else if (a + b == 15){
    cout << "+" << endl;
  }else{
    cout << "x" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import bisect
n, k = map(int, input().split())
alist = list(map(int, input().split()))
positions = [[] for i in range(200002)]
for i in range(n):
    positions[alist[i]].append(i)
visited = [0] * n
lastList = []
nextP = 0
times =0
while True:
    num = alist[nextP]
    if len(positions[num]) == 1:
        lastList.append(nextP)
        visited[nextP] = times
        times += 1
        nextP += 1
        if nextP == n:
            break
    else:
        nextIn = bisect.bisect_right(positions[num], nextP)
        if nextIn == len(positions[num]):
            lastList.append(nextP)
            visited[nextP] = times
            times += 1
            nextP = positions[num][0] + 1
        else:
            nextP = positions[num][nextIn] + 1
            if nextP == n:
                break
if times != 0:
    loopIn = k % (times + 1)
    if loopIn != 0:
        loopIn -= 1
        lastIn = lastList[loopIn]
        result = []
        while True:
            num = alist[lastIn]
            nextIn = bisect.bisect_right(positions[num], lastIn)
            if nextIn == len(positions[num]):
                result.append(num)
                lastIn += 1
            else:
                lastIn = positions[num][nextIn] + 1
            if lastIn == n:
                break
        if len(result) > 0:
            print(' '.join(map(str, result)))


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

vector<int> to[1010];
vector<string> message[1010];

void dfs(int v,int d){
	rep(i,to[v].size()){
		rep(j,d) cout << '.';
		cout << message[v][i] << endl;
		dfs(to[v][i],d+1);
	}
	return;
}

int main(void){
	int n;
	cin >> n;
	for(int i=1;i<=n;++i){
		int p;
		string msg;
		cin >> p >> msg;
		to[p].pb(i);
		message[p].pb(msg);
	}
	dfs(0,0);
	return 0;
}

Measured memory_bytes: 1524
#include <cstdio>
#include <algorithm>
#include <vector>

const int MN = 55;

int N, ap[MN], bp[MN], ad[MN];
std::vector<int> A[MN], B[MN];
void DFS(int u, int pa, std::vector<int> *H, int *p) {
	p[u] = pa;
	for (int v : H[u]) if (v != pa) DFS(v, u, H, p);
}

int op[MN], in[MN], que[MN], l, r;
std::vector<int> G[MN];
inline int Calc() {
	int cnt = 0;
	for (int i = 1; i <= N; ++i) cnt += op[i] = ap[i] != bp[i];
	for (int i = 1; i <= N; ++i) if (!op[i] && op[ap[i]]) return -1;
	for (int i = 1; i <= N; ++i) G[i].clear(), in[i] = 0;
	for (int i = 1; i <= N; ++i) if (op[i]) {
		if (op[ap[i]]) G[i].push_back(ap[i]), ++in[ap[i]];
		if (op[bp[i]]) G[bp[i]].push_back(i), ++in[i];
	}
	l = 1, r = 0;
	for (int i = 1; i <= N; ++i) if (op[i] && !in[i]) que[++r] = i;
	while (l <= r) {
		int u = que[l++];
		for (int v : G[u]) if (!--in[v]) que[++r] = v;
	}
	return r != cnt ? -1 : cnt;
}

int main() {
	int Tests;
	scanf("%d", &Tests);
	while (Tests--) {
		scanf("%d", &N);
		int Ans = N + 1;
		for (int i = 1; i <= N; ++i) A[i].clear(), B[i].clear(), ad[i] = 0;
		for (int i = 1, x, y; i < N; ++i)
			scanf("%d%d", &x, &y), A[x].push_back(y), A[y].push_back(x), ++ad[x], ++ad[y];
		for (int i = 1, x, y; i < N; ++i)
			scanf("%d%d", &x, &y), B[x].push_back(y), B[y].push_back(x);
		DFS(1, 0, A, ap), DFS(1, 0, B, bp);
		int ok = 1;
		for (int i = 1; i <= N; ++i) if (ap[i] != bp[i]) ok = 0;
		if (ok) { puts("0"); continue; }
		for (int i = 1; i <= N; ++i) if (ad[i] == 1) {
			DFS(i, 0, B, bp);
			for (int j = 1; j <= N; ++j) if (j != i) {
				DFS(j, 0, A, ap), ap[j] = i, ap[i] = 0;
				int ans = Calc();
				if (~ans) Ans = std::min(Ans, ans + 1);
			}
		}
		printf("%d\n", Ans > N ? -1 : Ans);
	}
	return 0;
}

// Luogu : PinkRabbit

Measured memory_bytes: 384
n, m = list(map(int, input().split()))

MAX = 2*10**5+1
MOD = 10**9+7
fact = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]
invfact = [0 for i in range(MAX)]

def comb_build(n):
  fact[0] = inv[0] = invfact[0] = 1
  fact[1] = inv[1] = invfact[1] = 1
  for i in range(2, n):
    fact[i] = fact[i-1]*i%MOD
    inv[i] = inv[MOD%i]*(MOD-MOD//i)%MOD
    invfact[i] = invfact[i-1]*inv[i]%MOD

def nCk(n, k):
  if n<k or n<0 or k<0:
    return 0
  return (((fact[n]*invfact[k])%MOD)*invfact[n-k])%MOD

def prime_factor(n):
  from collections import defaultdict
  ret = defaultdict(int)
  for i in range(2, int(n**(1/2))+10):
    while n%i==0:
      ret[i] += 1
      n //= i
  if n!=1:
    ret[n] = 1
  return ret

comb_build(MAX)
ans = 1
for e in prime_factor(m).values():
  ans *= nCk(e+n-1, e)%MOD
print(ans%MOD)

Measured memory_bytes: 27160
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {int A;
	cin >> A;
	cout << A + A * A + A * A * A << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#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 rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    ll a, b, x;
    scan(a, b, x);
    ll ans = b / x - a / x;
    if (a % x == 0)
        ans++;
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define reps2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n, k;

int main() {
    cin >> n >> k;
    double ans = 0;
    reps(i, n) {
        int num = i, a = 0;
        while (num < k) {
            num *= 2;
            a++;
        }
        ans += 1. / n * pow(0.5, a);
    }
    cout << fixed << setprecision(12);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  
  public static void main (String [] args){
    
    Scanner scanner = new Scanner(System.in);     
    
    int num1 = scanner.nextInt();
    
    int num2 = scanner.nextInt();
    
    int a [] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
    
    int x = a[num1];
      
    int y = a[num2];
      
      if (a[num1] == a[num2]){
      
      System.out.println("Yes");
        
      } else {
        
        System.out.println("No");
        
      }
    
    scanner.close();
    
  }
  
}
   

Measured memory_bytes: 21588
import random
 
def calc(D, s, t):
  last = [0 for _ in range(26)]
 
  value = 0
  for i in range(D):
    day = i + 1
    value += s[i][t[i]-1]
    last[t[i]-1] = day
    for j in range(26):
      value -= c[j] * (day - last[j])
  return value
 
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [random.randint(1,26) for _ in range(D)]
 
val = calc(D, s, t)
for _ in range(30000):
  d_rand = random.randint(1,D)
  q_rand = random.randint(1,26)
  old = t[d_rand-1]
  t[d_rand-1] = q_rand
  if val > calc(D, s, t):
    t[d_rand-1] = old
  else:
    val = calc(D, s, t)
for i in range(D):
  print(t[i])

Measured memory_bytes: 86724
#include<iostream>
#include<cassert>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));

int f(int n, int t) {
	if (!t)return 1;
	int a = f(n, t >> 1);
	a *= a;
	if (t & 1)a *= n;
	return a;
}

signed main() {
	int N;
	cin >> N;
	vector<int>dp(N + 1, INF);
	dp[0] = 0;
	for (int i = 1; i <= N; i++) {
		int num;
		num = 1;
		while (i - num >= 0) {
			dp[i] = min(dp[i], dp[i - num] + 1);
			num *= 6;
		}
		num = 1;
		while (i - num >= 0) {
			dp[i] = min(dp[i], dp[i - num] + 1);
			num *= 9;
		}
	}
	int ans = dp[N];
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<vector>
using namespace std;

const long mod = 1000000007;
const long indlim = 5368709119;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
long mybase(long N, long B) { if (N == 0) return 0; string S = ""; while (N != 0) { string M = to_string(N % B); N -= N % B; N /= B; S = M + S; }return stol(S); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	string res = ":(";
	long A ,B; cin >> A >> B;

	if (A <= 8 && B <= 8) res = "Yay!";

	cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;

int main(int argc, char **argv) {
    int a[5];
    int res = 0;
    
    for(int i = 0; i < 5; ++i)
        scanf("%d", a + i);

    int swap_index = 0;
    for(int i = 0; i < 5; ++i)
        if(a[i] % 10 != 0 && a[i] % 10 < a[swap_index] % 10)
            swap_index = i;

    swap(a[swap_index], a[4]);

    for(int i = 0; i < 5; ++i) {
        if(res % 10 != 0) res += (10 - res % 10);
        res += a[i];
    }
    printf("%d\n", res);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

struct UF {
	vi e;
    vector<ll> sumv;
    vector<int> ans, nume;
    int tot;
    UF(int n, const vector<ll> &x) : e(n, -1), sumv(x), ans(n, 0), nume(n, 0), tot(0) {}
	bool same_set(int a, int b) { return find(a) == find(b); }
	int size(int x) { return -e[find(x)]; }
	int find(int x) { return e[x] < 0 ? x : e[x] = find(e[x]); }
	void join(int a, int b, ll y) {
		a = find(a), b = find(b);
		if(a==b) {
            ++nume[a];
            if(y<=sumv[a]) {
                ++tot;
                ++ans[a];
            }
            return;
        }
		if (e[a] > e[b]) swap(a, b);
		e[a] += e[b]; e[b] = a;
        nume[a] += nume[b];
        sumv[a] += sumv[b];
        ++nume[a];
        tot -= ans[a];
        tot -= ans[b];
        if(y<= sumv[a]) {
            ans[a] = nume[a];
        }
        else {
            ans[a] = ans[a]+ans[b];
        }
        tot += ans[a];
	}
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<ll> x(n);
    rep(i,0,n) cin >> x[i];
    vector<tuple<ll,int,int>> edges;
    rep(i,0,m) {
        int u, v;
        ll y;
        cin >> u >> v >> y;
        --u;
        --v;
        edges.emplace_back(y,u,v);
    }
    sort(all(edges));
    UF uf(n, x);
    for(const auto &e: edges) {
        int u, v;
        ll y;
        tie(y,u,v) = e;
        uf.join(u,v,y);
    }
    int ans = m-uf.tot;
    cout << ans << "\n";
}


Measured memory_bytes: 4592
package main

import (
	"fmt"
	"strings"
)

func main() {
	var (
		s1, s2, s3 string
	)

	fmt.Scan(&s1, &s2, &s3)

	fmt.Print(strings.ToUpper(s1[0:1]) + strings.ToUpper(s2[0:1]) + strings.ToUpper(s3[0:1]))
}


Measured memory_bytes: 1844
//#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<class T>
void read(T& x)
{
	T res = 0, f = 1; char c = getchar();
	while (!isdigit(c)) {
		if (c == '-')f = -1; c = getchar();
	}
	while (isdigit(c)) {
		res = (res << 3) + (res << 1) + c - '0'; c = getchar();
	}
	x = res * f;
}
const ll N = 2000000 + 10;
int n, a[N], c[N],mx=1000000,prime[N],tot,mu[N];
ll mod = 998244353;
ll sum[N];
bool isprime[N];
void init()
{
	memset(isprime, 1, sizeof(isprime));
	mu[1] = 1;
	for (int i = 2; i <= mx; i++)
	{
		if (isprime[i])prime[++tot] = i, mu[i] = -1;
		for (int j = 1; j <= tot && prime[j] * i <= mx; j++)
		{
			isprime[prime[j] * i] = 0;
			if (i % prime[j] == 0)
			{
				mu[i * prime[j]] = 0;
				break;
			}
			mu[i * prime[j]] = -mu[i];
		}
	}
	for (int i = 1; i <= mx; i++)
	{
		for (int j = 1; j * i <= mx; j++)
			sum[i * j] = (sum[i * j] + mu[i] * i)%mod;
	}
}
int main()
{
	//ios::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
	freopen("182.txt", "r", stdin);
#endif // ONLINE_JUDGE
	read(n);
	ll suma = 0;
	for (int i = 1; i <= n; i++)read(a[i]), c[a[i]]++,suma+=a[i];
	init();
	suma %= mod;
	ll ans = 0;
	for (int i = 1; i <= mx; i++)
	{
		ll cnt = 0;
		for (int j = 1; j <= mx / i; j++)cnt = (cnt + 1ll * j * c[j * i])%mod;
		ll num1 = cnt * cnt % mod;
		ll num2 = i * sum[i] % mod;
		ans = (ans + num1 * num2 % mod)%mod;
	}
	ll ds2 = (mod + 1) / 2;
	ans = (ans - suma) *ds2%mod;
	printf("%lld\n", (ans % mod + mod)%mod);
	return 0;
}


Measured memory_bytes: 22344
#include <stdio.h>
int main(){

  int h, w, i, j;
  while(1)
    {
      scanf("%d %d", &h, &w);
      if( h == 0 && w == 0) break;
      for(i = 0; i < h; i++)
	{
	  for(j = 0; j < w; j++)
	    {
	      printf("#");
	    }
	  printf("\n");
	}
      printf("\n");
    }
  return 0;
} 

Measured memory_bytes: 572
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.collections.ArrayList

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, q) = readIntegerList()
    val fTree = FenwickTree(n)
    val aList = readLongList()
    for ((i, a) in aList.withIndex()) fTree.add(i, a)

    repeat(q) {
        val (a, b, c) = readLongList()
        when (a) {
            0L -> fTree.add(b.toInt(), c)
            else -> out.println(fTree.sum(b.toInt(), c.toInt()))
        }
    }
}


/**
 * Fenwick tree(0-indexed).
 * https://github.com/da-louis/ac-library-kt/blob/master/src/main/kotlin/jp/atcoder/library/kotlin/fenwickTree/FenwickTree.kt
 *
 * convert from [AtCoderLibraryForJava - FenwickTree](https://github.com/NASU41/AtCoderLibraryForJava/blob/24160d880a5fc6d1caf9b95baa875e47fb568ef3/FenwickTree/FenwickTree.java)
 */
class FenwickTree(private val n: Int) {
    private val data: LongArray = LongArray(n)

    /**
     * Fenwick tree constructor.
     */
    constructor(data: LongArray) : this(data.size) {
        build(data)
    }

    /**
     * Add value x to p.
     */
    fun add(p: Int, x: Long) {
        var vp = p
        assert(vp in 0 until n)
        vp++
        while (vp <= n) {
            data[vp - 1] += x
            vp += vp and -vp
        }
    }

    /**
     * Calc sum [l, r].
     */
    fun sum(l: Int, r: Int): Long {
        assert(l in 0..r && r <= n)
        return sum(r) - sum(l)
    }

    private fun sum(r: Int): Long {
        var vr = r
        var s: Long = 0
        while (vr > 0) {
            s += data[vr - 1]
            vr -= vr and -vr
        }
        return s
    }

    private fun build(dat: LongArray) {
        System.arraycopy(dat, 0, data, 0, n)
        for (i in 1..n) {
            val p = i + (i and -i)
            if (p <= n) {
                data[p - 1] += data[i - 1]
            }
        }
    }
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 122096
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,y;
	scanf("%d %d",&y,&n);
	if(y>=6&&y<=12)
		printf("%d",n/2);
	else if(y>12)
		printf("%d",n);
	else
		printf("0");
	return 0;
}

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

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

   int x = stoi(a + b);
   bool ans = false;
   for(int i = 1; i < 1000; i++){
     if(x == i * i){
      ans = true; 
      break;
     }
   }
   if(ans == true){
     cout << "Yes" << endl;
   }
   else{
     cout << "No" << endl;
   }
 }


Measured memory_bytes: 256
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main()
{
	ll N = 0;
	string ret = "Yes";// Yes

	cin >> N;

	vector< ll > t(N + 1);
	vector< ll > x(N + 1);
	vector< ll > y(N + 1);

	t[0] = 0;
	x[0] = 0;
	y[0] = 0;
	Rep(i, N) {
		cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
	}

	Rep(i, N) {
		ll delta_t = t[i + 1] - t[i];
		ll delta_x = x[i + 1] - x[i];
		ll delta_y = y[i + 1] - y[i];
		ll dist = abs(delta_x) + abs(delta_y);

		if (dist <= delta_t) {
			if (delta_t % 2 == 0) {
				// delta_t = Even
				if (dist % 2 != 0) {
					ret = "No";
					break;
				}
			}
			else {
				// delta_t = Odd
				if (dist % 2 == 0) {
					ret = "No";
					break;
				}
			}
		}
		else {
			ret = "No";
			break;
		}
	}

	cout << ret << endl;

	return 0;
}





Measured memory_bytes: 2560
from heapq import heapify, heappop, heappush
N = int(input())
A = [int(i) for i in input().split()]
heapify(A)
while len(A) > 1:
    curr_attacker, curr_attacked = heappop(A), heappop(A)
    if curr_attacked % curr_attacker != 0:
        heappush(A, curr_attacked % curr_attacker)
    heappush(A, curr_attacker)
print(A[0])

Measured memory_bytes: 14180
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

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

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(i64, N, K);
    const i64 r = N % K;
    print(min(r, K - r));

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

const int INF=0x3fffffff;

int n;

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

// 欧拉函数的板子，返回 phi(x)
int get_phi(int x)
{
    int res = x;
    for (int i = 2; i <= x / i; i ++ )
        if (x % i == 0)
        {
            res -= res / i;
            while (x % i == 0) x /= i;
        }
    if (x > 1) res -= res / x;
    return res;
}

// 快速幂板子，求 10 的 k 次方模 mod 的结果
int qmi(int k, int mod)
{
    int res = 1, a = 10;
    while (k)
    {
        // mod 即 c，最大是 n * 9 = 9e6，乘法就可能会爆 int，要转 long long 
        if (k & 1) res = res * 1ll * a % mod;
        a = a * 1ll * a % mod;
        k >>= 1;
    }
    return res;
}

int main()
{
    scanf("%d", &n);
    // 让 n 变成 c
    if (n % 7 == 0) n /= 7; // 由于 7 是质数，所以这里不用再求一遍最大公约数，直接判断是否有因子 7 即可
    n *= 9;
    // phi 存 phi(c) 的值。res 记录答案，初始化为正无穷
    int phi = get_phi(n), res = INF;
    for (int i = 1; i <= phi / i; i ++ )
        if (phi % i == 0) // 如果 i 是 phi 的因子，那么分别判断 i 和 phi / i 是否是合法解，如果是，则更新答案
            if (qmi(i, n) == 1) res = min(res, i); // 由于 i <= phi / i，所以如果 i 是合法解，就不用再判断 phi / i 了
            else if (qmi(phi / i, n) == 1) res = min(res, phi / i);
    printf("%d\n", res == INF ? -1 : res); // 如果 res == INF，说明无解，输出 -1，否则输出 res
    return 0;
}


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

int n ;
int ans ;

void input ( ) {
    cin >> n ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        int x ;
        cin >> x ;
        if ( ( i % 2 ) == 1 && ( x % 2 ) == 1 ) { ++ ans ; }
    }
}

void solve ( ) {
    cout << ans << "\n" ;
}



int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int N,ans,memo[101][4][4][4];
int mod=1000000007;
int check(int len,int a,int b,int c){
	if(len==N)return 1;
	if(memo[len][a][b][c]>0)return memo[len][a][b][c];
	int ret = 0;
  	for(int d=0;d<4;d++){
		if(b==0&&c==1&&d==2)continue;
		if(b==1&&c==0&&d==2)continue;
		if(b==0&&c==2&&d==1)continue;
		if(a==0&&c==1&&d==2)continue;
		if(a==0&&b==1&&d==2)continue;
		ret += check(len+1,b,c,d);
		ret %= mod;
    }
	memo[len][a][b][c] = ret;
 	return ret;
}
int main() {
	cin>>N;
 	cout<<check(0,3,3,3);
	return 0;
}


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

using namespace std;

#define INF (1LL<<45)
typedef vector<double> Vec;

int N;
Vec vw,pf,vf,th;

double f(double W,double pw){
    double res = 0;
    for(int i = 0 ; i < N ; i++){
	double Fi = max(0.0,(th[i]-W*vw[i])/vf[i]);
	res += Fi*pf[i];
    }
    res += W*pw;
    return res;
}

void init(){
    vw.clear(); vw.resize(N);
    pf.clear(); pf.resize(N);
    vf.clear(); vf.resize(N);
    th.clear(); th.resize(N);
}

int main(){
    double pw;
    while(scanf("%d %lf",&N,&pw), N){
	init();
	for(int i = 0 ; i < N ; i++){
	    scanf("%lf %lf %lf %lf",&vw[i],&pf[i],&vf[i],&th[i]);
	}
	double L = 0, R = INF;
	for(int i = 0 ; i < 150 ; i++){
	    double l = (L*2 + R) / 3;
	    double r = (L + R*2) / 3;
	    if(f(l,pw) > f(r,pw)){
		L = l;
	    }else{
		R = r;
	    }
	}
	printf("%.12f\n",f((L+R)/2,pw));
    }
    return 0;
}

Measured memory_bytes: 6044
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

if __name__=='__main__':
    x = I()
    if 400<=x and x<600:
        print(8)
    elif x<800:
        print(7)
    elif x<1000:
        print(6)
    elif x<1200:
        print(5)
    elif x<1400:
        print(4)
    elif x<1600:
        print(3)
    elif x<1800:
        print(2)
    elif x<2000:
        print(1)
    exit()

Measured memory_bytes: 27160
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)

int N;
const int MAX_N = 1000;
int A[MAX_N];
int main(int, char *[])
{
    cin >> N;
    for(int i = 0; i < N; ++i)
        cin >> A[i];

    const int min = *min_element(A, A + N);
    const int max = *max_element(A, A + N);
    cout << (max - min) << endl;

    return 0;
}


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

int main() {	

	int n; cin >> n;
	vector<tuple<string, int, int>> tu;
	for (int i = 0; i < n; i++) {
		string s;
		int p;
		cin >> s >> p;
		tu.emplace_back(s, -1 * p, i + 1);
	}
	sort(tu.begin(), tu.end());
	
	for (auto u : tu) {
		cout << get<2>(u) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#include <bitset>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1e9+7
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

int main(){
    string s;
    cin >> s;
    int num=0;
    for(int i=0;i<s.size();i++){
        string t;
        t+=s[i];
        int x=stoi(t);
        num+=x;
    }
    if(num%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m , k;


void solve(int testCase){

    scanf("%d %d %d" , &n , &m , &k);
    if(n + m + k >= 22)printf("bust\n");
    else printf("win\n");


}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
/*
CODED BY               
**************
DARSHAN JAIN
darshanjain31
**************
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define M 1000000007
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}

int main()
{
  ll n;
  cin>>n;
  double mid=(double)n/3;
    double f=mid*mid*mid;
  cout << std::setprecision(7) <<f<< endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
vector_a = []
vector_b = []
for i in range(n):
    vector_a.append(list(map(int,input().split())))
for i in range(m):
    vector_b.append(list())
    vector_b[i]=int(input())

for i in range(n):
    tmp=0
    for j in range(m):
        tmp+=vector_a[i][j]*vector_b[j]
    print(tmp)

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

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

using ll = long long;
using ull = unsigned long long;

int main() {
  string a, b;
  cin >> a >> b;
  string a_copy = a;
  do {
    char c = a_copy[0];
    rep(i, a_copy.size() - 1) a_copy[i] = a_copy[i + 1];
    a_copy[a_copy.size() - 1] = c;
    rep(i, a_copy.size()) {
      if (a_copy[i] == b[0]) {
        int count = 0;
        rep(j, b.size()) {
          if (i + j + 1 > a_copy.size()) break;
          if (a_copy[i + j] == b[j]) count++;
          if (count == b.size()) {cout << "Yes" << endl; return 0;}
        }
      }
    }
  } while(a_copy != a);
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3204