akhauriyash/Code-Regression huggingface dataset:
//AOJ 0567: Best Pizza
#include<iostream>
#include<algorithm>
using namespace std;
const int MAX_N = 100;
int n, a, b, c, ans, cal = 0, cost = 0, tcal[MAX_N];
int main(){
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++){
		cin >> tcal[i];
	}
	ans = c / a;
	cost = a;
	cal = c;
	sort(tcal, tcal + n);
	for (int i = n - 1; i >= 0; i--){
		if (ans < tcal[i] / b){
			cal += tcal[i];
			cost += b;
			ans = cal / cost;
		}
		else break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1180
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        String[] a = new String[n];
        String[] b = new String[n];
        for(int i = 0; i < n; i++) {
            String c = sc.next();
            char mark = c.charAt(0);
            char num = c.charAt(1);
            a[i] = String.valueOf(mark) + String.valueOf(num);
            b[i] = String.valueOf(mark) + String.valueOf(num);
        }

        bubbleSort(a, n);
        selectionSort(b, n);

        printArray(a, n);
        System.out.println("Stable");
        printArray(b, n);
        if(equals(a, b, n)){
            System.out.println("Stable");
        }else{
            System.out.println("Not stable");
        }
    }

    private static void printArray(String[] a, int n) {
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++) {
            if(i != 0) sb.append(" ");
            sb.append(a[i]);
        }
        System.out.println(sb);
    }

    private static boolean equals(String[] a, String[] b, int n) {
        for(int i = 0; i < n; i++) {
            if(!a[i].equals(b[i])) return false;
        }
        return true;
    }

    private static void bubbleSort(String[] a, int n) {
        boolean flag = true;
        while(flag) {
            flag = false;
            for(int j = n - 1; j >= 1; j--) {
                if(a[j].charAt(1) < a[j - 1].charAt(1)) {
                    String tmp = a[j];
                    a[j] = a[j - 1];
                    a[j - 1] = tmp;
                    flag = true;
                }
            }
        }
    }

    private static void selectionSort(String[] a, int n) {
        for(int i = 0; i < n - 1; i++) {
            int minj = i;
            for(int j = i + 1; j < n; j++) {
                if(a[j].charAt(1) < a[minj].charAt(1)) minj = j;
            }

            if(i != minj){
                String tmp = a[i];
                a[i] = a[minj];
                a[minj] = tmp;
            }
        }
    }
}


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

int main(){
  int k,x;cin >> k >> x;
  if(500*k >= x)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
var xx = IntArray(0)
var yy = IntArray(0)

fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    xx = IntArray(n){0}
    yy = IntArray(n){0}

    repeat(n) {
        val (x, y) = readLine()!!.split(" ").map { it.toInt() }
        xx[it] = x
        yy[it] = y
    }

    /*
    NOTE:

    A (0, 0)
    B (100 0)
    C (0, 100)

    AB -> 100
    AC -> 100
    BC -> 100√2

    ABC 100 + 100√2 => AB+BC
    ACB 100 + 100√2 => AC+BC
    BAC 100 + 100 => AB+AC
    BCA 100√2 + 100 => BC+AC
    CAB 100 + 100 => AB+AC
    CBA 100√2 + 100 => BC+AB
    —> AB*4 + BC*4 + AC*4
    => (AB+AC+BC)*4 / N! (== 3*2*1)
    => (AB+AC+BC)*2 / 3
    => (AB+AC+BC)*2 / N

    sum*2*(N-1)! / N!
    =>  sum*2 / N
    */
    var sum = 0.0
    for (i in 0 until n-1) {
        for (j in i+1 until n) {
            sum += Math.sqrt(Math.pow((xx[i]-xx[j]).toDouble(), 2.0) + Math.pow((yy[i]-yy[j]).toDouble(), 2.0))
        }
    }

    println(sum * 2 / n)
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    ll n, k;
    cin >> n >> k;
    cout << k * (ll) pow(k - 1, n - 1) << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define mod 924844033
#define next nxt

int n,x[N],y[N],next[N],p[N],s[N],r[N];
long long fac[N],inv[N],a[N],b[N];

void travel(int x){
	s[x]=1;
	for (int t=p[x];t;t=next[t])
		if (!s[y[t]])
		travel(y[t]),s[x]+=s[y[t]];
}

long long power(long long x,long long y){
	long long t=1;
	for (;y;x=x*x%mod,y/=2)
		if (y&1) t=t*x%mod;
	return t;
}

void dntt(long long a[],int k){
	int n=1<<19;
	for (int i=0;i<n;i++)
		if (r[i]>i) swap(a[i],a[r[i]]);
	for (int i=1;i<n;i*=2){
		long long t=power(5,mod-1+(mod-1)/(2*i)*k),p=1;
		for (int j=0;j<n;j++,p=p*t%mod)
			if ((i&j)==0){
				long long x=a[j],y=p*a[j+i]%mod;
				a[j]=(x+y)%mod,a[j+i]=(x-y)%mod;
			}
	}
}

void ntt(long long a[],long long b[]){
	int n=1<<19;
	for (int i=0;i<n;i++) r[i]=(r[i/2]/2)|((i&1)*n/2);
	dntt(a,1);dntt(b,1);
	for (int i=0;i<n;i++) a[i]=a[i]*b[i]%mod;
	dntt(a,-1);
	long long inv=power(n,mod-2);
	for (int i=0;i<n;i++) a[i]=a[i]*inv%mod;
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();
	for (int i=1;i<=n-1;i++){
		x[2*i-1]=y[2*i]=read();
		y[2*i-1]=x[2*i]=read();
		next[2*i-1]=p[x[2*i-1]];p[x[2*i-1]]=2*i-1;
		next[2*i]=p[x[2*i]];p[x[2*i]]=2*i;
	}
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for (int i=2;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	for (int i=2;i<=n;i++) inv[i]=-(mod/i)*inv[mod%i]%mod;
	for (int i=2;i<=n;i++) inv[i]=inv[i-1]*inv[i]%mod;
	travel(1);a[n]=n*fac[n]%mod;
	for (int i=2;i<=n;i++)
		a[s[i]]=(a[s[i]]-fac[s[i]])%mod,
		a[n-s[i]]=(a[n-s[i]]-fac[n-s[i]])%mod;
	for (int i=0;i<=n;i++) b[i]=inv[n-i];
	ntt(a,b);
	for (int k=1;k<=n;k++)
		printf("%lld\n",((a[n+k])%mod*inv[k]%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 48384
#include<bits/stdc++.h>
using namespace std;
 
int mid[200005], ans[200005];
int n,ar[200005];
int main()
{
    int mod = 1e9 + 7;
    scanf("%d",&n);
    assert(n==n);
    for(int i=1;i<=n;i++)scanf("%d",ar+i);
    ar[0]=-1;
    ans[0]=1;
    for(int i=1;i<=n;i++){
        ans[i] += ans[i-1];
        ans[i] %= mod;
        if(ar[i] != ar[i-1]){
            ans[i] += mid[ar[i]];
            ans[i] %= mod;
            mid[ar[i]] += ans[i-1];
            mid[ar[i]] %= mod;
        }
    }
    printf("%d\n",ans[n]);
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,pos=0,neg=0,res=0;
  cin>>n;
  vector<int> a(n);
  vector<pair<int,int>> po;
  for(auto& c:a)cin>>c;
  sort(a.begin(),a.end());
  neg = lower_bound(a.begin(),a.end(),0)-a.begin();
  pos = a.end()-upper_bound(a.begin(),a.end(),0);
  int posi=n-1,negi=0;
  if(!neg){
    int head=0,tail=n-1;
    po.emplace_back(a[head],a[tail]);
    res=a[head++]-a[tail--];
    while(head<tail){
      po.emplace_back(res,a[tail]);
      res=res-a[tail--];
    }
    if(head==tail){
      po.emplace_back(a[head],res);
      res=a[head]-res;
    }
  }
  else if(!pos){
    int head=0,tail=n-1;
    sort(a.begin(),a.end(),greater<>());
    po.emplace_back(a[head],a[tail]);
    res=a[head++]-a[tail--];
    while(head<tail){
      po.emplace_back(res,a[tail]);
      res=res-a[tail--];
    }
    if(head==tail){
      po.emplace_back(res,a[head]);
      res=res-a[head];
    }
  }
  else{
    int ph=n-pos,nt=neg-1;
    while(ph<posi){
      po.emplace_back(a[nt],a[posi]);
      a[nt]-=a[posi--];
    }
    // ph+1~tail
    while(negi<ph){
      po.emplace_back(a[ph],a[negi]);
      a[ph]-=a[negi++];
    }
    res=a[ph];
  }
  cout<<res<<"\n";
  for(auto p:po)cout<<p.first<<" "<<p.second<<"\n";
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  cin >> n>>k;
  vector<long> h(n);
  long a=1000000000;
  for(int i=0; i<n; i++) cin >> h[i];
  sort(h.begin(),h.end());
  for(int i=0; i<n-k+1; i++){
  	a=min(h[i+k-1]-h[i],a);
  }
  
  
    cout << a << endl;
}

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

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll a;
    string s;
    cin >> a;
    cin >> s;
    if(a>=3200) cout << s << endl;
    else cout << "red" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//}

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
int cnt[2][105];

int main() {
	ll n, y;
	cin >> n >> y;
	int yukichi = -1, higuchi = -1, noguchi = -1;
	for (int i = 0;i <= n;++i) {
		for (int j = 0;j <= n - i;++j) {
			int k = n - i - j;
			if (10000 * i + 5000 * j + 1000 * k == y) {
				yukichi = i;
				higuchi = j;
				noguchi = k;
			}
		}
	}
	cout << yukichi << " " << higuchi << " " << noguchi << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int a;
    cin >> a;
    string S;
    cin >> S;
    
    cout << (a >= 3200 ? S : "red") << endl;



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

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

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();}

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 EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)

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

typedef pair<string, pii> psp;

int d[] = {-4, 1, 4, -1};

map<string, int> table;

void bfs() {
	queue<psp> Q;
	Q.push(psp("01234567", pii(0, 0)));

	string str, str2;
	int cost, zpos, nzpos;
	while(!Q.empty()) {
		psp p = Q.front();
		Q.pop();
		str = p.first;
		cost = p.second.first + 1;
		zpos = p.second.second;
		table[str] = cost;

		REP(i, 4) {
			nzpos = zpos + d[i];
			if(0 <= nzpos && nzpos <= 7) {
				if(zpos == 3 && nzpos == 4) {
					continue;
				}
				if(zpos == 4 && nzpos == 3) {
					continue;
				}

				str2 = str;
				swap(str2[zpos], str2[nzpos]);
				if(!table[str2]) {
					Q.push(psp(str2, pii(cost, nzpos)));
				}
			}
		}
	}
}

int main() {
	bfs();

	string s;
	while(getline(cin, s)) {
		string str;
		REP(i, s.size()) {
			if(s[i] != ' ') {
				str += s[i];
			}
		}

		cout << table[str]-1 << endl;
	}

	return 0;
}

Measured memory_bytes: 3564
N = int(input())

grid = [[0,0,0]]

for i in range(N):
  array = list(map(int, input().strip().split()))
  grid.append(array)
    
for h in range(N):
  bool = False
  t = 0
  x = 0
  y = 0
  t = grid[h+1][0] - grid[h][0]
  x = abs(grid[h+1][1] - grid[h][1])
  y = abs(grid[h+1][2] - grid[h][2])
  
  if grid[h+1][0] < 0 or grid[h+1][1] < 0 or grid[h+1][2] <0:
    break 

  if (t - x - y) % 2 == 0 and t >= x + y:
    bool = True
  
if bool:
  print("Yes")
else:
  print("No")


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

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

    string s;
    cin >> s;
    bool ans = false;
    if (s[2] == s[3] && s[4] == s[5])
        ans = true;
    
    ans ? cout << "Yes\n" : cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int n,q;
  int S[100000],T[50000];
  int i,j,cnt;
  int left,right,mid,key;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&S[i]);
    }

  scanf("%d",&q);
  for(j=0;j<q;j++)
    {
      scanf("%d",&T[j]);
    }
  cnt=0;

  for(j=0;j<q;j++)
    {
      key=T[j];
      left=0;
      right=n;
      while(left<right)
	{
	  mid=(left+right)/2;
	  if(S[mid]==key)
	    {
	      cnt++;
	      break;
	    }

	  else if(key<S[mid]) right=mid;

	  else left=mid+1;
	}
    }
  printf("%d\n",cnt);

  return 0;
  
  
}



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

int main(void){
    string s;
    cin >> s;
    
    long res = 1000, tmp;
    for (int i = 0; i < s.size() - 2; i++) {
        tmp = stol(s.substr(i, 3)) - 753;
        if (abs(tmp) < res) res = abs(tmp);
    }
  
    cout << res << endl;
    
}


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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

int main() {
  cout << setprecision(18);
  i32 X, Y, Z;
  cin >> X >> Y >> Z;
  cout << Z << " " << X << " " << Y;
}


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

const int N = 200005;

int n;
vector<int> G[N], R[N];
int deg[N];
bool incycle[N];
vector<int> cyc; int sz;
vector<int> ch[N];
int a[N];

void impossible() { printf("IMPOSSIBLE\n"); exit(0); }
void possible() { printf("POSSIBLE\n"); exit(0); }

int find_mex(vector<int> &vec) {
	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());
	int lst = 0;
	for (int i = 0; i < vec.size(); ++i) {
		if (vec[i] != lst) return lst;
		++lst;
	}
	return lst;
}

void find_cycle(int u) {
	incycle[u] = true;
	cyc.push_back(u);
	for (int v : G[u]) if (deg[v] && incycle[v] == 0) {
		find_cycle(v);
	}
}

bool recheck() {
	// build
	for (int i = sz - 1; i >= 1; --i) {
		int u = cyc[i];
		ch[u].clear();

		for (int v : G[u]) {
			ch[u].push_back(a[v]);
		}

		a[u] = find_mex(ch[u]);
	}

	// recheck
	for (int i = 1; i <= n; ++i) {
		ch[i].clear();
		for (int j : G[i]) ch[i].push_back(a[j]);
		if (a[i] != find_mex(ch[i])) return false;
	}
	return true;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		int p; scanf("%d", &p);
		R[i].push_back(p);
		G[p].push_back(i);
		deg[p]++;
	}

	queue <int> que;
	for (int i = 1; i <= n; ++i) if (!deg[i]) que.push(i), a[i] = 0;

	while(!que.empty()) {
		int u = que.front(); que.pop();

		for (int v : R[u]) {
			if (!deg[v]) continue;
			if (--deg[v] == 0) {
				que.push(v);
				vector<int> vec;
				for (int w : G[v]) {
					vec.push_back(a[w]);
				}
				a[v] = find_mex(vec);
			}
		}
	}

	memset(incycle, 0, sizeof incycle);
	for (int i = 1; i <= n; ++i) if (deg[i]) { // in cycle
		find_cycle(i);
		break;
	}

	/*************************************************************/
	// solve inside the cycle
	sz = cyc.size();
	int u = cyc[0];
	vector<int> vec;
	for (int v : G[u]) if (!deg[v]) {
		vec.push_back(a[v]);
	}
	// first case: a[u] = mex
	a[u] = find_mex(vec);

	if (recheck()) possible();

	// second case: a[u] = mex'
	vec.push_back(a[u]);
	a[u] = find_mex(vec);

	if (recheck()) possible();

	impossible();
}

Measured memory_bytes: 41204
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,r;
    cin >> h >> r;
    if (h >= 0) PRINT(1);
    else{
        if (abs(h) < r) PRINT(1);
        else if (abs(h) == r) PRINT(0);
        else PRINT(-1);
    }
}



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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O2")
//#pragma GCC optimization ("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif


int main()
{
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    string s;
    cin >> s;
    int a = 0;
    for(int i = 0;i < s.size();i++){
        int d = s[i] - '0';
        a += d;
    }
    if(a % 9 == 0)cout << "Yes\n";
    else cout << "No\n";
    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PA;
int main(){

  int h,w,n,a[11][2];
  char c[1001][1001];
  cin >> h >> w >> n;

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> c[i][j];
      if(c[i][j]>='1'&&c[i][j]<='9'){
	a[ c[i][j]-'0'][0] = j;
	a[ c[i][j]-'0'][1] = i;
      }
      if(c[i][j]=='S'){
	a[0][0] = j;
	a[0][1] = i;
      }
    }
  }

  int sum = 0,suji[1001][1001],flag=0;
  queue<PA> que;
  int dx[12] = {1,-1,0,0};
  int dy[12] = {0,0,1,-1};

  for(int i=0;i<n;i++){

    memset(suji,-1,sizeof(suji));
    que.push( PA(a[i][0],a[i][1]) );
    suji[ a[i][1] ][ a[i][0] ] = 0;
    while(!que.empty()){
      PA p = que.front();
      que.pop();
      
      for(int j=0;j<4;j++){
	int x = p.first + dx[j];
	int y = p.second + dy[j];

	if(x<0||y<0||x>=w||y>=h||suji[y][x]!=-1||c[y][x]=='X') continue;
	suji[y][x] = suji[p.second][p.first]+1;
	que.push( PA(x,y) );
      }
    }
    
    sum += suji[a[i+1][1]][a[i+1][0]];

  }

  cout << sum << endl;
  
  return (0);
}

Measured memory_bytes: 8032
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, k, ans = 0;
    cin >> a >> b >> c >> k;
    if(k > a){
        ans += a;
        k -= a;
    }else{
        ans += k;
        k = 0;
    }
    if(k > b){
        k -= b;
    }else{
        k = 0;
    }
    ans -= k;
    cout << ans << endl;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
typedef pii point;
using namespace std;
const ll INF = (1ll<<32);
const ll MOD = 1000000007;

int main() {
  ll n,c; cin>>n>>c;
  vi x(n),v(n); REP(i,n) cin>>x[i]>>v[i];
  vi d(n),e(n),f(n),g(n);
  {
    ll vsum=0;
    REP(i,n) {
      vsum+=v[i];
      d[i]=vsum-x[i];
      e[i]=vsum-x[i]*2;
    }
  }
  {
    ll vsum=0;
    for(ll i=n-1;i>=0;i--) {
      vsum+=v[i];
      f[i]=vsum-(c-x[i]);
      g[i]=vsum-2*(c-x[i]);
    }
  }
  vi dm(n),em(n),fm(n),gm(n);
  {
    dm[0]=d[0]; em[0]=e[0];
    FOR(i,1,n) {
      dm[i]=max(dm[i-1],d[i]);
      em[i]=max(em[i-1],e[i]);
    }
  }
  {
    fm[n-1]=f[n-1]; gm[n-1]=g[n-1];
    for(ll i=n-2;i>=0;i--) {
      fm[i]=max(fm[i+1],f[i]);
      gm[i]=max(gm[i+1],g[i]);
    }
  }
  ll ans=max(dm[n-1],fm[0]);
  REP(i,n-1) {
    ans=max(ans,d[i]+gm[i+1]);
    ans=max(ans,e[i]+fm[i+1]);
  }
  cout<<max(0ll,ans)<<endl;
}

// 7565


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

int main(){
 int a,b,c;
  cin >> a >> b >>c;
  
  int s=a+b+c;
  int m;
  m=max(a,max(b,c));
  
  int res=0;
  while(s%3!=0||s<3*m){
   s+=2;
   res++;
    if(s>3*m){
    m++;
    }
  }
 cout << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  
  int a1,a2,a3;
  scanf("%d %d %d",&a1,&a2,&a3);
  int sum=a1+a2+a3;
  if(sum>=22){
    printf("bust\n");
  }
  else{
    printf("win\n");
  }
  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    numbers = list(map(int, input().split()))
    for i in range(n):
        print("node {}: ".format(i + 1), end="")
        print("key = {}, ".format(numbers[i]), end="")
        if i + 1 > 1:
            print("parent key = {}, ".format(numbers[(i + 1) // 2 - 1]), end="")
        if (i + 1) * 2 <= n:
            print("left key = {}, ".format(numbers[(i + 1) * 2 - 1]), end="")
        if (i + 1) * 2 + 1 <= n:
            print("right key = {}, ".format(numbers[(i + 1) * 2 + 1 - 1]), end="")
        print("\n", end="")


if __name__ == "__main__":
    main()



Measured memory_bytes: 5720
#include <iostream>
#include <set>

int f(int a) {
	a = (a % 2) ? (3*a+1):(a / 2);
	return a;
}
int main()
{
	int s;
	std::cin >> s;
	int a1 = s;
	int counter = 1;
	int a2;
	std::set<int> st;
	st.insert(a1);
	while (true) {
		a2 = f(a1);
		counter++;
		if (!st.count(a2)) {
			st.insert(a2);
			a1 = a2;
		}
		else{ 
			counter = st.size() + 1;
			break;
		}
		if (counter > 1000000)break;
	}

	std::cout << counter;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

lint MOD = 1000000007;

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

    vector<pint> vp;
    lint i = 1;
    while (i <= N / i)
    {
        vp.emplace_back(i, N / i);
        i++;
    }
    int n = vp.size();
    REP(i, n)
    {
        if (vp[i].first == vp[i].second) continue;
        vp.emplace_back(vp[i].second, vp[i].first);
    }
    sort(ALL(vp));

    vector<lint> dp(vp.size());
    dp[0] = 1;

    REP(_, K)
    {
        vector<lint> dp_new(vp.size());
        REP(i, vp.size())
        {
            (dp_new[vp.size() - 1 - i] += dp[i]) %= MOD;
        }
        IREP(i, dp_new.size() - 1) (dp_new[i] += dp_new[i + 1]) %= MOD;
        REP(i, dp_new.size())
        {
            dp_new[i] = dp_new[i] * (i == 0 ? 1 : vp[i].first - vp[i - 1].first) % MOD;
        }
        swap(dp, dp_new);
    }
    lint ret = accumulate(ALL(dp), 0LL);
    cout << ret % MOD << endl;
    return 0;
}


Measured memory_bytes: 1912
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	string s;
	cin >> s;
	int a=0,b=0;
	
	for(int i=0;i<s.length();i++){
		if(s[i]=='A'){
			a++;
		}
		if(s[i]=='B'){
			b++;
		}
	}
	
	if(a>0 && b>0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;

int a, b, c;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    cin >> a >> b >> c;
    if(c < a - b)
        cout << 0 << endl;
    else
        cout << c - (a - b) << endl;

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
string a, b;
int res;
int main() {
    DAU
    cin >> a >> b;
    for (int i = 0; i < 3; ++i)
        res += (a[i] == b[i]);
    cout << res;
    PLEC
}


Measured memory_bytes: 3660
#include<iostream>
#include<cstring>
#include<algorithm>


using namespace std;

const int mx=1e5+123;
int dp[mx][4], h[mx][4], n;

int solve( int i, int c)
{
    if(i>=n)
        return 0;

    if(dp[i][c]!=-1)
        return dp[i][c];

    int ret= 0;

    for(int j=0; j<3; j++)
    {
        if(j!=c)
            ret=max(ret, (h[i][j]+ solve(i+1, j)));
    }

    return dp[i][c]= ret;
}

int main()
{
    memset(dp, -1, sizeof(dp));

    cin>> n;

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

    cout<< solve(0, 3)<< endl;

    return 0;
}



Measured memory_bytes: 14496
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
};
 
 
int main() {
    int N, M;
    cin >> N >> M;
 
    //友達集合を作る
    UnionFind UF(N);
    for (int i = 0; i < M; i++)
    {
        int A, B;
        cin >> A >> B;
        A -= 1; B -= 1;
        UF.unite(A, B);
    }
 
    //最大の友達集合を求める
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans = max(ans, UF.size(i));
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll a,b,n;

int main(){
	ios::sync_with_stdio(false);
	cin>>a>>b>>n;
	ll tmp;
	if(b>n)
		tmp=n;
	else
		tmp=b-1;
	cout<<a*tmp/b-a*(tmp/b);
	
	
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int a, b;
	cin >> a >> b;
	if (b % a) cout << b - a << endl;
	else cout << a + b << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();

    s += s;

    if(s.contains(t)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
int h,w;
int a[90][90],b[90][90];
bool dp[90][90][13600];//(i,j),差=k 
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>h>>w;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			cin>>a[i][j];
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			cin>>b[i][j];
	dp[1][1][abs(a[1][1]-b[1][1])]=true;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			int li,lj;
			if(i==1)
				goto x;
			li=i-1;
			lj=j;
			for(int k=0;k<=(h+w)*80;k++){
				if(!dp[li][lj][k])
					continue;
				int red=0,blue=k;
				dp[i][j][abs(red+a[i][j]-(blue+b[i][j]))]=true;
				dp[i][j][abs(red+b[i][j]-(blue+a[i][j]))]=true;
			}
			x:;
			if(j==1)
				goto y;
			li=i;
			lj=j-1;
			for(int k=0;k<=(h+w)*80;k++){
				if(!dp[li][lj][k])
					continue;
				int red=0,blue=k;
				dp[i][j][abs(red+a[i][j]-(blue+b[i][j]))]=true;
				dp[i][j][abs(red+b[i][j]-(blue+a[i][j]))]=true;
			}
			y:;
		}
	}
	for(int i=0;i<=h*w*80;i++)
		if(dp[h][w][i]){
			cout<<i<<endl;
			return 0;
		}
	return 0;
}


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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define f(i,a,b) for(ll i=a;i<b;i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define en '\n'

int main()
{
	IOS;
	int t=1;
//	cin>>t;
	while(t--)
	{
        string s,t;
        cin>>s>>t;
        if(s==t)
        {
            cout<<"Yes";
            return 0;
        }
        f(i,0,s.size())
        {
            string p(s.begin(),s.begin()+s.size()-i);
            string q(s.rbegin(),s.rbegin()+i);
            reverse(all(q));
            q+=p;
           // cout<<q<<" ";
            if(q==t)
            {
                cout<<"Yes";
                return 0;
            }
        }
        cout<<"No";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  int N, M;
  cin >> N >> M;
  priority_queue<int, vector<int>> pq;
  REP(i, N) {
    int a;
    cin >> a;
    pq.push(a);
  }
  REP(i, M) {
    int a = pq.top();
    pq.pop();
    pq.push(a / 2);
  }
  ll ans = 0;
  while (!pq.empty()) {
    ans += pq.top();
    pq.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 3928
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val N = sc.nextInt()
  val K = sc.nextInt()
  val X = sc.nextInt()
  val Y = sc.nextInt()

  val a = if (N > K) K else N
  val b = if (N > K) N - K else 0

  println(a * X + b * Y)
}


Measured memory_bytes: 27292
#include <iostream>

using namespace std;

typedef long long ll;

ll n, s;

ll func(ll b, ll n) {
  if (n < b) return n;
  return func(b, n/b) + n % b;
}

int main() {
  cin >> n >> s;
  
  ll b;
  for (b = 2; b * b <= n; b++) {
    if (func(b, n) == s) {
      cout << b << endl;
      return 0;
    }
  }
  
  while (b <= n) {
    ll mod = n / b;
    ll sm = func(b, n);
    if (mod <= s and s <= sm and (sm - s) % mod == 0) {
      cout << b + (sm - s) / mod << endl;
      return 0;
    }
    b += n % b / mod + 1;
  }
  
  if (n == s) {
    cout << n+1 << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.rstrip



cmap = { 'R' => 0, 'G' => 1, 'B' => 2 }

a = Array.new(n) { |i|
  cmap[s[i]]
}

rgbs = Array.new(3) { Array.new(n + 1, 0) }


n.times do |i|
  3.times do |c|
    rgbs[c][i+1] = rgbs[c][i] + (a[i] == c ? 1 : 0)
  end
end

sum = 0

1.upto(n - 1) do |j|
  (j+1).upto(n - 1) do |k|
    if a[j] != a[k]
      opp = 3 - a[j] - a[k]
      sum += rgbs[opp][j]
    end
  end
end

# p sum


buts = 0

n.times do |j|
  1.upto(n) do |w|
    i = j - w
    k = j + w
    if i >= 0 and k < n
      buts += 1 if a[i] != a[j] and a[j] != a[k] and a[k] != a[i]
    end
  end
end

# p buts

p sum - buts

Measured memory_bytes: 14356
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
	fast;
	string s;
	cin>>s;
	lli i,flag=0;
	fr(i,s.length())
	{
		if(s[i]=='7')
			flag=1;
	}
	if(flag==1)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 3652
import sys

input = sys.stdin.readline

N = int(input().strip())
As = [(int(input().strip()), i) for i in range(N)]
As.sort(reverse=True)
exception_index = As[0][1]
for i in range(N):
    if i == exception_index:
        print(As[1][0])
    else:
        print(As[0][0])

Measured memory_bytes: 31592
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        double b[]=new double[a];
        String c[]=new String[a];
        double sum=0;
        for(int i=0;i<a;i++){
            b[i]=sc.nextDouble();
            c[i]=sc.next();
            if(c[i].equals("JPY")){
                sum+=b[i];
            }else {
                sum+=b[i]*380000;
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 22612
S =input()
a =int(len(S)/ 2)
#print(a)
x =0

#print(S[0:a])
#print(S[a:2*a])


for i in range(a):
    #print(S[i],S[-(i+1)])
    if S[i] != S[-(i+1)]:
        x += 1

print(x)
        



Measured memory_bytes: 2940
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int k = in.nextInt();
        int[] p = in.nextIntArray(n);

        out.println(
                Arrays.stream(p).sorted().limit(k).sum()
        );
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

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


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

int main() {
    string s, t, r;
    cin >> s >> t >> r;
    cout << char(s[0] - 'a' + 'A') << char(t[0] - 'a' + 'A') << char(r[0] - 'a' + 'A') << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <queue>
#include <deque>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

template<class T>bool chmax(T &a, const T &b) {
   if (a < b) {
      a = b;
      return 1;
   }
   return 0;
}
template<class T>bool chmin(T &a, const T &b) {
   if (a > b) {
      a = b;
      return 1;
   }
   return 0;
}

using namespace std;
using ll = long long;

const int kInf = 2e9;
const ll kLInf = 2e18;

int 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};
int N, A;
int main()
{
   cout << fixed << setprecision(10);
   cin >> N;
   int ans = 1;
   REP(i, N) {
      cin >> A;
      if (!(A%2)) {
         if (A%3 && A%5) {
            ans = 0;
            break;
         }
      }
   }
   if (ans) {
      cout << "APPROVED" << endl;
   } else {
      cout << "DENIED" << endl;
   }
   return 0;
}



Measured memory_bytes: 256
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

constexpr int dx[4] = {1, -1, 0, 0};
constexpr int dy[4] = {0, 0, 1, -1};
char decode[4] = {'>', '<', 'v', '^'};
int encode[256];

void init() {
	memset(encode, -1, sizeof(encode));
	for(int i = 0; i < 4; ++i) encode[decode[i]] = i;
	encode['R'] = 0;
	encode['L'] = 1;
	encode['D'] = 2;
	encode['U'] = 3;
}

void solve() {
	int h, w;
	cin >> h >> w;

	vector<string> field(h + 2, string(w + 2, '#'));
	for(int i = 1; i <= h; ++i) {
		for(int j = 1; j <= w; ++j) {
			cin >> field[i][j];
		}
	}

	int n;
	string command;
	cin >> n >> command;

	int x, y, d;
	for(int i = 1; i <= h; ++i) {
		for(int j = 1; j <= w; ++j) {
			if(encode[field[i][j]] != -1) {
				x = j;
				y = i;
				d = encode[field[i][j]];
				goto next;
			}
		}
	}

	assert(false);

next:
	for(const auto &operation : command) {
		if(operation == 'S') {
			int cx = x + dx[d], cy = y + dy[d];
			while(field[cy][cx] == '.' || field[cy][cx] == '-') {
				cx += dx[d];
				cy += dy[d];
			}
			if(field[cy][cx] == '*') field[cy][cx] = '.';
		}
		else {
			d = encode[operation];
			if(field[y + dy[d]][x + dx[d]] == '.') {
				field[y][x] = '.';
				x = x + dx[d];
				y = y + dy[d];
			}
		}
	}

	field[y][x] = decode[d];

	for(int i = 1; i <= h; ++i) {
		cout << field[i].substr(1, w) << endl;
	}
}

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

	init();

	int t;
	cin >> t;
	while(t--) {
		solve();
		if(t) cout << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1216
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
using namespace std;


int main(void)
{
	int N; cin >> N;
	vector<vector<int>> c(10, vector<int>(10, 0));
	rep(i, 1, N + 1) {
		int tail = i % 10;
		int head = i;
		while (head > 9)head /= 10;
		c[head][tail]++;
	}
	lli ans = 0;
	rep(i, 1, 10)rep(j, 1, 10)ans += c[i][j] * c[j][i];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int N;
vector<int> A;
int ans = 0;
void rec(int n, vector<int> B) {
    if (n == N) {
        if (count_if(ALL(B), [](int a) { return a % 2 == 0; }) > 0) ans++;
        return;
    }
    vector<int> tmp(B);
    tmp.resize(B.size() + 1);
    tmp[B.size()] = A[n];
    rec(n + 1, tmp);
    tmp[B.size()] = A[n] - 1;
    rec(n + 1, tmp);
    tmp[B.size()] = A[n] + 1;
    rec(n + 1, tmp);
}

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

    cin >> N;
    A.resize(N);
    cin >> A;

    rec(0, {});
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n,i,a,b,c,d;
  scanf("%d",&n);
  d=n%10;
  n/=10;
  c=n%10;
  n/=10;
  b=n%10;
  n/=10;
  a=n;
  if(a-b-c-d==7) printf ("%d-%d-%d-%d=7\n",a,b,c,d);
  else if(a-b-c+d==7) printf("%d-%d-%d+%d=7\n",a,b,c,d);
  else if(a-b+c-d==7) printf("%d-%d+%d-%d=7\n",a,b,c,d);
  else if(a-b+c+d==7) printf("%d-%d+%d+%d=7\n",a,b,c,d);
  else if(a+b-c-d==7) printf("%d+%d-%d-%d=7\n",a,b,c,d);
  else if(a+b-c+d==7) printf("%d+%d-%d+%d=7\n",a,b,c,d);
  else if(a+b+c-d==7) printf("%d+%d+%d-%d=7\n",a,b,c,d);
  else if(a+b+c+d==7) printf("%d+%d+%d+%d=7\n",a,b,c,d);
  return 0;
}

Measured memory_bytes: 128
import sys
import math
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, n = map(int, input().split())

    if b - 1 <= n:
        res = a - math.ceil(a / b)
        print(res)
    else:
        res = (a * n) // b - a * (n // b)
        print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9184