akhauriyash/Code-Regression huggingface dataset:
# Bubble Sort

n = int(input())
A = list(map(int, input().split()))

def bubbleSort(A):
	n = len(A)
	cnt = 0 # 要素の交換回数
	flag = 1
	while flag:
		flag = 0
		for j in range(n - 1, 0, -1):
			if A[j] < A[j - 1]:
				A[j], A[j - 1] = A[j - 1], A[j]
				flag = 1
				cnt += 1
	return A, cnt

res, cnt = bubbleSort(A)
print(*res)
print(cnt)


Measured memory_bytes: 5608
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> A(N), s(N+1, 0);
    Rep (i, N) {
        cin >> A[i];
        s[i+1] = s[i] + A[i];
    }

    ll ans = 1e10;
    for (ll i = 2; i <= N-2; i++) {
        vector<ll> choice;
        double intro = s[i] / 2.0, outro = (s[N] + s[i]) / 2.0;
        ll idx1 = lower_bound(s.begin(), s.end(), intro) - s.begin();
        if (idx1 == i || abs(s[i]+s[0]-2*s[idx1]) > abs(s[i]+s[0]-2*s[idx1-1])) {
            idx1--;
        }
        choice.push_back(s[i]-s[idx1]);
        choice.push_back(s[idx1]-s[0]);

        ll idx2 = lower_bound(s.begin(), s.end(), outro) - s.begin();
        if (idx2 == N || abs(s[N]+s[i]-2*s[idx2]) > abs(s[N]+s[i]-2*s[idx2-1])) idx2--;
        choice.push_back(s[N]-s[idx2]);
        choice.push_back(s[idx2]-s[i]);

        sort(choice.begin(), choice.end());
        ans = min(ans, choice[3] - choice[0]);
    }

    cout << ans << endl;
}

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

typedef pair<pair<int, int>, int> P;
typedef pair<int, int> Pair;

int h, w;
queue<P> que;
int m[1005][1005];
char maze[1005][1005];

void dfs(int x, int y, int cnt) {
    if (m[y][x] != -1) return;
    m[y][x] = cnt;
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, -1, 0, 1};

    for (int i = -2;i <= 2;i++) {
        for (int j = -2;j <= 2;j++) {
            int ny = y + i, nx = x + j;
            if (maze[ny][nx] == '.' && nx >= 0 && nx < w && ny >= 0 && ny < h) {
                que.push((P){(Pair){(nx), (ny)}, cnt + 1});
            }
        }
    }

    for (int i = 0;i < 4;i++) {
        int nx = x + dx[i], ny = y + dy[i];
        if (maze[ny][nx] == '.' && nx >= 0 && nx < w && ny >= 0 && ny < h)
            dfs(x + dx[i], y + dy[i], cnt);
    }

    return;
}

int main () {
    int cx, cy;
    int dx, dy;

    cin >> h >> w;
    cin >> cy >> cx; cy--; cx--;
    cin >> dy >> dx; dy--; dx--;
    for (int i = 0;i < h;i++) {
        for (int j = 0;j < w;j++) {
            cin >> maze[i][j];
            m[i][j] = -1;
        }
    }

    dfs(cx, cy, 0);
    while(!que.empty()) {
        /*
        cout << "---------------------------------" << endl;
        for (int i = 0;i < h;i++) {
            for (int j = 0;j < w;j++) {
                if (maze[i][j] == '#') cout << maze[i][j];
                else cout << m[i][j];
            }
            cout << endl;
        }
        */

        P p = que.front(); que.pop();
        dfs(p.first.first, p.first.second, p.second);
    }

    /*
    for (int i = 0;i < h;i++) {
        for (int j = 0;j < w;j++) {
            if (maze[i][j] == '#') cout << maze[i][j];
            else cout << m[i][j];
        }
        cout << endl;
    }
    */

    cout << m[dy][dx] << endl;

    return(0);
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define REP(i,n) for(int i = 1; i < (n); i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n")

using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;

const int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int dy[8] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1; 


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

  double a, b, c, d;
  cin >> a >> b >> c >> d;
  double ans = sqrt(pow(abs(a-c),2)+pow(abs(b-d),2));
  printf("%.10lf\n", ans);
}


Measured memory_bytes: 3300
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
    int a1,a2,a3;
    cin >> a1 >> a2 >> a3;
    int res = a1+a2+a3;
    if (res >= 22 ) {
        cout << "bust" << "\n";
    } else {
        cout << "win" << "\n";
    }
}


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

int main(){
  int s, a;
  cin >> s;
  a = (s % 100) % 10;
  a = a + ( ((s % 100) - a) / 10);
  a = a + (s - (s % 100))/100 ;
  cout << a << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	while (1) {
		int N, K; cin >> N >> K;
		if (!N)break;
		vector<int>ss(K);
		for (int i = 0; i < K; ++i) {
			cin >> ss[i];
		}
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < K; ++j) {
				int a; cin >> a;
				ss[j] -= a;
			}
		}
		bool ok = all_of(ss.begin(), ss.end(), [](const int a) {
			return a >= 0;
		});
		if (ok)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3028
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
while ( true )
{
//  üÍ
int w, h;
cin >> w >> h;
if ( w == 0  &&  h == 0 )
break;

vector<string> elev( h );
for ( int i=0; i<h; i++ )
cin >> elev[i];

//  s[XðT·
int num = 0;                //  s[XÌÂ
vector<vector<int> > bx;    //  ubNÌxÀW
vector<vector<int> > by;    //  ubNÌyÀW

while ( true )
{
//  Ü¾s[XÉèÄçêÄ¢È¢ubNðT·
char t = '.';
for ( int y=0; y<h && t=='.'; y++ )
for ( int x=0; x<w && t=='.'; x++ )
if ( elev[y][x] != '.' )
t = elev[y][x],
elev[y][x] = '*';
if ( t == '.' )
break;

//  ×ÚµÄ¢éubNð'*'Éu·
bool up;
do
{
up = false;
for ( int y=0; y<h; y++ )
for ( int x=0; x<w; x++ )
if ( elev[y][x] == '*' )
{
if ( 0<x   && elev[y][x-1]==t )  elev[y][x-1]='*', up=true;
if ( 0<y   && elev[y-1][x]==t )  elev[y-1][x]='*', up=true;
if ( x<w-1 && elev[y][x+1]==t )  elev[y][x+1]='*', up=true;
if ( y<h-1 && elev[y+1][x]==t )  elev[y+1][x]='*', up=true;
}
}
while ( up );

//  '*'ÌÀWðs[XÉèÄÄA'.'Éu·
bx.push_back( vector<int>() );
by.push_back( vector<int>() );

for ( int y=0; y<h; y++ )
for ( int x=0; x<w; x++ )
if ( elev[y][x] == '*' )
{
bx[num].push_back( x );
by[num].push_back( y );
elev[y][x] = '.';
}

num++;
}

//  x¦çêÄ¢éÅ¶EÅEÌubNÆx¦Ä¢és[XðvZ
vector<int>         xL( num, w );       //  ¼s[XÉÚµÄ¢éÅ¶ÌubN
vector<int>         xR( num, 0 );       //  ¼s[XÉÚµÄ¢éÅEÌubN
vector<int>         parent( num, -1 );  //  ±Ìs[Xðx¦Ä¢és[Xi-1FnÊj
vector<vector<int> >child( num );       //  ±Ìs[Xªx¦Ä¢és[X

for ( int p=0; p<num; p++ )
{
for ( int b=0; b<4; b++ )
{
int s = -1;
for ( int p2=0; p2<num; p2++ )
for ( int b2=0; b2<4; b2++ )
if ( p2 != p  &&
bx[p][b]   == bx[p2][b2]  &&
by[p][b]+1 == by[p2][b2] )
s = p2;

if ( s != -1  ||
by[p][b] == h - 1 )
{
xL[p] = min( xL[p], bx[p][b] );
xR[p] = max( xR[p], bx[p][b] );
parent[p] = s;
}
}

if ( parent[p] != -1 )
child[parent[p]].push_back( p );
}

//  dSðvZ
vector<int>     Mn( num, -1 );  //  ±Ìs[XÆx¦Ä¢és[XÌubNÌÂi-1F¢vZj
vector<int>     Mx( num, 0  );  //  ±Ìs[XÆx¦Ä¢és[XÌubNÌxÀWÌv

bool end = false;

while ( ! end )
{
for ( int p=0; p<num; p++ )
{
//  x¦Ä¢és[XªvZÏÝÌs[X©çßÄ¢­
bool f = true;
for ( int c=0; c<(int)child[p].size(); c++ )
if ( Mn[child[p][c]] == -1 )
f = false;

if ( f  &&  Mn[p] == -1 )
{
Mn[p] = 0;
Mx[p] = 0;

for ( int c=0; c<(int)child[p].size(); c++ )
Mn[p] += Mn[child[p][c]],
Mx[p] += Mx[child[p][c]];

for ( int b=0; b<4; b++ )
Mn[p]++,
Mx[p] += bx[p][b];

//  nÊÉÚµÄ¢és[XÌdSªÜêÎI¹
if ( parent[p] == -1 )
end = true;
}
}
}

//  Àè«»è
bool stable = true;

for ( int p=0; p<num; p++ )
{
//  Mx[p]/Mn[p] <= xL[p] - 1/2  ||
//  Mx[p]/Mn[p] >= xR[p] + 1/2
if ( Mx[p]*2 <= xL[p]*Mn[p]*2 - Mn[p]  ||
Mx[p]*2 >= xR[p]*Mn[p]*2 + Mn[p] )
stable = false;
}

if ( stable )
cout << "STABLE" << endl;
else
cout << "UNSTABLE" << endl;
}
}

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

int main()
{
    int N;
    cin >> N;
    set<string> s;
    string S;
    for (int i = 0; i < N; i++)
    {
        cin >> S;
        s.insert(S);
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 19120
#include <iostream>
#define int long long
using namespace std;

int32_t main()
{
  int n; cin>>n;
  int arr[n + 1];
  for(int i = 0; i < n + 1; i++) cin>>arr[i];
  int brr[n];
  for(int i = 0; i < n ; i++) cin>>brr[i];
  int ans = 0;
  for(int i = 0; i < n; i++)
  {
    int tm = min(brr[i],arr[i]);
    brr[i] -= tm;
    int a = min(brr[i],arr[i+1]);
    arr[i+1] -= a;
    ans += tm + a;
    
  }
  cout<<ans;
}


Measured memory_bytes: 1792
import scala.annotation.tailrec
import scala.collection.mutable
import scala.io.StdIn._
object Main extends App {

  solve()
  @tailrec def solve(): Unit = {
    val Array(h, w) = readLine.trim.split(' ').map(_.toInt)
    if (h == 0 && w == 0) return
    val rooms = Array.fill(h){Array.fill(w){Nil: List[Door]}}
    var doorCount = 0
    for (i ← 0 until 2 * h - 1) {
      val states = readLine.trim.split(' ').filter(_.nonEmpty).map{_ == "0"}
      i % 2 match {
        case 0 ⇒ for (j ← states.indices if states(j))  {
          rooms(i / 2)(j) ::= Door(Room(i / 2, j + 1), doorCount)
          rooms(i / 2)(j + 1) ::= Door(Room(i / 2, j), doorCount)
          doorCount += 1
        }
        case 1 ⇒ for (j ← states.indices if states(j)) {
          rooms(i / 2)(j) ::= Door(Room(i / 2 + 1, j), doorCount)
          rooms(i / 2 + 1)(j) ::= Door(Room(i / 2, j), doorCount)
          doorCount += 1
        }
      }
    }
    val byBrokenDoor = (0 until doorCount).map{id ⇒ countMinCost(rooms, id)}.toArray
    val worst = Array.tabulate(h){i ⇒ Array.tabulate(w){j ⇒ byBrokenDoor.map{_(i)(j)}.max}}
    if (byBrokenDoor.exists(a ⇒ a(0)(0) == Int.MaxValue)) {
      println(-1)
      solve()
    }else {
      var left = 0
      var right = h * w * 2
      while (left < right){
        val mid = (left + right) / 2
        if (canPass(rooms, worst, mid)) right = mid
        else left = mid + 1
      }
      println(right)
      solve()
    }
  }
  def canPass(rooms: Array[Array[List[Door]]], worst: Array[Array[Int]], k: Int): Boolean = {
    val count = Array.fill(rooms.length){Array.fill(rooms.head.length){Int.MaxValue}}
    val queue = mutable.Queue(Room(0, 0))
    count(0)(0) = 0
    while(queue.nonEmpty) {
      val current = queue.dequeue()
      for (Door(next, _) ← rooms(current.h)(current.w) if count(next.h)(next.w) == Int.MaxValue) {
        if (worst(next.h)(next.w) + count(current.h)(current.w) + 1 <= k) {
          count(next.h)(next.w) = count(current.h)(current.w) + 1
          queue.enqueue(next)
        }
      }
    }
    count.last.last <= k
  }
  def countMinCost(rooms: Array[Array[List[Door]]], invalid: Int): Array[Array[Int]] = {
    val count = Array.fill(rooms.length){Array.fill(rooms.head.length){Int.MaxValue}}
    val queue = mutable.Queue(Room(rooms.length - 1, rooms.head.length - 1))
    count(rooms.length - 1)(rooms.head.length - 1) = 0
    while (queue.nonEmpty) {
      val current = queue.dequeue()
      for (next ← rooms(current.h)(current.w) if next.id != invalid && count(next.to.h)(next.to.w) == Int.MaxValue) {
        count(next.to.h)(next.to.w) = count(current.h)(current.w) + 1
        queue.enqueue(next.to)
      }
    }
    count
  }
}
case class Door(to: Room, id: Int)
case class Room(h: Int, w: Int)



Measured memory_bytes: 561260
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
 
typedef long long ll;
typedef long double ld;
using namespace std;
 
const int MOD = 1e9 + 7;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int sum = 0;
    int n;
    cin >> n;
    vector<int> b(n - 1);
    for(int i = 0; i < n - 1; i++)
    {
        cin >> b[i];
    }
    for(int i = 0; i < n - 2; i++)
    {
        sum += min(b[i], b[i + 1]);
    }
    cout << sum + b[0] + b[n - 2];
 
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int a,b,c,k; cin >> a >> b >> c >> k;
	std::vector<int> v = {a,b,c};
	sort(v.rbegin(), v.rend());
	cout << v[0]*pow(2,k) + v[1] + v[2] << endl;

	
}

Measured memory_bytes: 384
while True:
    H, W = map(int, input().split())
    if H == W == 0:
        break

    for i in range(H):
        if i % 2:
            if W % 2:
                print(".#" * (W//2) + ".")
            else:
                print(".#" * (W//2))
        else:
            if W % 2:
                print("#." * (W//2) + "#")
            else:
                print("#." * (W//2))

    print()



Measured memory_bytes: 5608
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] n = new int[N];
		String[] S = new String[N];
		int[] P = new int[N];
		for(int i = 0; i < N; i++) {
			n[i] = i+1;
			S[i] = sc.next();
			P[i] = sc.nextInt();
		}
		while(true) {
			boolean ok = true;
			for(int i = 0; i < N-1;i++) {
				if(S[i].compareTo(S[i+1]) >= 1) {
					String t = S[i];
					S[i] = S[i+1];
					S[i+1] = t;
					int v = n[i];
					n[i] = n[i+1];
					n[i+1] = v;
					int w = P[i];
					P[i] = P[i+1];
					P[i+1] = w;
					ok = false;
				}
			}
			if(ok)
				break;
		}
		while(true) {
			boolean ok = true;
			for(int i = 0; i < N-1;i++) {
				if(S[i].equals(S[i+1]) && P[i] < P[i+1]) {
					String t = S[i];
					S[i] = S[i+1];
					S[i+1] = t;
					int v = n[i];
					n[i] = n[i+1];
					n[i+1] = v;
					int w = P[i];
					P[i] = P[i+1];
					P[i+1] = w;
					ok = false;
				}
			}
			if(ok)
				break;
		}
		for(int i = 0; i < N; i++)
			System.out.println(n[i]);
	}

}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define pa pair<int,int>
#define CLR(a,x) memset(a,x,sizeof(a))
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
const int maxn=2e5+10;

inline char gc(){
	return getchar();
	static const int maxs=1<<16;static char buf[maxs],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxs,stdin),p1==p2)?EOF:*p1++;
}
inline ll rd(){
    ll x=0;char c=gc();bool neg=0;
    while(c<'0'||c>'9'){if(c=='-') neg=1;c=gc();}
    while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+c-'0',c=gc();
    return neg?(~x+1):x;
}

int N,a[maxn],b[maxn],rnk[maxn];

inline bool cmp(int x,int y){
	return b[x]>b[y];
}

int main(){
    //freopen("","r",stdin);
    N=rd();
    for(int i=1;i<=N;i++) a[i]=rd(),b[i]=rd(),rnk[i]=i;
   	sort(rnk+1,rnk+N+1,cmp);
   	ll now=2e9;
   	for(int i=1;i<=N;i++){
   		int x=rnk[i];
   		now=min(now,(ll)b[x]);
   		now-=a[x];
   	}
   	if(now<0) printf("No");
   	else printf("Yes");
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    string s[H];
    char inputs[H+1][W+1];
    for(int i = 0; i < H; i++){
        cin >> s[i];
        for(int j = 0; j < W; j++){
            inputs[i][j] = s[i][j];
        }
    }
    for(int i = 0; i < H; i++){
        inputs[i][W] = '#';
    }
    for(int i = 0; i < W+1; i++){
        inputs[H][i] = '#';
    }
    int maxw[H][W];
    int maxh[H][W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            maxw[i][j] = 0;
            maxh[i][j] = 0;
        }
    }

    for(int i = 0; i < H; i++){
        int tmpw = 0;
        for(int j = 0; j < W+1; j++){
            // search from left
            if(inputs[i][j] == '.'){
                tmpw++;
            }else{
                int tmpj = j;
                while(tmpj > 0){
                    if(inputs[i][tmpj-1] == '#'){
                        //tmpw = 0;
                        tmpj = 0;
                    }else{
                        maxw[i][tmpj-1] = tmpw;
                        tmpj--;
                    }
                }
                tmpw = 0;
            }
        }
        tmpw = 0;
    }
    
    for(int i = 0; i < W; i++){
        int tmph = 0;
        for(int j = 0; j < H+1; j++){
            // search from left
            if(inputs[j][i] == '.'){
                tmph++;
            }else{
                int tmpj = j;
                while(tmpj > 0){
                    if(inputs[tmpj-1][i] == '#'){
                        //tmpw = 0;
                        tmpj = 0;
                    }else{
                        maxh[tmpj-1][i] = tmph;
                        tmpj--;
                    }
                }
                tmph = 0;
            }
        }
        tmph = 0;
    }



    int ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            ans = max(ans, maxh[i][j] + maxw[i][j]);
        }
    }
    cout << ans-1 << endl;
    return 0;
}

Measured memory_bytes: 39552
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch KthTerm | diff KthTerm.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address KthTerm.cpp && ./a.out

/*
 
 3/15/2020
 
 22:13-
 
 */

int N;
VI as={
  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 solve() {
  cout<<as[N-1]<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

// void call(int n){
//   int i = 1;
//  CHECK_NUM:
//   int x = i;
//   if ( x % 3 == 0 ){
//     cout << " " << i;
//     goto END_CHECK_NUM;
//   }
//  INCLUDE3:
//   if ( x % 10 == 3 ){
//     cout << " " << i;
//     goto END_CHECK_NUM;
//   }
//   x /= 10;
//   if ( x ) goto INCLUDE3;
//  END_CHECK_NUM:
//   if ( ++i <= n ) goto CHECK_NUM;
//
//   cout << endl;
// }

public class Main{

    static StringBuilder sb;

    public static void main(String[] args) {
	try {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    List<String> lines = new ArrayList<String>();

	    for (String line = br.readLine(); line != null; line = br.readLine()) {
		lines.add(line);
	    }
	    //lines.add("60");
	    br.close();

	    Integer n = Integer.parseInt(lines.get(0));
	    sb = new StringBuilder();

	    for (int i = 1; i <= n; i++) {
		if (i%3==0) {
		    sb.append(" " + i);
		} else if (i%10==3) {
		    sb.append(" " + i);
		} else if (String.valueOf(i).contains("3")) {
		    sb.append(" " + i);
		}
	    }
	    System.out.println(sb.toString());
	    System.exit(0);

	} catch (Exception e) {
	    System.out.println(e.getMessage());
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	}
    }
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

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

ll ans[] = {4,4,9,4,7,10,18,5,21,8,16,11,11,19,19,6,14,22,22,9,9,17,17,12,25,12,113,20,20,20,108,7,28,15,15,23,23,23,36,10,111,10,31,18,18,18,106,13,26,26,26,13,13,114,114,21,34,21,34,21,21,109,109,8,29,29,29,16,16,16,104,24,117,24,16,24,24,37,37,11,24,112,112,11,11,32,32,19,32,19,94,19,19,107,107,14,120,27,27,27};

int main(){
	int s;scanf("%d",&s);;printf("%d\n",ans[s-1]);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

void dfs(int now, int past, ll d, ll &sum, VVI &e){
    sum += d;
    for (int next : e[now]){
        if (next == past) continue;
        dfs(next, now, d + 1, sum, e);
    }
}

int main() {
    ll n;
    cin >> n;
    VL d(n);
    vector<PL> p(n);
    REP(i,n){
        d[i] = lin();
        p[i] = PL(d[i], i);
    }
    sort(ALL(p));
    reverse(ALL(p));

    map<ll, ll> mp;
    REP(i,n) mp[p[i].first] = i;
    VL cnt(n, 1);

    vector<PL> ans;
    REP(i,n-1){
        ll x = p[i].first - (n - 2 * cnt[i]);
        if (!mp.count(x) || mp[x] <= i){
            cout << -1 << endl;
            return 0;
        }
        int j = mp[x];
        cnt[j] += cnt[i];
        ans.push_back(PL(p[i].second, p[j].second));
    }

    VVI e(n);
    for (P p : ans){
        e[p.first].push_back(p.second);
        e[p.second].push_back(p.first);
    }

    ll sum = 0;
    dfs(p[0].second, -1, 0, sum, e);

    if (sum != p[0].first){
        cout << -1 << endl;
        return 0;
    }

    REP(i,n-1){
        printf("%lld %lld\n", ans[i].first + 1, ans[i].second + 1);
    }

    return 0;
}


Measured memory_bytes: 25588
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
using  namespace std; 

#define MAXN 1000001 

// stores smallest prime factor for every number 
ll spf[MAXN]; 

// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
	spf[1] = 1; 
	for (ll i=2; i<MAXN; i++) 

		// marking smallest prime factor for every 
		// number to be itself. 
		spf[i] = i; 

	// separately marking spf for every even 
	// number as 2 
	for (ll i=4; i<MAXN; i+=2) 
		spf[i] = 2; 

	for (ll i=3; i*i<MAXN; i++) 
	{ 
		// checking if i is prime 
		if (spf[i] == i) 
		{ 
			// marking SPF for all numbers divisible by i 
			for (ll j=i*i; j<MAXN; j+=i) 

				// marking spf[j] if it is not 
				// previously marked 
				if (spf[j]==j) 
					spf[j] = i; 
		} 
	} 
} 
ll getFactorization(ll x) 
{ 
    if(x==1)
    return 1;
	map<ll,ll> ret; 
	while (x != 1) 
	{ 
		ret[spf[x]]++; 
		x = x / spf[x]; 
	}
	ll ans=1;
	for(auto it=ret.begin();it!=ret.end();it++)
	{
	    ans*=(it->S+1);
	}
	return ans; 
} 

int main()
{
    fast;
   ll t=1;
   //std::cin >> t;
   while(t--)
   {
       sieve();
       ll n,c,ans=0;
       std::cin >> n;
       fr(c,1,n)
       {
           ll d=getFactorization(n-c);
               ans+=d;
       }
       cout<<ans<<"\n";
   }
}

Measured memory_bytes: 11464
#include<bits/stdc++.h>
using namespace std;
#define pb push_back 
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORi(i,a,b) for(int i=a;i<b;i++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define print(a) for(auto x:a) cout<<x<<' ';cout<<endl;
#define printM(b) for(auto y:b) {print(y);}
#define printP(p) cout<<p.first<<' '<<p.second<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
template <typename T> 
T cmax(T x, T y) 
{ 
   return (x > y)? x: y; 
} 
 
void solve()
{
  int n;
  cin>>n;
  
  
  if(n>=30)
  {
    cout<<"Yes";
  }
  else
  {
    cout<<"No";
  }
}
int main()
{
 
  fast;
  int t=1;
//cin>>t;
  while(t--){
 
solve();
cout<<endl;
  }
 
 
  
  return 0;
}

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

#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define eb emplace_back

typedef long long ll;
typedef pair<int,int> ii;
typedef vector< pair<int,int> > vii;
const int INF = 0x3f3f3f3f;

int main() {
    ios::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    cout << max({a+b,a-b,a*b}) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main () {
  int N;
  cin >> N;
  int A[4];
  for (int i = 3; i >= 0; i --) {
    A[i] = N % 10;
    N /= 10;
  }
  for (int i_ = 0; i_ < 8; i_ ++) {
    int i = i_;
    int ans = A[0];
    char op[3];
    for (int j = 1; j <= 3; j ++) {
      if (i % 2) {
        ans += A[j];
        op[j - 1] = '+';
      }
      else {
        ans -= A[j];
        op[j - 1] = '-';
      }
      i /= 2;
    }
    if (ans == 7) {
      for (int i = 0; i < 3; i ++) cout << A[i] << op[i];
      cout << A[3] << "=7" << endl;
      return 0;
    }
  }
}



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

void solve_A(){
	//AAAAAAAAAA
	int a,b;
	cin >> a >> b;
	cout << max(0,a-2*b) << endl;
}

void solve_B(){
	//BBBBBBBBBB
	int n,i,d[100],sum=0,sum2=0;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> d[i];
		sum+=d[i];
		sum2+=(d[i]*d[i]);
	}
	cout << (sum*sum-sum2)/2 << endl;
}

void solve_C(){
	//CCCCCCCCCC
	int n,i,ans=1;
	char s[100005];
	cin >> n >> s;
	for(i=1;i<n;i++) if(s[i-1]!=s[i]) ans++;
	cout << ans << endl;
}

void solve_D(){
	//DDDDDDDDDD
	long long n,i,j,l,m,ans=0;
	vector<long long> g;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> l;
		g.push_back(l);
	}
	sort(g.begin(),g.end());
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			m=g[i]+g[j];
			ans += (n-(lower_bound(g.begin(),g.end(),m)-g.begin()));
		}
	}
	cout << n*(n-1)*(n-2)/6 - ans << endl;
}

int main() {
	// your code goes here
	//solve_A();
	//solve_B();
	//solve_C();
	solve_D();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n,a,b;
  cin>>n;
  vector<int> v(n);
  cin>>a>>b;
  int cal;
  cin>>cal;
  for(int i=0;i<n;++i)
    cin>>v[i];
  sort(begin(v),end(v),greater<int>());
  int cost = a;
  for(int i=0;i<n;++i){
    if(cal*(cost+b) > (cal+v[i])*cost)break;
    cal += v[i];
    cost += b;
  }
  cout << (cal / cost) << endl;
  return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a==0&&b==0)
        cout<<0<<endl;
    cout<<(a-1)*(b-1)<<endl;
    return 0;
}

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

#define ff              first
#define ss              second
//#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int, int>
#define mci             map<char,int>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define rep(i,x,y)  for(int i=x;i<=y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--)
#define ll unsigned long long
using namespace std;

signed main()
{

    ios_base::sync_with_stdio(false);cin.tie(NULL);
int N, arr[N+1];
cin>>N;
rep(i, 0, N)
cin>>arr[i];
int count = 0;
rep(i, 0, N)
{
  if((i+1)%2!=0 && arr[i]%2!=0)
    count++;
}
cout<<count<<endl;
   
 cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;

  
return 0;
}

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

int main(){
	int n;
	cin >> n;
	map<string,int> mp;
	rep(i,n){
	  string s;
	  cin >> s;
	  ++mp[s];
	}
	
	int mx = 0;
	for(auto x : mp){
	  mx = max(x.second,mx);
	}
	for(auto x : mp){
	  if(x.second == mx){
	    cout << x.first << endl;
	  }
	}
 return 0;
}

Measured memory_bytes: 27008
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

ll ncr(ll n, ll r){
  if(n < r) return 0;
  if(r > n-r) r = n-r;

  ll a = 1, b = 1;
  for(int i = 0; i < r; i++){
    a *= (n - i);
  }
  for(int i = 0; i < r; i++){
    b *= (i + 1);
  }
  return a/b;
}


int main(){
  ll N;
  cin >> N;
  vll A(N);
  priority_queue<int> que;
  map<ll, ll> m;
  set<ll> se;
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    que.push(A.at(i));
    se.insert(A.at(i));
  }
  ll before = -1;
  int counter = 0;
  while(!que.empty()){
    ll x = que.top(); que.pop();
    if(before == -1) counter ++;
    else{
      if(before != x){
        m[before] = counter;
        before = x;
        counter = 1;
      }
      else counter++;
    }
    before = x;
  }
  m[before] = counter;

  ll sum;
  auto itee = begin(se);
  for(int j = 0; j < se.size(); j++){
      auto ite = itee++;
      int x = *ite;
      sum += ncr(m.at(x), 2);
  }
  

  for(int i = 0; i < N; i++){
    ll result = sum;
    result -= ncr(m.at(A.at(i)), 2);
    result += ncr(m.at(A.at(i)) - 1, 2);
    cout << result << endl;
  }
}

Measured memory_bytes: 17780
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
typedef long long ll;
typedef pair<int, int> pii;
#define int ll

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

constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int D, E;

signed main() {
    while(cin >> D >> E, D || E) {
        double ans = INF;
        repq(i,0,100) repq(j,0,100) {
            if(i + j != D) continue;
            double cost = abs(E - sqrt(i*i + j*j));
            chmin(ans, cost);
        }
        printf("%.12f\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3100
// scanf 等でエラーを出さないように追加
#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <memory>
#include <algorithm>
#include <numeric>
#include <set>
#include <functional>
#include <utility>


using namespace std;


typedef long long ll;



char s[101];

int main() {

	scanf("%s", s);

	const int length = strlen(s);


	bool checked_C = false;
	bool checked_F = false;

	for (int i = 0; i < length; i++) {
		if (s[i] == 'C') {
			checked_C = true;
			continue;
		}
		if (checked_C && s[i] == 'F') {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A, B, P;
  cin >> N >> A >> B;
  P = N * A;
  
  if (P < B) {
    cout << P << endl;
  }
  else if (P > B) {
    cout << B << endl;
  }
  else {
    cout << P << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int l; cin >> l;
	int n;
	for(int i=1;;i++){
		if((1<<i)>l){
			n=i;
			break;
		}
	}
	int p=__builtin_popcount(l);
	p--;
	cout << n << " " << 2*(n-1)+p << endl;
	for(int i=1;i<n;i++){
		cout << i << " " << i+1 << " " <<  0 << endl;
		cout << i << " " << i+1 << " " << (1<<(n-i-1)) << endl;
	}
	int cur=(1<<(n-1));
	for(int i=n-2;i>=0;i--){
		if(l&(1<<i)){
			cout << 1 << " " << n-i << " " << cur << endl;
			cur+=(1<<i);
		}
	}
}



Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"0 0 0 1"# => "-1 1 -1 0",

r#"2 3 6 6"# => "3 10 -1 7",

r#"31 -41 -59 26"# => "-126 -64 -36 -131",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        x1: isize, y1: isize, x2: isize, y2: isize,
    }
    let x = x2 - x1;
    let y = y2 - y1;
    format!("{} {} {} {}", x2 - y, y2 + x, x1 - y, y1 + x)
}

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

int main() {
  long long int N, K;
  cin >> N >> K;
  vector<pair<long long int, long long int>> X(N);
  for (long long int i = 0; i < N; i++) {
    long long int A, B;
    cin >> A >> B;
    X.at(i) = make_pair(A, B);
  }
  sort(X.begin(), X.end());
  long long int S = 0;
  for (long long int i = 0; i < N; i++) {
    S += X.at(i).second;
    if (S >= K) {
      cout << X.at(i).first << endl;
      break;
    }
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int max=0;
  int N; cin >> N;
  vector<int> sum(N);
  vector<string> blue(N);
  for (int i=0;i<N;i++){
    cin >> blue.at(i);
  }
  int M; cin >> M;
  vector<string> red(M);
  for (int i=0;i<M;i++){
    cin >> red.at(i);
  }
  for (int i=0;i<N;i++){
    for (int l=0;l<N;l++){
      if(blue.at(i)==blue.at(l)){
        sum.at(i)++;
      }
    }
    for (int j=0;j<M;j++){
      if(blue.at(i)==red.at(j)){
        sum.at(i)--;
      }
    }
  }
  for(int i=0;i<N;i++){
    if (sum.at(i)>max) max=sum.at(i);
  }
  cout << max << endl;
}

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

int N;
int ma;
int main()
{
	cin >> N;
	for(int i = 1;i <= N;i++)
	{
		if((i + 1) * i / 2 >= N)
		{
			ma = i;
			break;
		}
	}

	for(int i = ma;i >= 1;i--)
	{
		if(N - i >= 0)
		{
			cout << i << endl;
			N -= i;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int MAX(int a,int b){return a<b?b:a;}
//int P[1010],L[1010],R[1010],H[1010],C=1;
int P[4][1010],C=1,H[1010];
//int hyouka(int i,int x){return N[i]<=x?N[i]<x?-1:0:1;}
char N[1010][110];
int hyouka(int i,char *s){return strcmp(N[i],s);}
int h(int a){return H[P[2][a]]-H[P[1][a]];}
void rot(int a,int t){
  int b=P[t][a],r=P[0][a];
  P[t][r]==a?(P[1][r]=b):(P[2][r]=b);
  if(P[3-t][b])P[0][P[3-t][b]]=a;
  P[t][a]=P[3-t][b];
  P[3-t][b]=P[0][b];
  P[0][b]=P[0][a];
  P[0][a]=b;
  H[a]=MAX(H[P[1][a]],H[P[2][a]])+1;
  H[b]=MAX(H[P[1][b]],H[P[2][b]])+1;
}
int mfind(char *x){
  int i,j,r,n;
  if(C==1){
    P[1][0]=C;
    //N[C]=x;
    strcpy(N[C],x);
    P[0][C++]=0;
    return 1;
  }
  for(i=1;r=hyouka(i,x);i=n){
    if(r<0){
      if(P[1][i]==0){
	P[1][i]=C;
	P[0][C]=i;
	H[i]=MAX(1,H[i]);
	//N[C]=x;
	strcpy(N[C],x);
	C++;
      }
      n=P[1][i];
    }
    else{
      if(P[2][i]==0){
	P[2][i]=C;
	P[0][C]=i;
	H[i]=MAX(1,H[i]);
	strcpy(N[C],x);
	//N[C]=x;
	C++;
      }
      n=P[2][i];
    }
  }//printf("%d\n",i);
  j=P[0][i];
  while(1){
    if(h(j)<-1){
      if(h(P[1][j])>0)rot(P[1][j],1);
      rot(j,2);
      break;
    }
    if(h(j)>1){
      if(h(P[2][j])<0)rot(P[2][j],2);
      rot(j,1);
      break;
    }
    if(h(j)==0)break;
    j=P[0][j];
    if(j==0)break;
  }//printf("%d\n",i);
  return i;
}      
int main(){
  int i,l,max=0,mj=1,r,a[1010]={};
  char *c,*mi,s[1020];
  fgets(s,1010,stdin);
  mi=strtok(s," \n");
  a[mj=mfind(mi)]++;
  max=strlen(mi);
  // printf("%s\n",mi);
  while(c=strtok(NULL," \n")){
    //printf("%s\n",c);
    a[r=mfind(c)]++;
    //printf("%d\n",r);
    l=strlen(c);//printf("%s %d\n",mi,l);
    if(max<l){
      max=l;
      strcpy(mi,c);
    }//printf("a\n");
    if(a[r]>a[mj])mj=r;//printf("a\n");
  }
  //printf("%s %d\n",mi,mj);
  printf("%s %s\n",N[mj],mi);
  return 0;
}

Measured memory_bytes: 564
#include <iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a==1 && b==2 || a==2 && b==1) cout<<3;
  else if(a==1 && b==3 || a==3 && b==1) cout<<2;
  else cout<<1;
  return 0;
}


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

using namespace std;

int N, D;
int p[55][55];
int dp[55][55][55];
int pre[55][55][55];

int main() {
  cin >> N >> D;
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < D; ++j) cin >> p[i][j];
    reverse(p[i], p[i]+D);
  }

  fill((int*)dp[0], (int*)dp[55], INT_MAX);
  fill((int*)pre[0], (int*)pre[55], INT_MAX);

  for(int i = 0; i < N; ++i) dp[1][0][i] = p[i][0];

  for(int i = 1; i < D; ++i) {
    for(int j = 0; j < D; ++j) {
      for(int k = 0; k < N; ++k) {
	if(dp[i][j][k] == INT_MAX) continue;
	for(int l = 0; l < N; ++l) {
	  if(dp[i+1][j+(k!=l)][l] > dp[i][j][k]+p[l][i]) {
	    dp[i+1][j+(k!=l)][l] = dp[i][j][k]+p[l][i];
	    pre[i+1][j+(k!=l)][l] = k;
	  } else if(dp[i+1][j+(k!=l)][l] == dp[i][j][k]+p[l][i]) {
	    pre[i+1][j+(k!=l)][l] = min(pre[i+1][j+(k!=l)][l], k);
	  }
	}
      }
    }
  }

  /*
  for(int k = 0; k <= D; ++k) {
    for(int i = 0; i <= D; ++i) {
      for(int j = 0; j < N; ++j) {
	cout << dp[k][i][j] << " ";
      }
      cout << endl;
    }
    cout<<endl;
  }
  for(int k = 0; k <= D; ++k) {
    for(int i = 0; i <= D; ++i) {
      for(int j = 0; j < N; ++j) {
	cout << pre[k][i][j] << " ";
      }
      cout << endl;
    }
    cout<<endl;
  }
  */

  int P = INT_MAX, M = INT_MAX;
  for(int i = 0; i <= D; ++i) {
    for(int j = 0; j < N; ++j) {
      if(P > dp[D][i][j]) {
	P = dp[D][i][j];
	M = i;
      } else if(P == dp[D][i][j]) {
	M = min(M, i);
      }
    }
  }

  cout << P << " " << M << endl;

  int now = -1;
  for(int i = 0; i < N; ++i) {
    if(P == dp[D][M][i]) {
      now = i;
      break;
    }
  }

  vector<int> ans;
  int d = D, m = M;
  while(now != INT_MAX) {
    ans.push_back(now);
    int ne = pre[d][m][now];
    m -= (now != ne);
    now = ne;
    --d;
    //cout<<now<<" "<<m<<" "<<d<<endl;
  }
  for(int i : ans) cout << i+1 << endl;

  return 0;
}



Measured memory_bytes: 4476
n,m=map(int,input().split())
low=1
high=n
for i in range(m):
  l,r=map(int,input().split())
  if l>low:
    low=l
  if r<high:
    high=r
if high>=low:
  print(high-low+1)
else:
  print(0)

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

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

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  string s;
  cin >> s;
  int ans = 0;
  int same = 1;
  vector<int> sa(0);
  rep(i,0,s.size()-1){
    if(s[i]==s[i+1]) {
      same++;
      continue;
    }
    if(s[i]!=s[i+1]) {
      if(same%3!=0) sa.pb(same%3);
      if(same%3==0) ans += 2*(same/3);
      else ans += (2*(same/3) + 1);
      same = 1;
    }
  }
  if(same%3!=0) sa.pb(same%3);
  if(same%3==0) ans += 2*(same/3);
  else ans += (2*(same/3) + 1);
  if(sa.size()!=0){
    rep(i,0,sa.size()-1){
      if(sa[i]==2 && sa[i+1]==2) {
        ans++;
        sa[i]=1;
        sa[i+1]=1;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2680
/*
          .  .
          |\_|\
          | a_a\
          | | "]
      ____| '-\___
     /.----.___.-'\
    //        _    \
   //   .-. (~v~) /|
  |'|  /\:  .--  / \
 // |-/  \_/____/\/~|
|/  \ |  []_|_|_] \ |
| \  | \ |___   _\ ]_}
| |  '-' /   '.'  |
| |     /    /|:  |
| |     |   / |:  /\
| |     /  /  |  /  \
| |    |  /  /  |    \
\ |    |/\/  |/|/\    \
 \|\ |\|  |  | / /\/\__\
  \ \| | /   | |__
       / |   |____)
       |_/
*/

#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
const int INF = 1 << 29;
const int mxn = 2e5+5;
using namespace std;

int main()
{
    FLASH
    ll a,b,n;
    cin >> a >> b >> n;
    if(n < b)
    {
        cout << (a * n) / b;
        return 0;
    }
    if(n == b)
    {
        cout << (a * (n - 1)) / b;
        //cout << max( ((a * (n - 1)) / b) , (a * n) / b - a * (n / b) );
        return 0;
    }
    ll t;
    if(a < n)
        t = a;
    else
        t = n;
    ll ans = 0;
    t = min(a,b);
    t = (b -1);
    ll k1 = (a * t) / b;
    ll k2 = a * (t / b);
    ans = max(ans,k1-k2);
    /*while(t >= 1)
    {
        ll k1 = (a * t) / b;
        ll k2 = a * (t / b);
        ans = max(ans,k1-k2);
        t--;
    }*/
    cout << ans;
    return 0;
}



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

int main(){
	int n, max_dis, x, y, count = 0;
	cin >> n >> max_dis;

	for(int i = 0; i < n; i++){
		cin >> x >> y;
		x = abs(x); y = abs(y);
		double dis = sqrt(pow(x, 2) + pow(y, 2));

		if(dis <= max_dis)
			count += 1;

	}
	cout << count;




}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;

int fpow(int a, int b, int p){
	int res = 1;
	while(b>0){
		if(b&1) res = res * a % p;
		a = a * a % p;
		b>>=1;
	}
	return res;
}

int main(){
	fastio();
	int n, p; string s;
	cin >> s;
  	p=2019;
  	n=s.size();
	vector<int> have(p, 0);
	have[0] = 1;
	ll ans = 0;
	int ps = 0;
	if (p == 2) for(int i = 0; i<n; i++) ans+= (((s[i]-'0')%2 == 0)?ll(i+1):0);
	else if (p == 5) for(int i = 0; i<n; i++) ans+= (((s[i]-'0')%5 == 0)?ll(i+1):0);
	else for(int i = n-1; i>=0; i--){
		ps+= fpow(10, n-i-1, p)*(s[i]-'0');
		ps %= p;
		ans+= ll(have[ps]);
		have[ps]++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3708