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

int main(){
  int n,m;
  string s[100];
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  sort(s,s+n);
  for(int i=0;i<n;i++){
    cout<<s[i];
  }
  cout<<endl;
}

Measured memory_bytes: 256
def main():
    N, M, X = map(int, input().split())

    books = [list(map(int, input().split())) for _ in range(N)]

    min_total_cost = 10**9

    for i in range(2**N):
        total_cost = 0
        learned = [0] * M

        for j in range(N):
            if (i >> j) & 1:
                cost, *points = books[j]
                total_cost += cost

                learned = [x + y for x, y in zip(learned, points)]

        if min(learned) >= X:
            min_total_cost = min(min_total_cost, total_cost)

    if min_total_cost == 10**9:
        print('-1')
    else:
        print(min_total_cost)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9220
#include<iostream>
#include<set>
using namespace std;
long a,b,c;
int n;
long ans;
main()
{
	cin>>a>>b>>c>>n;
	ans=2*a*b+2*b*c+2*c*a;
	set<pair<int,pair<int,int> > >S;
	for(;n--;)
	{
		int x,y,z;cin>>x>>y>>z;
		int cnt=!x+!y+!z+(x==a-1)+(y==b-1)+(z==c-1);
		cnt+=S.find(make_pair(x-1,make_pair(y,z)))!=S.end();
		cnt+=S.find(make_pair(x+1,make_pair(y,z)))!=S.end();
		cnt+=S.find(make_pair(x,make_pair(y-1,z)))!=S.end();
		cnt+=S.find(make_pair(x,make_pair(y+1,z)))!=S.end();
		cnt+=S.find(make_pair(x,make_pair(y,z-1)))!=S.end();
		cnt+=S.find(make_pair(x,make_pair(y,z+1)))!=S.end();
		ans+=6-cnt*2;
		S.insert(make_pair(x,make_pair(y,z)));
	}
	cout<<ans<<endl;
}



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

int main(void){
    int n, a, b;
    cin >> n >> a >> b;
    if(n*a < b){
        cout << n*a << endl;
    }else{
        cout << b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

ll gcd(ll x,ll y){
  if (y==0){
    return x;
  }
  return gcd(y,x%y);
}

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    ll M=0;
    rep(i,N){
        cin >> A[i];
        M=max(M,A[i]);
    }
    ll g=gcd(A[0],A[1]);
    for (int i=2;i<N;i++){
        g=gcd(g,A[i]);
    }
    if (K%g==0&&K<=M){
        cout << "POSSIBLE" << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main(){
	IOS;
	int n, k;
	cin >> n >> k;
	int arr[n];
	for(int i = 0; i < n; i++)
		cin >> arr[i];

	sort(arr, arr+n);
	int ans = 0;
	for(int i = 0; i < k; i++)
		ans += arr[i];

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

Measured memory_bytes: 3560
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



struct Edge{
	Edge(int arg_pre,int arg_current){
		pre = arg_pre;
		current = arg_current;
	}
	int current,pre;
};


typedef vector<ll> V;
typedef vector<V> MATRIX;

vector<Edge> edge;
int num_station,N,M,Z,start,goal;

MATRIX calc(MATRIX left,MATRIX right){

	MATRIX ret(N,V(N));

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++)ret[i][k] = 0;
	}

	for(int row = 0; row < N; row++){
		for(int col = 0; col < N; col++){
			for(int a = 0; a < N; a++){
				ret[row][col] |= left[row][a]*right[a][col];
			}
		}
	}

	return ret;

}


MATRIX pow(MATRIX MULT,int count){

	MATRIX ret(N,V(N));

	for(int row = 0; row < N; row++){
		for(int col = 0; col < N; col++){
			if(row == col)ret[row][col] = 1;
			else{
				ret[row][col] = 0;
			}
		}
	}

	while(count > 0){
		if(count%2 == 1)ret = calc(ret,MULT);
		MULT = calc(MULT,MULT);
		count /= 2;
	}

	return ret;
}

void func(){

	goal = num_station-1;
	edge.clear();

	edge.push_back(Edge(0,0));

	int from,to;
	for(int loop = 0; loop < M; loop++){
		scanf("%d %d",&from,&to);
		from--;
		to--;
		edge.push_back(Edge(from,to));
		edge.push_back(Edge(to,from));
	}

	N = 2*M+1;

	MATRIX MULT(N,V(N));

	for(int i = 0; i < edge.size(); i++){
		if(edge[i].pre == 0 && edge[i].current != 0){
			MULT[0][i] = 1;
		}else{
			MULT[0][i] = 0;
		}
	}

	vector<int> TO_GOAL;

	for(int i = 1; i < edge.size(); i++){
		if(edge[i].current == goal){
			TO_GOAL.push_back(i);
		}
		for(int k = 0; k < edge.size(); k++){
			if(k == 0){
				MULT[i][k] = 0;
				continue;
			}

			if(edge[k].current != edge[i].current && edge[k].pre == edge[i].current && edge[k].current != edge[i].pre){
				MULT[i][k] = 1;
			}else{
				MULT[i][k] = 0;
			}
		}
	}

	if(Z > 1){
		MULT = pow(MULT,Z);
	}

	bool FLG = false;

	for(int i = 0; i < TO_GOAL.size(); i++){
		if(MULT[0][TO_GOAL[i]] != 0){
			FLG = true;
			break;
		}
		if(FLG)break;
	}


	if(!FLG){
		printf("no\n");
	}else{
		printf("yes\n");
	}
}


int main(){

	start = 0;

	while(true){
		scanf("%d %d %d",&num_station,&M,&Z);
		if(num_station == 0 && M == 0 && Z == 0)break;

		func();
	}
	return 0;
}




Measured memory_bytes: 3452
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

static const ll INF = 1e9+10;
int main(){
    ll N; cin >> N;
    vector<ll> A(N+1), B(N+1), C(N+1);
    for(ll i = 0; i < N;  i++) cin >> A[i];
    for(ll i = 0; i < N;  i++) cin >> B[i];
    for(ll i = 0; i < N;  i++) cin >> C[i];
    A[N] = INF, B[N] = INF, C[N] = INF;

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long ans = 0;

    vector<ll> B_C(N+1, 0);
    for(ll i = 0; i < N; i++){
        ll b = B[i];
        ll idc = upper_bound(C.begin(), C.end(), b) - C.begin();
        B_C[i] = N-idc;
    }
    for(ll i = N-2; i >= 0; i--){
        B_C[i] = B_C[i+1] + B_C[i];
    }

    for(ll i = 0; i < N; i++){
        ll idb = upper_bound(B.begin(), B.end(), A[i]) - B.begin();
        ans += B_C[idb];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int a, b;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> a >> b;
	int c = a + b;
	cout << (a % 3 == 0 || b % 3 == 0 || c % 3 == 0 ? "Possible" : "Impossible") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int a[2][3];

int solve() {
    sort(a[0], a[0]+3);
    int res = 0, i = 0;
    while (true) {
        if (a[i][0] % 2 || a[i][1] % 2 || a[i][2] % 2) break;
        for (int j = 0; j < 3; j++) {
            a[1-i][j] = (a[i][j] + a[i][(j+1)%3]) / 2;
        }
        sort(a[1-i], a[1-i]+3);
        if (a[i][0] == a[1-i][0] && a[i][1] == a[1-i][1] && a[i][2] == a[1-i][2]) return -1;
        i = 1 - i;
        res++;
    }
    return res;
}

void input() {
    for (int i = 0; i < 3; i++) cin >> a[0][i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len;
    cin >> len;
    set<int> s;
    for(int i = 0; i < len; i++) {
        int a;
        cin >> a;
        if(s.count(a))
            s.erase(a);
        else
            s.insert(a);
    }
    cout << s.size();
}

Measured memory_bytes: 8244
import sys
input = sys.stdin.readline
from collections import deque

mod = 10 ** 9 + 7
N = int(input())
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

P = [-1] * N
Q = deque([0])
R = []
while Q:
    i = deque.popleft(Q)
    R.append(i)
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            X[a].remove(i)
            deque.append(Q, a)

##### Settings
unit = 1
merge = lambda a, b: a * b % mod
adj_bu = lambda a, i: a * inv(SIZE[i]) % mod
adj_td = lambda a, i, p: a * inv(N-SIZE[i]) % mod
adj_butd = lambda a, i: a * inv(N) % mod
#####

nn = 200200
mod = 10**9+7

fa = [1] * (nn+1)
fainv = [1] * (nn+1)
for i in range(nn):
    fa[i+1] = fa[i] * (i+1) % mod
fainv[-1] = pow(fa[-1], mod-2, mod)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % mod

inv = lambda i: fainv[i] * fa[i-1] % mod

SIZE = [1] * N
for i in R[1:][::-1]:
    SIZE[P[i]] += SIZE[i]

ME = [unit] * N
XX = [0] * N
TD = [unit] * N
for i in R[1:][::-1]:
    XX[i] = adj_bu(ME[i], i)
    p = P[i]
    ME[p] = merge(ME[p], XX[i])
XX[R[0]] = adj_bu(ME[R[0]], R[0])

for i in R:
    ac = TD[i]
    for j in X[i]:
        TD[j] = ac
        ac = merge(ac, XX[j])
    ac = unit
    for j in X[i][::-1]:
        TD[j] = adj_td(merge(TD[j], ac), j, i)
        ac = merge(ac, XX[j])
        XX[j] = adj_butd(merge(ME[j], TD[j]), j)

XX = [x * fa[N] % mod for x in XX]
print(*XX, sep = "\n")

Measured memory_bytes: 123980
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
T GCD(T a, T b) {if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }
template<class T>
inline T upper(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	string s;
	cin >> s;

	bool flg = false;
	int cnt = 0, ans = 0;
	for (char c : s) {
		if (c == 'A') {
			flg = true;
		}

		if (flg) cnt++;

		if (c == 'Z') ans = cnt;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
int n, m;
bool vis[N];
int a[N];

void solve()
{
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        a[i] = i;
    if (n & 1)
    {
        for (int i = 1; i <= m; ++i)
            printf("%d %d\n", (n >> 1) + 1 - i, (i << 1) + (n >> 1) - i);
    }
    else
    {
        int tot = 0;
        for (int i = 1; i <= n / 4; ++i)
        {
            tot++;
            printf("%d %d\n", i, (n / 2) - i + 1);
            if (tot >= m)
                return;
        }
        for (int i = n / 2 + 1, j = n - 1;; ++i, --j)
        {
            tot++;
            printf("%d %d\n", i, j);
            if (tot >= m)
                return;
        }
    }
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);

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

    std::cin >> n;

    int ans = 0;
    int top = 10;
    int low = 1;
    for (int i = 1; i <= n; ++i) {
        if (low <= i && i < top)
            ++ans;
        if (i >= top) {
            top *= 100;
            low *= 100;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
from collections import deque

N,M=map(int,input().split())

#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [[]for i in range(N+1)]
deq=deque()

for i in range(M):
    A,B=map(int,input().split())
    S[A].append(B)
    S[B].append(A)
    
#print(S)    
lenN=len(S[N])
for i in range(lenN):
    v=S[N][i]
    #print(v)
    #print(S[v])
    
    if 1 in S[v]: 
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")        

Measured memory_bytes: 38656
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,x,b;
    while(cin>> x >> a >>b)
    {
        long s=0,r=0;
        s=(abs(x-a)),r=(abs(x-b));
        if(s<r) cout << "A";
        else cout <<"B";
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
char s[101];
A(){
	char a[101],b[101],t,t2;
	return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);
}
B(){
	char*p=s,l=0;
	if(*p=='>'&&*++p=='^'){
		for(;*++p=='Q';l++)
			if(*++p!='=')
				return 0;
		if(l>0&&*p=='~'&&*++p=='~'&&*++p==0)
			return 1;
	}
	return 0;
}
main(){
	scanf("%*d\n");
	for(;~scanf("%[^\n]\n",s);){
		if(A())
			puts("A");
		else if(B())
			puts("B");
		else
			puts("NA");
	}
}

Measured memory_bytes: 0
#include<stdio.h>
int main (void){
int a,b,c,d,e,f;
scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
int g[10];
g[0]=b-a;
g[1]=c-a;
g[2]=d-a;
g[3]=e-a;
g[4]=c-b;
g[5]=d-b;
g[6]=e-b;
g[7]=d-c;
g[8]=e-c;
g[9]=e-d;
if(g[0]<=f&&g[1]<=f&&g[2]<=f&&g[3]<=f&&g[4]<=f&&g[5]<=f&&g[6]<=f&&g[7]<=f&&g[8]<=f&&g[9]<=f){
  printf("Yay!");
}else{
  printf(":(");
}
return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

signed main(){

	lli n;
	cin>>n;
	map<lli,vector<lli>> ab;
	vector<lli> a(n),b(n);
	REP(i,0,n-1){
		lli tmpA,tmpB;
		cin>>tmpA>>tmpB;
		ab[tmpA].push_back(tmpB);
		ab[tmpB].push_back(tmpA);
		a[i]=tmpA;
		b[i]=tmpB;
	}

	vector<lli> c(n);
	REP(i,0,n)cin>>c[i];
	sort(c.begin(),c.end(),greater<lli>());

	/*隣り合う点が1つしかない箇所から順に埋めていき、そこから幅優先探索を行う*/

	queue<lli> q;
	lli ans[10010]={0};
	lli index = 0;
	ans[1]=c[0];
	index++;
	q.push(1);

	while(q.size()){
		lli top = q.front();
		q.pop();
		for(lli i=0;i<ab[top].size();i++){
			lli now = ab[top].at(i);
			if(ans[now]==0){
				ans[now]=c[index];
				q.push(now);
				index++;
			}
		}
	}

	lli sum=0;
	for(lli i=0;i<n-1;i++){
		sum += min(ans[a[i]],ans[b[i]]);
	}
	cout<<sum<<endl;
	REP(i,1,n+1){
		cout<<ans[i]<<" ";
	}
	cout<<endl;

	return 0;
}

Measured memory_bytes: 1920
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let rdx: Vec<u32> = read_vec();
    let r = rdx[0];
    let d = rdx[1];
    let mut tmp = rdx[2];
    for _ in 0..10 {
        tmp = r * tmp - d;
        println!("{}", tmp);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  int M;
  cin >> M;
  vector<P> work(N);
  for (int i = 0; i < N; i++) cin >> work[i].first >> work[i].second;
  sort(work.begin(),work.end());
  priority_queue<int, vector<int>, less<int>> Q;
  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < M; i++) {
    while (0 == 0) {
      if (cnt == N) {
        break;
      }
      if (work[cnt].first <= i+1) {
        Q.push(work[cnt].second);
        cnt++;
      } else {
        break;
      }
    }
    if (!Q.empty()) {
      int money = Q.top();
      ans += money;
      Q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int D[40][40],C[600][600],P[3][40],ans=2147483647;
int main() {
	int n,c;
	cin>>n>>c;
	 for (int i=1;i<=c;i++)
        for (int j=1;j<=c;j++)
            cin>>D[i][j];
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
            cin>>C[i][j];
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
            for (int k=1;k<=c;k++)
                P[(i+j)%3][k]+=D[C[i][j]][k];
    for (int i=1;i<=c;i++)
        for (int j=1;j<=c;j++)
            for (int k=1;k<=c;k++)
                if (i!=j&&i!=k&&j!=k)
                    ans=min(ans,P[0][i]+P[1][j]+P[2][k]);
    cout<<ans<<endl;
 
	return 0;
}

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


int main(){
    string X; cin >> X;
    stack<char> st;
    
    for(int i=0; i<X.length(); i++){
        if(X[i]=='S'){
            st.push(X[i]);
        }
        else if(X[i]=='T' && st.empty()){
            st.push(X[i]);
        }
        else if(X[i]=='T' && st.top()=='T'){
            st.push(X[i]);
        }
        else if(X[i]=='T' && st.top()=='S'){
            st.pop();
        }
    }
    
    cout << st.size() << endl;
}


Measured memory_bytes: 644
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	ll q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;

	ll mi_1l = min(s, min(h * 2, q * 4));
	ll mi_2l = min(s * 2, min(h * 4, min(q * 8, d)));

	cout << n / 2 * mi_2l + n % 2 * mi_1l << endl;
	
	return	0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
S = input().strip()

ans = 0

for bit in range(2 ** (len(S) - 1)):
    th = [0]
    for i in range(len(S) - 1):
        if bit & (0x01 << i):
            th.append(i + 1)
    th.append(len(S))
    
    ans += sum([int(S[th[i]: th[i + 1]]) for i in range(len(th) - 1)])

print(ans)

Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int N;
  cin >> N;
  if (N % 10 == 3) cout << "bon" << endl;
  else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) cout << "pon" << endl;
  else cout << "hon" << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 3616
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int K, T;
  cin >> K >> T;
  priority_queue<int> que;
  FOR(i,0,T) {
    int in;
    cin >> in;
    que.push(in);
  }
  while(!que.empty()) {
    int a = que.top();que.pop();
    if(que.empty()) {
      cout << a - 1 << endl;
      return 0;
    }
    int b = que.top();que.pop();
    if(a-1>0) que.push(a-1);
    if(b-1>0) que.push(b-1);
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
# assign prize of the 3 places
first = 300000
second = 200000
third = 100000
extra = 400000
no = 0
# get two integers as the competitions
X, Y = map(int, input().split())
# output
if X == 1 and Y == 1:
    {
        print(first + first + extra)
    }
elif X == 1 and Y == 2:
    {
        print(first + second)
    }
elif X == 1 and Y == 3:
    {
        print(first + third)
    }
elif X == 2 and Y == 1:
    {
        print(second + first)
    }
elif X == 2 and Y == 2:
    {
        print(second + second)
    }
elif X == 2 and Y == 3:
    {
        print(second + third)
    }
elif X == 3 and Y == 1:
    {
        print(third + first)
    }
elif X == 3 and Y == 2:
    {
        print(third + second)
    }
elif X == 3 and Y == 3:
    {
        print(third + third)
    }
elif X == 1 and Y > 3:
    {
        print(first + no)
    }
elif X == 2 and Y > 3:
    {
        print(second + no)
    }
elif X == 3 and Y > 3:
    {
        print(third + no)
    }
elif X > 3 and Y == 3:
    {
        print(no + third)
    }
elif X > 3 and Y == 2:
    {
        print(no + second)
    }
elif X > 3 and Y == 1:
    {
        print(no + first)
    }
else:
    {
        print(0 )
    }

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<vector>
#include<ctime>
#define ll long long
#define pr(x) cerr<<#x<<"="<<x<<endl
using namespace std;
#define N 500010
ll sum[N],a[N],b[N],c[N],ex[N],sumb[N],ans,i,n,cnt,size;
void init()
{
	sort(ex+1,ex+1+cnt);
	size=unique(ex+1,ex+1+cnt)-ex-1;
	for (i=1;i<=n;i++) 
	{
		a[i]=upper_bound(ex+1,ex+1+size,a[i])-ex-1;
		b[i]=upper_bound(ex+1,ex+1+size,b[i])-ex-1;
		c[i]=upper_bound(ex+1,ex+1+size,c[i])-ex-1;
	}
}
int main()
{
	scanf("%lld",&n);
	for (i=1;i<=n;i++) scanf("%lld",&a[i]),ex[++cnt]=a[i];
	sort(a+1,a+1+n);
	for (i=1;i<=n;i++) scanf("%lld",&b[i]),ex[++cnt]=b[i];
	sort(b+1,b+1+n);
	for (i=1;i<=n;i++) scanf("%lld",&c[i]),ex[++cnt]=c[i];
	sort(c+1,c+1+n);
	init();
	for (i=1;i<=n;i++) sum[a[i]+1]++;
	for (i=1;i<=size;i++) sum[i]+=sum[i-1];
	for (i=1;i<=n;i++) sumb[b[i]+1]+=sum[b[i]];
	for (i=1;i<=size;i++) sumb[i]+=sumb[i-1];
	for (i=1;i<=n;i++) ans+=sumb[c[i]];
	printf("%lld\n",ans);
}

Measured memory_bytes: 22784
#include<bits/stdc++.h>
using namespace std;
int M=1000000007;
long long int kai(int n){
  if(n==1) return 1;
  long long int ret=n*kai(n-1)%M;
  return ret;
}
int main(){
  int n,m;cin>>n>>m;
  if(abs(n-m)>1) cout<<0<<endl;
  if(abs(n-m)==1){
    long long int a=(kai(n)*kai(m))%M;
    cout<<a<<endl;
  }
  if(n==m){
    long long int b=(kai(n)*kai(n)*2)%M;
    cout<<b<<endl;
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
   int a, b, c;
   cin >> a >> b >> c;
   if(a == b && b == c){
       cout << '1' << endl;
   } else if(a == b || a == c || b == c) {
       cout << '2' << endl;
   } else {
       cout << '3' << endl;
   }
   return 0;
}

Measured memory_bytes: 256
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    if(p!=2&&p!=5){
    reverse(all(s));
    int co[p],cur=0,ans=0,exp=1;;
    fill(co, 0);
    co[0]++;
    for(int i=0;i<n;i++)
    {
        //cout<<s[i]<<" ";
        int num=(int)(s[i]-'0');
        num=(num*exp)%p;
        cur=(cur+num)%p;
        //cout<<num<<" "<<cur<<" "<<co[cur]<<"\n";
        ans+=co[cur];
        co[cur]++;
        exp=(exp*10)%p;
    }
    cout<<ans;
    }
    else
    {
        int ans=0;
        for(int i=n-1;i>=0;i--)
        {
            int num=s[i]-'0';
            if(num%p==0)
            ans+=(i+1);
        }
        cout<<ans;
    }
}


Measured memory_bytes: 3776
N = int(input())
bool = 0
data = list(map(int,input().split()))
for i in range(1,N):
  a = data[N-i]
  p = data[N-i-1]
  if p <= a:
    continue
  elif p-1 == a:
    data[N-i-1] -= 1
  else:
    bool = 1
    print('No')
    break
if bool == 0:
  print('Yes')

Measured memory_bytes: 14396
H,W,K = map(int, input().split())
C = []
for i in range(H):
    C.append(list(input()))
ans = 0

for maskH in range(1<<H):
    for maskW in range(1<<W):
        black = 0
        for i in range(H):
            for j in range(W):
                #両方のmaskが0の時だけ、'#'ならblack++する
                if maskH&(1<<i) and maskW&(1<<j) and C[i][j]=='#':
                    black += 1
        if black == K:
            ans += 1

print(ans)

Measured memory_bytes: 9200
#include <stdio.h>

int main(void){
    int H, W, i, j;
    //scan H and W until 0 0
    while(1){
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0 )
        break;

    for ( i = 1; i <= H; i++ ){
        for ( j = 1; j <= W; j++ ){
            if(i%2 != j%2){
                printf(".");
            } else {
                printf("#");
            }
        }
        printf("\n");
    }
        printf("\n");
    }
}

    


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int N; cin >> N;
    vector<double> V(N);
    REP(i,N) cin >> V[i];
    sort(ALL(V));
    double ans = V[0];

    FOR(i,1,N){
        ans = (ans+V[i])/2.0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3784
#include <cstdio>
#include <iostream>
#include <algorithm>
//#include <vector>
//#include <set>
#include <map>
//#include <string>
#include <cstring>
//#include <stack>
#include <queue>
//#include <cmath>
//#include <ctime>
//#include <bitset>
//#include <utility>
//#include <assert.h>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
#define tm tmp
//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const int INF=0x3f3f3f3f;
const double INFF=1e24;
const int MAX=1e5+5;
//const ll MAXN=2e8;
//const int MAX_N=MAX;
const ll MOD=1e9+7;
//const long double pi=acos(-1.0);
const long double eps=1e-9;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
void open()
{
//    freopen("1009.in","r",stdin);
    freopen("out.txt","w",stdout);
}
char a[15];
int main()
{
    while(~scanf("%s",a))
    {
        if(strlen(a)<4)
            printf("No\n");
        else if(a[0]=='Y'&&a[1]=='A'&&a[2]=='K'&&a[3]=='I')
            printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}
/*

*/


Measured memory_bytes: 256
import sys
N = int(input())
array_value = list(map(int,input().split()))
array_cost = list(map(int,input().split()))

if not ( 1 <= N <= 20 ): sys.exit()
for I in array_value:
    if not ( 1 <= I <= 50 ): sys.exit()
for J in array_cost:
    if not ( 1 <= J <= 50 ): sys.exit()

value_check = 0
for K in range(len(array_value)):
    value = array_value[K] - array_cost[K]
    value_check += value if value >= 1 else 0

print(value_check)

Measured memory_bytes: 9140
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
  for j in range(i+1, n):
    for k in range(j+1, n):
      if l[i]+l[j]>l[k] and l[i]+l[k]>l[j] and l[j]+l[k]>l[i] and l[i] != l[j] and l[j] != l[k] and l[i] != l[k]: 
        ans += 1
print(ans)

Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

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

	int n;
	cin >> n;
	string s;
	cin >> s;
	if (n & 1) {
		cout << "No\n";
	} else {
		int ok = 1;
		for (int i = 0; i < n / 2; i++) {
			ok &= (s[i] == s[i + n / 2]);
		}
		if (ok) cout << "Yes\n";
		else cout << "No\n";
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
typedef long long LL;
const int N=5005,P=1e9+7;
int n,A,B,f[N],g[N][2];
int fpow(int k1,int k2){
	int k3=1;
	for(;k2;k2>>=1,k1=1LL*k1*k1%P)if(k2&1)k3=1LL*k3*k1%P;
	return k3;
}
int main(){
	cin>>n>>A>>B;
	if(A>B)swap(A,B);
	f[1]=1;
	rep(i,1,B-1){
		(f[i+1]+=f[i])%=P;
		rep(j,i+A+1,B)(f[j]+=f[i])%=P;
	}
//	printf(">>> %d %d\n",A,B);
//	rep(i,1,B)printf("%d ",f[i]);puts("");
	rep(i,1,B-1)g[i][0]=f[i+1];
	rep(i,1,A-1)g[i][1]=1;
	rep(i,1,n){
		rep(j,i+1,min(n,i+B-1))if(j==n)(g[j][0]+=1LL*g[i][1]*f[j-i+1]%P)%=P;else (g[j][0]+=1LL*g[i][1]*f[j-i]%P)%=P;
		rep(j,i+1,min(n,i+A-1))(g[j][1]+=g[i][0])%=P;
//		printf("g[%d][0]=%d g[%d][1]=%d\n",i,g[i][0],i,g[i][1]);
	}
	printf("%lld\n",((LL)fpow(2,n)-g[n][0]-g[n][1]+P+P)%P);
	return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;

const int N = 2005, M = 1e9 + 7;
int n, k, a[N];

int main() {
    cin >> n >> k;
    FI(i,1,n) scanf("%d", &a[i]);
    int mul = 1LL * k * (k - 1) / 2 % M;
    int inner = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            if (a[i] > a[j]) inner++;
        }
    }
    inner = 1LL * inner * k % M;
    int outer = 0;
    for (int i = 1; i <= n; i++) {
        int cnt = 0;
        for (int j = 1; j <= n; j++) {
            if (a[j] > a[i]) cnt++;
        }
        outer += 1LL * cnt * mul % M;
        outer %= M;
    }
    cout << (inner + outer) % M << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=55;
int n;
int a[maxn],b[maxn];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(a,a+n);
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]!=b[i])
		cnt++;
	}
	if(cnt==2 || cnt==0)
	puts("YES");
	else
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<algorithm>
#include<queue>
#include<string>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
string edge[10][2];

string substitute(string tar,string &from,string &to){
  string ret;
  for(int i=0;i<tar.size();i++){
    bool flag=true;
    rep(j,from.size()){
      if ( from[j]!=tar[i+j]){flag=false;break;}
    }
    if ( flag == false)ret+=tar[i];
    else {
      ret+=to;
      i+=from.size()-1;
    }
  }
  return ret;
}

int bfs(string &start,string &goal,int n){
  queue<pair<string,int> > Q;
  set<string>S;
  Q.push(make_pair(start,0));
  S.insert(start);
  while(!Q.empty()){
    pair<string,int> now =Q.front();
    Q.pop();
    if ( now.first == goal)return now.second;
    rep(i,n){
      string next = substitute(now.first,edge[i][0],edge[i][1]);
      if ( S.find(next) == S.end() && next.size()<= goal.size()){
	S.insert(next);
	Q.push(make_pair(next,now.second+1));
      }
    }
    
  }
  return -1;
}


main(){

  int n;
  while(cin>>n && n){
    string start,goal;
    rep(i,n)cin>>edge[i][0]>>edge[i][1];
    cin>>start>>goal;
    cout << bfs(start,goal,n) <<endl;
  }
}

Measured memory_bytes: 1056
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main() {
	int n, d, a; cin >> n >> d >> a;
	vector<pair<int, int> > xh(n);
	for (auto& e : xh) cin >> e.first >> e.second;
	sort(xh.begin(), xh.end());
	vector<long long> imos(n + 1);
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		if (i) imos[i] += imos[i - 1];
		long long tmp = xh[i].second - imos[i] * a;
		if (tmp > 0) {
			int r = upper_bound(xh.begin(), xh.end(), make_pair(xh[i].first + 2 * d, (int)1e9)) - xh.begin();
			long long cnt = (tmp + a - 1) / a;
			imos[i] += cnt;
			imos[r] -= cnt;
			ans += cnt;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
using namespace std;
int s[10000];
vector<int>v[10000];
int main(void) {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		s[i] = i;
		v[i].push_back(i);
	}
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		int k;
		cin >> k;
		if (k) {
			int a, b;
			cin >> a >> b;
			cout << (s[a] == s[b]) << endl;
		}
		else {
			int a, b;
			cin >> a >> b;
			a = s[a];
			b = s[b];
			if (a == b) continue;
			for (int j = 0; j < v[b].size(); j++) {
				v[a].push_back(v[b][j]);
				s[v[b][j]] = a;
			}
		}
	}
}


Measured memory_bytes: 59972
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <cmath>
#include <sstream>
#include <map>
#define F first
#define S second
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
typedef pair<double, double> pdd;
typedef pair<int, int> pii;
typedef pair< int , pair<int, int> > pip;
typedef unsigned long long ull;
const double EPS = 10e-6;
const int MMM = 1000000007;
ull gcd(ull m, ull n) {
	if (m < n)swap(m, n);
	if (n == 0)return m;
	return gcd(n, m % n);
}
ull lcm(ull m, ull n) {
	return m * n / gcd(m, n);
}

int gcd(int m, int n) {
	if (m < n)swap(m, n);
	if (n == 0)return m;
	return gcd(n, m % n);
}
int lcm(int m, int n) {
	return m * n / gcd(m, n);
}
int main()
{
	string a;
	while(cin>>a&&a!="#")
	{
		int ansa=(a[a.size()-1]=='h')?0:90,ansb=1;
		int n,w;
		for(int i=a.size()-6;i>=0;i--)
		{
			if(a[i]=='w')
			{
				ansa*=2;
				ansb*=2;
				ansa+=90;
			}
			else if(a[i]=='n')
			{
				ansa*=2;
				ansb*=2;
				ansa-=90;
			}
			
		}
		while(ansb!=1&&ansa!=0&&ansb%2==0&&ansa%2==0)
		{
			ansb/=2;
			ansa/=2;
		}
		if(ansb==1||ansa==0)cout<<abs(ansa)<<endl;
		else
		 cout<<abs(ansa)<<"/"<<abs(ansb)<<endl;
	}
}

Measured memory_bytes: 1192
import collections
import functools
import itertools
import math
import operator


N = int(input())


def get_prime_factorized(N):
    R = []
    b, e = 2, 0
    while b ** 2 <= N:
        while N % b == 0:
            N  = N // b
            e += 1
        if e > 0:
            R.append([b, e])
        b, e = b + 1, 0
    if N > 1:
        R.append([N, 1])
    return R

def n_C_r(n, r):
    return int(math.factorial(n) / math.factorial(r) / math.factorial(n-r))

if N > 9:
    L = [l[1]+1 for l in get_prime_factorized(math.factorial(N))]
    L = [[3, 5, 15, 25, 75] if l >= 75 else [3, 5, 15, 25] if l >= 25 else [3, 5, 15] if l >= 15 else [3, 5] if l >= 5 else [3] if l >= 3 else [1] for l in L]
    L = [l for l in L if l != [1]]
    L = list(itertools.chain.from_iterable(L))
    C = collections.Counter(L)

    R = C[75] + n_C_r(C[5], 2) * n_C_r(C[3]-2, 1) + C[25] * (C[3] - 1) + C[15] * (C[5] - 1)

    print(R)
else:
    print(0)


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

ll A, B, C;
ll K;

int main(void) {
    cin >> A >> B >> C >> K;

    ll ans = 0;

    ans += 1 * min(A, K);
    K -= A;
    if (K > 0) {
        K -= B;
        if (K > 0) {
            ans -= 1 * min(C, K);
        }
    }

    cout << ans << endl;


    return 0;
}

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

using namespace std;

int main()
{
    unsigned long a, b;
    unsigned long d, r;
    double f;

    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = 1.000000 * a / b;
    cout << d << " " << r << " ";
    printf("%.5lf\n", f);
    return 0;
} 

Measured memory_bytes: 1236
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        if (a < b) {
            for (int i = 0; i < b; i++) {
                System.out.print(a);
            }
        } else {
            for (int i = 0; i < a; i++) {
                System.out.print(b);
            }
        }
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
#define MOD (int)10000000007
#define X 1001100011100001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for0e(i, n) for (int i = 0; i <= n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define ll long long int
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define F first
#define S second
#define pi pair<int, int>
#define ppi pair<pair<int,int> , int >
#define vii vector<pi>
const int MAXN = (int)((1e5) + 100);
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;} 
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int N =  (int)(1e6+5); 
// ========================================================
signed main(){
  #ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  #endif
  fio;
    ll n, k, ans;
    cin>>n>>k;
    // operation = replace n with abs(n-k) zero or more times
    cout<<min(n%k,k-(n%k));
  rr;
}



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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 2e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7;
const ll infll = 1e18 + 7;

int n, k, ans;
bool a[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> k;
    ForE(i, 1, k){
        int x; cin >> x;
        while (x--){
            int y; cin >> y; a[y] = 1;
        }
    }
    ForE(i, 1, n){
        if (!a[i]) ans++;
    }
    cout << ans;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

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

int main() 
{ 
 int buy,oturi,kozeni,a,b,c,d,e,f; 
 while(1){
  cin>>buy;
  if(buy==0)
   break;
  else{
   oturi=1000-buy;
   a=oturi/500;
   if(a)b=(oturi-500)/100;
     else b=oturi/100;
   c=oturi%100/50;
   if(c)d=(oturi%100-50)/10;
     else d=oturi%100/10;
   e=oturi%10/5;
   if(e)f=oturi%10-5;
      else f=oturi%10;   

   kozeni=a+b+c+d+e+f;
   cout<<kozeni<<"\n";
  }
 }
 return 0; 
} 
  

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
  int n;
  cin >> n;
  int c = 0;
  rep(i,n){
	int a;
    cin >> a;
    c += a%2;
  }
  if(c%2==0){
  	cout << "YES"<< endl;  
  }else{
  	cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256