akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        var regex = new Regex("[ACGT]*");
        var mc = regex.Matches(s);

        var max = 0;

        foreach(Match m in mc) {
            max = Math.Max(max, m.Value.Length);
        }

        return max;
    }
}


Measured memory_bytes: 15952
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;

#define read(x) scanf("%d",&x)
#define readl(x) scanf("%lld",&x)
#define ll long long 
#define ull unsigned long long

ll a,b,n;
ll x;

int main()
{
	cin>>a>>b>>n;
	if(n<b) x=n;
	else x=b-1;
	cout<<floor((double)a*(double(x)/b-floor(double(x)/b)))<<endl;
	return 0;
}

Measured memory_bytes: 3756
// 最大公約数
// a,bの最小公倍数(LCM)はa*b/GCD
/*
 * C言語のサンプルプログラム - Webkaru
 * - 入力した2つの自然数の最大公約数を求める -
 */
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    int N;
    cin>>N;
    vector<vector<pair<int,int>>> s(N);
    rep(i,N){
        int A;
        cin>>A;
        rep(j,A){
            int x,y;
            cin>>x>>y;
            x--;
            s[i].emplace_back(x,y);
        }
    }
    int ans=0;
    rep(i,1<<N){
        int ii=i;
        bool b=true;
        int c=0;
        while(ii>0){
            if(ii&1){
                for(pair<int,int> p : s[c]){
                    b&= (((i>>p.F)&1)==p.S);
                }
            }
            ii=ii>>1;
            c++;
        }
        if(b) ans=max(ans,__builtin_popcount(i));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
x = [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]

y = input()
K = int(y)

print(x[K-1])

Measured memory_bytes: 9180
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(f) printf("%.10lf\n",f)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
typedef long long int ll;
int main(void){
  ll a[2],b[2],c[2];
  scanf("%lld %lld %lld",&a[0],&b[0],&c[0]);
  if(a[0]%2<1&&a[0]==b[0]&&b[0]==c[0]){
    PRN(-1);
    return 0;
  }
  int ans=0;
  while(!(a[ans%2]%2+b[ans%2]%2+c[ans%2]%2)){
    a[(ans+1)%2]=b[ans%2]/2+c[ans%2]/2;
    b[(ans+1)%2]=c[ans%2]/2+a[ans%2]/2;
    c[(ans+1)%2]=a[ans%2]/2+b[ans%2]/2;
    ans++;
  }
  PRN(ans);
  return 0;
}

Measured memory_bytes: 128
import queue

K = int(input())
q = queue.Queue()

for i in range(1, 10):
    q.put(i)
v = 0
for i in range(K):
    v = q.get()
    m = v%10
    if m != 0:
        q.put(10*v+m-1)
    q.put(v*10+m)
    if m != 9:
        q.put(10*v+m+1)
print(v)


Measured memory_bytes: 12480
M = 10**9 + 7
n, k = [int(c) for c in input().split()]
out = 0
for kk in range(k, n+2):
    mm = kk * (kk-1) / 2
    MM = kk * (2*n - kk +1) / 2
    out += (MM - mm + 1)
    out %= M
print(int(out % M))

Measured memory_bytes: 67548
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int n; cin >> n;
		if (n == 0) break;
		vector< vector<bool> > a(n, vector<bool>(31));
		for (int i = 0; i < n; i++) {
			int f; cin >> f;
			while (f--) {
				int j; cin >> j;
				a[i][j] = true;
			}
		}
		vector<ll> b(n);
		for (int i = 0; i < n; i++)
			b[i] = 1LL << i;
		int j;
		for (j = 1; j <= 30; j++) {
			ll x = 0;
			for (int i = 0; i < n; i++)
				if (a[i][j])
					x |= b[i];
			for (int i = 0; i < n; i++)
				if (a[i][j])
					b[i] = x;
			if (x == (1LL << n) - 1)
				break;
		}
		cout << (j <= 30 ? j : -1) << endl;
	}
}

Measured memory_bytes: 1204
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        char[] N = new char[100];
        int D = in.read(N, 0, 100);
        int K = in.i();
        int[][][] dp = new int[D + 1][K + 1][10];
        dp[0][0][0] = 1;

        for (int d = 1; d <= D; d++) {
            for (int k = 0; k <= K; k++) {
                for (int j = 0; j < 10; j++) {
                    dp[d][k][0] += dp[d - 1][k][j];
                }
                if (k > 0) {
                    for (int i = 1; i < 10; i++) {
                        for (int j = 0; j < 10; j++) {
                            dp[d][k][i] += dp[d - 1][k - 1][j];
                        }
                    }
                }
            }
        }

        int ans = 0;

        for (int d = D; d > 0; d--) {
            int n = N[D - d] - '0';
            for (int i = 0; i < n; i++) {
                ans += dp[d][K][i];
            }
            if (n != 0 && --K == -1) {
                break;
            }
        }
        if (K == 0) {
            ans++;
        }

        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 32720
#include <iostream>
#include <string>
using namespace std;
string tiles[100];
int main()
{
	int X,Y;
	while(1)
	{
		cin >> Y >> X ;
		if(X==0 && Y==0) break;
		for(int i=0;i<Y;i++) cin >> tiles[i] ;
		bool Loop=false; bool flag[100][100]={false};

		int curr_x=0; int curr_y=0; flag[0][0]=true;
		while(tiles[curr_y][curr_x]!='.')
		{
			if(tiles[curr_y][curr_x]=='>') curr_x++;
			else if(tiles[curr_y][curr_x]=='<') curr_x--;
			else if(tiles[curr_y][curr_x]=='^') curr_y--;
			else if(tiles[curr_y][curr_x]=='v') curr_y++;
			if(flag[curr_y][curr_x]==true) {Loop=true; break;}
			else flag[curr_y][curr_x]=true;
		}
		if(Loop==true) cout << "LOOP" << endl;
		else cout << curr_x << ' ' << curr_y << endl;
	}
}

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

vector <int> health;
int n;

int HCF(){
  int temp = __gcd(health[0], health[1]);
  for(int i = 2; i < n; i++){
    temp = __gcd(health[i], temp);
  }
  return temp;
}


int main(){
  cin >> n;
  health.clear(); health.resize(n);
  for(int i = 0; i < n; i++){
    cin >> health[i];
  }
  cout << HCF() << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

	vector<int> a(n);
	for (auto& e : a) cin >> e;

	int cost = 0;
	a.insert(a.begin(), 0);
	a.push_back(0);

	vector<int> m;
	for (int i = 1; i < n + 1; i++) {
		cost += abs(a[i] - a[i-1]);
		m.push_back(abs(a[i] - a[i-1]) + abs(a[i+1]-a[i]) - abs(a[i+1]-a[i-1]));
	}
	cost += abs(0 - a[n]);

	for (auto i : m) {
		cout << cost - i << endl;
	}
	return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, dp[3001][3001], MOD = 1e9 + 7;
string s;

int main() {
	cin >> n >> s;
	
	s = "<" + s;
	dp[0][0] = 1;
	inc1(i, n) {
		if(s[i - 1] == '<') {
			inc(j, n + 1 - i) { dp[i][j] = (dp[i - 1][j    ] + (j == 0 ? 0 : dp[i][j - 1])) % MOD; }
		} else {
			dec(j, n + 1 - i) { dp[i][j] = (dp[i - 1][j + 1] +               dp[i][j + 1] ) % MOD; }
		}
	}
	
	cout << dp[n][0] << endl;
	
	return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 1005;
ll A[MAX_N];

pair<ll, vector<int>> mss(vector<ll> v) {
  ll res = 0;
  vector<int> res_idx; 
  for (int i = 0; i < (int)v.size(); i++) {
    if (v[i] > 0) {
      res += v[i];
      res_idx.push_back(i);
    }
  }

  if (res_idx.size() == 0) {
    auto p = max_element(ALL(v));
    res = *p;
    res_idx.push_back(p - v.begin());
  }
  return {res, res_idx};
}

int main2() {
  int N = nextInt();
  REP(i, N) A[i] = nextInt();

  vector<ll> even, odd;
  for (int i = 0; i < N; i+=2) even.push_back(A[i]);
  for (int i = 1; i < N; i+=2) odd.push_back(A[i]);

  pair<ll, vector<int>> res0 = mss(even);
  pair<ll, vector<int>> res1 = mss(odd);

  vector<int> v;
  if (res0.first >= res1.first) {
    cout << res0.first << endl;
    v = res0.second;
    REP(i, v.size()) v[i] *= 2;
    // pv(ALL(v));
  
  } else {
    cout << res1.first << endl;
    v = res1.second;
    REP(i, v.size()) v[i] = v[i] * 2 + 1;
    // pv(ALL(v));
  }

  vector<int> ops;
  for (int i = N-1; i > v.back(); i--)
    ops.push_back(i);

  if (v.size() >= 2) {
    for (int i = v.size() - 1; i - 1 >= 0; i--) {
      int L = (v[i] - v[i-1]) / 2;
      REP(j, L-1) ops.push_back(v[i-1] + 2);
      ops.push_back(v[i-1]+1);
    }
  }

  REP(k, v.front()) ops.push_back(0);

  // cout << "vvvvv" << endl;
  cout << ops.size() << endl;
  for (auto x : ops) cout << (x+1) << endl;
  // cout << "-----" << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

using namespace std;

typedef long long llint;

const int MAXN = 200005;
const int MOD = 1000000007;

llint h, w, a, b, sol;
llint f[MAXN], r[MAXN];

llint pot (llint x, int e) {
    if (e == 0) return 1;
    if (e & 1) return pot(x, e-1) * x % MOD;
    llint t = pot(x, e/2);
    return t * t % MOD;
}

void precompute () {
    f[0] = r[0] = 1;
    for (int i=1; i<MAXN; i++) {
        f[i] = f[i-1] * i % MOD;
        r[i] = pot(f[i], MOD - 2);
    }
}

llint nck (int n, int k) {
    return f[n] * r[k] % MOD * r[n-k] % MOD;
}

int main () {
    precompute();
    cin >> h >> w >> a >> b;
    for (int i=w; i>b; i--) {
        sol = (sol + nck(w-i + a-1, a-1) * nck(h-a-1 + i-1, i-1)) % MOD;
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<lld> vll;
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define srt(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define mod 1000000007
#define pi 3.1415926535
lld a,b,c,d,e,f,g,h,i,j,k=0,l=0,m=1,n=1,o,q=0,r=0,u,v,w,x,y,z,s,t,p=0;
lld temp=0,ans=0;
double f1,f2,f3,f4,f5,f6;
char c2,c3,c4,c5,c6;
vll v11;
pair<lld,lld>p1,p2,p3;
map<lld,lld>mv;bool a12[200005],a13[200005];
bool b11[500006],c11[500006];lld a11[500006];
lld gcd(lld a, lld b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
}
void dfs(lld i,vector<lld>vg[])
{
    if(b11[i]==true)    return;
    p++;
    b11[i]=true;
    for(auto x11:vg[i])
    {
        if(b11[x11]==false)
        {
            dfs(x11,vg);
        }
    }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  t=1;
  //cin>>t;
  while(t--)
  {
    string s3,s1,s2;
    cin>>n;
    //lld p1,q1,a1,b1,c1,d1;
    lld a1[n+1]={0},b1[n],c1[n+1];vector<lld>vg[n+1];
    map<lld,lld>m1,m2;queue<lld>q2;vll v1,v2;p=q=0;
    rep(i,0,n)
    {
        cin>>a1[i];
    }
    b1[n-1]=0;
    for(i=n-2;i>-1;i--)
    {
        b1[i]=(b1[i+1]+a1[i+1])%mod;
    }
    for(i=0;i<n;i++)
    {
        p=p+(a1[i]*b1[i])%mod;
        p=p%mod;
    }
    cout<<(p);
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 11460
(function(input) {
    var p = input.split(' ').map(Number);
    var x = p.shift();
    var y = p.shift();
    console.log(greatestCommonDevisor(x, y));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function greatestCommonDevisor(x, y) {
    return Math.max.apply(null, commonDevisor(x, y));
}

function commonDevisor(x, y) {
    if (x % y !== 0) {
        x = x % y;
    }
    var a = [];
    for (var i = 1; i <= x; i++) {
        if (x % i === 0 && y % i === 0) {
            a.push(i);
        }
    }
    return a;
}

Measured memory_bytes: 8560
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    # はじめは最初の条件だけを見る
    n = int(input())
    S = input()
    res = 0
    for center in range(1, n - 1):
        letters = ['R', 'G', 'B']
        letters.remove(S[center])
        a = S[:center].count(letters[0])
        b = S[center+1:].count(letters[1])
        res += a * b
        a = S[:center].count(letters[1])
        b = S[center+1:].count(letters[0])
        res += a * b

    # 2つ目の条件に該当するものを引く
    for d in range(1, n):
        for center in range(n):
            left = center - d
            right = center + d
            if 0 <= left and right < n:
                T = {S[left], S[center], S[right]}
                res -= len(T) == 3

    print(res)
resolve()

Measured memory_bytes: 68496
n,k=map(int,input().split())
f=[None]*4001
f[0]=1
mod=10**9+7
ans=0
import sys
sys.setrecursionlimit(20000)
def factorial(m):
    if not f[m]:
        f[m]=(factorial(m-1)*m)
    return f[m]
def nCm(n,m):
    if n<m:
        return 0
    return factorial(n)//factorial(m)//factorial(n-m)
for i in range(1,k+1):
    print(nCm((n-k+1),i)*nCm(k-1,i-1)%mod)

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


bool is_k(const string s) {
//    cout << s <<endl;
    for(int i = 0; i < s.size()/2; ++i) {
//        cout << s.substr(i,1) << s.substr(s.size()-i-1,1) << endl;
        if(s.substr(i,1) == s.substr(s.size()-i-1,1)){
        } else {
            return false;
        }
    }
    return true;
}

int main(void)
{
    string S;
    cin >> S;
    bool a;
    a = is_k(S);
    a &= is_k(S.substr(0,(S.size()-1)/2));
    a &= is_k(S.substr((S.size()+2)/2));
    if(a) {
        cout << "Yes" << endl;    
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    scanf("%d",&x);
    int ans=0,now=0;
    do
    {
        ans+=x,ans%=360,now++;
    }
    while(ans%360);
    printf("%d",now);
    return 0;
}

Measured memory_bytes: 3808
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

ll gcd(ll a, ll b)
{
	ll tmp = 0;
	if(a >= b) {
	} else {
		return gcd(b,a);
	}
	while((tmp = a%b)) {
		a = b;
		b = tmp;
	}
	return b;
}
int main()
{
	int X = 0;
	scanf("%d", &X);
	int npi = 360, i = 1;
	int ans = 0;
	while (1) {
		npi = 360 * i;
		if ((npi%X) == 0) {
			ans = npi/X;
			printf("%d\n", ans);
			break;
		}
		i++;
	}

/*	ll ans2 = gcd(360, X);
	ll ans3 = 0;
	//printf("%lld\n", ans);
	if (ans2 != 1) {
		ans3 = 360/ans2;
	} else {
		ans3 = 360*X;
	}
	printf("%lld\n", ans3);*/
	return 0;
}


Measured memory_bytes: 1736
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int X, A, B; cin >> X >> A >> B;

	int now = B - A;
	if(now <= 0) cout << "delicious" << endl;
	else if(now <= X) cout << "safe" << endl;
	else cout << "dangerous" << endl;


	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ff              first
#define ss              second
#define f(i,n)          for(int i=0;i<n;i++)
#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define rightmostbit(x) __builtin_ffsll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout << fixed; cout << setprecision(x); cout << y;
#define pi              3.141592653589793238
#define mk(a,n)         int n;cin>>n;vi a(n);for(int i=0;i<n;i++) cin>>a[i]
#define w(x)            int x; cin>>x; while(x--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
typedef tree<pii, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void g_b()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
int32_t main()
{
	g_b();
	int n, d; cin >> n >> d;
	int ans = 0;
	while (n--)
	{
		int x, y; cin >> x >> y;
		double dis = sqrt(x * x + y * y);

		if (dis <= d)ans++;
	}
	cout << ans;
	return 0;

}



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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

const int MOD = 1000000007;

int N;
LL A, B;
LL S[1<<20];

LL DP[1<<20];
LL pref[1<<20];

int main() {
  scanf("%d%lld%lld", &N, &A, &B);
  if (B < A) swap(A, B);

  S[0] = -(1e18+100);
  FOR(i,1,N+1) scanf("%lld", &S[i]);
  S[1+(N++)] = 3e18;

  REP(i,N-2) if (S[i+2] - S[i] < A) {
    printf("0\n");
    return 0;
  }

  DP[0] = 1;

  int a_start = 1;
  FOR(i,1,N+1) {
    pref[i] = (pref[i-1] + DP[i-1]) % MOD;

    int last_good_b = lower_bound(S, S+i, S[i]-B+1) - S - 1;
    int first_good_b = a_start - 1;
    if (first_good_b <= last_good_b) {
      DP[i] = (pref[last_good_b+1] - pref[first_good_b]) % MOD;
    }

    if (S[i] - S[i-1] < A) a_start = i;
  }

  LL result = (DP[N] + MOD) % MOD;
  printf("%lld\n", result);
}


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

int main(){
  int i,j;ll cnt=0;
  string s;
  cin>>s;
  int b=0;
  for(i=0;i<s.size();i++){
    if(s[i]=='B')b++;
    if(s[i]=='W')cnt+=b;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n,r=0,x;
cin>>n;
fflush(stdin);
  vector<int>*v=new vector<int>();
  for(int i=0;i<n;i++)
  {cin>>x;
  v->push_back(x);

  }
  for(int i=0;i<n-1;i++)
  {if(v->at(i)>v->at(i+1))
     {int t=v->at(i)-v->at(i+1);
         r=r+t;
     v->at(i+1)=v->at(i+1)+t;
     }
    else continue;}
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
const ll inf = 1LL<<60;
ll dp[1100][1<<12];
int main() { 
  int n,m;
  cin >> n >> m;
  vl a(m),b(m),key(m,0);
  rep(i,m){
    cin >> a[i] >> b[i];
    rep(j,b[i]){
      int c;
      cin >> c;
      c--;
      key[i]+= (1<<c);
    }
  }
  rep(i,1100){
    rep(j,1<<12)dp[i][j] = inf;
  }
  dp[0][0] = 0;
  rep(i,m){
    rep(j,(1<<n)){
      mins(dp[i+1][j],dp[i][j]);

      int nj = j|key[i];
      mins(dp[i+1][nj],dp[i][j]+a[i]);
    }
  }
  cout<< (dp[m][(1<<n)-1]<inf ? dp[m][(1<<n)-1]:-1)<<endl;
  return 0;
}

Measured memory_bytes: 35456
n,m = map(int,input().split())
mod = 10**9 + 7

## nCkのmodを求める関数
# テーブルを作る(前処理)
max = 5 * 10**5 + 100
fac, finv, inv = [0]*max, [0]*max, [0]*max

def comInit(max):
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,max):
      fac[i] = fac[i-1]* i% mod
      inv[i] = mod - inv[mod%i] * (mod // i) % mod
      finv[i] = finv[i-1] * inv[i] % mod

comInit(max)

# 二項係数の計算
def com(n,k):
    if(n < k):
        return 0
    if( (n<0) | (k < 0)):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

cnt = [0] * (n+1)
tot = 0
for i in range(n,-1,-1):
    cnt[i] = com(n,i)*(fac[n-i])*com(m-i ,n-i)
    cnt[i] %= mod
    tot = cnt[i] - tot
    tot %= mod

ans = tot * fac[m] * finv[m-n]
ans %= mod
print(ans)

Measured memory_bytes: 123856
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

long long a[100005];

int main(void){
    int n;
    long long G;
    long long k;
    long long max = 0;
    scanf("%d %lld", &n, &k);
    for (int i = 0; i < n; i++){
        scanf("%lld", &a[i]);
        if (max < a[i]){
            max = a[i];
        }
        if (i == 0){
            G = a[i];
        }else{
            G = gcd(a[i], G);
        }
    }

    if (k <= max && k%G == 0){
        printf("POSSIBLE\n");
    }else{
        printf("IMPOSSIBLE\n");
    }
    return 0;
}


Measured memory_bytes: 896
#ifndef Local
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef long long Long;

// gp_hash_table<int, int> table;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, k;

vector<int> buildFirstLess(const vector<int>& perm) {
  vector<int> first_less(n);
  first_less.back() = n;
  for (int i = n - 2; i >= 0; --i) {
    int& curr = first_less[i];
    curr = i + 1;
    while (curr != n && perm[i] < perm[curr]) {
      curr = first_less[curr];
    }
  }
  return first_less;
}

vector<int> buildFirstToChange(const vector<int>& first_less) {
  vector<int> first_to_change(n, -1);
  set<pair<int, int>> changes;
  for (int i = n - 1; i >= 0; --i) {
    if (first_less[i] != n) {
      changes.emplace(i, first_less[i]);
    }
    while (!changes.empty() && changes.begin()->second - i + 1 > k) {
      changes.erase(changes.begin());
    }
    if (!changes.empty()) {
      first_to_change[i] = changes.begin()->first;
    }
  }
  return first_to_change;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  cin >> n >> k;

  vector<int> perm_forward(n);

  for (int& x : perm_forward) {
    cin >> x;
  }

  auto first_less_forward = buildFirstLess(perm_forward);
  auto first_to_change_forward = buildFirstToChange(first_less_forward);

  auto perm_backward = perm_forward;
  reverse(perm_backward.begin(), perm_backward.end());
  for (int& x : perm_backward) {
    x *= -1;
  }
  auto first_less_backward = buildFirstLess(perm_backward);
  auto first_to_change_backward = buildFirstToChange(first_less_backward);

  reverse(first_to_change_backward.begin(), first_to_change_backward.end());

  for (int& x : first_to_change_backward) {
    if (x != -1) {
      x = n - 1 - x;
    }
  }


  set<pair<int, int>> changes;
  for (int i = 0; i + k - 1 < n; ++i) {
    changes.emplace(first_to_change_forward[i],
      first_to_change_backward[i + k - 1]);
  }

  cout << changes.size() << endl;
}


Measured memory_bytes: 14336
// AtCoder Beginner Contest 173
// B - Judge Status Summary

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <random>
#include <vector>
#include <chrono>

using namespace std;
//using namespace std::chrono;


int main()
{
	//steady_clock::time_point start = steady_clock::now();
	int N;
	cin >> N;
	int ac, wa, tle, re;
	ac = wa = tle = re = 0;
	string S[N];
	for (int i=0; i<N; i++) {
		cin >> S[i];
	}

	for (int i=0; i<N; i++) {
		if (S[i] == "AC") {
			ac++;
		} else if (S[i] == "WA") {
			wa++;
		} else if (S[i] == "TLE") {
			tle++;
		} else if (S[i] == "RE") {
			re++;
		}
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
	//計算時間集計
	/*
	steady_clock::time_point end = steady_clock::now();
    steady_clock::duration d = end - start;
	cout << "計算時間は" << duration_cast<milliseconds>(d).count() << "ミリ秒です。\n";
	*/
}





Measured memory_bytes: 6752
#include <cassert>
#include <cstdint>
#include <utility>
#include <vector>

class UnionFind {

public:
	using size_type = std::uint_fast32_t;

private:
	std::vector<std::pair<bool, size_type>> tree;

public:
	UnionFind(const size_type size) : tree(size, std::make_pair(1, 1)) {}
	size_type find(const size_type x) {
		assert(x < size());
		if (tree[x].first)
			return x;
		return tree[x].second = find(tree[x].second);
	}
	bool unite(size_type x, size_type y) {
		assert(x < size());
		assert(y < size());
		x = find(x);
		y = find(y);
		if (x == y)
			return false;
		if (tree[x].second < tree[y].second)
			std::swap(x, y);
		tree[x].second += tree[y].second;
		tree[y] = std::make_pair(0, x);
		return true;
	}
	bool same(const size_type x, const size_type y) {
		assert(x < size());
		assert(y < size());
		return find(x) == find(y);
	}
	size_type size(const size_type x) {
		assert(x < size());
		return tree[find(x)].second;
	}
	size_type size() const noexcept { return tree.size(); }
	bool empty() const noexcept { return tree.empty(); }
};


#include<iostream>
#include<cstdint>

int main() {
	using uint32 = std::uint_fast32_t;
	using uint64 = std::uint_fast64_t;
	uint64 n, m;
	std::cin >> n >> m;
	UnionFind T(n * 2);

	for (uint32 i = 0;i < m;++i) {
		uint32 a, b;
		std::cin >> a >> b;
		--a;--b;
		T.unite(a, b + n);
		T.unite(a + n, b);
	}

	for (uint32 i = 0;i < n;++i)
		if (T.same(i, i + n)) {
			std::cout << n*(n - 1) / 2 - m << std::endl;
			return 0;
		}

	uint64 cnt = 0;
	for (uint32 i = 0;i < n;++i)
		if (T.same(0, i))
			++cnt;

	std::cout << (n - cnt) * cnt - m << std::endl;

	return 0;
}

Measured memory_bytes: 3456
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

struct node{
	int num;
	node *parent,*left,*right;
};
node *root,*NIL;

void print_inorder(node *x){
	if(x==NIL) return ;
	print_inorder(x->left);
	printf(" %d",x->num);
	print_inorder(x->right);
	return ;
}

void print_preorder(node *x){
	if(x==NIL) return ;
	printf(" %d",x->num);
	print_preorder(x->left);
	print_preorder(x->right);
	return ;
}

void insert(int a){
	node *x=root,*y=NIL;
	node *z=new node();
	z->num=a;z->left=NIL;z->right=NIL;
	while(x!=NIL){
		y=x;
		if(z->num < x->num) x=x->left;
		else x=x->right;
	}
	z->parent=y;
	if(y==NIL) root=z;
	else {
		if(z->num < y->num) y->left=z;
		else y->right=z;
	}
	return ;
}

int main(){
	int n;
	cin>>n;
	string s;
	int a;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s[0]=='i') cin>>a,insert(a);
		else{
			print_inorder(root);
			printf("\n");
			print_preorder(root);
			printf("\n");
		}
	}
	return 0;
}


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

vector<pair<int,int>> g[100002];
int ans[100002];

void dfs(int x,int p,int w){
	ans[x] = w;
	//cout<<"dfdf";
	for(auto a: g[x]){
		if(a.first!=p){
			dfs(a.first,x,w^a.second);
		}
	}
}

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

	for(int i = 0; i < n-1; i++){
		int x,y,w;
		cin>>x>>y>>w;
		g[x].push_back({y,w%2});
		g[y].push_back({x,w%2});
	}

	dfs(1,0,0);
	for(int i = 1; i<=n; i++){
		cout<<ans[i]<<"\n";
	}

}

Measured memory_bytes: 8320
//int64_t a;
//10のi乗pow(10, i);
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  int a = n/1000;
  n = n%1000;
  int b = n/100;
  n = n%100;
  int c = n/10;
  n = n%10;
  int d = n/1;
  int num1 = a*10+b;
  int num2 = c*10+d;
  
  int Aflag=0,Bflag=0;
  if(1<=num1 && num1<=12)Aflag=1;
  if(1<=num2 && num2<=12)Bflag=1;

  if(Aflag==1 && Bflag==1)cout<<"AMBIGUOUS"<<endl;
  else if(Aflag==1 && Bflag==0)cout<<"MMYY"<<endl;
  else if(Aflag==0 && Bflag==1)cout<<"YYMM"<<endl;
  else if(Aflag==0 && Bflag==0)cout<<"NA"<<endl;
}

/*  string s;
  cin >> s;
  int a= s.at(0)*10 +s.at(1);
  int b= s.at(2)*10 +s.at(3);
*/



Measured memory_bytes: 256
#include<stdio.h>

#define N 2000

int A[N];

int solve(int i,int m,int n){
  int res;
  if(m==0){
    return 1;
  }
  if(i>=n){
    return 0;
  }
  res = solve(i + 1,m,n) || solve(i+1,m-A[i],n);
  return res;
}

int main(){
  int i,n,q,m,S[N];

  scanf("%d",&n);

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

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m,n)){
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }

  return 0;
}



Measured memory_bytes: 2100
# coding: utf-8
# Your code here!
import numpy as np
import scipy.misc as sc
def getNearestValue(listA, num):
    idx = np.abs(np.asarray(listA) - num).argmin()
    return listA[idx]
    
lenlist=input()
List=list(map(int,input().split()))
if lenlist=="2":
    List.sort()
    n=List[1]
    r=List[0]
    print(n,r)
    quit()
n=max(List)
r=getNearestValue(List,n/2)
print(n,r)

Measured memory_bytes: 25632
#include <iostream>
#include <vector>

int main() {
  int height, width;
  std::cin >> height >> width;

  std::vector<std::string> grid(height);
  std::vector<std::vector<int>> count(height, std::vector<int>(width, 0));

  for (int r = 0; r < height; r++) {
    std::cin >> grid[r];

    // 左を何マス照らせるか
    {
      int cnt = 0;
      for (int c = 0; c < width; c++) {
        if (grid[r][c] == '.') {
          count[r][c] += cnt;
          cnt++;
        } else {
          cnt = 0;
        }
      }
    }

    // 右を何マス照らせるか
    {
      int cnt = 0;
      for (int c = width - 1; c >= 0; c--) {
        if (grid[r][c] == '.') {
          count[r][c] += cnt;
          cnt++;
        } else {
          cnt = 0;
        }
      }
    }
  }

  for (int c = 0; c < width; c++) {
    // 上を何マス照らせるか
    {
      int cnt = 0;
      for (int r = 0; r < height; r++) {
        if (grid[r][c] == '.') {
          count[r][c] += cnt;
          cnt++;
        } else {
          cnt = 0;
        }
      }
    }

    // 下を何マス照らせるか
    {
      int cnt = 0;
      for (int r = height - 1; r >= 0; r--) {
        if (grid[r][c] == '.') {
          count[r][c] += cnt;
          cnt++;
        } else {
          cnt = 0;
        }
      }
    }
  }

  int answer = 0;
  for (int r = 0; r < height; r++) {
    for (int c = 0; c < width; c++) {
      if (grid[r][c] == '.') {
        answer = std::max(answer, count[r][c] + 1);
      }
    }
  }

  std::cout << answer << std::endl;

  return 0;
}

Measured memory_bytes: 20096
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

X, Y = MII_split()

ans = 'No'
for turu in range(X + 1):
    if turu * 2 + (X - turu) * 4 == Y:
        ans = 'Yes'
        break
print(ans)

Measured memory_bytes: 9136
ans=[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]
k=int(input())

print(ans[k-1])


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int popcount(long long n) { int cnt = 0; for ( ; n; n &= n - 1) cnt++; return cnt; }
int MSB1(long long x) { int d = 0; while ((1LL << d) <= x) d++; return d; }

int main() {
    int L; cin >> L;
    int n = MSB1(L);
    int m = (n - 1) * 2 + popcount(L) - 1;
    cout << n << " " << m << endl;
    for (int i = 0; i + 1 < n; i++) {
        cout << i + 1 << " " << i + 2 << " " << 0 << endl;
        cout << i + 1 << " " << i + 2 << " " << (1 << i) << endl;
    }
    int cur = 1 << (n - 1);
    for (int i = n - 2; i >= 0; i--) if (L & (1 << i)) {
        cout << i + 1 << " " << n << " " << cur << endl;
        cur += 1 << i;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    int D;
    cin >> D;
    vector<int> c(26), lastc(26);

    for (int i = 0; i < 26; i++){
        cin >> c.at(i);
    }
    vector<vector<int>> score(365, vector<int>(26));
    for (int i = 0; i < 365; i++){
        for (int j = 0; j < 26; j++){
            cin >> score.at(i).at(j);
        }
    }
    for (int i = 0; i < D; i++){
        int M = -1000000007, t= 0;
        for (int j = 0; j < 26; j++){
            M = max(M, score.at(i).at(j));
            if (score.at(i).at(j) == M){
                t = j + 1;
            }
        }
        if (i % 100 >= 74){
            cout << i % 26 + 1 << endl;
        }
        else {
            cout << t << endl;
        }
    }

}

Measured memory_bytes: 3684
# Next Mayor

ans = []

while True:
    n, p = map(int, input().split())
    if n == 0 and p == 0:
        break

    stone = p
    person = [0] * n
    i = 0
    while True:
        i = i % n
        if stone > 1:
            person[i] += 1
            stone -= 1
            i += 1

        elif stone == 1:
            stone -= 1
            person[i] += 1
            if person[i] == p:
                ans.append(i)
                break
            else:
                i += 1

        else:
            stone += person[i]
            person[i] = 0
            i += 1

for i in ans:
    print(i)



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
    int n;cin>>n;
    int l[n],r[n],count=0;
    rep(i,n)cin >> l[i] >> r[i];
    rep(i,n)count +=r[i]-l[i]+1;
    cout << count << endl;
    return 0;
}





Measured memory_bytes: 384
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int
main()
{
  int N;
  cin >> N;
  int count = 0;
  int min_value = N + 1;
  for (int n = 0; n < N; n++)
  {
    int P;
    cin >> P;
    if (P < min_value) {
      count++;
      min_value = P;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())

h_list = []
for _ in range(n):
    h = int(input())
    h_list.append(h)

h_list.sort()

ans = 10000000000
for i in range(n-k+1):
    tmp = abs(h_list[i]-h_list[i+k-1])
    if ans > tmp:
        ans = tmp

print(ans)


Measured memory_bytes: 7444
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int n;
		int[][][] room =new int[4][3][10];
		for(int i=0;i<4;i++) {
			for(int j=0;j<3;j++){
				for(int k=0;k<10;k++){
					room[i][j][k]=0;
				}
			}
		}
		Scanner scan = new Scanner(System.in);
		n=scan.nextInt();
		
		for(int i=0;i<n;i++)
		{
			int b, f, r, v;
			
			b=scan.nextInt();
			f=scan.nextInt();
			r=scan.nextInt();
			v=scan.nextInt();
			
			room[b-1][f-1][r-1]=room[b-1][f-1][r-1]+v;
		}
		for(int i=0;i<4;i++) {
			for(int j=0;j<3;j++){
				for(int k=0;k<10;k++){
					System.out.print(" "+room[i][j][k]);
				}
				System.out.println();

			}
			if(i!=3)
				System.out.println("####################");
		}
	}
}

Measured memory_bytes: 29480
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000
//bool cmp(P a,P b){ return a.second < b.second;}


	ll N,M,K,ans=0;
	ll A[200010];
	ll B[200010];
    string S;



int main(){
	std::ios_base::sync_with_stdio(false);
    cin>>N;
	REP(i,N){
		cin>>A[i];
		B[A[i]-1]++;
	}
	REP(i,N){
		ans+=B[i]*(B[i]-1)/2;
	}
	DEB(ans)END
	REP(i,N){
		ll temp=ans;
		DEB(B[A[i]-1]*(B[A[i]-1]-1)/2)END
		DEB((B[A[i]-1]-1)*(B[A[i]-1]-2)/2)END
		std::cout << temp-(B[A[i]-1]*(B[A[i]-1]-1)/2)+((B[A[i]-1]-1)*(B[A[i]-1]-2)/2) << '\n';
	}
	return 0;
}
//ABC 121 D - XOR World


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    ll a; cin >> a;
    string s;
    cin >> s;
    ll len=s.size();
    rep(i,len){
    int x=s[i]-'A';
    x=(x+a)%26;
    s[i]='A'+x;
    cout << s[i] ;
    }
    cout << endl;

  }


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for A - White Cells
	var h, w int
	var a, b int

	fmt.Scanf("%d %d", &h, &w)
	fmt.Scanf("%d %d", &a, &b)
	fmt.Printf("%d", h*w-(a*w+b*h-a*b))
}


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

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;

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

    int total=0;
    for(int i=0; i<k; i++){
        total += p[i];
    }
    cout << total << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
ll n;
  ci(n);
  vll A(n);
  FOR(i,0,n){
    ci(A[i]);
    A[i]-=i+1;
  }
  SORT(A);
  ll ans=0;
  FOR(i,0,n){
    ans+=abs(A[i]-A[n/2]);
  }
  co(ans)
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
	int n, a = 0, b = 0, c = 0;
    scanf("%d", &n);
    for(int i = 1, x; i <= n; i ++) {
        scanf("%d", &x);
        if(x % 4 == 0) b ++;
        else if(x % 2 == 0) a ++;
        else c ++;
    }
    b -= c;
    if(b >= 0 ||(b == -1 && a == 0)) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256