akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
//#define int long long
#define PI 3.14159265
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int mod=1e9+7;
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int arr[n];
    int fr[4]={};
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        fr[arr[i]]++;
    }
    double dp[305][305][305]={};
    for(int i=0;i<=n;i++)
        for(int j=0;j<=n;j++)
            for(int k=0;k+i+j<=n;k++)
            {
                if(i+j+k==0)
                  continue;
                if(i)
                  dp[i][j][k]+=i*dp[i-1][j+1][k];
                if(j)
                  dp[i][j][k]+=j*dp[i][j-1][k+1];
                if(k)
                  dp[i][j][k]+=k*dp[i][j][k-1];
                dp[i][j][k]+=n;
                  dp[i][j][k]/=(i+j+k+0.0);
            }
    cout<<setprecision(10)<<dp[fr[3]][fr[2]][fr[1]];
}


Measured memory_bytes: 221952
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int H, W; cin >> H >> W;
	vvi c(H, vi(W));
	REP(i,H) REP(j,W) {
		cin >> c[i][j];
	}
	vvi dp(H, vi(W));
	dp[0][0] = 1;
	vi dx = {-1, -1, 0};
	vi dy = {-1, 0, -1};
	REP(i,H) REP(j,W) {
		if (c[i][j] == 1) {
			dp[i][j] = 0;
			continue;
		}
		int _min = numeric_limits<int>::max();
		REP(k,3) {
			if (i + dy[k] < 0 || j + dx[k] < 0) {
				_min = min(_min, 0);
			} else {
				_min = min(_min, dp[i + dy[k]][j + dx[k]]);
			}
		}
		dp[i][j] = _min + 1;
	}
	int max_side = 0;
	REP(i,H) REP(j,W) {
		max_side = max(max_side, dp[i][j]);
	}
	cout << max_side * max_side << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



Measured memory_bytes: 18396
N, M = map(int, input().split())
H = list(map(int, input().split()))
l = []
for i in range(M):
    A, B = map(int, input().split())
    if(H[A-1]>H[B-1]):l.append(B-1)
    elif(H[A-1]==H[B-1]):
      l.append(A-1)
      l.append(B-1)
    else:l.append(A-1)
l = list(set(l))
print(len(H)-len(l))

Measured memory_bytes: 92016
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <set>
#include <utility>
#include <climits>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>

#define ll long long
#define ull unsigned long long
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int x;
	cin >> x;
	for (int i = -1000; i < 1000; ++i) {
		for (int j = -1000; j < 1000; ++j) {
			if (1LL * i * i * i * i * i - j * 1LL * j * j * j * j == x) {
				cout << i << ' ' << j;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

// 約数列挙：nの約数を昇順に返す
vector<long long int> enumDivisors(long long int n){
    vector<long long int> ret;
    for(long long int i=1; i*i<=n; i++){
        if(n%i == 0){
            ret.push_back(i);
            if(n/i != i) ret.push_back(n/i);
        }
    }
    //sort(ret.begin(), ret.end());
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n;
    cin >> n;
    vi a(n+1, 0);
    vi cnt(n+1, 0);
    vi ans;
    repf(i, n) cin >> a[i];

    perf(i, n){
        if(cnt[i]%2 != a[i]){
            ans.push_back(i);
            auto p = enumDivisors(i);
            for(auto t: p) cnt[t]++;
        }
    }

    sort(all(ans));
    n = ans.size();
    cout << n << endl;
    rep(i, n) cout << ans[i] << ((i == n-1) ? endl : " ");
}

Measured memory_bytes: 5108
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define int long long
#define REP(i,n) for (int i=0;i<(n);i++)
#define MOD 1000000007

int fact(int);

signed main(){
    int N,M;
    cin >> N >> M;
    if(N-M>=2||-2>=N-M){
        cout << 0 << endl;
    }else if(N==M){
        M=fact(N);
        cout << (M*M*2)%MOD;
    }else{
        cout << (fact(N)*fact(M))%MOD;
    }
return 0;
}

int fact(int K){
    int a=1;
    REP(i,K){
        a=(a*(i+1))%MOD;
    }
    
    return a;
}

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

int main() {
    int n;
    cin >> n;
    for(int i=1;i<n+1;i++){
        int ans = 0;
        for(int x=1;x<45;x++){
            for(int y=x;y<60;y++){
                for(int z=y;z<101;z++){
                    if(pow(x+y,2)+pow(y+z,2)+pow(z+x,2)==2*i){
                        if(x<y&&y<z) ans+=6;
                        if(x<y&&y==z) ans+=3;
                        if(x==y&&y<z) ans+=3;
                        if(x==y&&y==z) ans+=1;
                    }
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3632
<?php
fscanf(STDIN, "%d", $a);

$arr = [];
for($x = 1; $x < 100 ; $x++){
    for($y = 1; $y < 100 ; $y++){
        for($z = 1; $z < 100 ; $z++){
            $ans = ($x * $x) + ($y * $y) + ($z * $z) +($x * $y) + ($y * $z) + ($x * $z);
            if(isset($arr[$ans])){
                $arr[$ans]++;
            }else{
                $arr[$ans] = 1;
            }
        }
    }
}

for($i = 1; $i <= $a ; $i++){
    if(isset($arr[$i])){
        echo $arr[$i] . "\n";
    }else{
        echo 0 . "\n";
    }
}
?>

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

using namespace std;
typedef long long LL;
int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
const int N = 300001;
int read() {
	int s = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
	return s * f;
}
void put(int x) {
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int a[N];

bool check(int id, int c) {
	int o;
	if(a[id] == id) o = 1;
	else o = 0;
	return o == c;
}

int main() {
	int n = read(); a[n + 1] = n + 1, a[0] = 0;
	for(int i = 1; i <= n; i++) a[i] = read();
	for(int i = 2; i <= n; i++) {
		if(a[i] != i && a[i - 1] != i - 1 && a[i + 1] != i + 1) {puts("No"); return 0;}
	} for(int i = 1; i <= n; i++) if(a[i] != i){
		int now = 0, l = i, r = i;
		while(r + 1 <= n && check(r + 1, now ^ 1)) r++, now ^= 1;
		int ll = 0, rr = 0;
		for(int j = l; j <= r; j++) {
			if(a[j] < l || a[j] > r) {puts("No"); return 0;}
			if(a[j] < j) {
				if(ll > a[j]) {puts("No"); return 0;}
				ll = a[j];
			} if(a[j] > j) {
				if(rr > a[j]) {puts("No"); return 0;}
				rr = a[j];
			}
		} i = r;
	} puts("Yes");
	return 0;
}


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

#define MT make_tuple
#define all(x) begin(x), end(x)
#define putchar(x) cout << (x)
static int fastio = [](){ ios_base::sync_with_stdio(false); cin.tie(0); cout.precision(17); return 0; }();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename ...T> string format(const string& fmt, T&&... args) {
    size_t sz = snprintf(nullptr, 0, fmt.c_str(), args...) + 1;
    unique_ptr<char[]> buf(new char[sz]);
    snprintf(buf.get(), sz, fmt.c_str(), args...);
    return string(buf.get(), buf.get() + sz - 1);
}

template<class T> struct rge { T b, e; auto begin() const { return b; } auto end() const { return e; } };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
template<class T> auto dud(T* x) -> decltype(cerr << *x, 0);
template<class T> char dud(...);

struct debug {
#ifdef LOCAL
    debug(int line) {
        if(line) cerr << "LINE(" << line << ") -> ";
    }
    template<class T> typename enable_if<sizeof dud<T>(0) != 1, debug&>::type operator<<(T i) {
        cerr << boolalpha << i; return * this;
    }
    template<class T> typename enable_if<sizeof dud<T>(0) == 1, debug&>::type operator<<(T i) {
        return *this << range(begin(i), end(i));
    }
    template<class T, class U> debug& operator<<(pair<T, U> d) {
        return *this << "(" << d.first << ", " << d.second << ")";
    }
    debug& operator<<(tuple<>&) { return *this << "()"; };
    template<class ...T> debug& operator<<(tuple<T...> d) {
        *this << "("; debug_tuple<sizeof...(T), 0>(d);
        return *this << ")";
    }
    template<size_t L, size_t I, class T> void debug_tuple(const T& t) {
        *this << (I == 0 ? "" : ", ") << get<I>(t);
        if(I + 1 < L) debug_tuple<L, (I + 1) % L>(t);
    }
    template<class T> debug & operator <<(rge<T> d) {
        *this << "[";
        for(auto it = d.b; it != d.e; ++it)
            *this << (it != d.b ?  ", " : "") << *it;
        return *this << "]";
    }
    debug& operator<<(ostream&(*pf)(std::ostream&)) {
        cerr << pf; return *this;
    }
#else
    debug(int) {}
    template<class T> debug& operator<<(T&&) { return *this; }
    debug& operator<<(ostream&(*)(std::ostream&)) { return *this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ << ": " << (__VA_ARGS__) << "] "

#define debug0()  debug(__LINE__)
#define debug1(x) debug(0)
#define GET_MACRO(_0, _1, NAME, ...) NAME
#define debug(...) GET_MACRO(_0, ##__VA_ARGS__, debug1, debug0)(__VA_ARGS__)
/*}}}*/
using LL = long long;

const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const LL LLINF = 0x3f3f3f3f3f3f3f3f;
const int MAX_N = 200005;

void solve(int) {
    vector<int> x(5);
    for(int i = 0; i < 5; ++i) {
        cin >> x[i];
    }
    for(int i = 0; i < 5; ++i) {
        if(x[i] == 0) {
            cout << i + 1 << endl;
            return;
        }
    }
}

int main() {
    int T = 1;
    //cin >> T;
    for(int i = 1; i <= T; ++i) {
        solve(i);
    }
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
	double n;cin>>n;
	if((ll)n%2==1)
	{
		double res=((n+1)/2)/n;
		cout<<fixed<<setprecision(10)<<res;
	}
	else
	{
		cout<<"0.5000000000";
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#ifndef INT_MAX
#  define INT_MAX std::numeric_limits<int>().max()
#endif
#ifndef INT_MIN
#  define INT_MIN std::numeric_limits<int>().min()
#endif
#define LL_MAX std::numeric_limits<ll>().max()
#define LL_MIN std::numeric_limits<ll>().min()
#define INF LL_MAX

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())

ll N, A, B;

int main()
{
    cin >> N >> A >> B;

    if(A == B) {
        printf("1\n");
        return 0;
    }
    if(N == 1 && A != B) {
        printf("0\n");
        return 0;
    }
    if(B < A) {
        printf("0\n");
        return 0;
    }

    ll pattern = B - A + 1;
    ll movable = N - 2;
    printf("%lld\n", (pattern - 1) * movable + 1);
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
using vl = vector<ll>;
using vi = vector<int>;
using vchar = vector<char>;
using vstr = vector<string>;
using pll =  pair<ll,ll>;

const ll mod = 1000000007;
const ll inf = 1000000000000000;

#define pi acos(-1)
#define pb push_back
#define test int TEST;cin>>TEST;while(TEST--)
#define vsort(xx) sort(xx.begin(),xx.end())
#define vrevsort(xx) sort(xx.rbegin(),xx.rend())
#define rep(i,a,b) for(int i=a;i<b;i++)


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    long n,k;
    cin>>k>>n;
    vi a(n);
    
    rep(i,0,n){
        cin>>a[i];
    }
    vsort(a);
    
     long mn=a[n-1]-a[0];
    rep(i,0,n-1){
        mn=min(k-a[i+1]+a[i],mn);
    }
    cout<<mn;
    
    
    
   
    return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long 
#define vi vector<int>
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define vii vector<pair<int,int> >
#define pb push_back
#define inf -1000000007
#define f(i,a,b) for(i=a;i<b;i++)

using namespace std;
bool cmp(string &a,string &b)
{
	if(a.size()==b.size())return a<b;
	return a.size()<b.size();
}
ll d[200001];
int main()
{
  ll x,k,d,i,j;
  
  cin>>x>>k>>d;
  
  if(x%d==0)
  {
      i=abs(x/d)-1;
  }
  else i=abs(x/d);
  
  if(k>i)
  {
      k=k-i;
       x=abs(x)-(i*d);
      if(k%2)
      {
         x=abs(x-d);
         cout<<x;
      }
      else cout<<x;
  }
  else
  {
      x=abs(x)-k*d;
      
      cout<<x;
  }
    
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

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

  vector<int> ans(n+1);
  ans[0] = sum;
  for(int i = 1; i < n; i+=2){
    ans[0] -= a[i]*2;
  }
  //cout << ans[0] << endl;
  for(int i = 1; i < n; i++){
    ans[i] = a[i-1]*2 - ans[i-1];
  }

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

  return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if ((a + b) > (c + d)) {
    cout << "Left" << endl;
  }
  else if ((a + b) == (c + d)) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
signed main() {
  ios::sync_with_stdio(false);
  int N; string S; cin >> N >> S;
  map<char, int> counter;
  for(char c : S) {
    if(c != '+') counter[c]++;
  }
  map<int, vector<char>> c2a;
  for(auto iter : counter) {
    c2a[iter.second].push_back(iter.first);
  }
  stringstream ss;
  bool is_first = true;
  for(auto iter : c2a) {
    if(!is_first) ss << '+';
    is_first = false;
    if(iter.first != 1) {
      ss << iter.first << "*";
      if(iter.second.size() >= 2) ss << "(";
    }
    bool is_first2 = true;
    for(auto ch : iter.second) {
      if(!is_first2) ss << '+';
      is_first2 = false;
      ss << ch;
    }
    if(iter.first != 1) {
      if(iter.second.size() >= 2) ss << ")";
    }
  }
  // DEBUG(ss.str());
  cout << ss.str().size() << endl;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    pair<int,int>p[n+1];
    for(int i=0;i<n;i++)
        cin>>p[i].first;
    for(int i=0;i<n;i++)
        cin>>p[i].second;
    int lim=(1<<n);
    int mn=1e9;
    for(int i=0;i<lim;i++)
    {
        vector<pair<int,int> >s[2];
        for(int j=0;j<n;j++)
        {
            if(i&(1<<j))
            {
                if(j&1)
                    s[0].push_back({p[j].second,j});
                else
                    s[1].push_back({p[j].second,j});
            }
            else
            {
                if(j&1)
                    s[1].push_back({p[j].first,j});
                else
                    s[0].push_back({p[j].first,j});                
            }            
        }

        int mm[20]={0};
        int pos[20];
        int perm[20];

        int prev=0;
        bool flag=true;
        int ans=0;

        sort(s[0].begin(),s[0].end());
        sort(s[1].begin(),s[1].end());
        int sz[2];
        int xx[2]={0};
        sz[0]=s[0].size();
        sz[1]=s[1].size();
        for(int j=0;j<n;j++)
        {
            if(xx[j&1]==sz[j&1])
            {
                flag=false;
                break;
            }
            pair<int,int> k = s[j&1][xx[j&1]];
            if(k.first<prev)
            {
                flag=false;
                break;
            }
            prev=k.first;
            pos[k.second]=j;
            perm[j]=k.second;
            xx[j&1]++;
        }
        
        int lol[20]={0};
        for(int j=0;j<n;j++)
            lol[j]=j;
        if(!flag)
            continue;
        for(int j=0;j<n;j++)
        {
            if(perm[j]!=lol[j])
            {
                for(int k=j;k<n;k++)
                {
                    if(lol[k]==perm[j])
                    {
                        for(int jj=k-1;jj>=j;jj--)
                        {
                            swap(lol[jj],lol[jj+1]);
                            ans++;
                        }
                        break;
                    }
                }
            }
        }

        if(flag)
            mn=min(mn,ans);
    } 
    if(mn==1e9)
        cout<<-1;
    else
        cout<<mn;       

} 



Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

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

	while (1) {
		int a = N / 100;
		int b = (N % 100) / 10;
		int c = N % 10;
		if (a == b && b == c) {
			cout << N << endl;
			return 0;
		}
		N++;
	}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

#define ll long long

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int n;
int m;

vector<pair<int, int>> a;

void input() {
  cin >> n >> m;

  a.resize(m);
  for (auto&& i : a) {
    cin >> i.first >> i.second;

    --i.first;
    --i.second;
  }
}

void solve1() {
  vector<int> sum(n);

  for (auto&& i : a) {
    sum[i.first]++;
    sum[i.second + 1]--;
  }

  for (int i = 1; i < n; ++i)
    sum[i] = sum[i - 1] + sum[i];

  int ans = 0;

  for (auto&& i : sum)
    ans += i == m;

  cout << ans;
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve1();
}


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

int main(int argc, char const *argv[])
{
	// freopen("in", "r", stdin);
	vector<pair<int, int>> ans;
	int n; cin >> n;
	for(int i = 1; i <= n; i++) {
		for(int j = i + 1; j <= n; j++) {
			if(j != n + ((n & 1) ^ 1) - i) {
				ans.emplace_back(i, j);
			}
		}
	}
	cout << ans.size() << endl;
	for(auto i : ans) cout << i.first << ' ' << i.second << endl;
	return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	string s;
	cin >>n >>s;
	string t;
	char old = ':';
	rep(i, n){
		if(old != s[i]) t += s[i];
		old = s[i];
	}
	
	cout << sz(t) <<"\n";
	return 0;
	
}


Measured memory_bytes: 512
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

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

// ここまで

fn run() {
    input! {
        n: usize,
        h: [i32; n],
    }
    let mut dp = vec![0; n];
    dp[1] = (h[1] - h[0]).abs();
    for i in 2..n {
        let x = dp[i - 2] + (h[i] - h[i - 2]).abs();
        let y = dp[i - 1] + (h[i] - h[i - 1]).abs();
        dp[i] = std::cmp::min (x, y);
    }
    println! ("{}", dp[n - 1]);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
# AGC012A - AtCoder Group Contest
def main():
    # sort -> first 1/3 as smallest ones
    # the sum of 2nd ones: 1111 23 23 23 23
    N, *A = map(int, open(0).read().split())
    A.sort()
    ans = sum(A[N::2])
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 36292
#include <queue>
#include <cstdio>
using namespace std;
int n,c,v,dp[500007];
int main() {
	scanf("%d",&n); dp[n]=1;
	for(int i=(n+2)/2;i>1;i--) dp[i]=dp[2*i-1]+2*dp[2*i]+dp[2*i+1];
	for(int i=2;i<=n;i++) c+=dp[i]*i;
	priority_queue<int> que;
	for(int i=0;i<n;i++) scanf("%d", &v), que.push(-v);
	for(int i=0;i<n;i++) {
		if(i) printf(" ");
		printf("%d", -que.top()); que.pop();
	}
	printf("\n%d\n", c);
	return 0;
}

Measured memory_bytes: 5408
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i < n; i++){
        if(n % i == 0){
            ans += n / i - 1;
        }else{
            ans += n / i;
        }
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define pi                  3.14159265359
ll INF=1e18+10;
ll MOD=1e9+7;

const int N=sqrt(1e9);
ll s[101][N+10];
ll b[101][N+10];

int main()
{
    ll n,k;cin>>n>>k;
    ll sqn = sqrt(n);

    mem(s,0);mem(b,0);
    rep(i,1,sqn+1)
    {
        s[1][i]=1;
        b[1][i]=(n/i)-(n/(i+1));
        if(((n/i)*(n/i))<=n)
            b[1][i]=0;
    }

    for(int i=2;i<=k;i++)
    {
        for(int j=1;j<=sqn;j++)
            s[i-1][j]=(s[i-1][j]+s[i-1][j-1])%MOD;
        for(int j=sqn-1;j>=1;j--)
            b[i-1][j]=(b[i-1][j]+b[i-1][j+1])%MOD;

        for(int j=1;j<=sqn;j++)
        {
            s[i][j]=(s[i-1][sqn]+b[i-1][j])%MOD;
            b[i][j]=(((n/j)-(n/(j+1)))*s[i-1][j])%MOD;
            if(((n/j)*(n/j))<=n)
            b[i][j]=0;
        }
    }

    ll ans=0;
    for(int i=1;i<=sqn;i++)
    {
        ans+=(s[k][i]);
        ans%=MOD;
        ans+=(b[k][i]);
        ans%=MOD;
    }
    cout<<ans;
}


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

int main(){
  string s;
  bool can = false;
  cin >> s;
  if(s[0] == s[1] && s[2] == s[3]) can = true;
  if(s[0] == s[2] && s[1] == s[3]) can = true;
  if(s[0] == s[3] && s[1] == s[2]) can = true;
  if(s[0] == s[1] && s[1] == s[2] && s[2] == s[3] && s[3] == s[0]) can = false;
  if(can)cout << "Yes" << endl;
  else cout << "No" <<endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
 
#入力受け取り
H,W=map(int,input().split())
Ch,Cw=[int(x)-1 for x in input().split()]
Dh,Dw=[int(x)-1 for x in input().split()]
maze=[input() for i in range(H)]
 
dirs=[-2,-1,0,1,2] #ワープ移動できる縦横の範囲

#初期化
dist=[[float('inf')]*W for _ in range(H)] #distには各点への到達コストを格納
dist[Ch][Cw]=0
queue=deque()
queue.append((0,Ch,Cw)) #キューには(コスト、x座標、y座標)を追加していく
arrive=False #ゴールに到着すればTrueに変更

while queue:
    k,i,j=queue.popleft()
    if k>dist[i][j]:
        continue
    if i==Dh and j==Dw:
        arrive=True
        break
    for di in dirs:
        for dj in dirs:
            if di==dj==0:
                continue
            ni,nj=i+di,j+dj #移動後の座標(ni,nj)
            if not (0<=ni<H and 0<=nj<W):
                continue
            if maze[ni][nj]=='#': #移動先が壁の中
                continue
            if k<dist[ni][nj]: 
                if abs(di)+abs(dj)==1: #歩行圏内(コスト:0)
                    nk=k
                    dist[ni][nj]=nk
                    queue.appendleft((nk,ni,nj))
                else: #歩行圏外(コスト:1)
                    nk=k+1
                    dist[ni][nj]=nk
                    queue.append((nk,ni,nj))   
if arrive:
    ans=dist[Dh][Dw]
else:
    ans=-1
print(ans)

Measured memory_bytes: 184596
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3
0.0 0.0
2.0 0.0
1.0 1.0

output:
1.41421356237
"""

import sys
from operator import attrgetter


class ClosestPair(object):
    def __init__(self, in_data):
        """
        Init closest pairs points set.
        """
        self.p_num = int(in_data[0])
        points = map(lambda x: x.split(), in_data[1:])
        p_list = [complex(float(x), float(y)) for x, y in points]
        # pre_sort by axis_X
        self.p_list = sorted(p_list, key=attrgetter('real'))

    def closest_pair(self, array, array_length):
        if array_length <= 1:
            return float('inf')
        mid_idx = array_length // 2
        div_line = array[mid_idx].real
        d_min = min(self.closest_pair(array[:mid_idx], mid_idx),
                    self.closest_pair(array[mid_idx:], array_length - mid_idx))

        # sort array_part by axis_Y while recursively comparing
        array.sort(key=attrgetter('imag'))

        min_stack = list()
        for ele in array:
            size = len(min_stack)

            # eliminate p which distance(p,div_line) >= d
            if abs(ele.real - div_line) >= d_min:
                continue

            for j in range(size):
                alt = ele - min_stack[size - j - 1]
                if alt.imag >= d_min:
                    break
                d_min = min(d_min, abs(alt))

            min_stack.append(ele)

        return d_min

    def solve(self):
        return self.closest_pair(array=self.p_list, array_length=self.p_num)


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    case = ClosestPair(in_data=_input)
    print('{:.6f}'.format(case.solve()))

Measured memory_bytes: 24300
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  string s, t;
  cin >> s >> t;

  int n = s.length();
  int k = t.length();

  int latest = -1;
  for (int i = 0; i < n - k + 1; i++) {
    bool good = true;
    for (int j = 0; j < k; j++) {
      if (s[i+j] == '?') continue;
      else if (s[i+j] != t[j]) {
        good = false;
        break;
      }
    }
    if (good) latest = i;
  }

  if (latest == -1) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  for (int i = 0; i < k; i++) {
    s[latest+i] = t[i];
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == '?') s[i] = 'a';
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll x,a;
  cin >> x >> a;
  if(x<a){
    cout << 0;
  } else {
    cout << 10;
  }
 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include<tuple>
#define all(c) c.begin(),c.end()
#define pb push_back
#define em emplace_back
#define mp make_pair
#define ll long long int

using namespace std;

typedef vector<ll>vi;
typedef vector<vi>vii;
typedef pair<ll,ll>pi;
typedef tuple<ll,ll,ll>ti;




int main(){
    ios_base::sync_with_stdio(false);
    ll n,l;
    cin>>n>>l;
    vi v(n+1),cost(n+1);

    ll sum=0;
    for(auto i=1;i<=n;i++){
        cost[i]=l+i-1;
        sum+=cost[i];
    }

    ll minn=1e9;    
    for(auto i=1;i<=n;i++){
        minn=min(minn,abs(sum-(sum-cost[i])));
    }
    
//    cout<<minn<<" "<<sum<<endl;
    if ((sum<0 and minn>0 )or (minn<0 and sum>0)){
        sum=-abs(abs(sum)-abs(minn));
        cout<<sum<<endl;
    }
    else{
        cout<<sum-minn<<endl;
    }
    
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
   public static void main(String[] args) {  
      Scanner sc = new Scanner(System.in);
      int R = sc.nextInt();
      if(R < 1200)
         System.out.println("ABC");
      else if(R < 2800) 
         System.out.println("ARC");
      else 
         System.out.println("AGC");
   }
}

Measured memory_bytes: 21716
#include <stdio.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>

#define REP(i, n) for((i) = 0; (i) < (n); (i)++)
#define READ1(n1) scanf("%d", &(n1))
#define READ2(n1, n2) scanf("%d%d", &(n1), &(n2))
#define READ3(n1, n2, n3) scanf("%d%d%d", &(n1), &(n2), &(n3))
#define P1(n1) printf("%d\n", (n1))
#define P2(n1, n2) printf("%d, %d\n", (n1), (n2))
#define P3(n1, n2, n3) printf("%d, %d, %d\n", (n1), (n2), (n3))
typedef struct {
	int x, y;
	int flag;
} gem_t;

gem_t gems[20];
int gem_num;
int robot_x = 10, robot_y = 10, rest_gem;

void check_gem(int x, int y) {
	int i;
	REP(i, gem_num) {
		if(gems[i].x == x && gems[i].y == y && gems[i].flag == 0) {
			gems[i].flag = 1;
			rest_gem--;
		}
	}
}

void move_robot(int new_x, int new_y) {
	int delta = (robot_x < new_x) ? 1 : -1;

	for(; robot_x != new_x; robot_x += delta) {
		check_gem(robot_x, robot_y);
	}

	delta = (robot_y < new_y) ? 1 : -1;

	for(; robot_y != new_y; robot_y += delta) {
		check_gem(robot_x, robot_y);
	}

	check_gem(robot_x, robot_y);
}

int main(void)
{
	while(1) {
		int i, j, order_num;

		READ1(gem_num);

		if(gem_num == 0) break;

		rest_gem = gem_num;
		robot_x = 10;
		robot_y = 10;

		REP(i, gem_num) {
			READ2(gems[i].x, gems[i].y);
			gems[i].flag = 0;
		}

		READ1(order_num);

		for(i = 0; i < order_num;) {
			char c = getchar();
			if(c == 'N' || c == 'E' || c == 'W' || c == 'S') {
				int d;
				READ1(d);
				switch(c) {
				case 'N':
					move_robot(robot_x, robot_y + d);
					break;
				case 'E':
					move_robot(robot_x + d, robot_y);
					break;
				case 'W':
					move_robot(robot_x - d, robot_y);
					break;
				case 'S':
					move_robot(robot_x, robot_y - d);
					break;
				}
				i++;
			}
		}

		if(rest_gem == 0) {
			printf("Yes\n");
		} else {
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	ll w,h,x,y;
	cin >> w >> h >> x >> y;

	cout << w*h/2.0 << ' ' << (w%2 == 0 && h%2 == 0 && x == w/2 && y == h/2 ? 1 : 0) << endl;

	return 0;
}


Measured memory_bytes: 256
import sys

n, k = map(int, input().split())
D = [int(x) for x in input().split()]


def dfs(s: str, m: int) -> None:
    if s != "" and int(s) >= n:
        print(s)
        sys.exit()

    if len(s) == m:
        return

    for i in range(10):
        if i not in D:
            dfs(str(i) + s, m)


for i in range(sys.maxsize):
    dfs("", i)


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
 
inline double heron(double a, double b, double c){
    double s = (a + b + c) / 2;
    return sqrt(s * (s-a) * (s-b) * (s-c));
}
 
int N;
ll K;
double d[200001];
 
inline double g(int i, int j, int k) {
    double a = d[j - i], b = d[k - j], c = d[k - i];
    return heron(a, b, c);
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin >> N >> K) {
        rep(i, N) {
            double w = 2 * M_PI * i / N;
            double x = cos(w), y = sin(w);
            d[i] = hypot(x - 1, y);
        }
 
        double l = 0, r = 2, m;
        rep(i_, 35) {
            m = (l + r) / 2;
            ll z = 0;
            for(int i = 1; i < N - 1; ++i) {
                int j = (N + i) / 2;
                int L = i + 1, R = j + 1, M;
                if(g(0, i, i+1) > m) continue;
                while(R - L > 1) {
                    M = (L + R) / 2;
                    (g(0, i, M) <= m ? L : R) = M;
                }
                if(L == j)z += (ll)(N - i - 1)*i;
                else z += 2 * (L - i)*i;
            }
            (z >= K ? r : l) = m;
        }
        cout << setprecision(20) << l << endl;
    }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int x, y;
	cin >> x >> y;
	if ((4 * x - y) % 2 == 0 and (4 * x - y) / 2 >= 0 and (4 * x - y) / 2 <= x)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<set>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#include<vector>
#include <type_traits>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
	arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
	for (auto& i : arr) {
		fill_all(i, v);
	}
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}
#define yo 100001
typedef pair<double, double> dop;
//------------------変数-----------------------//
ll n, m, a[100010], cnt = 0;
string str;
//-------------------関数----------------------//


int main() {
	cin >> str;
	if (str.substr(0, 4) == "YAKI") { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}

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

using namespace std;
const int N = 1e5+5;
bool dp[N];
int v[105];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    for (int i = 1; i<=n; i++)
        cin >> v[i];
    for (int pile = 0; pile<=k; pile++)
        for (int i = 1; i<=n; i++)
            if (pile>=v[i] && !dp[pile-v[i]])
                dp[pile] = true;
    if (dp[k])
        cout << "First";
    else
        cout << "Second";
}


Measured memory_bytes: 384
import           Data.List
import           Control.Applicative
import           Control.Monad
import           Control.Monad.State

prcs :: IO (String, Int)
prcs = do
  (nm : tm : _) <- words <$> getLine
  return (nm, read tm)

ex
  :: Int
  -> Int
  -> [(String, Int)]
  -> State ([String], [(String, Int)]) [(String, Int)]
ex q tms [] = do
  (rs, ts) <- get
  case ts of
    [] -> return []
    _  -> do
      put (rs, [])
      ex q tms (reverse ts)
ex q tms ((nm, tm) : ts)
  | q < tm = do
    (rs, sts) <- get
    put (rs, (nm, tm - q) : sts)
    ex q (tms + q) ts
  | otherwise = do
    (rs, sts) <- get
    put ((nm ++ " " ++ show (tms + tm)) : rs, sts)
    ex q (tms + tm) ts

main = do
  (n : q : _) <- map read . words <$> getLine
  ts          <- replicateM n prcs
  mapM_ putStrLn (reverse $ fst $ execState (ex q 0 ts) ([], []))



Measured memory_bytes: 54236
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL K;
std::vector<LL>ans;

LL f(LL n)
{
	LL res = 0;
	while (n > 0)
	{
		res += n % 10;
		n /= 10;
	}
	return res;
}

int main()
{
	in >> K;
	for (LL i = 0; i <= 50; ++i)
	{
		for (LL j = 1; j <= 500; ++j)
		{
			if (i == 0 && j == 1) continue;
			LL tmp = j * pow(10LL, i);
			--tmp;
			ans.push_back(tmp);
		}
	}
	std::sort(ans.begin(), ans.end());
	ans.erase(std::unique(ans.begin(), ans.end()), ans.end());
	rep(i, ans.size())
	{
		for (int j = i + 1; j < ans.size(); ++j)
		{
			if ((long double)ans[i] / f(ans[i]) > (long double)ans[j] / f(ans[j]))
			{
				ans.erase(ans.begin() + i);
				--i;
				break;
			}
		}
	}
	rep(i, K) out << ans[i] << std::endl;
	return 0;
}


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

int main(){

    int A, B;
    int ans = 0;
    cin >> A >> B;
    
    for(int i = A; i <= B; i++){
        
        bool b = true;
        string str_A = to_string(i);        

        for(int j = 0; j < str_A.size()/2; j++){
            if(str_A[j] != str_A[str_A.size()-(1+j)]){
                b = false;
                break;
            }
        }
        if(b) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    public static void main(String[] args){
     Scanner scan = new Scanner(System.in);
     int[] x = new int[3];
     x[0] = scan.nextInt();
     x[1] = scan.nextInt();
     x[2] = scan.nextInt();
     Arrays.sort(x);
     System.out.println(x[0]+" "+x[1]+" "+x[2]);
    }
}


Measured memory_bytes: 26372
from operator import itemgetter
pres = []
numbers = []
N,M = map(int, input().split())

for i in range(M):
    numbers.append('')

for i in range(N):
    pres.append([])

i = 0
for t in range(M):
    p,y = map(int,input().split())
    pres[p-1].append((y,i))
    i+=1

i = 0
for p in pres:
    i+=1
    if p==[]:
        continue
    front = '00000' + str(i)
    front = front[-6:]
    temp_p = p
    temp_p.sort(key=itemgetter(0))
    j = 0
    for city in temp_p:
        j+=1
        back = '00000' + str(j)
        back = back[-6:]
        numbers[city[1]] = front+back
        
for num in numbers:
    print(num)


Measured memory_bytes: 35936
s = input().rstrip()
s_len = len(s)
flag = 0
for i in range(s_len):
  if i%2==0:
    if s[i]=="L":
      flag = -1
  else:
    if s[i]=="R":
      flag = -1
if flag == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (ll i = (int)(s); i < (int)(n); i++)
#define repp(i,n,s) for (ll i= (int)(n); i >= (int)(s); i--)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,x,m;cin>>n>>x>>m;
    vector<ll> a(m);
    rep(i,0,m){
        a[i] = i*i%m;
    }
    vector<ll> b(m+100),c;
    ll ans = 0;
    ll j = 0;
    while (true){
        if (b[x]==1 || j>=n) break;
        b[x] = 1;
        ans += x;
        c.push_back(x);
        x = a[x];
        j++;
    }

    if (j<n){
        int index = 0;
        rep(i,0,c.size()){
            if (c[i]==x){
                index = i;
                break;
            }
        }
        ll size = c.size()-index;
        rep(i,index,c.size()){
            if ((n-i-size)%size==0){
                ans += c[i]*((n-i-size)/size);
            }else{
                ans += c[i]*((n-i-size)/size+1);
            }
        }
    }
    
    cout<<ans<<endl;
}

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

int main()
{
	string s;
	cin>>s;
	int hugs=0;
	for(int i=0;i<s.length()/2;i++)
		
		if(s[i]!=s[s.length()-1-i])
			hugs++;
 cout<<hugs;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b;
bool flag=true;
int main() {
    string A;
    cin>>a>>b>>A;
    
    for(int i=0;i<a;i++)
    {
        if(A[i]>'9'||A[i]<'0')
        {
            flag=false;
        }
    }
    if(A[a]!='-')
    {
        flag=false;
    }
    for(int i=a+1;i<a+1+b;i++)
    {
        if(A[i]>'9'||A[i]<'0')
        {
            flag=false;
        }
    }
    if(flag==false)
    {
        printf("No");

    }
    else
    {
        printf("Yes");
    }
}
    
    
    
       


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

vector<int> to[200005];
vector<int> ans;
void dfs(int v,int p=-1){        //各頂点において親が一つに定まる木の場合はこれで書ける。vは現在の点でpはvの親。
    for(int u : to[v]){
        if(u == p) continue;
        ans[u] += ans[v];
        dfs(u,v);
    }
}

int main(){
    int n,q;
    cin >> n >> q;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    rep(i,q){
        int p,x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    dfs(0);
    rep(i,n){
        cout << ans[i] << " " ;
    }
    cout << endl;
}

Measured memory_bytes: 24268
S=list(map(int,input()))
s=len(S)
if s==1:
    print(S[0])
else:

    s=s-1
    t=pow(2,s)
    l=len(list(format(t-1,'b')))
    x=0
    for i in range(t):
        k=list(format(i,'b'))
        L=[0]*l
        x+=S[-1]
        v=1
        for i in range(l):
            if i+1<=len(k):
                L[l-i-1]=k[-1-i]
            if int(L[l-i-1])==0:
                v=v*10
                x+=v*S[len(S)-2-i]
            else:
                v=1
                x+=S[len(S)-2-i]
    print(x)

        
        




Measured memory_bytes: 40560
require 'pp'
require 'set'
require 'prime'

a,b,c,d = gets.chomp!.split(" ").map(&:to_i)

# cとdの最小公倍数
c_p = Prime.prime_division(c).to_h
d_p = Prime.prime_division(d).to_h

koubai = {1 => 1}
c_p.each do |v, c|
    if d_p[v] != nil
        s = [c, d_p[v]].max
        koubai[v] = s 
    else
        koubai[v] = c
    end

    d_p.delete(v)
end

koubai = koubai.merge(d_p)
min_koubai = 1
koubai.each do |k, v|
    min_koubai *= (k ** v)
end

# c の倍数
x = a / c
y = b / c
c_c = y - x + (a % c == 0 ? 1 : 0)

# d の倍数
x = a / d
y = b / d
d_c = y - x + (a % d == 0 ? 1 : 0)

# c*d の倍数の倍数
x = a / min_koubai
y = b / min_koubai
min_c = y - x + (a % min_koubai == 0 ? 1 : 0)

sum = b - a + 1
#puts sum
#puts c_c
#puts d_c
#puts min_c
puts sum - c_c - d_c + min_c


Measured memory_bytes: 2684
n,m = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
i = ar.index(1)
if n <= m:
    print(1)
    exit()
count = 0
am = 0
count += i // (m - 1)
am += i % (m - 1)
count += (n - 1 - i) // (m - 1)
am += (n - 1 - i) % (m - 1)
if am <= m - 1 and am > 0:
    count += 1
if am > m - 1:
    count += 2
print(count)

Measured memory_bytes: 20636