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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

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

int H, W, D;
Pi convD(Pi p) {
	return Pi(p.second - p.first + H, p.first + p.second);
}

char convmas[1111][1111];
void Main() {
	cin >> H >> W >> D;
	for (int i = 0; i < 1111; i++) {
		for (int j = 0; j < 1111; j++) {
			int by = (i/D)&1, bx = (j/D)&1;
			if (by == 0 && bx == 0) convmas[i][j] = 'R';
			if (by == 0 && bx == 1) convmas[i][j] = 'B';
			if (by == 1 && bx == 0) convmas[i][j] = 'Y';
			if (by == 1 && bx == 1) convmas[i][j] = 'G';
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			Pi base = Pi(i, j);
			Pi ret = convD(base);
			int y, x;
			tie(y, x) = ret;
			assert(y >= 0 && x >= 0);
			cout << convmas[y][x];
		}
		cout << el;
	}
}

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


Measured memory_bytes: 1664
L = list(map(int, input().split()))
p1 = (L[0], L[1])
p2 = (L[2], L[3])
vec = (L[2]-L[0], L[3]-L[1])


def rotate90(v):
    return -v[1], v[0]


vec = rotate90(vec)
p3 = (p2[0]+vec[0], p2[1]+vec[1])
vec = rotate90(vec)
p4 = (p3[0]+vec[0], p3[1]+vec[1])

print("{} {} {} {}".format(p3[0], p3[1], p4[0], p4[1]))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;

int n1,n2;
 
void solve()
{ 
  if(n1 > 8 || n2 > 8){
   cout << ":(" << endl;
  }else{
  cout << "Yay!" << endl;
  }
 
}

int main(void)
{
  cin >> n1 >> n2;
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef int_fast64_t ll;
typedef int_fast32_t intt;
typedef int_fast32_t tmp_m;
#define deb(x) cout << #x << ' ' << x << endl
#define rep(i, a, b) for (tmp_m i = a; i < b; ++i)
#define repp(i, a, b) for (tmp_m i = a; i >= b; --i)
#define pb push_back
#define st stack
#define pa pair
#define vc vector
#define qu queue
#define pq priority_queue
#define fr first
#define sc second
#define mp map
const intt mod = 1e9 + 7;

struct pr {
  intt x;
  intt y;
  intt dst;
  pr() {}
  pr(intt x, intt y, intt dst) : x(x), y(y), dst(dst) {}
  inline bool operator<(const pr& b) const {
    if (dst != b.dst) return dst > b.dst;
    if (x != b.x) return x > b.x;
    return y > b.y;
  }
};

struct point {
  intt x;
  intt y;
  point() {}
  point(intt x, intt y) : x(x), y(y) {}
  inline bool operator<(const point& b) const {
    if (x != b.x) return x > b.x;
    return y > b.y;
  }
};

inline bool spoint(point a, point b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}

inline bool spr(pr a, pr b) {
  if (a.dst != b.dst) return a.dst < b.dst;
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}



void solve() {
  intt r;
  cin >> r;
  printf("%.12lf\n", 2 * r * M_PI);
  // cout << 2 * r * M_PI << endl;
}

void init() {
  // remove if interactive
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  // memset(dp, -1, sizeof dp);
}

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


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
// using Graph = vector<vector<int>>;
const int MOD = 1000000007;

struct UnionFind {
  vector<int> par;  // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N) {  //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) {  // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {  // xとyの木を併合
    int rx = root(x);         // xの根をrx
    int ry = root(y);         // yの根をry
    if (rx == ry) return;  // xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] =
        ry;  // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y) {  // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  vector<int> y(m);
  vector<int> z(m);
  rep(i, m) {
    int X, Y, Z;
    cin >> X >> Y >> Z;
    X--;
    Y--;
    x[i] = X;
    y[i] = Y;
  }

  vector<bool> tf(n, false);
  UnionFind tree(n);
  rep(i, m) { tree.unite(x[i], y[i]); }
  rep(i, n) tf[tree.root(i)] = true;
  int res = 0;
  rep(i, n) if (tf[i]) res++;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 2048
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
const int mod=1e9+7,maxn=2e5+10,inf=2e9;
typedef long long LL;
LL fac[maxn],invfac[maxn];
std::vector<int> ed[maxn];
int n,x,y;
bool vis[maxn];
int minw[maxn],c[maxn],w[maxn],id[maxn],seq[maxn];
int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(!isdigit(ch))
    {
        f=(ch=='-')?-f:f;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return f<0?-x:x;
}
bool cmpid(int id1,int id2)
{
    return w[minw[id1]]<w[minw[id2]];
}
int cnt;
void fill(int x)
{
    if(vis[x]) return;
    vis[x]=true;
    seq[++cnt]=c[x];
    for(int i=0;i<ed[x].size();i++) fill(ed[x][i]);
}
void addedge(int u,int v)
{
    ed[u].push_back(v);
    ed[v].push_back(u);
}
LL qp(LL x,int y)
{
    if(y==0) return 1;
    int w=0;
    while((y>>w)>1)w++;
    LL ret=x;
    while(w>0)
    {
        --w;
        ret=ret*ret%mod;
        if((y>>w)&1)ret=ret*x%mod;
    }
    return ret;
}
int main()
{
    n=read();x=read();y=read();
    for(int i=1;i<=n;i++){c[i]=read();w[i]=read();}
    for(int i=1;i<=n;i++) minw[i]=0;
    w[0]=inf;
    for(int i=1;i<=n;i++) if(w[i]<w[minw[c[i]]]) minw[c[i]]=i;
    for(int i=1;i<=n;i++) id[i]=i;
    std::sort(id+1,id+n+1,cmpid);
    for(int i=1;i<=n;i++)if(w[i]+w[minw[c[i]]]<=x&&i!=minw[c[i]])
        addedge(i,minw[c[i]]);
    for(int i=1;i<=n;i++)
    {
        if(c[i]!=id[1]&&w[i]+w[minw[id[1]]]<=y) addedge(i,minw[id[1]]);
        if(minw[id[2]]>0&&c[i]!=id[2]&&w[i]+w[minw[id[2]]]<=y) addedge(i,minw[id[2]]);
    }
    fac[0]=1;
    for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
    invfac[n]=qp(fac[n],mod-2);
    for(int i=n-1;i>=0;i--) invfac[i]=invfac[i+1]*(i+1)%mod;
    memset(vis,0,sizeof vis);
    LL ans=1;
    for(int i=1;i<=n;i++) if(!vis[i])
    {
        cnt=0;
        fill(i);
        ans=ans*fac[cnt]%mod;
        std::sort(seq+1,seq+cnt+1);
        int cur=1;
        for(int j=2;j<=cnt;j++)
            if(seq[j]!=seq[j-1])
            {
                ans=ans*invfac[cur]%mod;
                cur=1;
            } else cur++;
        ans=ans*invfac[cur]%mod;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 19048
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>


using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long ll;

//abc103
//最小公倍数 -1のMODでよさそう
int main() {

    ll r;
    cin >> r;

    ll res;

    res = 3 * r* r;


    cout << res << endl;

    return 0;

}

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

#define  FOR(i,s,g) for(int i=s;i<g;i++)
#define RREP(i  ,n) for(int i=n-1;i>=0;i--);
#define  REP(i,  n) for(int i=0;i<n;i++)

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

const char en = '\n';
const ull  INFL = 810000001919114514;
const ull  INF  =         1919114514;

int main(){
	cin.tie();ios::sync_with_stdio(false);
	
	string s;
	cin>>s;

	s.insert(s.begin()+4,' ');

	cout<<s<<en;

	return 0;
}


Measured memory_bytes: 256
# 2019/03/03
# AtCoder Beginner Contest 120 - B

# Input
a, b, k = map(int,input().split())

# Calc
cnt = 0
anslist = list()
for idx in range(1, 101):
    if (a % idx) == 0 and (b % idx) == 0:
        anslist.append(idx)
        cnt += 1

anslist.sort(reverse=True)
# Output
print(anslist[k-1])


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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++){
        int count = 0;
    for (int j = 1; j <= n;j++){
        if(i%j == 0){
            count++;
        }
    }
    if (count == 8 && i % 2 != 0)
        ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>

int field[52][52];

void clear();

bool walk(int x, int y);

int main(){

	int w,h,ans;
	
	while(true){

		std::cin >> w >> h;
		if(w==0 && h==0)
			break;

		clear();
		for(int i=1; i<=h; i++)
			for(int j=1; j<=w; j++)
				std::cin >> field[i][j];

		ans = 0;
		for(int i=1; i<=h; i++)
			for(int j=1; j<=w; j++)
				if(walk(j, i))
					ans++;

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

	}

	return 0;
}

void clear(){
	for(int i=0; i<52; i++)
		for(int j=0; j<52; j++)
			field[i][j] = 0;
}

bool walk(int x, int y){
	if(field[y][x] == 0)
		return false;

	field[y][x] = 0;
	
	for(int i=-1; i<=1; i++)
		for(int j=-1; j<=1; j++)
			walk(x+i, y+j);

	return true;
}

Measured memory_bytes: 0
N, = map(int, input().split())
from collections import defaultdict
A = list(map(int, input().split()))
d = defaultdict(int)
for a in A:
    d[a] += 1
R=0
for k in d:
    R += k*d[k]
Q, = map(int, input().split())
for _ in range(Q):
    a, b = map(int, input().split())
    d[b] += d[a]
    R = R + (b-a)*d[a]
    d[a] = 0
    print(R)



Measured memory_bytes: 94460
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

ostream& operator<<(ostream& os, const pair<char, int>& unit) {
  return os << unit.first << "^" << unit.second;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int N = 51;

const int C = N * N * N, INF = (1 << 30) - 10;

struct Knap {
  int V;
  int dp[C];
  
  void init(int V) {
    this->V = V;
    fill(dp + 1, dp + V + 1, INF);
  }
  
  void addsingle(int w, int v) {
    for (int i = V; i >= w; --i)
      dp[i] = min(dp[i - w] + v, dp[i]);
  }
  
  void add(int w, int v, int c) {
    int k = 1;
    while (k <= c) {
      addsingle(w * k, min(v * (ll)k, (ll)INF));
      c -= k;
      k <<= 1;
    }
    if (c > 0)
      addsingle(w * c, min(v * (ll)c, (ll)INF));
  }
} knap;

struct Ele {
  int m, s, w;
  
  Ele() {}
  
  Ele(int m, int s, int w) : m(m), s(s), w(w) {}
  
  bool operator>(const Ele& rhs) const { return s * (ll)rhs.m > rhs.s * (ll)m; }
};

int n, x, d;
int m[N], p[N], s[N];
int ec;
Ele e[N];

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> n >> x >> d >> m[1];
  for (int i = 2; i <= n; ++i)
    cin >> m[i] >> p[i];
  fill(s + 1, s + n + 1, 1);
  for (int i = n; i > 1; --i) {
    s[p[i]] += s[i];
    m[p[i]] = min(m[i] + m[p[i]], x + 1);
  }
  knap.init(n * n * n);
  for (int i = 1; i <= n; ++i) {
    int lmt = i == 1 ? INF : d;
    knap.add(s[i], m[i], min(n, lmt));
    if (lmt > n)
      e[++ec] = Ele(m[i], s[i], lmt - n);
  }
  sort(e + 1, e + ec + 1, greater<Ele>());
  int ans = 0;
  for (int i = 0; i <= n * n * n; ++i) {
    if (knap.dp[i] > x) continue;
    int rest = x - knap.dp[i], cur = i;
    for (int j = 1; j <= ec; ++j) {
      int got = min(e[j].w, rest / e[j].m);
      rest -= got * e[j].m;
      cur += e[j].s * got;
    }
    ans = max(ans, cur);
  }
  cout << ans << '\n';

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> c;
    c.push_back(1);
    for (int i = 6; i <= N; i *= 6) {
        c.push_back(i);
    }
    for (int i = 9; i <= N; i *= 9) {
        c.push_back(i);
    }

    int dp[101000];
    fill(dp, dp + 101000, INF);
    dp[0] = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < c.size(); j++) {
            if(i>=c[j]){
                dp[i] = min(dp[i], dp[i - c[j]] + 1);
            }
        }
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  static int n, k;
  static int[] a;

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

    n = sc.nextInt();
    k = sc.nextInt();
    a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }

    int count = 0;
    for(int i = 0; i < n; i++){
      if(a[i] >= k){
        ++count;
      }
    }

    int[] b = new int[n - count];
    int m = 0;
    for(int i = 0; i < n; i++){
      if(a[i] < k){
        b[m++] = a[i];
      }
    }

    Arrays.sort(b);

    int low = -1, high = m;
    while(high - low > 1){
      int mid = (low + high) / 2;
      if(!check(mid, b)){
        low = mid;
      }
      else{
        high = mid;
      }
    }

    System.out.println(low + 1);
  }

  private static boolean check(int index, int[] b){
    int[] c = new int[b.length - 1];
    int m = 0;
    for(int i = 0; i < b.length; i++){
      if(i != index){
        c[m++] = b[i];
      }
    }

    boolean[][] dp = new boolean[m + 1][k + 1];
    dp[0][0] = true;
    for(int i = 1; i <= m; i++){
      for(int j = 0; j < dp[i].length; j++){
        if(j - c[i - 1] >= 0){
          dp[i][j] = dp[i - 1][j] || dp[i - 1][j - c[i - 1]];
        }
        else{
          dp[i][j] = dp[i - 1][j];
        }
      }
    }

    for(int s = k - b[index]; s < k; s++){
      if(dp[m][s]){
        return true;
      }
    }

    return false;
  }
}

Measured memory_bytes: 212588
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-6
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e5+10;
const int N = 1e5+10;
const int E = 1e6+10; 
int n,m;

int main() {
	cin>>n>>m;
	int ans  = (n-1)/m+1;
	cout<<ans<<endl; 
}

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

int N, num, node[10005]; 
vector<int> G[10005], c;

void dfs(int x, int px){
  
  for(int nx : G[x] ){
    if( nx != px ) dfs( nx, x );
  }
  
  node[x] = c[num++];
  
}

signed main(){
  
  cin>>N;
  
  for(int i=0;i<N-1;i++){
    int a, b;
    cin>>a>>b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);    
  }
    
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    c.push_back(a);
  }
  
  sort(c.begin(),c.end());
  
  dfs( 0, 0 );
  
  int ans = 0;
  
  for(int i=0;i<N-1;i++){
    ans += c[i];
  }
  
  cout<<ans<<endl;
  
  for(int i=0;i<N;i++){
    if( i ) cout<<' ';
    cout<<node[i];
  }
  
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std ;
typedef long long ll ;



int main(){
	string s , t ;
	cin >> s >> t ;
	int ans = 0 ; 
	for( int i = 0 ; i < s.size() ; i++ ){
		if( s[i] != t[i])ans++ ;
	}
	cout << ans << endl ; 


	return 0 ;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  int x[m];
  int sum = 0;
  int kukan[m - 1];
  for (int i = 0; i < m; i++) cin >> x[i];

  sort(x, x + m);

  for (int i = 0; i < m - 1; i++) {
    kukan[i] = x[i + 1] - x[i];
    sum += x[i + 1] - x[i];
  }
  sort(kukan, kukan + m - 1);

  for (int i = m - 1 - 1; i > (m - 1) - 1 - (n - 1); i--) sum -= kukan[i];

  if (n >= m) cout << 0 << endl;
  else cout << sum << endl;

}


Measured memory_bytes: 1024
# ABC080D - Recording
def main():
    N, C, *STC = map(int, open(0).read().split())
    recorders = [[0] * (10 ** 5 + 1) for _ in range(C + 1)]
    for s, t, c in zip(*[iter(STC)] * 3):
        recorders[c][s - 1 : t] = [1] * (t - s + 1)
    ans = max(sum(sliced) for sliced in zip(*recorders))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 36384
#include<stdio.h>

void  swap(int *x, int *y)
{
    int  temp;
    temp = *x;        /* xの値を一時保存 */
    *x = *y;          /* xの値をyの値に書き換える */
    *y = temp;        /* yの値をxの値に書き換える */
}

int Partition(int A[],int p,int r){
	//基準値をxに記録。
	int x = A[r];
	int i = p;
	
	/*
	pからiまで<=x, i+1からjまでをx<。
	jを増やしながら基準値とA[j]を比べる。とにかく左側に小さいのを持ってくる。
	A[j]の方が大きい場合は何もしない。
	A[j]の方が小さい場合はA[j]をA[i]に持ってってiを１増やす。
	*/
	for(int j = p; j < r; j++){
		if(A[j] <= x){
			swap(&A[i],&A[j]);
			i++;
		}
	}
	swap(&A[i],&A[r]); //このswapはfor文の中に組み込んでもいい。その場合はj<=rでreturn i-1。
	return i;
}

int main()
{
    int i,n,m;
    
    scanf("%d", &n);
    int A[n];
    
    for(i=0; i<n; i++){
        scanf("%d", &A[i]);
    }
    
    m=Partition(A,0,n-1);
    
    for(i=0; i<n; i++){
        if(i) printf(" ");
    	if(i==m){
    		printf("[%d]", A[i]);
    	} else {
    		printf("%d", A[i]);
    	}
    }
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 2128
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    h::Int,w::Int=parseMap(split(readline()))
    s=Vector{String}([readline() for i in 1:h])
    cnt=Vector{Vector{Int}}([[0 for i in 1:w] for j in 1:h])
    res::Int=0
    for i in 1:h
        res=0
        for j in 1:w
            if s[i][j]=='#'
                res=0
            else
                cnt[i][j]+=res
                res+=1
            end
        end
        res=0
        for j in w:-1:1
            if s[i][j]=='#'
                res=0
            else
                cnt[i][j]+=res
                res+=1
            end
        end
    end
    for i in 1:w
        res=0
        for j in 1:h
            if s[j][i]=='#'
                res=0
            else
                cnt[j][i]+=res
                res+=1
            end
        end
        res=0
        for j in h:-1:1
            if s[j][i]=='#'
                res=0
            else
                cnt[j][i]+=res
                res+=1
            end
        end
    end
    ans::Int=0
    for i in 1:h
        for j in 1:w
            if s[i][j]=='.'
                cnt[i][j]+=1
            end
            ans=max(ans,cnt[i][j])
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 153468
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

V = sum(v)
dp = [[float("inf")] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
	for j in range(V + 1):
		if j - v[i] >= 0:
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i])
		dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

ans = 0
for j in range(V + 1):
	if dp[N][j] <= W:
		ans = j

print(ans)


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  string s; std::cin >> s;
  int a = 0, b = 0, c = 0;
  rep(i, s.size()) {
    if (s[i] == 'a') a++;
    else if (s[i] == 'b') b++;
    else c++;
  }
  int ma = a, mi = a;
  chmax(ma, b), chmin(mi, b);
  chmax(ma, c), chmin(mi, c);
  std::cout << (ma-mi < 2 ? "YES" : "NO") << "\n";
}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define MOD 1000000007
typedef pair<li, li> PI;

int main(void) {
	li n;
	string s;
	cin >> n >> s;

	li res = 0;
	rep(i, n - 2 ) {
		if (s.substr(i, 3) == "ABC") {
			++res;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
 int a,b,c;
 scanf("%d %d %d", &a,&b,&c);
 
 if(a <= b&&b <= c) 
     printf("%d %d %d\n", a,b,c);
 else if(b <= a&&a <= c)
     printf("%d %d %d\n", b,a,c);
 else if(a <= c&&c <= b)
    printf("%d %d %d\n", a,c,b);
 else if(b <= c&&c <= a)
    printf("%d %d %d\n", b,c,a);
 else if(c <= a&&a <= b)
    printf("%d %d %d\n", c,a,b);
 else
    printf("%d %d %d\n", c,b,a);
 
 return 0;
}


Measured memory_bytes: 2044
import java.util.*;
public class Main{
	public static void main(String[] args){
		Main main = new Main();
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		String zeroS = S.replace("ABC", "0");
		int count = 0;
		for (char c : zeroS.toCharArray()) {
			if (c == '0') {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

template <class S>
S sum(vector<S>& a) {
  return accumulate(all(a), S());
}

int main(void){
	int m,n;
	cin >> n >> m;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	double b = sum(a)/4./m;
	int c = 0;
	rep(i,n){
		c += (a[i] >= b);
	}
	if(c >= m) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N, M;
    while(cin >> N >> M, N || M) {
        vector<int> A(N);
        for(int i=0; i<N; i++) cin >> A[i];

        int ans = -1;
        for(int i=0; i<N; i++) {
            for(int j=i+1; j<N; j++) {
                if(A[i] + A[j] <= M) {
                    ans = max(ans, A[i] + A[j]);
                }
            }
        }
        if(ans == -1) cout << "NONE" << endl;
        else cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3088
#include <stdio.h>
#include <iostream>
#include <cmath>
using namespace std;

int main(void)
{		
	int a, b;
	char op;
	
	while (1) {
		cin >> a >> op >> b;
		if (op == '?') break;
		
		int ans;
		if (op == '+') {
			ans = a + b;
		} else if (op == '-') {
			ans = a - b;
		} else if (op == '*') {
			ans = a * b;
		} else {
			ans = a / b;
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define int long long
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); //freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);
using namespace std;


int n;
int cnt[1000001];
vector <bool> ok(1000001, 1);

signed main()
{
    FLASH

    cin>>n;
    for(int i = 1; i <= n; i++){
        int a;
        cin>>a;
        cnt[a]++;
    }

    int ans = 0;

    if(cnt[1]){
        return cout<<(cnt[1] == 1), 0;
    }

    for(int i = 1; i <= 1000000; i++){
        if(cnt[i] == 0) continue;
        ok[i] = ok[i]&(cnt[i] == 1);
        for(int j = 2*i; j <= 1000000; j += i) ok[j] = 0;
    }

    for(int i = 1; i <= 1000000; i++) ans += ((cnt[i] == 1) and ok[i]);
    cout<<ans<<'\n';
}

Measured memory_bytes: 11584
sx,sy,tx,ty = map(int, input().split())

ans = ""

ans += 'U' * (ty-sy) + 'R' * (tx-sx)
ans += 'D' * (ty-sy) + 'L' * (tx-sx)

ans += 'L' + 'U' * (ty-sy+1) + 'R' * (tx-sx+1) + 'D'
ans += 'R' + 'D' * (ty-sy+1) + 'L' * (tx-sx+1) + 'U'

print(ans)




Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int x,y;
    cin>>x>>y;
    cout<<(ll)x*y/__gcd(x,y)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt(), c = scanner.nextInt(), k = scanner.nextInt(), ans = 0;
        Queue<Integer> t = IntStream.range(0, n).map(i -> scanner.nextInt()).sorted().boxed().collect(Collectors.toCollection(ArrayDeque::new));
        while (!t.isEmpty()) {
            for (int i = 1, f = t.poll() + k; i < c && !t.isEmpty() && t.peek() <= f; i++)
                t.remove();
            ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 57528
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>


#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define inf 5555555555555555555
#define mod 1000000007
#define pi 3.14159265358979323846
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> n;
  ll a[111];
  FOR(i, 0, n)cin >> a[i];
  mi = inf;
  FOR(i, -100, 101) {
	m = i;
	tmp = 0;
	FOR(j, 0, n) {
	  tmp += llabs(m - a[j])*llabs(m - a[j]);
	}
	mi = min(mi, tmp);
  }
  cout << mi << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

    class Program
    {
        static void Main(string[] args)
        {
            int n;
            int[] a;
            n = Int32.Parse(Console.ReadLine());
            a = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();

            int ans = 0;
            for (int i=0; i<a.Length; i++)
            {
                int div = a[i];
                while(div % 2 == 0)
                {
                    div = div / 2;
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }
    }


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

int n;
vector <int> graph[200005];
int visit [200005];

int diameter () {
	int i=0;
	queue<int> q;

	q.push(1); visit[i] = 1;

	while (!q.empty()) {
		int u = q.front(); q.pop();
		for (i=0; i<graph[u].size(); i++) {
			int v = graph[u][i];
			if (visit[v] == 0) {visit[v] = visit[u]+1; q.push(v); } 
		}
	}

	int idx=-1, val=-1;
	for (i=1; i<=n; i++) {
		val = max(val, visit[i]);
		if (val == visit[i]) idx = i;
	}

	memset(visit, 0, sizeof(visit));

	q.push(idx); visit[idx] = 1;

	while (!q.empty()) {
		int u = q.front(); q.pop();
		for (i=0; i<graph[u].size(); i++) {
			int v = graph[u][i];
			if (visit[v] == 0) {visit[v] = visit[u]+1; q.push(v); } 
		}
	}

	idx=-1, val=1;
	for (i=1; i<=n; i++) {
		val = max(val, visit[i]);
		if (val == visit[i]) idx = i;
	}

	return val-1;
}

int main () {
	
	int x=0, y=0, i=0;

	cin >> n;

	for (i=0; i<n-1; i++) {
		cin >> x >> y;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}

	int res = diameter();

	//cout << res << endl;

	if (res== 0) cout << "First" << endl;
	else {

		if (res%3 == 1) cout << "Second" << endl;
		else cout << "First" << endl;

	}

	return 0;
}

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

int main ()
{
  int A,B,C;
  cin >> A >> B >>C;
  if (A==B && A==C) cout << "No" << endl;
  else if (A==B || A==C || B==C) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const int mod=924844033;
int edgenum,head[4000005],nex[4000005],vet[4000005],num[4000005],siz[4000005];
int fac[4000005],inv[4000005],c[4000005],d[4000005],ans[4000005],re[4000005],G[2];
int n,m,len,pr[4000005];
int ksm(int a,int b,int mod)
{
	int s=1;
	while (b>0)
	{
		if (b&1) s=(long long)s*a%mod;
		a=(long long)a*a%mod,b>>=1;
	}
	return s;
}
void Pre(int N)
{
	fac[0]=1;
	for (int i=1;i<=N;i++) fac[i]=(long long)fac[i-1]*i%mod;
	inv[N]=ksm(fac[N],mod-2,mod);
	for (int i=N-1;i>=0;i--) inv[i]=(long long)inv[i+1]*(i+1)%mod;
}
int C(int a,int b)
{
	return (long long)fac[a]*fac[b]%mod*fac[a-b]%mod;
}
void addedge(int u,int v)
{
	edgenum++,vet[edgenum]=v,nex[edgenum]=head[u],head[u]=edgenum;
}

void dfs(int u,int pre)
{
	siz[u]=1;
	for (int i=head[u];i!=0;i=nex[i])
		if (vet[i]!=pre) dfs(vet[i],u),siz[u]+=siz[vet[i]];
	num[siz[u]]=(num[siz[u]]+mod-1)%mod;
	if (pre!=0) num[n-siz[u]]=(num[n-siz[u]]+mod-1)%mod;
}

int calcg(int p)
{
	int m=p-1,tot=0;
	for (int i=2;i<=sqrt(p);i++)
		if (m%i==0)
		{
			pr[++tot]=i;
			while (m%i==0) m/=i;
		}
	if (m>1) pr[++tot]=m;
	for (int i=2;;i++)
	{
		int flag=0;
		for (int j=1;j<=tot;j++)
			if (ksm(i,(p-1)/pr[j],p)==1) {flag=1;break;}
		if (flag==0) return i;
	}
	return 0;
		
}

void NTT(int *num,int len,int flag)
{
	for (int i=0;i<len;i++)
		re[i]=(re[i>>1]>>1)+(i&1)*(len>>1);
	for (int i=0;i<len;i++)
		if (i<re[i]) swap(num[i],num[re[i]]);
		
	for (int i=1;i<len;i<<=1)
	{
		int w0=ksm(G[flag],(mod-1)/i/2,mod);
		for (int j=0;j<len;j+=i+i)
			for (int r=0,k=1;r<i;r++,k=(long long)k*w0%mod)
			{
				int x=num[j+r],y=(long long)num[i+j+r]*k%mod;
				num[j+r]=(x+y)%mod,num[i+j+r]=(x-y+mod)%mod;
			}
	}
	int invn=ksm(len,mod-2,mod);
	if (flag==1)
		for (int i=0;i<len;i++) num[i]=(long long)num[i]*invn%mod;
}

int main()
{
	Pre(2000000);
	scanf("%d",&n);
	for (int i=1,x,y;i<n;i++)
		scanf("%d%d",&x,&y),addedge(x,y),addedge(y,x);
	dfs(1,0),num[n]=n;
	for (int i=1;i<=n;i++) c[i]=(long long)num[i]*fac[i]%mod;
	for (int i=0;i<=n;i++) d[i]=inv[n-i];
	for (len=1;len<=n+n;len<<=1);
	G[0]=calcg(mod),G[1]=ksm(G[0],mod-2,mod);
	NTT(c,len,0),NTT(d,len,0);
	for (int i=0;i<len;i++) c[i]=(long long)c[i]*d[i]%mod;
	NTT(c,len,1);
	for (int i=1;i<=n;i++)
		ans[i]=(long long)c[i+n]*inv[i]%mod;
	for (int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 59264
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
  int a,b,c;
  cin>>a >> b >> c;
  cout << c <<' '<< a <<' '<< b << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <bitset>
#include <utility>
#include <queue>
#include <deque>

using namespace std;

int main(){

    int N, M;
    cin >> N >> M;

    cout << N*(N-1)/2 + M*(M-1)/2 << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n = int(input())
ma = len(str(n))

ans = 0
def dfs(stack):
    global ans
    if len(stack) > ma:
        return
    if len(stack) >= 3:
        num = int(''.join(map(str, stack)))
        if stack.count(3) and stack.count(5) and stack.count(7) and num <= n:
            ans += 1
    for i in [3,5,7]:
        stack.append(i)
        dfs(stack)
        stack.pop(-1)
    return ans

stack = []
print(dfs(stack))


Measured memory_bytes: 77600
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string s;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> s;
}

int solve(){
    cout << (s=="ARC"?"ABC":"ARC") << endl;
    return 0;
}   

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


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

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

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

ll MOD = 1000000007;
const ll INF = (1ll << 60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
ll euler_phi(ll n) {
    ll ret = n;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            ret -= ret / i;
            while (n % i == 0) n /= i;
        }
    }
    if (n > 1) ret -= ret / n;
    return ret;
}

class Combination {
    long long powmod(long long a, long long p) {
        long long ans = 1LL;
        long long mul = a;
        while (p > 0) {
            if ((p & 1) == 1) {
                ans = (ans * mul) % MOD;
            }
            mul = (mul * mul) % MOD;
            p >>= 1;
        }
        return ans;
    }

public:
    int N;
    long long mod;
    vector<long long> fact;
    vector<long long> revfact;

    Combination(int n, long long m) : N(n), mod(m), fact(n + 1), revfact(n + 1) {
        fact[0] = 1;
        for (int i = 1; i <= N; i++) {
            fact[i] = fact[i - 1] * i;
            fact[i] %= mod;
        }

        revfact[N] = powmod(fact[N], mod - 2);
        for (int i = N - 1; i >= 0; i--) {
            revfact[i] = revfact[i + 1] * (i + 1) % mod;
        }
    }

    long long getCombination(int a, int b) {
        if (a < 0 || b < 0) return 0;
        if (b > a)return 0;
        return fact[a] * revfact[b] % mod * revfact[a - b] % mod;
    }
};




int main() {
    int N,M; cin >> N >> M;
    if(N == M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;

int main(void){
	while(1){
		int n, a, b, c, x; cin >> n >> a >> b >> c >> x;
		if(!n && !a && !b && !c && !x) break;
		int y[200];
		for(int i=0; i<n; i++) cin >> y[i];
		int xx = x;
		int counter = 0;
		for(int i=0; i<=10000; i++){
			if(i!=0) xx = (a*xx + b) % c;
			if(y[counter] == xx) counter++;
			if(n == counter){
				cout << i << endl;
				break;
			}
			if(i == 10000) cout << -1 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>
#include <stack>
#include <iomanip>
#include <sstream>

using namespace std;

template <typename T>
inline bool sign(T A) {
    return (A>0)-(A<0);
}
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SREP(i,s,n) for(int i=s; (n-i)*sign(n-s)>0; i+=sign(n-s))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool _less(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

template <template<class,class,class...> class C, typename K, typename V, typename... Args>
V map_get(const C<K,V,Args...>& m, K const& key, const V & defval)
{
    typename C<K,V,Args...>::const_iterator it = m.find( key );
    if (it == m.end())
        return defval;
    return it->second;
}

#define MOD (1'000'000'000 + 7)



int main(void)
{
    string s;
    cin >> s;
    REP(i, s.length()) {
        int c = s[i] - '0';
        if (i >= 1 && s[i - 1] == s[i])
        {
            cout << i << " " << i + 1 << endl;
            return 0;
        }
        if (i >= 2 && s[i-2]==s[i]) {
            cout << i - 1 << " " << i + 1 << endl;
            return 0; 
        }
    }
    cout << "-1 -1" << endl;
}


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

int main(){
    int n;
    cin>>n;
    int m=n%10;
    if(m==3){
        cout<<"bon"<<endl;
    }
    else if(m==0 || m==1 || m==6 || m==8){
        cout<<"pon"<<endl;
    }
    else{
        cout<<"hon"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int jenny[8]={4,1,2,1,2,1,4,1};
int main(){
	int p[7];
	int sum;
	int pi;
	while(scanf("%d %d %d %d %d %d %d %d",&p[0],&p[1],&p[2],&p[3],&p[4],&p[5],&p[6],&p[7])!=EOF){
		if(cin.eof())break;
		int ans=INF;
		for(int i=0;i <=7;i++){//どれだけずらすか
			sum = 0;
			for(int j=0;j <=7;j++){
				int d =jenny[(i+j)%8]-p[j];
				if(d <0){
					sum +=abs(d);
				}
			}
			if(ans==sum){
				int d1=0;
				int d2=0;
				for(int j =0;j <=7;j++){
					d1 +=jenny[(j+pi)%8]*pow(10.0,7-j);
				}
				for(int j=0;j <=7;j++){
					d2 +=jenny[(j+i)%8]*pow(10.0,7-j);
				}
				if(d1>d2){
					pi =i;
					continue;
				}
				continue;
			}
			if(ans>sum){
				ans =sum;
				pi =i;
			}
		}
		for(int i=0;i <=7;i++){
			cout <<jenny[(i+pi)%8];
			if(i!=7)cout<<" ";
			if(i==7)cout <<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1212
/**
 *	 Code by b21
 *	 Time: 18:59 Sat 14/03/2020
**/

#include <bits/stdc++.h>

using namespace std;

const int mn = 1 * (int)(1e5) + 10;
const int mod = 1 * (int)(1e9) + 7;
const int mm = 1 * (int)(1e3) + 10;
const int base = 1 * (int)(1e9);
const bool aNs = 0;

int tt, ntest = 1;
void docfile()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    if (ifstream("test.inp"))
    {
       freopen("test.inp", "r", stdin);
       if (!aNs) freopen("test.out", "w", stdout);
       else freopen ("test.ans", "w", stdout);
    }
   else if (ifstream("panasonic2020a.inp"))
    {
        freopen("panasonic2020a.inp", "r", stdin);
        freopen("panasonic2020a.out", "w", stdout);
    }
}

template <typename T>
void read(T& x)
{
    x = 0; T f = 1;
    char ch = getchar();
    while (!isdigit(ch)) f = ch == '-' ? - f : f, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    x *= f;
}

template <typename T>
void write (T a)
{
    if (a < 0)
    {
        putchar ('-');
        write (-a);
        return;
    }
    if (a < 10)
    {
        putchar ('0' + a);
        return;
    }
    write (a / 10);
    putchar ((char)('0' + (a % 10)));
}

int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}; 

void enter()
{
    int k;
    cin >> k;
    cout << a[k - 1];
}

void solve()
{

}

void print_result()
{

}

main()
{
    docfile();
    //cin>>ntest;
    for (tt = 1; tt <= ntest; ++ tt)
    {
        enter();
        solve();
        print_result();
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n, cur;
	scanf("%d\n", &n);
	int max = -1000001;
	int min = 1000001;
	long sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d\n", &cur);
		sum += cur;
		if (cur >= max) max = cur;
		if (cur < min) min = cur;
	}
	printf("%d %d %ld\n", min, max, sum);
    return 0;
}


Measured memory_bytes: 2092
# coding: utf-8
# Your code here!

num = int(input())
num_arr = [x for x in input().split()]

num_arr_rev = [None] * num
j = 0
for i in range(num,0,-1):
    num_arr_rev[j] = num_arr[i-1]
    j += 1
    
ans = " ".join(num_arr_rev)
print(ans)



Measured memory_bytes: 5604
import java.util.*;
import java.math.*;
 import static java.util.stream.Collectors.toList;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入

		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		int n = sc.nextInt();
		int maxR =n/r;
		int maxG =n/g;
		// int maxB =n/b;
		
		int count =0;
		for(int i=0;i<=maxR;i++){
			for(int j=0;j<=maxG;j++){
				int tmpSum = r*i + g*j;
				if(tmpSum>n){
					break;
				}
				if((n-tmpSum)%b==0){
					count++;
				}
			}
		}
		System.out.println(count);
 
	}

}




Measured memory_bytes: 21716
N, T = [int(x) for x in input().split()]
min_c = 1001
for i in range(N):
  c, t = [int(x) for x in input().split()]
  if T >= t:
    min_c = min(min_c, c)
print(min_c if min_c < 1001 else 'TLE')

Measured memory_bytes: 3060
n = int(input())
eigo = 'abcdefghijklmnopqrstuvwxyz'

keta = 1
j = 1
while n > 26**j:
    n -= 26**j
    keta += 1
    j += 1

n = n-1
ans =''

while keta != 0:
    a = n //(26**(keta-1))
    if a != 0:
        n = n -(26**(keta-1)*a)
        ans += eigo[a]
    else:
        ans+= eigo[0]
    keta -= 1

print(ans)

Measured memory_bytes: 61604