akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#define MAX 20000  // スタックの最大値

typedef struct {
	int top;         // スタックポインタ(一番上の位置)
	int S[MAX];
} Stack;


// スタック st の初期化
void initialize(Stack *st)
{
	st->top = 0;
	st->S[st->top] = 0;
}

// スタック st が空かどうかを確認
int isEmpty(Stack *st)
{
	return st->top == 0;
}

// スタック st が一杯かどうかを確認
int isFull(Stack *st)
{
	return st->top >= MAX - 1;
}

// スタック st に要素 x をプッシュ(一番上に要素を追加)
void push(int x, Stack *st)
{
	if (isFull(st))
		exit(1);

	st->top++;
	st->S[st->top] = x;
}

// スタック st から要素をポップ(一番上の要素を取り出す)
int pop(Stack *st) {
	if (isEmpty(st))
		exit(1);

	st->top--;
	return st->S[st->top+1];
}


int main(void)
{
	Stack st1;     // '\' の開始位置を格納するスタック
	Stack st2_j;   // 各水たまりの最も左の'\' の位置を格納するスタック
	Stack st2_a;   // 各水たまりの水量を格納するスタック

	// スタック初期化
	initialize(&st1);
	initialize(&st2_j);
	initialize(&st2_a);

	char c;
	int sum = 0;  // 水たまりの総水量
	int j;

	// 地形を読み込み，各水たまりの水量を計算
	for (int i = 0; (c = getchar()) != EOF; i++) {
		if (c == '\\') {  // '\' か出た時の処理
			push(i,&st1);	// 位置 i を st1 にプッシュ(write your code)

		} 
		else if (!isEmpty(&st1) && c == '/') {          // '/' か出た時の処理
			j = pop(&st1);
			sum += i-j;
			// 水たまりの総水量 sum を更新(write your code)
			
			// st2_j と st2_a を用いて水たまりの水量を更新
			int a = i - j;   // 更新する水たまりの水量を a に格納していく
			while (!isEmpty(&st2_j) && st2_j.S[st2_j.top] > j) {  
				// 最も左の '\' の位置が j よりも大きい場合，以下を繰り返す
				pop(&st2_j);
				a += pop(&st2_a);
				// 水たまりの水量を求めていく (write your code)
			}
			push(j,&st2_j);
			push(a,&st2_a);// 更新した水たまりの「最も左の'_' の位置」および「水量」を更新 (write your code)
		}
	}

	printf("%d\n", sum);       // 水たまりの総水量を出力
	printf("%d", st2_a.top);   // 水たまりの個数を出力

	// 各水たまりの水量を断面図の左から出力(スタックの底から出力)
	for (int i = 1; i <= st2_a.top; i++){
		printf(" %d", st2_a.S[i]);
	}
	
	printf("\n");

	return 0;
	
}


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

using namespace std;
using ll = unsigned long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
int main(){
    int n ,m;
    cin>>n>>m;
    vector<int> lr(n+2);
    for(int i=0;i<m;++i){
        int l,r;
        cin>>l>>r;
        lr[l]++;
        lr[r+1]--;
    }
    for(int i=0;i<n+1;++i){
        lr[i+1] += lr[i];
    }
    int ret = 0;
    for(int i=0;i<=n;++i){
        if(lr[i] == m)ret++;
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    long long sum, num;
    int anum;
    sum = 1000;
    for(int i = 0; i < n-1; i++) {
        if(a.at(i) <= a.at(i+1) ){
            num += sum / a.at(i);
            sum %= a.at(i);
            anum = a.at(i);
        }
        if( a.at(i) >= a.at(i+1)){
            if( num > 0){
                sum += num*a.at(i);
                num = 0;
            }
        }
    }
    sum += a.at(n-1)*num;
    cout << sum << endl;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <bitset>
#include <string.h>
#include <stack>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <math.h>
#include <queue>
#include <complex>
#include <functional>
using namespace std ;
typedef long long ll ;
typedef long double ld ;
typedef unsigned long long ull ;
#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define pi (acos(-1.0))
#define fi first
#define se second
#define lson (o<<1),l,mid
#define rson (o<<1|1),mid+1,r
#define MP make_pair
#define sqr(x) ((x)*(x))
#define ALL(v) (v).begin(),(v).end()
#define showtime fprintf(stderr,"time = %.15f\n",clock() / (double)CLOCKS_PER_SEC)
const double eps = 1e-9 ;
const int inf = 0x3f3f3f3f ;
const ll INF = (ll)4e18 ;
const int MOD=(int)1e9+7,BAS=257,invBAS=70038911;
inline int sign(double x){return x<-eps?-1:x>eps;}
inline int clz(int x){return __builtin_clz(x);}
inline int clz(ll x){return __builtin_clzll(x);}
inline int lg2(int x){return !x ? -1 : 31-clz(x);}
inline int lg2(ll x){return !x ? -1 : 63-clz(x);}

char s[100000+10];
int main () {
	scanf ("%s", s+1);
	for (int i=1 ; s[i+1] ; i++)
		if (s[i]==s[i+1]||s[i]==s[i+2]||s[i+1]==s[i+2]) 
			printf("%d %d\n", i, !s[i+2]?i+1:i+2), exit(0);
	return puts ("-1 -1"), 0;
}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  b -= a;
  a = 0;
  b = abs(b);
  n--;

  rep(i, n) {
    ll cl = i;
    ll cr = n - i;

    ll l = -d * cl + c * cr;
    ll r = -c * cl + d * cr;

    if (l <= b && b <= r) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;

  return 0;
}


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

int main()
{
    int x, y;

    cin >> x>>y;
    while( (x != 0) || (y != 0)){
        if (x <= y){
            cout << x << " "<< y<<endl;
        }
        else if (x > y)
        {
            cout << y << " "<< x<< endl;
        }
        
        
        cin >> x >> y;
    };
    return 0;

}


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

int main() {
  int N;
  cin >> N;
  int a[N];
  int sum = 0;
  for (int i = 0 ; i < N ; i++) {
    cin >> a[i];
    sum += a[i];
  }
  int avg = sum / N;
  int res1 = 0, res2 = 0;
  for (int i = 0 ; i < N ; i++) {
    res1 += (a[i] - avg) * (a[i] - avg);
    res2 += (a[i] - avg - 1) * (a[i] - avg - 1);
  }
  cout << min(res1, res2) << endl;
}


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

using namespace std;
int main() {
	int h, w;
	char mp[105][105];
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> mp[i][j];
		}
	}
	for (int i = 0; i < w + 2; i++) {
		cout << '#';
	}
	cout << endl;
	for (int i = 0; i < h; i++) {
		cout << "#";
		for (int j = 0; j < w; j++) {
			cout << mp[i][j];
		}
		cout << "#" << endl;
	}
	for (int i = 0; i < w + 2; i++) {
		cout << '#';
	}
	cout << endl;

	system("pause");
	return 0;
}

Measured memory_bytes: 504
import java.util.Scanner;
public class Main {
	static int bord[][]=new int[10][10];
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int x,y,size,i,j,count=0,max=0;
		while(s.hasNext()){
			String[] str = s.next().split(",");
			x = Integer.parseInt(str[0]);
			y = Integer.parseInt(str[1]);
			size = Integer.parseInt(str[2]);
			if(size==1){
				small(x,y);
			}
			if(size==2){
				middle(x,y);
			}
			if(size==3){
				large(x,y);
			}
		}//while
		for(i=0;i<10;i++){
			for(j=0;j<10;j++){
				if(bord[i][j]==0)
					count++;
				if(bord[i][j]>max)
					max=bord[i][j];
			}
		}
		System.out.println(count);
		System.out.println(max);
	}//main
	public static void small(int x,int y){
		bord[x][y]++;
		if(x-1>-1)
			bord[x-1][y]++;
		if(x+1<10)
			bord[x+1][y]++;
		if(y-1>-1)
			bord[x][y-1]++;
		if(y+1<10)
			bord[x][y+1]++;
	}
	public static void middle(int x,int y){
		small(x,y);
		if(x-1>-1 && y-1>-1)
			bord[x-1][y-1]++;
		if(x+1<10 && y+1<10)
			bord[x+1][y+1]++;
		if(x+1<10 && y-1>-1)
			bord[x+1][y-1]++;
		if(x-1>-1 && y+1<10)
			bord[x-1][y+1]++;
	}
	public static void large(int x,int y){
		middle(x,y);
		if(x-2>-1)
			bord[x-2][y]++;
		if(x+2<10)
			bord[x+2][y]++;
		if(y-2>-1)
			bord[x][y-2]++;
		if(y+2<10)
			bord[x][y+2]++;
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
   // freopen("input.txt","r",stdin);
	//freopen("new.txt","w",stdout);

	int x;
	cin>>x;
	if(x>=30)
		cout<<"Yes";
	else
		cout<<"No";
    return 0;
}

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

// #define multitest 1
// #define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

bool isSquare(int n)
{
	return (int(sqrt(n)) * int(sqrt(n))) == n;
}

void solve()
{
	int n, d;
	cin >> n >> d;
	vector<vector<int>> Point(n, vector<int>(d));
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < d; ++j)
			cin >> Point[i][j];
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < i; ++j)
		{
			int diff = 0;
			for (int k = 0; k < d; ++k)
				diff += (Point[i][k] - Point[j][k]) * (Point[i][k] - Point[j][k]);
			if (isSquare(diff))
				ans++;
		}
	}
	cout << ans;
}

int main()
{
#ifndef Debug
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<cstring>
using namespace std;
int match[13];
bool used[13];
int seq[13]; 
int n,m;
string s[13];
void solve(int x)
{
	if(x>m)
	{
		map<string,int>mp;
		map<string,bool>ok;
		for(int i=1;i<=m;i++)used[i]=false;
		int k=1;
		for(int i=1;i<=m/2;i++)
		{
			while(k<=n && (used[k] || match[k]==k))k++;
		    used[k]=used[match[k]]=true;
		    seq[i]=k;
		    seq[m+1-i]=match[k];
		}
		for(int i=1;i<=n;i++)
		{
			string t="";
			for(int j=1;j<=m;j++)t+=s[i][seq[j]-1];
			mp[t]++;
		}
		int mark=0;
		for(int i=1;i<=n;i++)
		{
			string t1="",t2="";
			for(int j=1;j<=m;j++)t1+=s[i][seq[j]-1];
			for(int j=m;j>=1;j--)t2+=s[i][seq[j]-1];
			if(t1==t2)
			{
				if(ok[t1])continue;
				if(mp[t1]&1)
				{
					if(mark)return;
					mark=i;
				}
				ok[t1]=true;
				continue;
			}
			if(!mp[t2])
			{
				if(n&1)
				{
					if(mark)return;
					if(t1!=t2)return;
					mark=i;
				}
				else return;
			}
			else mp[t2]--;
		}
		printf("YES");
		exit(0);
	}
	if(match[x])
	{
		solve(x+1);
		return;
	}
	for(int i=x+1;i<=m;i++)
	{
		if(!match[i])
		{
			match[i]=x;
			match[x]=i;
			solve(x+1);
			match[i]=0;
			match[x]=0;
		}
	}
} 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>s[i];
	if(m&1)
	{
		for(int i=1;i<=m;i++)
		{
			seq[(m+1)/2]=i;
			match[i]=i;
			solve(1);
			match[i]=0;
		}
	}
	else
	{
		solve(1);
	}
	printf("NO");
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
import numpy as np
from heapq import heapify, heappop, heappush
import copy
from collections import deque
# queueとして使う場合 push, popleftを使う
from bisect import bisect_left, bisect_right
# bisect_left: 配列の順序関係が崩れない条件で挿入することができる一番左の点
# bisect_right: 配列の順序関係が崩れない条件で挿入することができる一番右の点
# A = [1, 1, 1, 2, 2, 2, 4]
# print(bisect_left(A, 2))  # 3
# print(bisect_right(A, 2))  # 6
# print(bisect_left(A, 3))  # 6
# print(bisect_right(A, 3))  # 6


def main():
    S = input()
    max_num = 0
    num = 0
    for i in S:
        if i in ['A', 'T', 'G', 'C']:
            num += 1
            max_num = max(num, max_num)
        else:
            num = 0
    print(max_num)



if __name__ == '__main__':
    main()


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

int main(){
    int n , x;
    while(true){
        cin >> x >> n;
        if ( x == 0 && n == 0 )break;
        if ( x < n ){
            cout << x << " " << n << endl;
        }else {
            cout << n << " " << x << endl; 
        }

    }   

}


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


int main() {

	int H, W;
	int s[52][52];
	cin >> H >> W;
	const int w = -1;
	const int b = -2;

	int countWhite = 0;
	for (int i = 0; i <= H + 1; i++) {
		for (int j = 0; j <= W + 1; j++) {
			s[i][j] = b;
		}
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			char c;  cin >> c;
			if (c == '.') {
				s[i][j] = w;
				countWhite++;
			}
			else
			{
				s[i][j] = b;
			}
		}
	}

	if (s[0][0] == '#' || s[H][W] == '#') {
		cout << "-1" << endl;
		return 0;
	}
	else {
		int counter = 0;

		vector<pair<int, int>> next;
		next.push_back(pair<int, int>(1, 1));
		while (s[H][W] == w && next.size() > 0) {

			vector<pair<int, int>> frontier(next);
			next.clear();

			for (auto p : frontier) {
				int x = p.first;
				int y = p.second;
				if (s[x - 1][y] == w) {
					s[x - 1][y] = counter;
					next.push_back(pair<int, int>(x - 1, y));
				}
				if (s[x + 1][y] == w) {
					s[x + 1][y] = counter;
					next.push_back(pair<int, int>(x + 1, y));
				}
				if (s[x][y - 1] == w) {
					s[x][y - 1] = counter;
					next.push_back(pair<int, int>(x, y - 1));
				}
				if (s[x][y + 1] == w) {
					s[x][y + 1] = counter;
					next.push_back(pair<int, int>(x, y + 1));
				}
			}
			counter++;
		}

		if (s[H][W] == w) {
			cout << "-1" << endl;
		}
		else {
			int numCanChange = countWhite - (counter + 1);
			cout << numCanChange << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll ho[55][55];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,x;cin>>n>>m>>x;
  bool fl = false;
  ll ans = llINF;
  for(int i=0;i<n;i++){
    for(int j=0;j<m+1;j++){
      cin>>ho[i][j];
    }
  }
  for(int i=0;i<BITLE(n);i++){
    vi sum(m+10);
    ll co = 0;
    for(int j=0;j<n;j++){
      if(i&BITLE(j)){
	for(int k=0;k<m;k++)
	  sum[k] += ho[j][k+1];
	co += ho[j][0];
      }
    }
    bool fll = true;
    for(int j=0;j<m;j++){
      if(sum[j] < x)fll = false;
    }
    if(fll){
      fl  =true;
      ans = min(ans,co);
    }
  }
  if(fl)cout<<ans<<endl;
  else cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
 
template <typename T>
void cetak(T t){cout << t << ')' << endl;}
template <typename T, typename... V>
void cetak(T t, V... v) {cout << t; if (sizeof...(v)) cerr << ", "; cetak(v...);}
 
#define debug(x...) cout<< '(' << #x << ") = ("; cetak(x) 
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())

const int MOD = 1e9 + 7;
const int mx = 5e5 + 10;

int ini[mx];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string ss;
    cin >> ss;
    int balance = 0;
    long long jaw = 0;
    string itu;
    stack<int> s;
    for(int i = 0; i < sz(ss); i++){
        if(ss[i] == '('){
            balance += 1;
            ini[balance + 200000] += 1;
            itu += ss[i];
        }
        else if(ss[i] ==')'){
            jaw += ini[balance + 200000];
            itu += ss[i];
            s.push(ini[balance + 1 + 200000]);
            ini[balance + 1 + 200000] = 0;
            balance -= 1;
        }
        else{
            if(itu.back() == '('){
                itu.pop_back();
                ini[balance + 200000] -= 1;
                balance -= 1;
            }
            else{
                balance += 1;
                ini[balance + 1 + 200000] = s.top();
                s.pop();
                itu.pop_back();
                jaw -= ini[balance + 200000];
            }
        }
        cout << jaw << '\n';
    }
}


Measured memory_bytes: 4836
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n";
using namespace std;
using ll=long long;
using ld=long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class KStones {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n, k;
	    in >> n >> k;
	    vector<int> a(n);
	    for(int i=0; i<n; i++){
	        in >> a[i];
	    }

        vector<bool> dp(k+1, false);
	    for(int i=k; i>=0; i--){
	        for(int j=0; j<n; j++){
	            if(i+a[j] <= k){
	                dp[i] = dp[i] | !dp[i+a[j]];
	            }
	        }
	    }

//	    debug.vd(dp);

	    if(dp[0]) out << "First" << endl;
	    else out << "Second" << endl;
	}
};


int main() {
	KStones solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a_t = [0]
for i in range(n):
    a_t.append(a[i] + a_t[i])
s = sum(a)
ans = float("inf")
for i in range(1, n):
    ans = min(ans, abs(s - a_t[i] * 2))
print(ans)

Measured memory_bytes: 24832
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
double dp[305][305][305];
int visited[305][305][305]={0},n;
double func(int i,int j,int k){
    if(i==0 and j==0 and k==0)
        return 0;

    if(visited[i][j][k]==1)
        return dp[i][j][k];

    visited[i][j][k]=1;
    double ans=1.0;
    if(i)
        ans+=(1.0*i/n)*func(i-1,j,k);
    if(j)
        ans+=(1.0*j/n)*func(i+1,j-1,k);
    if(k)
        ans+=(1.0*k/n)*func(i,j+1,k-1);

    return dp[i][j][k]=(1.0*ans*n)/(i+j+k);
}
int main(){
    cin>>n;

    int x,a=0,b=0,c=0;
    for(int i=0;i<n;i++){
        cin>>x;
        if(x==1)
            a++;
        else if(x==2)
            b++;
        else
            c++;
    }

    cout<<fixed<<setprecision(12)<<func(a,b,c);
}

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

int main() {
    int i;
    int a, b;
    int ans, sp;
    scanf("%d%d", &a, &b);
	sp = 1;
	ans = 0;
	while(1){
		if(sp >= b) break;
		ans++;
		sp += (a-1);
	}
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    while (1) {
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        int ans = 0;
        repd(i, 1, n + 1) {
            repd(j, i + 1, n + 1) {
                repd(k, j + 1, n + 1) {
                    if (i + j + k == x) ans++;
                }
            }
        }

        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>                                                                                                              
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
                 
#define push_back pb
#define PII pair<int,int>   
                 
#define VS vector<string>   
#define VI vector<int>      
#define ll long long int    
#define debug(x) cout << x << " :" <<#x << endl                                            
class union_find {                                                                         
public:          
    union_find(int n)                    
        : par_(n, -1)                    
    {}           
    void init(int n) {                   
        par_.assign(n, -1);              
    }            
                 
    int root(int x) {                    
        return par_[x] < 0 ? x : par_[x] = root(par_[x]);                                  
    }            
                 
    bool unite(int x, int y) {           
        x = root(x); y = root(y);        
        if(x == y) {                     
            return false;                
        } else { 
            if(par_[x] < par_[y]) {      
                par_[x] += par_[y];      
                par_[y] = x;             
            } else {                     
                par_[y] += par_[x];      
                par_[x] = y;             
            }    
            return true;                 
        }        
    }            
                 
    bool same(int x, int y) {            
        return root(x) == root(y);       
    }            
                 
    int size(int x) {                    
        return -par_[root(x)];           
    }            
                 
private:         
    std::vector<int> par_;               
};               
                 
int main(void) { 
    union_find uf(12);
    uf.init(12); 
    uf.unite(1,3);uf.unite(3,5);uf.unite(5,7);uf.unite(7,8);uf.unite(8,10);uf.unite(10,12);
    uf.unite(4,6);uf.unite(6,9);uf.unite(9,11);
    int x,y; cin >> x >> y;                                                                                                          
    if(uf.same(x,y)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	static int[] list = new int[10001];
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		list[0] = 1;
		for(int i = 1; i < 10001; i++) {
			list[i] = list[i-1] + i;
		}
		while(sc.hasNext()) {
			int n = (int)sc.nextLong();
			out.println(list[n]);
		}
		out.flush();
	}
}
	
//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}

Measured memory_bytes: 16900
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

bool cmp(int a,int b){
	return a>b;
}
int a[101];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int ff=1;ff<=150000;ff++) {
		int xx;
		xx++;
	}
	sort(a+1,a+n+1,cmp);
	int s1=0,s2=0;
	for(int i=1;i<=n;i++){
		if(i%2==1) s1+=a[i];
		else s2+=a[i];
	}
	cout<<s1-s2;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    while(true) {
    	int h, w;
    	cin >> h >> w;
    	if(h==0 && w==0) {
    		break;
    	}
    	for(int i=1; i<=h; i++) {
    		if(i%2==0) {
    			for(int j=1; j<=w; j++) {
    				if(j%2==0) {
    					cout << "#";	
    				}else {
    					cout << ".";
    				}
    			}
    		}else {
    			for(int k=1; k<=w; k++) {
    				if(k%2==0) {
    					cout << ".";
    				}else {
    					cout << "#";	
    				}
    			}
    		}
    		cout << endl;
    	}
    	cout << endl;
    }
}


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

int a,b,c;

int main(){

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

    cin>>a>>b>>c;
    if(a==b && b==c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
using namespace std;

int main(){
	string s;
	bool flag=false; //??????
	map<long,long> mp;
	set<long> thismonth; //????????????????????£??????
	
	while(getline(cin,s)){	
		if(s==""){
			flag=true; //??????
			continue;	
		}
		
		int point=0;
		while(s[point]!=',') point++;
		//printf("point = %d\n", point);
		
		string tmp=s.substr(0,point);
		//string b=s.substr(point+1, s.size()-1-point);
		
		//cout << a << " " << b <<endl;
		
		stringstream ss;
		ss<<tmp;
		long a;
		ss>>a;
		
		if(!flag){
			if(mp.find(a) == mp.end()) mp[a]=1;	
			else mp[a]++;
		}
		else{
			thismonth.insert(a);
			
			if(mp.find(a) == mp.end()){} //?????????????????????????????§??????	
			else mp[a]++;	
		}			
	}
	
	for(map<long,long>::iterator itr=mp.begin(); itr!= mp.end(); ++itr){
			if(thismonth.find(itr->first) != thismonth.end())
			cout << itr->first << " " << itr->second << endl;
	}
}

Measured memory_bytes: 1228
#include <string>
#include <iostream>
#include <vector>
#include <sstream>

using namespace::std;

int main(void){
  int num;
  string input;

  cin >> num;
  cin.ignore();

  getline(cin, input);

  stringstream ss(input);
  vector<int> a;

  string buf;

  while(!ss.eof()){
    ss >> buf;
    a.push_back(stoi(buf));
  }

  int cnt=0;
  for(int i=1;i<num;i++){
    if(a.at(i) == a.at(i-1)){
      a.at(i) = a.at(i-1)+1;
      if(a.at(i)>10000)a.at(i)=1;

      if((i+1)!=num && a.at(i) == a.at(i+1)){
        a.at(i)= a.at(i+1)+1;
        if(a.at(i)>10000)a.at(i)=1;
      }
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


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

int main() {
  long x; cin >>x;
  long cnt = 0;
  cnt += (x/11)*2;
  
  if (x%11>6) cnt += 2;
  else if (x%11>0) cnt++;
  
  cout <<cnt <<endl;
  
  //cout <<ans <<endl;
  
  //if (ans) cout <<"YES" <<endl;
  //else cout <<"NO" <<endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
using namespace std;
inline int read()
{
	int k=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) k=k*10+c-'0';return f*k;
}
const int N=2055;
bitset<N*N> bt;
int n,a[N],mid,sum; 
int main()
{
//	freopen("1.in","r",stdin);
	n=read();bt[0]=1;
	for(int i=1;i<=n;i++)
	{
		a[i]=read(),mid+=a[i];
		bt|=(bt<<a[i]);
	}
	mid=(mid+1)>>1;
	for(int i=mid;;i++)
		if(bt[i])
			{printf("%d\n",i);break;}
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  rep(i,n) cin >> a[i+1];
  vector<int> b(n+1);
  
  for(int i=n;i>=1;i--){
    int s = 0;
    for(int j=i+i;j<=n;j+=i){
      s ^= b[j];
    }
    b[i] = s^a[i];
  }
  vector<int> ans;
  for(int i=1;i<=n;i++){
    if(b[i])ans.push_back(i);
  }
  cout << ans.size() << endl;
  
  rep(i,ans.size()){
    printf("%d%c",ans[i],i+1==ans.size()?'\n':' ');
  }
}

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

using namespace std;

const int N = 2e2+7;
const int INF = 0x3f3f3f3f;

int n;
int m[N][N], col[N], dis[N][N];

bool check(int cur, int last)
{
    if (col[cur] != -1) {
        return col[cur] != last;
    }
    col[cur] = last^1;
    for (int i = 1; i <= n; ++i) {
        if (i == cur || !m[cur][i]) continue;
        if (!check(i, col[cur])) return false;
    }
    return true;
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            char c;
            cin >> c;
            m[i][j] = c-'0';
            dis[i][j] = m[i][j] ? 1 : INF;
            if (i == j) dis[i][j] = 0;
        }
    }
    memset(col, -1, sizeof col);
    if (!check(1, 1)) {
        cout << -1 << endl;
        return 0;
    }
    
    for (int k = 1; k <= n; ++k) {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                dis[i][j] = min(dis[i][j], dis[i][k]+dis[k][j]);
            }
        }
    }
    int res = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            res = max(res, dis[i][j]);
        }
    }
    cout << res+1 << endl;
    return 0;
}

Measured memory_bytes: 640
N,K=list(map(int,input().split()))
p=list(map(int,input().split()))


e=[(x+1)/2 for x in p]

tmp=sum(e[0:K])
ans=tmp
for i in range(K,N):
	tmp+=e[i]-e[i-K]
	ans=max(ans,tmp)

print(ans)	




Measured memory_bytes: 24804
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;
const ll LOG = 20;
ll com = 0, n, m, v, u, w;
bitset<N> mark;

vl G[N];
void DFS(ll v){
	mark[v] = 1;
	for (auto u:G[v]){
		if (!mark[u]) DFS(u);
	}
	return;
}

int main(){
	IOS;
	cin >> n >> m;
	for (int i = 1; i <= m; i++){
		cin >> v >> u >> w;
		G[v].pb(u);
		G[u].pb(v);
	}
	for (int i = 1; i <= n; i++){
		if (!mark[i]){
			com ++;
			DFS(i);
		}
	}
	cout << com;
	
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




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

int main() {
    
    rep(i, 5){
        int a;
        cin >> a;
        
        if(a == 0){
            cout << i+1 << endl;
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 3632
// 辺が(N-1)本とき、隣り合う(N-1)組の頂点対の最短距離は1となり、
// 頂点対(i,j)の内、最短距離が2,3,4,...となるのは
// N*(N-1)/2 - (N-1) = (N-1)(N-2)/2組である
// (N-1)(N-2)/2 < Kのとき、最短距離が2となる頂点対をK個作ることは不可能
// (N-1)(N-2)/2 >= Kのとき、頂点1とそれ以外の頂点を結ぶ(N-1)本の辺だけが
// 存在するグラフを作る（「スター」、「うに」と呼ぶ）
// このとき、頂点1以外の頂点対の最短距離は全て2であり、その数は(N-1)(N-2)/2組
// 頂点1以外の頂点対(i,j)を結ぶ辺を加えると、その頂点対だけ最短距離が1となり、
// 最短距離が2の頂点対を1つ減らせる。
// この操作で調整して、条件を満たすグラフを構築
#include <bits/stdc++.h>
using namespace std;

int graph[110][110];

int main() {
    int N, K;
    cin >> N >> K;
    if ((N - 1) * (N - 2) / 2 < K) {
        cout << -1 << endl;
        return 0;
    }
    /*
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            graph[i][j] = 100000000;
        }
    }
    for (int i = 0; i < N; ++i) {
        graph[i][i] = 0;
    }
    */
    cout << (N - 1) + (N - 1) * (N - 2) / 2 - K << endl;
    
    for (int i = 2; i <= N; ++i) {
        cout << 1 << " " << i << endl;
        //graph[0][i - 1] = graph[i - 1][0] = 1;
    }
    
    int p = (N - 1) * (N - 2) / 2 - K;
    int u = 2, v = 3;
    while (p--) {
        cout << u << " " << v << endl;
        //graph[u - 1][v - 1] = graph[v - 1][u - 1] = 1;
        ++v;
        if (v > N) {
            ++u;
            v = u + 1;
        }
    }
    // デバッグ
    /*
    for (int k = 0; k < N; ++k) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (graph[i][j] == 2) ++cnt;
        }
    }
    if (cnt / 2 == K)
        cout << "validate" << endl;
    else
        cout << "wrong" << endl;
    */
    return 0;
}

Measured memory_bytes: 256
A,B = input().split()

max_num = max(int(A),int(B))
min_num = min(int(A),int(B))
i = 0
flag = False

while flag == False:
    i += 1
    if (max_num*i)% min_num == 0:
        print(max_num*i)
        flag = True

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <climits>

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

using namespace std;


int main()
{
    int n;
    string s = "";
    cin >> n;

    int cur[int(3 * 1e5 + 1)];

    int e = 0;
    rep (i, n) {
	char tmp;
	cin >> tmp;
	s += tmp;
	if (tmp == 'E')
	    cur[i] = ++e;
	else
	    cur[i] = e;
    }

    int res = INT_MAX;
    rep (i, n) {
	int left_e, left_w, right_e, right_w;
	if (i > 0) {
	    left_e = cur[i] - (cur[i] - cur[i - 1]);
	    left_w = i - left_e;
	} else {
	    left_e = 0;
	    left_w = 0;
	}

	if (i < n) {
	    right_e = cur[n - 1] - cur[i];
	    right_w = (n - (1 + i)) - right_e;
	} else {
	    right_e = 0;
	    right_w = 0;
	}

	int tmp = left_w  + right_e;
	res = min(res, tmp);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1924
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<int,int>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
   lli A,B,C,L,R,N,M,K,X=0,Y=0,W,H=INF,sum=0,num=0,flag=0;string S,T,O;
   cin >> N >> K;
   Vecpr(P,lli,lli,N);Vecpr(Q,lli,lli,N);
   rep(i,0,N){
      cin >> P[i].first >> Q[i].first;
      P[i].second=i;
      Q[i].second=i;
   }
   Sort(P);
   M=P[N-1].first;
   X=P[N-1].second;
   Rev(P);
   Sort(Q);Rev(Q);
   rep(i,0,N){
      if(Q[i].first<=M||K<1)break;
      K-=Q[i].first;
      sum++;
   }
   if(K>0){
      if(K%M)sum+=K/M+1;
      else sum+=K/M;
   }
   Out(sum);
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main() {
	long n, k;
	cin >> n;
	cin >> k;
	if (k == 0) {
		cout << n << endl;
	} else {
		long m1 = abs(n % k);
		m1 = min(m1, k - m1);
		cout << m1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

#define D 1000000007

using namespace std;

long long int bik(int a){
    long long int ret=1;
    for(int i=2; i<=a; i++){
        ret=(ret*i)%D;
    }
    return ret;
}

int main(){
    int n, m;
    cin>>n>>m;
    long long int ans;
    if(abs(n-m)>1){
        ans=0;
    }
    else{
        ans=(bik(n)*bik(m))%D;
        if(n==m) ans=(ans*2)%D;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [int(x) for x in input().split()]

cnt = 0
for i in range(len(s)-1):
    for j in reversed(range(i+1,len(s))):
        if(s[j-1] > s[j]):
            v = s[j]
            s[j] = s[j-1]
            s[j-1] = v
            cnt += 1
            
print(" ".join(map(str,s)))
print(cnt)


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

constexpr int INF = 1e9;

int main() {
    string s;
    int x, y;
    cin >> s >> x >> y;

    if(count(begin(s), end(s), 'F') == s.size()) {
        if(x == s.size()) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
    }

    bool first_flag = s[0] == 'F';

    vector<vector<int>> op(2);
    int dir = 0, step = 0;
    for(auto c : s) {
        if(c == 'T') {
            if(step > 0) {
                op[dir].push_back(step);
            }
            step = 0;
            dir = !dir;
        } else {
            step++;
        }
    }
    if(step > 0) {
        op[dir].push_back(step);
    }

    auto check = [&](vector<int> op, int pos) {
        vector<int> tbl(16001);
        int* dp = &tbl[8000];
        dp[0] = 1;
        for(int i = 0; i < (int)op.size(); ++i) {
            int st = op[i];
            vector<int> nxt(16001);
            int* dp2 = &nxt[8000];
            for(int i = -8000; i + st <= 8000; ++i) {
                dp2[i + st] |= dp[i];
            }
            if(first_flag) {
                first_flag = false;
            } else {
                for(int i = 8000; i - st >= -8000; --i) {
                    dp2[i - st] |= dp[i];
                }
            }
            tbl = move(nxt);
            dp = &tbl[8000];
        }

        return dp[pos] == 1;
    };

    if(check(op[0], x) && check(op[1], y)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    string a;
    string b;
    string c;
    cin >> a >> b >> c;
    if(a.back() == b.front() && b.back() == c.front()){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


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

int main(){
    int N; cin >> N;
    vector<int> A(N);
    map<int,int> cnt;
    for(int i=0;i<N;i++){
        cin >> A[i];
        cnt[A[i]]++;
    }
    int ans=0;
    for(auto it=cnt.begin();it!=cnt.end();it++){
        if(it->second%2==1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5376
#include <cstdio> 
#include <iostream>
using namespace std;
const int  maxn = 2000007; 
typedef unsigned short uc;
const int M = 10001;
int b[maxn], c[M+3];
#define Rep(i, a, b) for (int i = a; i <= b; ++i)
// 计数排序适用于-数字很多，但范围比较集中的 数据 

int  main()
{
    int n, x; scanf("%d", &n);
    Rep(i, 0, M)  c[i] = 0;
    for (int i = 0; i < n; i++)
	{ 
        scanf("%d", &x);
        c[x]++;
    }

	for (int i = 0, j = 0; i < M; ++i)
	{// M + k
		if (c[i])
		{
			for (int k = 0; k < c[i]; ++k)
			{
				b[j++] = i;
			}
		}
	}
	
	for (int i = 0; i < n; i++)
        printf("%d%c", b[i], i==n-1 ? '\n' : ' ');
 
	return 0;
}
// 7 2 5 1 3 2 3 0
// 8 4 5 0 3 1 5 0 5 


Measured memory_bytes: 11032
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

  vector<int> A,B;
  for(int i=0;i<n;i++){
    if(s[i]=='W') A.push_back(i);
  }
  for(int i=n-1;i>=0;i--){
    if(s[i]=='R') B.push_back(i);
  }
  A.push_back(n);
  B.push_back(-1);
  
  int ans;
  rep(i,n){
    if(A[i]>B[i]){
      ans=i;
      break;
    }
  }
  
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 4540
#include<iostream>
#include<cstdio>
#include<bitset>
using namespace std;
const int N=2000005;
int n,s;
bitset<N>v;
int main()
{
	scanf("%d",&n);
	v[0]=1;
	for(int i=1,x;i<=n;i++)
	{
		scanf("%d",&x);
		s+=x,v|=v<<x;
	}
	for(int i=s/2;;i--)
		if(v[i])
		{
			printf("%d\n",s-i);
			return 0;
		}
	return 0;
}

Measured memory_bytes: 1024
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

const MOD: i64 = 1_000_000_007;

fn main() {
    let (_, _) = scan!(i64, i64);
    let xs = scan!(i64;;);
    let ys = scan!(i64;;);

    let mut x_sums = 0;
    for (i, &x) in xs.iter().enumerate() {
        x_sums += i as i64 * x - (xs.len() - 1 - i) as i64 * x;
        x_sums %= MOD
    }
    let mut y_sums = 0;
    for (i, &y) in ys.iter().enumerate() {
        y_sums += i as i64 * y - (ys.len() - 1 - i) as i64 * y;
        y_sums %= MOD
    }
    println!("{}", x_sums * y_sums % MOD);
}


Measured memory_bytes: 10492
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>

#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define srep(i) for (int i = 0; i < s.size(); i++)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979

using namespace std;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};

int n,b, gx, gy;
char field[105][105];
int cnt[105][105];
string s;

int a[9] = {111, 222, 333, 444, 555, 666, 777, 888, 999};

int main(){
    cin>>n;
    for(int i=0; i<9; i++){
        if(a[i]>=n){
            cout<<a[i]<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256