akhauriyash/Code-Regression huggingface dataset:
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int n,a[100010],cnt;
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1,cmp);
	int k=1;
	while (k<=n && k<=a[k])
	{
		k++;
	}
	k--;
	int p;
	if ((a[k]-k)&1)
	{
		p=1;
	}
	else
	{
		p=0;
		int j=k+1;
		while (j<=n && a[j]==k)
		{
			j++;
			p^=1;
		}
	}
	if (p)
	{
		puts("First");
	}
	else
	{
		puts("Second");
	}
    return 0;
}
//因为有了因为，所以有了所以。既然已成既然，何必再说何必。

Measured memory_bytes: 640
<?php
fscanf(STDIN, "%d %d %d", $bottle, $bottle_in, $kakeru);

$hairu_ryou = $bottle - $bottle_in;
if ($hairu_ryou >= $kakeru) {
	echo "0\n";

} else {
    echo ($kakeru - $hairu_ryou) ."\n";
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;
#define MOD 1000000007
using namespace std;

pii sec(vi & v){
	vi used(sz(v) + 1 , 0);
	rep(i , sz(v)){
		int e = v[i];
		if(used[e])
			return {used[e] - 1 , i};
		used[e] = i + 1;
	}
}

int fac[100102], ifac[100102];

inline int fpow(int a, int st) {
	int ans = 1;
	while (st) {
		if (st % 2) ans = (ll)ans * a % MOD;
		a = (ll)a * a % MOD;
		st /= 2;
	}
	return ans;
}

inline int cnk(int n, int k) {
	if (n < 0 || k < 0 || k > n) return 0;
	return (ll)fac[n] * ifac[n - k] % MOD * ifac[k] % MOD;
}

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

	fac[0] = ifac[0] = 1;
	repi(i, 100001) {
		fac[i] = (ll)fac[i - 1] * i % MOD;
		ifac[i] = fpow(fac[i], MOD - 2);
	}
	

	int n;
	cin >> n;
	
	vi v(n + 1);
	rep(i , n + 1){
		cin >> v[i];
	}
	
	auto m = sec(v);
	
	ll ans = 0;
	
	vector<vector<ll>> dp(n + 1 , vector<ll>(3));
	int k = 0;
	repi(i , n + 1){
		ans = 0;
		if(i == 1){
			ans = n;
		}else if(i == n + 1){
			ans = 1;
		}else{
			ans = cnk(n + 1 , i) % MOD;

			ans -= cnk(n - m.se + m.fi , i - 1);

			ans %= MOD;
			while(ans < 0)ans += MOD;
		}
		cout << ans << nl;
	}

	return 0;
}

Measured memory_bytes: 7928
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
#define BIG 2000000007
 
#define MOD 1000000007
typedef unsigned long long ull;
typedef   signed long long sll;
 
typedef struct {
	ull above;
	ull below;
	int index;
} hw;
 
#define N_MAX 100000
#define M_MAX 100000
 
ull n, m, k;
ull h, w;
// ull a[N_MAX];
// ull b[N_MAX];
// ull dp[N_MAX][M_MAX + 1];
char s[N_MAX + 1];
char t[N_MAX + 1];
 
void swap_adj(ull *a, ull *b){
	ull tmp = *b;
	*b = *a;
	*a = tmp;
	return;
}
 
int comp(const void *a, const void *b){
	if (*(ull*)a > *(ull*)b) {
		return -1;
	} else if (*(ull*)a < *(ull*)b) {
		return +1;
	} else {
		return 0;
	}
}
 
ull divide(ull a, ull b){
	ull x = MOD - 2;
	ull ans = 1;
	while (x) {
		if (x & 1) ans = (ans * b) % MOD;
		b = (b * b) % MOD;
		x /= 2;
	}
	return (a * ans) % MOD;
}
 
int digits(ull x){
	int i = 1;
	while (x >= 10) {
		x /= 10;
		i++;
	}
	return i;
}
 
int min(ull x, ull y){
	return (x < y) ? x : y;
}
 
ull gcd(ull x, ull y){
	if (x < y) {
		return gcd(y, x);
	} else if (y == 0) {
		return x;
	} else {
		return gcd(y, x % y);
	}
}
 
ull bitpow(ull a, ull x){
	ull result = 1;
	while (x) {
		if (x & 1) {
			result *= a;
			result %= MOD;
		}
		x /= 2;
		a = (a * a) % MOD;
	}
	return result;
}
 
ull solve(){
	int i, j;
	const size_t len = strlen(t);
 
	for (i = 0; i < len; i++) {
		if (t[i] != s[0]) continue;
		for (j = 1; i + (k - 1) * j <= len - 1; j++) {
			int seeki;
			for (seeki = 1; seeki < k; seeki++) {
				if (t[i + seeki * j] != s[seeki]) break;
			}
			if (seeki == k) return 1;
		}
	}
 
	return 0;
}
 
int main(void){
	int i, j, k;
	int a[3];
	int x = 0;
 
	scanf("%d%d%d", &i, &j, &k);

	if (i + j == k || j + k == i || k + i == j) {
		puts("Yes");
	} else {
		puts("No");
	}

	// solve();
 
	return 0;
}


Measured memory_bytes: 128
// Problem : E - Crested Ibis vs Monster
// Contest : AtCoder Beginner Contest 153
// URL : https://atcoder.jp/contests/abc153/tasks/abc153_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)
#define arr v
#include<bits/stdc++.h>
using namespace std;
int main()
{
        int h,n;
        cin >> h >> n;
        vector<int> v(h+1,1e9+5);
        v[0]=0;
        for(int i=0;i<n;i++)
        {
                int de,cos;
                cin >> de >> cos;
                for(int j=0;j<=h;j++)
                {
                        if(j<=de)
                        v[j]=min(v[j],cos);
                        else
                        v[j]=min(v[j],v[j-de]+cos);
                        //cout << v[j+de] <<" ";
                }
                /*for(int j=h-1;j>=0;--j)
                {
                        arr[j]=min(arr[j],arr[j+1]);
                }*/
        }      
        cout << v[h] << endl;  
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		while(true){
			int a=scan.nextInt();
			String op=scan.next();
			int b=scan.nextInt();
			
			if(op.equals("?"))break;
			
			if(op.equals("+"))System.out.println(a+b);
			if(op.equals("-"))System.out.println(a-b);
			if(op.equals("*"))System.out.println(a*b);
			if(op.equals("/"))System.out.println(a/b);
		}
	}
}


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

struct Card
{
  char suit, value;
};

void bubble(struct Card A[], int N) {
  for(int i = 0; i < N; i++) {
    for(int j = N - 1; j >= i + 1; j--) {
      if (A[j].value < A[j-1].value) {
        Card t = A[j];
        A[j] = A[j-1];
        A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[], int N)
{
  int minj;
  for(int i = 0; i < N - 1; i++) {
    minj = i;
    for(int j = i; j < N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    Card t = A[i];
    A[i] = A[minj];
    A[minj] = t;
  }
}

void print(struct Card A[], int N) {
  for (int i = 0; i < N; i++)
  {
    if (i)
      cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
  for (int i = 0; i < N; i++)
  {
    if (C1[i].suit != C2[i].suit) return false;
  }
  return true;
}

int main()
{
  Card C1[100], C2[100];
  int N;
  cin >> N;
  char ch;
  for (int i = 0; i < N; i++)
    cin >> C1[i].suit >> C1[i].value;
  
  for (int i = 0; i < N; i++) C2[i] = C1[i];

  bubble(C1, N);
  selection(C2, N);

  print(C1, N);
  cout << "Stable" << endl;
  print(C2, N);
  if (isStable(C1, C2, N)) 
  {
    cout << "Stable" << endl;
  }
  else
  {
    cout << "Not stable" << endl;
  }
  return 0;
}


Measured memory_bytes: 3108
// A : minimum spanning tree
#include <stdio.h>
#include <stdlib.h>
#define N 10000
#define I 1000000
#define W 0
#define B 1

int n;  // the number of vertices in G
int m[N][N] = {0};
int set[N];
int col[N];

int genericMST();

int main() {
  int i, j, k = 1, l, u;
  int min, sum = 0, cnt = 1;

  // input
  scanf("%d", &n);  // the number of vertices in G
  for(i = 0; i < n; i++) {
    for(j = 0; j < n; j++) {
      scanf("%d", &m[i][j]); // adjacency matrix M
    }
  }
  // initialization
  for(i = 0; i < n; i++) {
    set[i] = 0;
    col[i] = W;
  }
  // MST
  col[0] = B;
  while(cnt != n) {
    min = I;
    for(i = 0; i < k; i++) {
      for(j = 0; j < n; j++) {
        if((m[set[i]][j] < min) && (m[set[i]][j] != -1) && (col[j] != B)){
          min = m[set[i]][j];
          u = j;
        }
      }
    }
    col[u] = B;
    set[k] = u;
    k++;
    if(min != I) sum += min;
    cnt++;
  }

  printf("%d\n", sum);

  return 0;
}



Measured memory_bytes: 2252
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, long long K, long long S){
    ll T;
    if(S == 1000000000){
        T = S-1;
    }
    else {
        T = S+1;
    }

    if(K > 0){
        if(N == 1){
            cout << S << endl; return;
        } else {
            REP(i, K){
                if(i == N)
                    cout<< S;
                else
                    cout<< S <<" ";
            }
            for(ll i=K; i< N; i++){
                if(i == N)
                    cout << T;
                else
                    cout << T << " ";
            }
            cout<<endl;
        }
    }
    else{//* K == 0
        REP(i, N){
            if(i == N)
                cout << T ;
            else 
                cout << T << " ";
        }
        cout<< endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long S;
    scanf("%lld",&S);
    solve(N, K, S);
    return 0;
}


Measured memory_bytes: 1280
from sys import stdin

N = int(stdin.readline().rstrip())
S = stdin.readline().rstrip()
ans = ''

alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

for i in range(len(S)):
    j = 0
    while alphabet[j] != S[i]:
        j += 1
    ans += alphabet[(j + N) % 26]

print(ans)


Measured memory_bytes: 41452
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
const int MOD = 1000000007;

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

    if (n % 2 == 0)
    {
        cout << (n / 2) << endl;
    }
    else if (n % 2 == 1)
    {
        cout << (n / 2) + 1 << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
xs = [0] * n
for i in range(n):
    s, p = input().split()
    xs[i] = [s, int(p), i + 1]
xs.sort(key=lambda v: (v[0], 100 - v[1]))
print(*map(lambda v: v[2], xs), sep="\n")


Measured memory_bytes: 62548
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(void)
{
	int N;

	std::cin >> N;
	bool flag = false;
	string str = std::to_string(N);
	for (int i = 0; i < 2; i++)
	{
		if (str[i] == '9')
		{
			cout << "Yes";
			flag = true;
			break;
		}

	}
	if (!flag)
		cout << "No";



}

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

using namespace std;

char stage[2][5000][5];

int main()
{
    int n;
    
    while (scanf("%d", &n) && n){
        int height[5] = {0};
        int turn = 0;
        int ct = 0;
        memset(stage, 0, sizeof(stage));
        for (int rep = 0; rep < n; rep++){
            int d, p, q;
            scanf("%d %d %d", &d, &p, &q); --q;
            if (d == 1){
                int mh = *max_element(height + q, height + p + q);
                for (int j = q; j < p + q; j++){
                    stage[turn][mh][j] = 1;
                    height[j] = mh + 1;
                }
            }
            else {
                for (int j = 0; j < p; j++){
                    stage[turn][height[q]++][q] = 1;
                }
            }
            
            int look = *max_element(height, height + 5);
            memset(stage[1 - turn], 0, sizeof(stage[1 - turn]));
            memset(height, 0, sizeof(height));
            ct = 0;
            int nh = 0;
            for (int i = 0; i < look; i++){
                bool ok = true;
                for (int j = 0; j < 5; j++){
                    if (stage[turn][i][j] == 0) ok = false;
                }
                if (!ok){
                    for (int j = 0; j < 5; j++){
                        stage[1 - turn][nh][j] = stage[turn][i][j];
                        if (stage[1 - turn][nh][j]){
                            height[j] = nh + 1;
                            ct++;
                        }
                    }
                    nh++;
                }
            }
            turn = 1 - turn;
        }
        
        printf("%d\n", ct);
    }
    
    return (0);
}

Measured memory_bytes: 1244
import heapq

N, M = map(int,input().split())
A = list(map(lambda x: int(x) * (-1), input().split()))
heapq.heapify(A)

for _ in range(M):
  tmp_min = heapq.heappop(A)
  heapq.heappush(A, (-1) * (-tmp_min // 2))

print(-sum(A))

Measured memory_bytes: 20456
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

const int K = 1e9;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  map <pair <int, int>, int> cnt;
  for (int i = 0; i < n; ++i) {
    long double c;
    cin >> c;
    ll x = (ll)(c * K + 0.5);
    int c2 = 0, c5 = 0;
    while (x % 2 == 0) {
      ++c2;
      x /= 2;
    }
    while (x % 5 == 0) {
      ++c5;
      x /= 5;
    }
    ++cnt[{c2, c5}];
  }
  ll ans = 0;
  for (auto a : cnt) {
    for (auto b : cnt) {
      if (a.first.first + b.first.first >= 18 && a.first.second + b.first.second >= 18) {
        if (a != b) {
          ans += (ll)a.second * b.second;
        } else {
          ans += (ll)a.second * (a.second - 1);
        } 
      }
    }
  }
  ans /= 2;
  cout << ans << '\n';
}



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

int main() {
  string S;
  cin >> S;
  int a, b = 0;
  for(int i = 0; i < S.size(); i++) {
    if(i%2==0) {
      if(S.at(i) != '0') {
        a++;
      }
    }
    else if(i%2==1) {
      if(S.at(i) != '1') {  
        a++;
      }
    }
  }
  for(int i = 0; i < S.size(); i++) {
    if(i%2==0) {
      if(S.at(i) != '1') {
        b++;
      }
    }
    else if(i%2==1) {
      if(S.at(i) != '0') {  
        b++;
      }
    }
  }
  cout << min(a,b) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;

int main() {
  int w, h, x, y; cin >> w >> h >> x >> y;
  double ans = (double)w*h/2;
  int num = (w == 2*x && h == y*2) ? 1 : 0;
  printf("%.10lf %d\n", ans, num);

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node
{
	int key;
	Node *right, *left, *parent;		
};

Node *root, *NIL;

Node * treeMinimum(Node *x)
{
	while(x->left != NIL)
	{
		x=x->left;
	}
	return x;
}

Node * find(Node *u, int k)
{
	while(u != NIL && k != u->key)
	{
		if(k < u->key)
		{
			u = u->left;
		}
		else
		{
			u = u->right;
		}
	}

	 return u;
}

Node * treeSuccessor(Node *x)
{
	if(x->right != NIL)
	{
		return treeMinimum(x->right);
	}
	Node *y = x->parent;
	while(y != NIL && x == y->right)
	{
		x=y;
		y=y->parent;
	}
	return y;
}

void treeDelete(Node *z)
{
	Node *y;	//削除する対象
	Node *x;	//yの子

	//削除する節点を決める
	if(z->left == NIL || z->right == NIL)
	{
		y = z;
	}
	else
	{
		y = treeSuccessor(z);
	}

	//yの子xを決める
	if(y->left != NIL)
	{
		x = y->left;
	}
	else
	{
		x = y->right;
	}

	if(x != NIL)
	{
		x->parent = y->parent;
	}

	if(y->parent == NIL)
	{
		root = x;
	}
	else
	{
		if(y == y->parent->left)
		{
			y->parent->left = x;
		}
		else
		{
			y->parent->right = x;
		}
	}

	if(y != z)
	{
		z->key = y->key;
	}

	free(y);
}

void insert(int k)
{
	Node *y=NIL;
	Node *x=root;
	Node *z;

	z=(Node *)malloc(sizeof(Node));
	z->key=k;
	z->left=NIL;
	z->right=NIL;

	while(x !=  NIL)
	{
		y=x;
		if(z->key < x->key)
		{
			x= x->left;
		}
		else
		{
			x= x->right;
		}
	}

	z->parent=y;
	if(y==NIL)
	{
		root=z;
	}
	else
	{
		if(z->key < y->key)
		{
			y->left=z;
		}
		else
		{
			y->right=z;
		}
	}
}

void inorder(Node *u)
{
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

void preorder(Node *u)
{
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

int main()
{
	int n,i,x;
	string com;

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		cin >> com;
		if(com == "find")
		{
			scanf("%d",&x);
			Node *t = find(root ,x);
			if(t != NIL)
			{
				printf("yes\n");
			}
			else
			{
				printf("no\n");
			}
		}
		else if(com == "insert")
		{
			scanf("%d", &x);
			insert(x);
		}
		else if(com == "print")
		{
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if(com == "delete")
		{
			scanf("%d",&x);
			treeDelete(find(root,x));
		}
	}

	return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) (sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg)),arg)

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

using namespace std;
using R=long double;

int n,x[110],y[110];

using R=long double;
const R PI = acos(R(-1));
const R INF = 1e40;
using P=complex<R>;
using C=tuple<R,R,R>;
#define mod(x,y) fmod(fmod(x,y)+y,y)

inline C shadow(R theta){
	R a=0.0,b=0.0,c=2.0*n;

	using state=tuple<R,int>;
	vector<state> ary;

	rep(i,n) ary.push_back(make_tuple(1.0*x[i]*sin(theta)+1.0*y[i]*cos(theta),i));
	sort(_all(ary));
	
	rep(i,n-1){
		R cur,nxt; int idx,idx2;
		tie(cur,idx)=ary[i],tie(nxt,idx2)=ary[i+1];
		if(nxt-cur<2.0){
			c-=2.0;
			a+=(x[idx2]-x[idx]),b+=(y[idx2]-y[idx]);
		}
	}
	return make_tuple(a,b,c);
}

int main(void){
	while(cin >> n,n){		
		vector<R> candiate={0.0,PI/2.0,PI};
		rep(i,n) cin >> x[i] >> y[i];
		cout.precision(20);

		rep(j,n)rep(i,j){
			P a=P(x[i],y[i]),b=P(x[j],y[j]);
			R c=arg(b-a),e=asin(2.0/abs(b-a));
			candiate.push_back(mod(PI-c,PI));
			candiate.push_back(mod(PI-c+e,PI));
			candiate.push_back(mod(PI-c-e,PI));
		}

		uniq(candiate);
		candiate.push_back(candiate[0]+PI);	
		int m=int(candiate.size());

		rep(i,m-1){
			R cur=candiate[i],nxt=candiate[i+1],a,b,c;
			tie(a,b,c)=shadow((cur+nxt)/2.0);
			R theta=mod(atan(a/b),PI);
			if(cur < mod(theta,PI) && mod(theta,PI) < nxt) candiate.push_back(mod(theta,PI));
		}	

		R cmin=INF,theta1=-1.0;
		for(auto &theta:candiate){
			R a,b,c;
			tie(a,b,c)=shadow(theta);
			if(chmin(cmin,a*sin(theta)+b*cos(theta)+c)) theta1=theta;
		}
		cout << fixed << theta1 << endl;
		
		R cmax=0.0,theta2=-1.0;
		for(auto &theta:candiate){
			R a,b,c;
			tie(a,b,c)=shadow(theta);
			if(chmax(cmax,a*sin(theta)+b*cos(theta)+c)) theta2=theta;
		}
		cout << fixed << theta2 << endl;

	}
	return 0;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main(){
  COMinit();
  int N,K; cin>>N>>K;
  vi A(N);
  int ans=0;
  rep(i,0,N) cin>>A[i];
  sort(ALL(A));
  rep(i,K-1,N){
    ans+=COM(i,K-1)*A[i]%MOD;
    ans%=MOD;
  }
  REP(i,0,N-K){
    ans+=MOD;
    ans-=COM(N-i-1,K-1)*A[i]%MOD;
    ans%=MOD;
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 12928
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 100000;
const ll P = 1000000007;
int N;
int A[Nmax+1];
ll fact[3*Nmax];

ll ext_gcd(ll a, ll b, ll &x, ll &y){
	if(b == 0){
		x = 1;
		y = 0;
		return a;
	}
	ll nx, ny;
	ll g = ext_gcd(b, a%b, nx, ny);
	x = ny;
	y = nx - a/b *ny;
	return g;
}

ll inv_mod(ll x, ll p){
	ll y,z;
	ext_gcd(x, p, y, z);
	while(y < 0) y+=p;
	return y;
}

ll fact_mod(ll n, ll p, ll &e){
	// n! = a * p^e
	// return = a % p
	if(n == 0){
		e = 0;
		return 1;
	}

	ll na = fact_mod(n/p, p, e);

	e += n/p;
	ll a = na * fact[n%p] % p;

	if((n/p)%2) a = a * (p-1)%p;
	return a;
}

ll comb_mod(ll n, ll m, ll p){
	ll e1,e2,e3;
	ll a1 = fact_mod(n, p, e1);
	ll a2 = fact_mod(m, p, e2);
	ll a3 = fact_mod(n-m, p, e3);

	if(e1 > e2+e3) return 0;
	else return a1*inv_mod(a2*a3%p, p)%p;
}

int main(){
	cin >> N;
	for(int i=0; i<=N; i++){
		cin >> A[i];
		A[i]--;
	}

	fact[0] = fact[1] = 1;
	for(int i=2; i<3*Nmax; i++) fact[i] = fact[i-1]*i%P;

	vector<int> appear(N+1, -1);
	int dupi, dupj;
	for(int i=0; i<=N; i++){
		if(appear[A[i]] >= 0){
			dupi = appear[A[i]];
			dupj = i;
			break;
		}
		appear[A[i]] = i;
	}

	if(N==1){
		cout << 1 << endl;
		cout << 1 << endl;
		return 0;
	}

	for(int i=0; i<=N; i++){
		if(i > N+dupi-dupj){
			cout << comb_mod(N+1, i+1, P) << endl;
		}
		else{
			cout << (comb_mod(N+1, i+1, P)-comb_mod(N+dupi-dupj, i, P)+P)%P << endl;
		}
	}

	return 0;
}


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

int main(){
	int a, b, sum, cou;
	
	while(cin >>a >>b && a != EOF && b != EOF){
		sum = a + b;
		cou = 0;
		while(sum != 0){
			sum = sum / 10;
			cou++;
		}
		cout <<cou<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    int sum = 0,mini = INF;
    for(int i = 0;i < N;i++){
        int a;
        cin >> a;
        sum += a;
        if(a % 10)mini = min(mini, a);
    }
    if(sum % 10 == 0)sum -= mini;
    if(mini == INF)sum = 0;
    cout << sum << endl;
}

Measured memory_bytes: 256
s = str(input())
S = list(set(s))
d = {}
for v in S:
    x = s
    cnt = 0
    while x.count(v) < len(x):
        new_x = [0] * (len(x) - 1)
        for i in range(len(x) - 1):
            if x[i] == v or x[i + 1] == v:
                new_x[i] = v
        cnt += 1
        x = new_x
    d[v] = cnt
print(min(d.values()))


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int main(){
  ios_base::sync_with_stdio(false);

  int d, n;

  cin >> d >> n;

  if(n == 100){
    n += 1;  
  }
  
  for(int i=0;i<d;i++){
    n *= 100;
  }

  cout << n << endl;

  return 0;
}



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

int main() {
  int A[100][100], b[100], c[100];
  int n, m, a_ij, b_i;

  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a_ij;
      A[i][j] = a_ij;
    }
  }

  for (int i = 0; i < m; i++) {
    cin >> b_i;
    b[i] = b_i;
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c[i] += A[i][j] * b[j];
    }
  }

  for (int i = 0; i < n; i++) {
      cout << c[i] <<endl;
    }

  return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++) cin >> d[i];
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j) continue;
            ans += d[i] * d[j];
        }
    }
    cout << ans/2;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int N, D;
    cin >> N >> D;
    vector< vector<int> > X(N, vector<int>(D, 0));
    REP(i, N) {
        REP(j, D) {
            cin >> X[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i < N; ++i) {
        for(int j = i + 1; j < N; ++j) {
            int dist = 0;
            for(int k = 0; k < D; ++k) {
                dist += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            for(int k = 1; k < 1000; ++k) {
                if(k * k == dist) {
                    ans++;
                    break;
                }
            }
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1000011
#define MAX(x,y) (x>y?x:y)

using namespace std;

long long a[N],b[N],k,n,m,q,dap;

long long f1(long long x,long long y,long long sum){
    long long mid = (x+y)/2;
    if(x==y) return x;
    if(b[mid]+sum>k) return f1(x,mid,sum);
    else return f1(mid+1,y,sum);
}

int main()
{
    int i;
    
    scanf("%lld %lld %lld",&n,&m,&k);
    for(i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        a[i] += a[i-1];
    }
    for(i=1;i<=m;i++){
        scanf("%lld",&b[i]);
        b[i] += b[i-1];
    }

    dap = 0;
    for(i=0;i<=n;i++){
        if(a[i]>k) break;
        q = f1(1,m,a[i]);
        if(q<m) q++;
        while(q){
            if(b[q]+a[i]<=k) break;
            q--;
        }
        dap = MAX(dap,i+q);
    }

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


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

int main(){
	int shop[5];
	char ans;int answer;
	int s1,s2;
	
	while(cin>>s1>>s2){
	
		if(s1==0&&s2==0)break;
		shop[0]=s1+s2;
		
	for(int i=1;i<5;i++){
		cin>>s1>>s2;
		shop[i]=s1+s2;
	}
	answer=0;
	for(int i=0;i<5;i++){
	answer=max(shop[i],answer);
	}
	if(answer==shop[0])ans='A';
	if(answer==shop[1])ans='B';
	if(answer==shop[2])ans='C';
	if(answer==shop[3])ans='D';
	if(answer==shop[4])ans='E';
	
	cout<<ans<<" "<<answer<<endl;
}
	return 0;
	
}

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

int main () {
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    y[i] = x[i];
  }

  sort(y.begin(), y.end());
  int mi = y[0]; 
  int ma = y[n - 1]; 

  int ans = 1e6;
  for (int i = mi; i <= ma; i++) {
    int sum = 0;
    for (int j = 0; j < n; j++) {
      sum += pow(x[j] - i, 2);
    }
    ans = min(sum, ans);
  }

  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define MAX  1e18
#define ss 1e15
#define pb push_back

int main() {
    int n;
    cin>>n;
    int a[n+2],b[n+1];
    for(int i=1;i<=n+1;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    lli prev = 0;
    lli ans = 0;
    for(int i=1;i<=n;i++){
        if(a[i] >= (b[i] + prev)){
            ans += (b[i] + prev);
            prev = 0;
        }else{
            ans += a[i];
            if(prev >= a[i]){
                prev = b[i];
            }else{
                prev = b[i] + prev - a[i];
            }
        }
    }
    if(prev >= a[n+1]){
        ans += a[n+1];
    }else{
        ans += prev;
    }
    cout<<ans<<"\n";
    return 0;
}





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

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

	long long name_M = 0;
	long long name_A = 0;
	long long name_R = 0;
	long long name_C = 0;
	long long name_H = 0;
	string name;
	long long cnt = 0;

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

		if (name[0] == 'M') {
			name_M++;
		}
		else if (name[0] == 'A') {
			name_A++;
		}
		else if (name[0] == 'R') {
			name_R++;
		}
		else if (name[0] == 'C') {
			name_C++;
		}
		else if (name[0] == 'H') {
			name_H++;
		}
	}

	cnt = (name_M * name_A * name_R) + (name_M * name_A * name_C) + (name_M * name_A * name_H) +
		(name_M * name_R * name_C) + (name_M * name_R * name_H) +
		(name_M * name_C * name_H) +
		(name_A * name_R * name_C) + (name_A * name_R * name_H) +
		(name_A * name_C * name_H) +
		(name_R * name_C * name_H);

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(void) {
    io;
    int k, s;
    cin >> k >> s;
    int answer = 0;
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            int m = s - i - j;
            if (m>= 0  && m <=k && ((m+i+j) == s)) {
                answer++;
            }
        }
    }
    cout << answer << "\n";
    return 0;
}



Measured memory_bytes: 3560
PROGRAM piyo
      IMPLICIT NONE
      
      integer :: a,b,c
      logical flag1,flag2
      
      read*,a,b,c
      
      flag1 = a==b.and.b==c
      flag2 = a/=b.and.b/=c.and.a/=c
      
      if(flag1.or.flag2)then
        print*,'No'
      else
        print*,'Yes'
      end if
      
      
      
      
      END PROGRAM
      

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int N;	cin>>N;
	vector<pair<double,double>> a(N);
	rep(i,0,N){
		cin>>a[i].first;
		cin>>a[i].second;
	}
	double ans=0;
	int cnt=0;
	sort(all(a));
	do{
		double temp=0;
		rep(i,0,N-1){
			temp+=sqrt(		(a[i].first-a[i+1].first)*(a[i].first-a[i+1].first)
						+	(a[i].second-a[i+1].second)*(a[i].second-a[i+1].second)
					);
		}
		DBG(temp,"","","");
		DBG(a[0].first,a[1].first,a[2].first,"");
		DBG(a[0].second,a[1].second,a[2].second,"");
		ans+=temp;
		cnt++;
	}while(next_permutation(all(a)));
	
	DBG(ans,cnt,"","");
	ans/=cnt;
	cout << fixed << setprecision(9);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

template<class T,class F>
constexpr T bisection(T l,T r,F f,bool left=true,bool discrete=true){
  T eps=discrete?1:pow(10,-12);
  if((!left)^f(r)) return left?r:r+1;
  if(left^f(l)) return left?l-1:l;
  while(r-l>eps){
    T h=(l+r)/2;
    if((!left)^f(h)) l=h;
    else r=h;
  }
  return discrete?left?l:r:(l+r)/2;
}

void solve(){
  ll n,k; cin>>n>>k;
  vector<ll> A(n);
  rep(i,n) cin>>A[i];
  sort(A.begin(),A.end());

  auto check=[&](ll x){
    vector<ll> dp(k,0);
    dp[0]=1;
    rep(i,n){
      if(i==x) continue;
      vector<ll> newdp=dp;
      ll a=A[i];
      rep(j,k){
        if(j+a<k) newdp[j+a]=max(dp[j+a],dp[j]);
      }
      dp=newdp;
    }
    return *max_element(dp.begin()+max((ll)0,k-A[x]),dp.end());
  };
  cout<<bisection((ll)0,n-1,check,false)<<"\n";
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

int main() {
  unsigned long long large = 1000000007;
  unsigned long long N, K; cin >> N >> K;
  vector<unsigned long long> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  vector<pair<unsigned long long, unsigned long long>> vp(N);
  for(int i = 0; i < N; i++){
    vp[i].first = 0;
    vp[i].second = 0;
    for(int j = 0; j < N; j++){
      if(A[i] > A[j]){
        if(i < j) vp[i].second++;
        else vp[i].first++;
      }
      vp[i].first %= large;
      vp[i].second %= large;
    }
  }
  unsigned long long res = 0;
  for(int i = 0; i < N; i++){
    if(K%2==0){
      res += vp[i].first * ((K-1)%large * (K/2)%large)%large;
      res %= large;
      res += vp[i].second * ((K/2)%large * (K+1)%large)%large;
      res %= large;
    }else{
      res += vp[i].first * (((K-1)/2)%large * K%large)%large;
      res %= large;
      res += vp[i].second * (K%large * ((K+1)/2)%large)%large;
      res %= large;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int r;
    cin>>r;
    if (r<1200) cout<<"ABC\n";
    else if (r<2800) cout<<"ARC\n";
    else cout<<"AGC\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
 
vector<set<int>> mm;
vector<set<int>> km;
 
vector<bool> seen;
vector<int> group_memo;
vector<int> group_size;
int group_id = 0;
 
void rec(int person)
{
  seen[person] = true;
  group_memo[person] = group_id;
  group_size[group_id]++;
  for (auto next : mm[person])
  {
    if (seen[next] == false) rec(next);
  }
  return;
}
 
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n, m, k;
  cin >> n >> m >> k;
 
  mm.assign(n + 1, set<int>());
  for (int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;
    mm[a].insert(b);
    mm[b].insert(a);
  }
 
  km.assign(n + 1, set<int>());
  for (int i = 0; i < k; i++)
  {
    int c, d;
    cin >> c >> d;
    km[c].insert(d);
    km[d].insert(c);
  }
 
  seen.assign(n + 1, false);
  group_memo.assign(n + 1, -1);
  group_size.assign(n + 1, 0);
 
  for (int i = 1; i <= n; i++)
  {
    if (seen[i] == false)
    {
      rec(i);
    }
    group_id++;
  }
 
  for (int i = 1; i <= n; i++)
  {
    if (group_memo[i] == -1)
    {
      cout << 0 << endl;
      continue;
    }
 
    int ans = group_size[group_memo[i]] - 1;
    for (auto m : mm[i])
    {
      if (group_memo[m] == group_memo[i]) ans--;
    }
    for (auto k : km[i])
    {
      if (group_memo[k] == group_memo[i]) ans--;
    }
    cout << ans << endl;
  }
 
  return 0;
}

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

using namespace std;
using ll = long long;

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

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

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

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

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

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

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

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

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

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

bool isPrime(ll num) {
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    for (ll i = 3; i * i <= num; i += 2) {
        if (num % i == 0) { return false; }
    }

    return true;
};

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

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

template <class T>
bool is_integer(T x) {
    return std::floor(x) == x;
}

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

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

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

    int list[] = { 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 };
    int K; cin >> K;
    cout << list[K - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split(' ')))
h_or_l = [1 for _ in range(n)]

for i in range(n - 1):
    if h[i] >= h[i + 1]:
        h_or_l[i + 1] += h_or_l[i]

print(max(h_or_l) - 1)

Measured memory_bytes: 14224
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;


ll N,M;
vector<ll>V[100001];
vector<ll> d;
vector<ll> c;


int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N>>M;
	cout << "Yes" << endl;

	FOR(i, 0, M) {
		ll a, b;
		cin >> a >> b;
		V[a].emplace_back(b);
		V[b].emplace_back(a);
	}
	d.resize(N + 2,0);
	c.resize(N + 1);
	d[1] = 0;

	queue<ll> que;
	que.push(1);

	while (!que.empty()) {
		ll cur = que.front(); que.pop();

		FOR(i, 0, V[cur].size()) {
			ll now = V[cur][i];
			if (d[now] == 0 &&now!=1) {
				d[now] = d[cur] + 1;
				c[now] = cur;
				que.push(now);
			}
		}
	}

	FOR(i, 2, N + 1)cout << c[i] << endl;


	return 0;
}

Measured memory_bytes: 13780
#include <stdio.h>

int main () {

	int N;
	int a[101];
	int alice = 0, bob = 0;
	
    scanf("%d", &N);
  	
	for(int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}

	int flag = 0; // aliceの場合は、１たつ
    int tmp_a_i = 0;
	for(int i = 0; i < N; i++) {
		tmp_a_i = a[i];
		
		for(int j = i; j < N; j++) {
			int tmp_a_j;
			
			if(a[j] > tmp_a_i) {
				tmp_a_j = tmp_a_i;
				tmp_a_i = a[j];  // a[j] ないのより tmp が小さければ入れ替え
				a[j] = tmp_a_j;
			}
		
		}
		
		if(flag == 0) {
			alice += tmp_a_i;
			flag = 1;
		} else {
			bob += tmp_a_i;
			flag = 0;
		}
		
	}
	
	
	printf("%d\n", alice - bob);


}

Measured memory_bytes: 1724
/*
 * atcoder/abc135_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
#define MOD 1000000007

const ll K = 13;
const ll R = 5;
string S;
vector<ll> A;
ll N;
ll dp[100002][15];
ll rec(ll n = 0, ll rem = 0) {
  ll &cc = dp[n][rem];
  if (~cc) return cc;
  // cout << S[n] << " " << rem << endl;
  if (n == N) return cc = rem == R;
  if (S[n] != '?') {
    ll d = S[n] - '0';
    rem += (d * A[n]) % K;
    rem %= K;
    return cc = rec(n+1, rem % K);
  }

  ll ways = 0;
  for (ll d=0; d<10; d++) {
    ll r = (rem + (d * A[n]) % K) % K;
    ways += rec(n+1, r);
    ways %= MOD;
  }
  return cc = ways;
}
void solve() {
  cin >> S;
  N = S.size();
  A.resize(N);
  reverse(S.begin(), S.end());
  A[0] = 1;
  loop(n,1,N) A[n] = (A[n-1] * 10) % K;
  memset(dp, -1, sizeof(dp));

  cout << rec() << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#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)

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
//#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>

using namespace std;
using LLI = long long int;

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//int gcd(int x, int y) {
//	int tmp, r;
//	if (x < y) {
//		tmp = x;
//		x = y;
//		y = tmp;
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

int main(void) {
	int A,B,K,cnt = 0;
	cin >> A >> B >> K;
	int a = max(A, B);
	while (cnt < K) {
		if (A%a == 0 && B%a == 0) {
			cnt++;
		}
		a--;
	}
	cout << a+1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <vector>

using namespace std;

vector<int> v1, v2;
char s[8010];
int l, x, y;
bool d[2][18001];
int p=9000;

bool pos(vector<int>& v, int n) {
	if(v.empty()) return n==0;
	if(n+p<0 || n+p>18000) return false;
	memset(d,0,sizeof(d));
	d[1][p]=1;
	int from=1, to=0;
	for(int i=0;i<v.size();i++) {
		for(int j=-9000;j<=9000;j++) {
			d[to][j+p]=0;
			int tar=j-v[i]+p;
			if(tar>=0 && tar<=18000 && d[from][tar]) {
				d[to][j+p]=1;
			}
			tar=j+v[i]+p;
			if(tar>=0 && tar<=18000 && d[from][tar]) {
				d[to][j+p]=1;
			}
		}
		from^=1; to^=1;
	}
	return d[(v.size()-1)%2][n+p];
}

int main() {
	scanf("%s %d %d",s,&x,&y);
	l=strlen(s);
	int t=0, cur=0;
	bool fst=true;
	for(int i=0;i<=l;i++) {
		if(s[i]=='F') cur++;
		else {
			if(fst && cur>0) {
				x-=cur;
				cur=0;
				t^=1;
				fst=false;
				continue;
			}
			if(cur) {
				if(!t) v1.push_back(cur);
				else v2.push_back(cur);
			}
			cur=0; t^=1;
			fst=false;
		}
	}
	if(pos(v1,x) && pos(v2,y)) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256