akhauriyash/Code-Regression huggingface dataset:
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Unfair Nim
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 300;
const int BN = 40;

/* typedef */

typedef long long ll;

/* global variables */

ll as[MAX_N];

/* subroutines */

/* main */

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

  ll sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lld", as + i);
    sum ^= as[i];
  }

  ll a0 = as[0], a1 = as[1], bits = sum ^ a0 ^ a1;
  ll x = 0, y = 0, z = a0 + a1;
  //printf("bits=%lld, z=%lld\n", bits, z); 

  for (int k = BN - 1; k >= 0; k--) {
    ll bk = 1LL << k;
    if ((bits & bk) != 0) x |= bk;
    else if (x + (y | bk) * 2 <= z) y |= bk;
  }
  //printf("x=%lld, y=%lld\n", x, y);

  ll b0 = y, b1 = y;
  for (int k = BN - 1; k >= 0; k--) {
    ll bk = 1LL << k;
    if ((x & bk) != 0) {
      if ((b0 | bk) <= a0) b0 |= bk;
      else b1 |= bk;
    }
  }

  if (b0 == 0)
    for (int k = 0; k < BN; k++) {
      ll bk = 1LL << k;
      if ((b1 ^ bk) != 0) {
	b0 ^= bk, b1 ^= bk;
	break;
      }
    }
  //printf("b0=%lld, b1=%lld\n", b0, b1);

  if (b0 == 0 || b0 > a0 || b0 + b1 != z) puts("-1");
  else printf("%lld\n", a0 - b0);
  return 0;
}


Measured memory_bytes: 3216
#include <stdio.h>
#include <stdlib.h>

#define N 200000

int aa[N], bb[N];

int compare(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;
	int diff1 = bb[i] - bb[j];
	int diff2 = aa[i] - aa[j];

	return diff1 != 0 ? diff1 : diff2;
}

int main() {
	static int ii[N];
	int n, i, time;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d%d", &aa[i], &bb[i]);
		ii[i] = i;
	}
	qsort(ii, n, sizeof *ii, compare);
	time = 0;
	for (i = 0; i < n; i++) {
		time += aa[ii[i]];
		if (time > bb[ii[i]]) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

int main(){
    string s,t;
    cin>>s>>t;
    map<string,ll>m;
    cin>>m[s];
    cin>>m[t];
    string u;
    cin>>u;
    m[u]--;
    cout<<m[s]<<" "<<m[t]<<endl;
    }


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int minM = Integer.MAX_VALUE;
		int sumM = 0;
		while (sc.hasNextInt()) {
			int m = sc.nextInt();
			if (m < minM) {
				minM = m;
			}
			sumM += m;
		}

		System.out.println(N + ((X - sumM) / minM));
	}
}

Measured memory_bytes: 23252
N, M, C = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
A_list = [[int(x) for x in input().split()] for _ in range(N)]
ans = 0
for A in A_list:
    cnt = 0
    for a, b in zip(A, B):
        cnt += a*b
    ans += (cnt + C > 0)
print(ans)


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

int main() {
  
  int i,n,flag=0;
  cin >> n;
  vector<int> a(n);
  for(i=0;i<a.size();i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());

  for (i = 0; i < n-1; i++) {
      if(a.at(i) == a.at(i+1)){
        flag = 1;
        break;
      }
  }
  
  if(flag == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
VI G[200011];
int D[200011];

int bfs(int s) {
    memset(D, 0x3f, sizeof D);
    VI ord;
    ord.reserve(N);
    ord.push_back(s);
    D[s] = 0;
    REP (i_, N) {
	int v = ord[i_];
	EACH (e, G[v]) if (D[*e] > D[v]+1) {
	    D[*e] = D[v]+1;
	    ord.push_back(*e);
	}
    }
    return max_element(D, D+N) - D;
}

void MAIN() {
    scanf("%d", &N);
    REP (i, N-1) {
	int x, y;
	scanf("%d%d", &x, &y);
	x--; y--;
	G[x].push_back(y);
	G[y].push_back(x);
    }

    int x = bfs(0);
    int y = bfs(x);
    int R = D[y];

    if (R % 3 == 1) {
	puts("Second");
    } else {
	puts("First");
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 13556
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<int> h(N);
	int x = 0;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
		x = max(x, h[i]);
	}
	//cout << x << endl;

	int ans = 0;
	for (int n = 1; n <= x; n++) {
		int cnt = 0;
		for (int i = 0; i < N; i++) {
			if (h[i] >= n) {
				cnt++;
				if (i && (h[i - 1] >= n)) cnt--;
			}
		}
		//cout << n << ':' << cnt << endl;
		ans += cnt;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3624
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
vector<T> divisor(const T n) {
	vector<T> res;
	for (T i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			res.emplace_back(i);
			if (i * i != n) res.emplace_back(n / i);
		}
	}
	sort(res.begin(), res.end());
	return res;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint N;
	cin >> N;

	int ans = (int)divisor(N - 1).size() - 1;

	auto div = divisor(N);
	for (const auto &e : div) {
		
		if (e == 1) continue;
		lint tmp = N;
		while (tmp >= e) {
			if (tmp % e) {
				tmp %= e;
			}
			else tmp /= e;
		}
		if (tmp == 1) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, k; cin >> n >> k;
  if (k == 0) {
    cout << 1LL * n * n << '\n';
    return 0;
  }
  ll ans = 0;
  FOR(b, k + 1, n + 1) {
    int tmp = b - k, nx = n / b * b;
    ans += nx / b * tmp;
    ans += max(min(nx + b - 1, n) - (nx + b - 1 - tmp), 0);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <fstream>

using namespace std;
typedef long long ll;


int main()
{
    ll N;

    ll A[5];
    ll iMin = 10000000000000000;
    ll res = 0;

//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());
    cin >> N;


    for(int i = 0; i < 5; i++)
    {
        cin >> A[i];
        iMin = min(iMin,A[i]);
    }

    //切り上げ
    res = (N + iMin-1)/iMin;
    res += 4;

    cout << res <<endl;
    return 0;
}



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

#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MN = 2e5 + 5, LN = 17, MOD = 1e9 + 7, INF = 0x3f3f3f3f, BSZ = 320;
int N;
ll K;
int a[MN];
int dis[MN];
bool vis[MN];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> N >> K;
    for (int i = 1; i <= N; i++) cin >> a[i];
    if (a[1] == 1) {
        cout << 1 << '\n';
        return 0;
    }
    vector<int> v;
    v.push_back(1);
    vis[1] = true;
    int cur = a[1];
    int len = 0, notin = 0;
    dis[a[1]] = 1;
    while (true) {
        v.push_back(cur);
        vis[cur] = true;
        if (vis[a[cur]]) {
            notin = dis[a[cur]];
            len = dis[cur] + 1 - dis[a[cur]];
            break;
        }
        dis[a[cur]] = dis[cur] + 1;
        cur = a[cur];
    }
    if (K < notin) cout << v[K] << '\n';
    else cout << v[notin + ((K - notin) % (ll) len)] << '\n';
    return 0;
}


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

using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  set<string> st;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        string t = "";
        t += to_string(i), t += to_string(j), t += to_string(k);
        int ok = 0;
        for (int l = 0; l < n; l++) {
          if (ok == 0 && t[0] == s[l])
            ok = 1;
          else if (ok == 1 && t[1] == s[l])
            ok = 2;
          else if (ok == 2 && t[2] == s[l])
            ok = 3;
        }
        if (ok == 3) st.insert(t);
      }
    }
  }
  cout << st.size() << endl;

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int h, w, ans, d[55][55];
char g[55][55];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> h >> w;
    rep(i, 0, h) rep(j, 0, w) {
        cin >> g[i][j];
        if (g[i][j] == '.') ans++;
    }
    rep(i, 0, 55) rep(j, 0, 55) d[i][j] = INF;
    queue<P> que;
    que.push(mp(0, 0));
    d[0][0] = 0;
    while (!que.empty()) {
        P xy = que.front(); que.pop();
        g[xy.first][xy.second] = '#';
        rep(i, 0, 4) {
            int nx = xy.first + dx[i], ny = xy.second + dy[i];
            if (0 <= nx && nx < h && 0 <= ny && ny < w && g[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(mp(nx, ny));
                d[nx][ny] = d[xy.first][xy.second] + 1;
            }
        }
    }
    if (d[h-1][w-1] == INF) cout << -1 << endl;
    else cout << ans - d[h-1][w-1] - 1 << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(raw_input())
p=map(int,raw_input().split(' '))

i=[]
for j in range(1,N+1):
    if p[j-1]==j:
        i.append(j-1)

#print i
s=len(i)

flg=0
for n in range(len(i)-1):
    if flg==1:
        flg=0
        continue
    if i[n+1]-i[n]==1:
        s-=1
        flg=1

print s



Measured memory_bytes: 12240
<?php


[$N] = fscanf(STDIN, "%d");
$L = fscanf(STDIN, str_repeat("%d", $N));
$map = [];
$list = [];
foreach($L as $value){
    if(!isset($map[$value])){
        $map[$value] = 1;
        $list[] = $value;
    }else{
        $map[$value]++;
    }
}
$ans = 0;
sort($list);
$count = count($list);
if($count < 3){
    echo 0;
    exit;
}
for($i=0;$i<$count-2;$i++){
    for($j=$i+1;$j<$count-1;$j++){
        for($k=$j+1;$k<$count;$k++){
            if($list[$i] + $list[$j] > $list[$k] &&
            $list[$j] + $list[$k] > $list[$i] &&
            $list[$k] + $list[$i] > $list[$j]){
                $ans += $map[$list[$i]] * $map[$list[$j]] * $map[$list[$k]];
            }
        }
    }
}
echo $ans;

Measured memory_bytes: 16308
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
char query(int x) {
    cout << x << endl;
    string S; cin >> S;
    if (S[0] == 'V') exit(0);
    return S[0];
}
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<char> A(N+1);
    A[0] = A[N] = query(0);
    int a = 0, b = N;
    for (;;) { // [a, b], a and b are known
        int mid = (a + b) / 2;
        A[mid] = query(mid);
        int even = (mid - a - 1) % 2;
        if (even ^ (A[a] == A[mid])) {
            b = mid;
        } else {
            a = mid;
        }
    }
    return 0;
}

Measured memory_bytes: 980
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
LL as[1145];
vector<int> ans;

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

  PLL neg_max = PLL(-1e9-1, -1);
  rep(i, N) {
    scanf("%lld", &as[i]);
    neg_max = max(neg_max, PLL(as[i], i));
  }

  if (neg_max.first < 0) {
    printf("%lld\n", neg_max.first);
    printf("%d\n", N-1);
    rep(i, N-1-neg_max.second) {
      printf("%d\n", N-i);
    }

    rep(i, neg_max.second) {
      printf("1\n");
    }

    return 0;
  }

  deque<char> disused(N);
  LL odd_sum = 0;
  for (int i=0; i<N; i+=2) {
    if (as[i] >= 0) odd_sum += as[i];
    else disused[i] = true;
  }

  LL even_sum = 0;
  for (int i=1; i<N; i+=2) {
    if (as[i] >= 0) even_sum += as[i];
    else disused[i] = true;
  }

  printf("%lld\n", max(odd_sum, even_sum));

  bool even = false;
  if (odd_sum < even_sum) {
    even = true;
  }

  for (int i=!even; i<N; i+=2) {
    disused[i] = true;
  }

  while (disused[0]) {
    ans.emplace_back(1);
    disused.pop_front();
  }

  while (disused.back()) {
    ans.emplace_back((int)disused.size());
    disused.pop_back();
  }

  bool found;
  do {
    int M = disused.size();
    found = false;
    reps(i, 1, M-1) {
      if (disused[i-1] && disused[i] && disused[i+1]) {
        ans.emplace_back(i+1);
        deque<char> tmp;
        rep(j, i-1) {
          tmp.emplace_back(disused[j]);
        }
        tmp.emplace_back(true);
        reps(j, i+2, M) {
          tmp.emplace_back(disused[j]);
        }
        disused.swap(tmp);
        found = true;
        break;
      }
    }
  } while(found);
  assert(disused.size()%2);

  for (int i=1; i<disused.size(); i+=2) {
    ans.emplace_back(2);
  }
  
  printf("%d\n", (int)ans.size());
  for (int v : ans) {
    printf("%d\n", v);
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int h,w;
    cin>>h>>w;
    string s[h];
    rep(i,h)cin>>s[i];
    vector<vector<int>> dist(h,vector<int>(w,inf));
    queue<pair<int,int>> que;
    rep(i,h)rep(j,w){
        if(s[i][j]=='#'){
            que.emplace(i,j);
            dist[i][j]=0;
        }
    }
    int d[]={1,0,-1,0,1};
    while(que.size()){
        auto p =que.front();
        que.pop();
        int x=p.first, y=p.second;
        rep(i,4){
            int nx=x+d[i],ny=y+d[i+1];
            if(nx<0||nx>=h||ny<0||ny>=w)continue;
            if(dist[nx][ny]>dist[x][y]+1){
                dist[nx][ny]=dist[x][y]+1;
                que.emplace(nx,ny);
            }
        }
    }
    int ans=0;
    rep(i,h)rep(j,w)ans=max(ans,dist[i][j]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 13456
#include<stdio.h>
#include<math.h>

void sosuu(int a[], int n);

int main(void){

	int n, i;

	scanf("%d", &n);

	int a[n];

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

	return 0;
}

void sosuu(int a[], int n){
	int i, ii;
	int count=n;

	for(i=0; i<n; i++){
		ii=2;
		while(ii<=sqrt(a[i])){ 
			if(a[i]%ii!=0){
				ii++;
			}
			else if(a[i]!=ii){
				count--;
				ii=a[i]+1;
			}
		}
	}
	printf("%d\n", count);
}



Measured memory_bytes: 2040
N = int(input())
S = input()
counter = 0
#N文字から3文字を拾いあげ、暗証番号のリストを作って検討していくと、
#5000^3の計算量となり、時間内には終わらない。
#暗証番号の候補となる３桁までの整数1000通りが
#Sの中にこの順番で存在するかどうかを確認すればよい。
for i in range(1000):
    #000から999までの文字列を作る
    num = "0"*(3-len(str(i))) + str(i)
    first = S.find(num[0])
    if first != -1:
        #間違い例：second = S.find(num[1],first)
        #求めたい文字が、相異なる三か所に見つかる必要がある。
        #つまり、first<second<thirdである必要がある
        second = S.find(num[1],first+1)
        if second != -1:
            third = S.find(num[2],second+1)
            if third != -1:
                #print(first,second,third)
                counter+=1
print(counter)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;

int main(void){

    string str;
    cin >> str;

    for(int i = 0;i < str.length();i++){
        cout << 'x';
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
void sor(vel &v) { sort(v.begin(), v.end()); }
int zero() { return 0; }
void swap(vel &que, vel &pos, int i, int j) {
	int x = que[i];
	int y = que[j];
	pos[x] = j;pos[y] = i;
	que[i] = y;que[j] = x;
}
void down(vel &que, vel &pos, vel &va, int n) {
	int i = 1;
	while (i * 2 <= n) {
		if (i * 2 == n) {
			swap(que, pos, i, 2 * i);
			i = 2 * i;
		}
		else {
			if (va[que[2 * i]] < va[que[2 * i + 1]]) {
				swap(que, pos, i, 2 * i);
				i = 2 * i;
			}
			else {
				swap(que, pos, i, 2 * i + 1);
				i = 2 * i + 1;
			}
		}
	}
}
void up(vel &que, vel &pos, vel &va, int i, int n) {
	while (i > 1) {
		int j = i / 2;
		if (va[que[i]] < va[que[j]]) {
			swap(que, pos, j, i);
			i = j;
		}
		else i = 0;
	}
}
signed main() {
	int n, m, k, s, p, q;
	cin >> n >> m >> k >> s >> p >> q;
	vel isz(n,0);
	vel isd(n, 0);
	vel que(n);
	int st = 0; int to = 0;
	for (int i = 0; i < k; i++) {
		int x; cin >> x; x--;
		isz[x] = 1;
		isd[x] = 1;
		que[to] = x;
		to++;
	}
	vel ko(n, 0);
	vel a(m);
	vel b(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		ko[a[i]]++; ko[b[i]]++;
	}
	vvel way(n);
	for (int i = 0; i < n; i++) { way[i] = vel(ko[i]); }
	vel co(n, 0);
	for (int i = 0; i < m; i++) {
		int a1 = a[i]; int b1 = b[i];
		way[a1][co[a1]] = b1;
		way[b1][co[b1]] = a1;
		co[a1]++; co[b1]++;
	}
	for (int i = 0; i < s; i++) {
		int qto = to;
		for (int j = st; j < to; j++) {
			int x = que[j];
			for (int in = 0; in < ko[x]; in++) {
				int y = way[x][in];
				if (isd[y] == 0) {
					isd[y] = 1;
					que[qto] = y;
					qto++;
				}
			}
		}
		st = to;
		to = qto;
	}
	int ma = q * n + 1;
	que = vel(n + 1);
	vel pos(n);
	for (int i = 1; i <= n; i++) {
		que[i] = i - 1;
		pos[i - 1] = i;
	}
	vel dij(n, ma);
	dij[0] = 0;
	vel va(n, ma);
	int fl = 0;
	while(fl==0) {
		int fr = que[1];
		va[fr] = ma;
		if (fr == n-1) fl = 1;
		down(que, pos, va, n);
		for (int nu = 0; nu < ko[fr]; nu++) {
			int to2 = way[fr][nu];
			int wac=ma;
			if (to2 == n - 1) wac = 0;
			else if (isd[to2] == 0) wac = p;
			else if (isz[to2] == 0) wac = q;
			if (dij[to2] > dij[fr] + wac) {
				dij[to2] = dij[fr] + wac;
				va[to2] = dij[fr] + wac;
				up(que, pos, va, pos[to2], n);
			}
		}
	}
	cout << dij[n - 1] << endl;
	return 0;
}



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

SP =[]
for i in range(N):
  S, P  = input().split()
  app = [i+1,S,int(P)]
  SP.append(app)



SP.sort(key=lambda x: x[2], reverse=True)
SP.sort(key=lambda x: x[1])

for i in range(N):
  print(SP[i][0])

Measured memory_bytes: 3060
import java.util.*;
import javax.lang.model.util.ElementScanner6;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 入力
        long h = sc.nextLong();
        long w = sc.nextLong();

        // 処理
        long out = (h * w + 1) / 2;
        if (h == 1 || w == 1) {
            out = 1;
        }

        // 出力
        System.out.println(out);
    }
}

Measured memory_bytes: 21844
#include<stdio.h>

int main()
{
  int x,y;
  
  while(1){
    scanf("%d %d",&x,&y); 
    if(x == 0 && y == 0)
       break;
    else if(x > y)
    printf("%d %d\n",y,x);

    else
    printf("%d %d\n",x,y);

    

}
    
    
return 0;
}


Measured memory_bytes: 1952
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    int N,D[200010];
    bool F[200010];
    int M,T[200010];
    bool ans=true;
    int pr=0;

int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N)cin>>D[i];
    cin>>M;
    REP(i,M)cin>>T[i];
    if(N<M)ans=false;
    else{
        sort(D,D+N);sort(T,T+M);
        REP(i,M){
            for(int j=pr;j<N;j++){
                if(D[j]<T[i])pr++;
                DEB(i)DEB(j)DEB(pr)DEB(D[j])DEB(T[i])END
                if(T[i]==D[j]&&!F[j]){
                    F[j]=true;
                    pr=i+1;
                    break;
                }
                if(j==N-1){
                    ans=false;
                    break;
                }
            }
            if(!ans)break;
        }
    }
    cout<<(ans?"YES":"NO");
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    string s;
    cin >> s;

    int n = (int) s.size() - 1;
    if ( n & 1 ) n--;

    while ( s.substr(0, n / 2) != s.substr(n / 2, n / 2) and n > 0 ) {
        n -= 2;
    }

    cout << n << endl;

    return 0;
}

Measured memory_bytes: 3608
//Deep Godhani
//DAIICT

#include<bits/stdc++.h>
using namespace std;

#define N 100000000000
#define PI acos(-1)
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define ll long long int
#define ld long double
#define precision(x,d) cout << fixed << setprecision(d) << x
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

#include <bits/stdc++.h>
using namespace std;

void solve()
{
	int n,m;
	cin >> n >> m;
	int a[m];
	ll sum= 0;
	for(int i=0;i<m;i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	if(sum > n)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << n-sum << endl;
	}
}
int main()
{
    FAST;
    ll t=1;
    //cin >> t;
    while(t--)
    {
      //cout << "************" << endl;
      solve();
      //cout << "************"  << endl;
    }
		return 0;
}


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

int main() {
  string s;
  cin >> s;
  ll sum=0;
  ll n=s.size();
  rep(i,n){
    sum += s[i]-'0';
  }
  
  if(sum % 9 == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return(0);
}

Measured memory_bytes: 3756
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <set>
using namespace std;


int main(){
    string s, ans = "No";
    cin >> s;
    if(s[0] == '9' || s[1] == '9') ans = "Yes";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int w, h;
int c[50][50];
int dx[8]={-1,0,1,-1,1,-1,0,1,};
int dy[8]={-1,-1,-1,0,0,1,1,1};
 
void dfs(int x,int y){
  c[y][x]=0;
  for(int i=0;i<8;i++){
    int ny=y+dy[i];
    int nx=x+dx[i];
    if(ny>=0&&ny<h&&nx>=0&&nx<w){
      if(c[ny][nx]==1) dfs(nx, ny);
    }
  }
}
 
int main(){
 
  int ans;
 
  while(cin>>w>>h, w){
 
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>c[i][j];
      }
    }
     
    ans=0;
     
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(c[i][j]==0) continue;
	if(c[i][j]==1){
	  ans++;
	  dfs(j, i);
	}
      }
    }
     
    cout<<ans<<endl;
  }
     
     
  return 0;
}

Measured memory_bytes: 3168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
  public static void main(String[] args) throws IOException {
  	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  	StringBuilder line = new StringBuilder(br.readLine());
  	String[] input = line.toString().split(" ");
  	int a = Integer.parseInt(input[0]);
  	int b = Integer.parseInt(input[1]);
  	int result1 = a * b;
  	int result2 = a + a + b + b; 
  	System.out.println(result1 + " " + result2);
 }		
}

Measured memory_bytes: 24188
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int N;
    cin >> N;
    vector<char>cs(N);
    int rcount = 0;
    for (int i=0; i<N; i++){
        cin >> cs[i];
        if (cs[i] == 'R')rcount++;
    }

    string ideal = "";
    for (int i=0; i<N; i++){
        if (i<rcount)ideal += "R";
        else ideal += "W";
    }

    // WR をなくす
    // 解はすくなくとも初期状態でのRの数よりは小さい
    // Rを左に寄せる
    //WRWWRWRR -> RWWWRWRR -> RRWWWWRR
    
    int diff = 0;

    for (int i=0; i<N; i++){
        if (ideal[i] != cs[i])diff++;
    }
    cout << diff/2 << endl;

}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    string s;
    cin >> s;
    int n = s.size();
    int a = 0;
    rep(i, n) a += s[i] - '0';
    int b = (n - 1) * 9 + (s[0]-'1');

    cout << max(a,b) << endl;

    return 0;
}


Measured memory_bytes: 3628
cmin = lambda a,b : a if a<b else b
cmax = lambda a,b : a if a>b else b
iin = lambda : int(input())
lin = lambda : list(map(int,input().split()))
rin = lambda n : [int(input()) for _ in range(n)]


a,b,c = map(int,input().split())

print("bust" if (a+b+c)>= 22 else "win")

Measured memory_bytes: 3064
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt()
  val ls = (1 to n).map(_ => sc.nextInt())
    .sorted

  val sum = ls.sum

  if (sum - ls(n - 1) <= ls(n - 1)) {
    println("No")
  } else {
    println("Yes")
  }
}


Measured memory_bytes: 27204
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::unordered_set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  string S; cin >> S;
  int N = std::stoi(S);

  int sum = std::accumulate(S.begin(), S.end(), 0, [](int r, char c){ return r + (c - '0'); });
  cout << (N % sum ? "No" : "Yes") << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
# ABC164a


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    s, w = map(int, input().split())
    if s <= w:
        print('unsafe')
    else:
        print('safe')


if __name__ == '__main__':
    main()


Measured memory_bytes: 61648
#include <stdio.h>
#include <math.h>
int main(void)
{
	double a, b, S, L, h, x;
	int C;
	scanf("%lf%lf%d", &a, &b, &C);
	h = sin(M_PI/180*C)*b;
	x = cos(M_PI/180*C)*b;
	L = a+b+sqrt(h*h+(a-x)*(a-x));
	S = (a*h)/2;
	printf("%f\n%f\n%f\n", S, L, h);
	return 0;
}

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

using namespace std;

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

typedef long long ll;
ll mod=1000003;
ll a[1000010], inv[1000010];

ll beki(ll x, int y)
{
	if(y==0) return 1;
	if(y==1) return x;
	ll tmp=beki(x, y/2);
	if(y%2==0) return tmp*tmp%mod;
	else return tmp*tmp%mod*x%mod;
}

ll inverse(ll x)
{
	return beki(x, mod-2);
}

int main()
{
	a[0]=1;
	inv[0]=1;
	rep(i, mod)
	{
		a[i+1]=a[i]*((ll)i+1)%mod;
		inv[i+1]=inverse(a[i+1]);
	}
	int q;
	cin >> q;
	ll x, d, n;
	rep(cnt, q)
	{
		cin >> x >> d >> n;
		ll t;
		if(d==0)
		{
			if(x==0) cout << 0 << endl;
			else cout << beki(x, (int)(n%(mod-1))) << endl;
		}
		else
		{
			t=inverse(d)*x%mod;
			if(t+n-1>=mod) cout << 0 << endl;
			else if(t==0) cout << 0 << endl;
			else
			{
				cout << a[(int)(t+n-1)]*inv[t-1]%mod*beki(d, (int)n)%mod << endl;
			}
		}	
	}
	return 0;
}

Measured memory_bytes: 16512
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<atcoder/all>
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;
using namespace atcoder;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}
vector<int> a;
vector<int> b;
signed main(){
    int n,m;
    cin >> n>> m;
    REP(i,n){
        int a1;
        cin >> a1;
        a.pb(a1);
    }
    REP(i,m){
        int b1;
        cin >> b1;
        b.pb(b1);
    }
    vector<int> c = convolution<998244353>(a,b);
    REP(i,c.size()-1){
        cout << c[i] << " ";
    }
    cout << c[c.size()-1] << endl;


    



    return 0;
}

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

// Solution class
class Solution {
    public Solution() { }
    private static final InputReader scan = new InputReader();
    // solve method
    public void solve() throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        // code goes here...
        double x = scan.nextDouble();

        double cube = Math.pow(x, 3.0);
        out.println((int)cube);

        out.close();
    }
}

// InputReader class
class InputReader {
    private final BufferedReader br;
    private StringTokenizer st = new StringTokenizer("");
    public InputReader() { br = new BufferedReader(new InputStreamReader(System.in)); }
    public String next() throws IOException {
        while (!st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException ie) { ie.printStackTrace(); }
        }
        return st.nextToken();
    }
    public String nextLine() throws IOException {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException ie) { ie.printStackTrace(); }
        return str;
    }
    public int nextInt() throws IOException { return Integer.parseInt(next()); }
    public long nextLong() throws IOException { return Long.parseLong(next()); }
    public double nextDouble() throws IOException { return Double.parseDouble(next()); }
}

// Main class
public class Main {
    public Main() { }
    // driver method
    public static void main(String[] args) throws IOException {
        new Solution().solve();
    }
}



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

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

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<string> S(N);
    for (auto& x : S) cin >> x;
    int res = 0;
    int a = 0, b = 0, ab = 0;
    for (auto& x : S) {
      for (int i = 0; i + 1 < x.size(); i++) {
        if (x[i] == 'A' && x[i + 1] == 'B') {
          ++res;
        }
      }
      if (x.front() == 'B' && x.back() == 'A') {
        ++ab;
      } else if (x.back() == 'A') {
        ++a;
      } else if (x.front() == 'B') {
        ++b;
      }
    }
    if (ab > 1) {
      res += ab - 1;
    }
    if (ab > 0) {
      if (a > 0) {
        ++res;
        --a;
      }
      if (b > 0) {
        ++res;
        --b;
      }
    }
    res += min(a, b);
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 768
import java.io.*;
import java.util.*;
import java.util.function.*;

class WeightedEdge {
	int from;
	int to;
	int weight;

	WeightedEdge(int from, int to, int weight){
		this.from = from;
		this.to = to;
		this.weight = weight;
	}
}

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		List<Queue<WeightedEdge>> edges = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			edges.add(new ArrayDeque<>());
		}
		for (int i = 0; i < N - 1; i++) {
			int u = Integer.parseInt(sc.get()) - 1;
			int v = Integer.parseInt(sc.get()) - 1;
			int w = Integer.parseInt(sc.get());
			edges.get(u).add(new WeightedEdge(u, v, w));
			edges.get(v).add(new WeightedEdge(v, u, w));
		}

		BitSet black = new BitSet();
		dfs(new BitSet(), black, 0, edges);
		StringJoiner joiner = new StringJoiner("\n");
		for (int i = 0; i < N; i++) {
			joiner.add(black.get(i) ? "1" : "0");
		}
		System.out.println(joiner.toString());
	}

	void dfs(BitSet visited, BitSet black, int start, List<? extends Queue<WeightedEdge>> ki) {
		if (visited.get(start)) return;
		visited.set(start);
		Queue<WeightedEdge> edges = ki.get(start);
		while (!edges.isEmpty()) {
			WeightedEdge w = edges.remove();
			if (w == null || w.weight <= 0) {
				continue;
			}
			if (w.weight % 2 == 0) {
				black.set(w.to, black.get(start));
			} else {
				black.set(w.to, !black.get(start));
			}
			dfs(visited,black, w.to, ki);
		}
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				try {
					return (line = line != null && line.hasMoreTokens() ? line : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		});
	}
}

Measured memory_bytes: 65100
N = int(input())
alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

def find_name(tmp_N, p, keta, alpha):
  if keta == 1:
    for i in range(len(alpha)):
      #print(tmp_N + (i+1))
      if tmp_N + (i+1) == N:
        p.append(i)
        return p
  else:
    for i in range(len(alpha)):
      if tmp_N + 26**(keta-1)*i+1 <= N <= tmp_N + 26**(keta-1)*(i+1):
        p.append(i)
        tmp_N = tmp_N + 26**(keta-1)*i
        keta -= 1
        return find_name(tmp_N, p, keta, alpha)
    
# 桁数の確認
keta = 1
tmp_N = 0
while 1:
  if tmp_N + 1 <= N <= tmp_N + 26**keta:
    break
  else:
    keta += 1
    tmp_N += 26**(keta-1)
#print(keta)

p = []
p = find_name(tmp_N, p, keta, alpha)
out = ''
#print(p)
for i in range(len(p)):
  out += alpha[p[i]]
print(out)



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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int i, j, k, a, b, res=0, temp;
    double t;
    cin>>a>>b>>t;
    t += 0.5;
    temp = a;
    for(i=1;temp<=t;i++){
        temp = a*i;
        if(temp>t)
            break;
        res += b;
    }

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


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H,W = MI()
    S = H*W
    ans = inf
    for h in range(H):
        if not (H-h)&1 or not W&1:
            piece = [h*W]
            piece.append(W*(H-h)/2)
            ans = min(ans, max(piece)-min(piece))
        else:
            if (H-h)&1:
                piece = [h*W]
                piece.append((H-h-1)*W/2)
                piece.append((H-h+1)*W/2)
                ans = min(ans, max(piece)-min(piece))
            if W&1:
                piece = [h*W]
                piece.append((W-1)*(H-h)/2)
                piece.append((W+1)*(H-h)/2)
                ans = min(ans, max(piece)-min(piece))
        

    for w in range(W):
        if not (W-w)&1 or not H&1:
            piece = [w*H]
            piece.append(H*(W-w)/2)
            ans = min(ans, max(piece)-min(piece))
        else:
            if (W-w)&1:
                piece = [h*W]
                piece.append((W-w-1)*H/2)
                piece.append((W-w+1)*H/2)
                ans = min(ans, max(piece)-min(piece))
            if H&1:
                piece = [h*W]
                piece.append((H-1)*(W-w)/2)
                piece.append((H+1)*(W-w)/2)
                ans = min(ans, max(piece)-min(piece))
    print(int(ans))
if __name__ == '__main__':
    main()


Measured memory_bytes: 44852
#include <stdio.h>

int main(void) {
	// your code goes here
	long long N,i,ans=1;

 scanf("%lld",&N);

 for(i=1;i<=N;i++){

 ans=ans*i;
 ans=ans%1000000007;

}

printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using IVN=System.Int32;
class abc167_a{
  public static void Main(){
    String s1 = Console.ReadLine();
    String s2 = Console.ReadLine();
    bool flag = true;
    for(int i=0; i<s1.Length; i++){
      if(s1[i] != s2[i]){
        flag = false;
        break;
      }
    }
    if(flag){
      Console.WriteLine("Yes");
    }
    else{
      Console.WriteLine("No");
    }
  }
}


Measured memory_bytes: 17352
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort(key=lambda x:x[0])
ans=0
for i in range(n):
  d=min(ab[i][1],m)
  m-=d
  ans+=ab[i][0]*d
  if m==0:
    break
print(ans)

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


int main()
{
    int n, count = 0;
    string s;
    cin >> n;
    map<string, short> encounter;
    while (n--)
    {
        cin >> s;
        if (encounter[s] == 0) {count++; encounter[s]++;}
    }
    cout << count;
}

Measured memory_bytes: 19076
from collections import deque


def foo(k):
    q = deque([(1, 0)])
    nodes = {} #i:k+1 for i in range(k)}
    while q:
        x, cost = q.popleft()
        if x in nodes:
            continue
        nodes[x] = cost
        zero = (x * 10) % k
        one = (x + 1) % k
        q.appendleft((zero, cost ))
        q.append((one, cost + 1))
    return nodes[0]



if __name__ == "__main__":
    k = int(input())
    print(foo(k)+1)


Measured memory_bytes: 24312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using pll = pair<ll,ll>;
using Graph = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i,l,r) for(ll i = (l); i <= (ll)(r); i++)
#define rep3(i,l,r) for(ll i = (l); i >= (ll)(r); i--)
#define dup(x,y) (((x)+(y)-1)/(y)) // x/yの除算の切り上げ
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; }
const int inf = 1001001001;
const ll INF = 1LL << 60;
const ll mod = 1000000007; //1000000007
const ld pi = acos(-1);
 
//xor演算
//a^b=b^a
//a^(b^c)=(a^b)^c
//a^a=0
//a+b=a^b + 2(a&b)
//(4a)^(4a+1)^(4a+2)^(4a+3)=0
 
 
int main(){
 
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n;
    cin >> n;
    ll x,y;
    cin >> x >> y;
    rep(i,n-1){
        ll a,b;
        cin >> a >> b;
        ll n=max(dup(x,a),dup(y,b));
        x=n*a;
        y=n*b;
    }
    cout << x+y << endl;
}

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

using namespace std;

#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int fact[2002],mark[4002],dp[4002][2002][2];

int main()
{
    FAST();
    int i,j,m,n,x,ans=0,cnt=0,mod=924844033;
    cin >> n >> m;
    for(i=1;i<=m;i++)
    {
        x=(n-i)/m+1;
        mark[cnt+1]=1,cnt+=x;
        mark[cnt+1]=1,cnt+=x;
    }
    dp[0][0][0]=1;
    for(i=1;i<=cnt;i++)
    {
        for(j=0;j<=n;j++)
        {
            dp[i][j][0]=(dp[i-1][j][0]+dp[i-1][j][1])%mod;
            if(!mark[i]  &&  j+1 <= n)dp[i][j+1][1]=dp[i-1][j][0];
        }
    }
    fact[0]=1;
    for(i=1;i<=n;i++)fact[i]=1LL*i*fact[i-1]%mod;
    for(i=0;i<=n;i++)
    {
        x=1LL*(dp[cnt][i][0]+dp[cnt][i][1])*fact[n-i]%mod;
        if(i & 1)ans+=mod-x;
        else ans+=x;
        if(ans >= mod)ans-=mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 66124
S = input()
list = [(i + j) for (i,j) in zip(S[::2],S[1::2])]
if int(list[0]) >= 1 and int(list[0]) <= 12:
     if int(list[1]) >= 1 and int(list[1]) <= 12:
         print("AMBIGUOUS")
     else:
         print("MMYY")
else:
     if int(list[1]) >= 1 and int(list[1]) <= 12:       
         print("YYMM")
     else:
         print("NA")

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
	int a,b,c,x; scanf("%d %d %d %d",&a,&b,&c,&x);
	int ans = 0;
	for(int i = 0; i <= a; i++){
		for(int j = 0; j <= b; j++){
			for(int k = 0; k <= c; k++){
				if(i*500+j*100+k*50 == x) ans++;
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

trans :: [String] -> [[Integer]] 
trans []=[]
trans (x:xs)=(map read.words$x) : trans xs

dist [a,b] [c,d]=abs (a-c)+abs (b-d)

comp a b=compare (snd a) (snd b)

nearFt :: [[Integer]] -> [Integer] -> Integer
nearFt checkPts student=(fst.head) $ sortBy comp $zip [1,2..] (map (dist student) checkPts)

nearPts :: [[Integer]] -> [[Integer]] -> [Integer]
nearPts students checkPts=map (nearFt checkPts) students

output n students checkPts size_n=do
  if(n==1) then 
             (putStrLn.show) $ last (nearPts students checkPts)
           else do
             (putStrLn.show) $ (nearPts students checkPts)!!(size_n-n)
             output (n-1) students checkPts size_n

main=do
  [n,m]<-map read.words<$>getLine
  data_students<- replicateM n getLine
  data_checkPts<- replicateM m getLine
  output n (trans data_students) (trans data_checkPts) n

Measured memory_bytes: 1020