akhauriyash/Code-Regression huggingface dataset:
def main():
    a, b = map(int, input().split())

    h = 0
    ans = 0
    for i in range(1, 1000):
        h += i

        if h > b:
            b_h = h - b
            if a_h == b_h:
                ans = b_h
                break
        if h > a:
            a_h = h - a

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
N = int(input())
H = list(map(int, input().split()))
dp = [10 ** 9] * N
dp[0] = 0

for i in range(N):
  if i + 1 < N: dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]))
  if i + 2 < N: dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]))

print(dp[-1])


Measured memory_bytes: 13924
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define MAXN 100005
#define endl "\n"
#define readln(x) getline(cin, x);
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
ll fpow(ll x, ll n, ll mod){if (n==0) return 1%mod; ll u = fpow(x, n/2, mod); u = (u*u)%mod; if (n%2==1)u = (u*x)%mod;return u;}
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

int N, a[MAXN],b[MAXN],c[MAXN], dp[MAXN][4], curr = -1;
int main(){
    //freopen("data.txt","r",stdin);
    cin >> N;
    for (int i = 1; i<=N; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[1][1] = a[1], dp[1][2] = b[1], dp[1][3] = c[1];
    for (int i = 2; i<=N; i++){
        dp[i][1] = max(dp[i-1][2], dp[i-1][3])+a[i];
        dp[i][2] = max(dp[i-1][1], dp[i-1][3])+b[i];
        dp[i][3] = max(dp[i-1][1], dp[i-1][2])+c[i];
    }
    cout << max(dp[N][1], max(dp[N][2], dp[N][3])) << endl;
    return 0;
}

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

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

    vector<int> A(M);
    for (auto &&i : A)
        cin >> i;

    int sum = 0;
    for (int i = 0; i < A.size(); ++i)
        sum += A.at(i);

    int answer = N - sum;
    if (N - sum < 0)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << answer << endl;
    }
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

ll N, ans;

int main()
{
	fast();
	cin >> N;
	for (ll i = 2, M = N; i * i <= M; i++)
	{
		ll z = i;
		while (N % z == 0)
			ans++, N /= z, z *= i;
		while (N % i == 0)
			N /= i;
	}

	cout << ans + (N != 1) << "\n";
}

Measured memory_bytes: 3656
#include<cstdio>
#include<vector>
using namespace std;

int main(){
  int n;
  scanf("%d", &n);
  vector<int> v(n);
  for(int i = 0; i < n; i++){
    int p;
    scanf("%d", &p);
    v[i] = p;
  }
  int count = 0;
  for(int i = 0; i < n; i++){
    if (i+1 != v[i]) count++;
  }

  bool ans = false;
  if (count == 0 || count == 2) ans = true;

  if (ans) printf("YES\n");
  else printf("NO\n");

  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second


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

int a[55];

int main(){
	while(1){
		int n,m,tmp,i=0;
		cin>>n>>m;
		tmp=m;
		if(n==0)return 0;
		memset(a, 0, sizeof(a));
		while(1){
			if(tmp>0){
				a[i]++;
				tmp--;
				if(a[i]==m){
					cout<<i<<endl;
					break;
				}
			}else{
				tmp=a[i];
				a[i]=0;
			}
			i++;
			if(i==n)i=0;
		}
	}
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long int ll;

int main(){
	ll n,a,b;

	cin >> n >> a >> b;

	ll diff = b-a;

	ll ans;

	if (diff % 2 == 0){
		cout << diff /2 << '\n';
	} else {
		ll temp1 = n-b;
		ll temp2 = a-1;

		if (temp1 < temp2){
			cout << temp1 + 1 + (b-a-1)/2 << '\n';
		} else {
			cout << temp2 + 1 + (b-a-1)/2 << '\n';
		}
	}
}

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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<string, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  vector<P> vec(n), sorted(n);
  rep(i, n) {
    string s; cin >> s;
    int p; cin >> p;
    vec[i] = sorted[i] = P(s, -p);
  }
  sort(sorted.begin(), sorted.end());
  rep(i, n) {
    rep(j, n) {
      if (sorted[i] == vec[j]) {
        cout << j+1 << '\n';
      }
    }
  }
}

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

#define sync {ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define ll long long int
#define mod 1000000007

int n,x,k;

void solve()
{
    cin>>n>>x>>k;
    int y = ceil(n/double(x));
    cout<<y*k;
}

int main()
{
    sync;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}







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

int main(){
    double pai=3.141592653589;
    double r;
    scanf("%lf",&r);
    printf("%.8lf %.8lf\n",r*r*pai,r*2*pai);
    return 0;
}


Measured memory_bytes: 3204
# coding: utf-8
import re
import bisect
from datetime import datetime as dt
import math

def gcd(a, b):
    return math.gcd(a, b)

def lcm(a, b):
    return a * b // gcd(a, b)

if __name__ == '__main__':
    a, b, c, d = map(int, input().split())
    ans = ''
    ans += 'R'*(c-a)
    ans += 'U'*(d-b)
    ans += 'L'*(c-a)
    ans += 'D'*(d-b)
    ans += 'D'
    ans += 'R'*(c-a+1)
    ans += 'U'*(d-b+1)
    ans += 'L'
    ans += 'U'
    ans += 'L'*(c-a+1)
    ans += 'D'*(d-b+1)
    ans += 'R' 
    print(ans)

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

int main() {
  ll n, c, k;
  cin >> n >> c >> k;
  vector<ll> t(n + 1);
  for (int i = 0; i < n; i++) cin >> t[i];
  t[n] = 3 * 1e9;
  sort(t.begin(), t.end());

  ll ans = 0;
  ll first = t[0];
  ll num = 1;
  for (int i = 1; i <= n; i++) {
    num++;
    if (num > c || t[i] - first > k) {
      num = 1;
      first = t[i];
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3960
// Last Change: 08/10/2019 22:51:13.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N, M;
  cin >> N >> M;

  vector<priority_queue<ll>> work(M + 1);
  priority_queue<pair<ll, ll>> cur;

  ll A, B;
  for (ll i = 0; i < N; ++i) {
    cin >> A >> B;
    if (A <= M) {
      work[A].push(B);
    }
  }

  ll ans = 0;
  for (ll i = 1; i <= M; ++i) {
    if (cur.empty() and work[i].empty()) {
      continue;
    }

    if (cur.empty()) {
      ans += work[i].top();
      work[i].pop();
      if (!work[i].empty()) {
        cur.push(make_pair(work[i].top(), i));
      }
      continue;
    }

    if (work[i].empty()) {
      ll pos = cur.top().second;
      ans += cur.top().first;
      cur.pop();
      work[pos].pop();
      if (!work[pos].empty()) {
        cur.push(make_pair(work[pos].top(), pos));
      }
      continue;
    }

    if (cur.top().first < work[i].top()) {
      ans += work[i].top();
      work[i].pop();
    } else {
      ll pos = cur.top().second;
      ans += cur.top().first;
      cur.pop();
      work[pos].pop();
      if (!work[pos].empty()) {
        cur.push(make_pair(work[pos].top(), pos));
      }
    }
    if (!work[i].empty()) {
      cur.push(make_pair(work[i].top(), i));
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 6400
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 200005

using namespace std;
typedef long long int ll;

vector <ll> vec;
ll add[SIZE];
ll ans[SIZE];

int main()
{
	int n,q;
	scanf("%d %d",&n,&q);
	vec.push_back(n);
	ll mn=n;
	for(int i=0;i<q;i++)
	{
		ll l;
		scanf("%lld",&l);
		mn=min(mn,l);
		while(!vec.empty()&&vec[vec.size()-1]>=l) vec.pop_back();
		vec.push_back(l);
	}
	//vec : 単調増加
	//for(int i=0;i<vec.size();i++) printf("%lld ",vec[i]);puts("");
	add[vec.size()-1]=1;
	for(int i=vec.size()-1;i>=1;i--)
	{
		//printf("* %lld\n",add[i]);
		ll now=vec[i];
		while(now>mn)
		{
			int to=lower_bound(vec.begin(),vec.end(),now)-vec.begin()-1;
			add[to]+=add[i]*(now/vec[to]);
			now%=vec[to];
		}
		//printf("%lld\n",now);
		ans[now]+=add[i];
	}
	ans[vec[0]]+=add[0];
	for(int i=n-1;i>=1;i--) ans[i]+=ans[i+1];
	for(int i=1;i<=n;i++) printf("%lld\n",ans[i]);
	return 0;
}


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

int main(){
  int i,j,c,n,a[100001],ans,ch[100001];
  while(1){
    cin >> n;
    if(n == 0) break;
    ans = 0;
    cin >> a[1];
    if(!a[1]) ans++;

    c = 0;

    for(i=2;i<=n;i++){
      cin >> a[i];
      if(!a[i]) ans++;

      if(i % 2 == 0 && a[i] != a[i-1]){
	if(c < 2){
	  if(a[i]) ans = 0;
	  else ans = i;
	}
	else{
	  if(a[i]) ans -= i - ch[c-1];
	  else ans += i - ch[c-1];
	  c--;
	}
      }
      
      else if(a[i] != a[i-1]) ch[c++] = i;
      
    }
    
    cout << ans << endl;
    
  }
  return 0;
}

/*
	for(j=i-1;j>=0;j--){
	  if(a[i] == a[j]) break;
	  a[j] = a[i];
	  if(a[j]) ans--;
	  else ans++;
	}
 */

Measured memory_bytes: 1176
import numpy as np
n = int(input())
a = []
b = []
for i in range(n):
    ai, bi =map(int, input().split())
    a.append(ai)
    b.append(bi)
a = np.array(a)
b = np.array(b)
i = np.argsort(b)
print('Yes') if (np.cumsum(a[i]) <= b[i]).all() else print('No')

Measured memory_bytes: 28168
import sys
#import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
s = list(rs()+"R")
cnt=0
ans=[0]*(len(s)-1)
for i in range(len(s)-1):
    cnt+=1
    if s[i]=="R" and s[i+1]=="L":
        ans[i]+=cnt-(cnt//2)
        ans[i+1]+=cnt//2
        cnt=0
        hook=i
        continue
    if s[i]=="L" and s[i+1]=="R":
        ans[hook]+=cnt//2
        ans[hook+1]+=cnt-(cnt//2)
        cnt=0
        continue
print(*ans)


Measured memory_bytes: 83812
#include <bits/stdc++.h>
            #define ll long long
            #define MOD 1000000007
            #define maxx ((ll)1e6+5)
            #define zuciso ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define test ll t; cin>>t; while(t--)
            #define int long long
            #define INF 1000000000000000005
            #define pb push_back
            #define pi 3.1415926
            #define MAX 300006
            #define MAX_N 1000000
            #define N 15000005
            #define fori(i,a,b) for(int i=a;i<b;i++)
            ll fpow(ll x,ll y,ll p=MOD){x=x%p;ll sum=1;while(y){if(y&1)sum=sum*x;sum%=p;y=y>>1;x=x*x;x%=p;}return sum;}
            ll fact[1000007]={0};
            void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%MOD;}
            ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(fpow(fact[r],MOD-2)))%MOD; res=(res*(fpow(fact[n-r],MOD-2)))%MOD; return res;}
            ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(fpow(fact[n-r],MOD-2)))%MOD; return res;}
            ll modmul(ll x, ll y){return (x*y)%MOD;}
            ll modadd(ll x, ll y){return (x+y)%MOD;}
            ll modsub(ll x, ll y){return (x-y+MOD)%MOD;}
            ll xx[4]={1,0,-1,0};
            ll yy[4]={0,1,0,-1};
           using namespace std;



            signed main(){
                zuciso;
                int x,y;
                cin>>x>>y;
                if(y%2==1){
                        
                        cout<<"No"<<endl;
                return 0;}
                
                int y1=y/2-x;
                int x1=x-y1;
                if(y1>=0 && x1>=0 && !(y1==0 && x1==0)){
                    cout<<"Yes"<<endl;
                }
                else{
                    cout<<"No"<<endl;
                }


            }


Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main()
{
  int n,m,e,i;
  e=0;
  cin>>n>>m;
  int a[n];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
    if(a[i]>=m)
      e++;
  }
  cout<<e;
  return 0;
}
    

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define oo 0x3f3f3f3f
#define ooll 0x3f3f3f3f3f3f3f3f
typedef long long ll;
int main(){
    int n, s;
    cin >> n >> s;
    int weight[n+1], price[n+1];
    int sum = 0;
    for(int i = 0; i < n ; ++i){
         cin >> weight[i] >> price[i];
         sum+=price[i];
    }
    vector<ll> dp(sum+1, ooll);
    dp[0] = 0LL;
    for(int i = 0; i < n ; ++i){
        for(int j = sum-price[i] ; j >= 0 ; --j){
            dp[j+price[i]] = min(dp[j+price[i]], dp[j]+weight[i]);
        }
    }

    ll ans = 0;
    for(int i = 0; i <= sum ; ++i){
        if(dp[i] <= s) ans = max(ans, (ll)i);
    }

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

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys


def solve(P: int, Q: int, R: int):
    print(min(P+Q, Q+R, P+R))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    P = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(P, Q, R)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>

#pragma warning(disable:4996)
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;

using namespace std;

struct point{
	Int j, i,step;
	point(Int i_, Int j_,Int s) :i(i_), j(j_),step(s){}
};

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

queue<point> que;
char tile[1001][1001];
int H, W;
bool ed[1001][1001];

point solve(char target)
{
	while (!que.empty()){
		point now(que.front());
		//ed[now.i][now.j] = true;
		que.pop();
		REP(i, 4){
			int x = now.j + dx[i];
			int y = now.i + dy[i];

			if (x < 0 || y < 0 || x > W || y > H || ed[y][x])
				continue;

			if (tile[y][x] == target){
				return point(y, x,now.step+1);
			}

			if (tile[y][x] != 'X'){
				que.push(point(y, x, now.step + 1));
				ed[y][x] = true;
			}
		}
	}
}

int main()
{
	cin.tie(0); ios::sync_with_stdio(false);
	//fstream fs("input.txt");
	////////////ここから開始///////////
	int n(0);
	cin >> H >> W >> n;

	REP(i, 1001)REP(j, 1001){ tile[i][j] = 'X'; ed[i][j] = false; }

	REP(i, H)REP(j, W)cin >> tile[i][j];

	REP(i, H)REP(j, W){ if (tile[i][j] == 'S')que.emplace(i, j, 0); }

	int ans(0);
	for (int i = 0; i < n; ++i){
		REP(i_1, H + 1)REP(j_1, W + 1){ ed[i_1][j_1] = false; }
		point t = solve('1' + i);
		que = {};
		que.emplace(t);
		ans = que.front().step;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const long long inf = 1LL << 22;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	vector<int>sum(n);
	rep(i, m) {
		int a, b; cin >> a >> b;
		sum[a - 1]++; sum[b - 1]++;
	}
	rep(i, n)cout << sum[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int gcd(int x,int y){
    if(x < y){
        int tmp = x;
        x = y;
        y = tmp;
    }
    while(y > 0){
        int r = x % y;
        x = y;
        y = r;
    }
    return x;
}
main(){
    int A[100000];
    int N,K;
    scanf("%d%d",&N,&K);
    for(int i = 0;i < N;i++){
        scanf("%d",&A[i]);
    }
    std::sort(A,A+N);
    int mindif = 1000000000;
    int max = A[N-1];
    for(int i = 0;i < N-1;i++){
        int g = gcd(A[i],A[i+1]);
        mindif = std::min(mindif,g);
    }
    if(max < K){
        printf("IMPOSSIBLE\n");
        return 0;
    }
    for(int i = N-1;i >= 0;i--){
        if(A[i]<K)break;
        if((A[i]-K)%mindif==0){
            printf("POSSIBLE\n");
            return 0;
        }
    }
    printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 640
MOD = 10**9+7
MAX = 2010
N, K = [int(s) for s in input().split()]
fac = [1, 1]
finv = [1, 1]
inv = [0, 1]
for i in range(2, MAX):
  fac.append(fac[i - 1] * i % MOD)
  inv.append(MOD - inv[MOD % i] * (MOD // i) % MOD)
  finv.append(finv[i - 1] * inv[i] % MOD)

def COM(n, k):
  if n < k: 
    return 0
  if n < 0 or k < 0:
    return 0
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

ans = []
for i in range(1, K+1):
  if i <= min(K,N-K+1):
    blue = COM(K-1,i-1)
    red = COM(N-K+1,i)
    both = blue*red%MOD
    print(both)
  else:
    print(0)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll mod = 1e9+7;

ll N, M;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(0);
	cin >> N >> M;

	ll ans = 1;
	for (int i=1; i<=N; i++) ans = ans * i%mod;
	for (int i=1; i<=M; i++) ans = ans * i%mod;

	if (abs(N-M) == 1) cout << ans;
	else if (N == M) cout << 2 * ans%mod;
	else cout << 0;

}

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

using namespace std;
#define ll long long
const int mod=1e9+7;
const int N=2e5+100;

int a[N];
int n;
ll qpow(ll x,ll n)
{
    ll sum=1;
    while(n){
       if(n&1) sum=sum*x%mod;
       x=x*x%mod;
       n>>=1;
    }
    return sum;
}

int main()
{
    ios::sync_with_stdio(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    ll sum=0;
    for(int i=1;i<n;i++){
        if(a[i]>a[i+1]){
            sum+=a[i]-a[i+1];
            a[i+1]=a[i];
        }
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 4424
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return(false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return(true);
  }

  int find(int k)
  {
    if(data[k] < 0) return(k);
    return(data[k] = find(data[k]));
  }

  int size(int k)
  {
    return(-data[find(k)]);
  }

  bool same(int x, int y)
  {
      return find(x) == find(y);
  }
};

int main()
{
    int N, Y;
    cin >> N >> Y;
    for (int i = 0; i <= N; ++i)
    {
        for(int j = 0; i + j <= N; ++j)
        {
            int k = N - (i + j);
            if (10000 * i + 5000 * j + 1000 * k == Y)
            {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long long
using namespace std;

signed main() {
 	string S;
 	cin >> S;
 	bool A = true;
 	for(int i = 0;i < 3;i++) {
 		if(S.at(i) == S.at(i + 1)) {
 			A = false;
 		}
 	}
 	if(A == false) {
 		cout << "Bad" << endl;
 	}
 	else {
 		cout << "Good" << endl;
 	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = sc.nextInt();
		}
		int min = 1000000;
		for(int t = -101;t<=101;t++) {
			int sum =0;
			for(int i=0;i<n;i++) {
				sum+=(t-a[i])*(t-a[i]);
			}
			min = Math.min(min,sum);
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 35828
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n;
string ans;
char mx='a';
void dfs(int x)
{
	if(x==n+1)
	{
		cout<<ans<<endl;
		return;
	}
	for(char c='a';c<=mx;c++)
	{
		string t=ans;
		ans+=c;
		dfs(x+1);
		ans=t;
	}
	if(x!=1&&mx<'z')
	{
		mx++;
		string t=ans;
		ans+=mx;
		dfs(x+1);
		ans=t;
		mx--;
	}
}
signed main()
{
	//freopen(".in","r",stdin);
//	freopen("f.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	dfs(1);
	return 0;
}


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

using namespace std;

typedef long long ll;

#define for(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define sz(x)        ((int)(x).size())
#define inf          1<<25

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

//typedef vector<int> vi;
//typedef vector<long long> vl;
//typedef vector<double> vd;
//typedef pair<int,int> pii;
//typedef pair<long,long> pll;
//typedef long long ll;

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

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

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

S = inputS()

l = ["dream","dreamer","erase","eraser"]

while S:
  flag = 0
  for i in range(4):
    word = l[i]
    if S[-len(word):] == word:
      S = S[:-len(word)]
      flag = 1
  if flag == 0:
    print("NO")
    exit()

print("YES")


Measured memory_bytes: 144380
from collections import Counter,defaultdict
n=int(input())
s=[input() for i in range(n)]

dict=defaultdict(lambda:60) #|S|<=50
sum_set=set(s[0])

for i in range(n):
    cnter=Counter(s[i])
    chset=set(s[i])
    for item in chset:
        dict[item]=min(dict[item],cnter[item])

    sum_set=sum_set & chset

ans=[]
for item in sum_set:
    for i in range(dict[item]):
        ans.append(item)

ans.sort()
print(*ans,sep="")

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

#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define VPII vector<PII>
#define LD long double

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(11);
    cerr << fixed << setprecision(6);

    int d,t,s;
    cin >> d >> t >> s;
    
    if((((d%s) == 0) ? (d/s) : ((d+(s-(d%s)))/s)) > t){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<uint> vuint;
typedef vector<ull> vull;
typedef vector<ll> vll;

#define init(type,var) type var;cin>>var;
#define vinit(type,var,n) vector<type> var((uint)n);rep(i,0,n)cin>>var[i];
#define linit(type,var,n) list<type> var;rep(i,0,n){type _v;cin>>_v;var.push_back(_v);}
#define range(container) container.begin(),container.end()
#define rep(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(out) cout<<(out)<<endl;

const ull INF = (ull)(-1LL);

typedef ull ntype;

typedef vector<ntype> vntype;
typedef list<ntype> lntype;

int main(void)
{
	init(ntype, s);
	init(ntype, w);

	outl(w>=s?"unsafe":"safe");

	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a * b > c * d)
    cout << a * b;
  if(a * b < c * d)
    cout << c * d;
  if(a * b == c * d)
    cout << a * b;
  return 0;
}

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


main() {
  int N, M; cin >> N >> M;
  vll a(N), b(N); rep(i, N) cin >> a[i] >> b[i];
  vll c(M), d(M); rep(j, M) cin >> c[j] >> d[j];

  vi pos(N);
  rep(i, N) {
    ll dist;
    rep(j, M) {
      ll dist_j = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (j == 0) {
        dist = dist_j;
        pos[i] = j + 1;
        continue;
      }
      if (dist_j < dist) {
        dist = dist_j;
        pos[i] = j + 1;
      }
    }
    cout << pos[i] << endl;
  }
}

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

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

vector<vector<int>> Q(N, vector<int>(2));
for(int i=0;i<N;i++){
  int l,r;
  cin>>l>>r;
  Q[i][0]=l;
  Q[i][1]=r;
}

// 左側の順にソート
sort(Q.begin(),Q.end());

vector<int> A(N), B(N);
// A→１回目のコンテストの右側
// A[i]→i個目まで１回目のコンテストで出題
A[0] = Q[0][1];
for(int i=1;i<N;i++){
  A[i]= min(A[i-1],Q[i][1]);
}
// B→２回目のコンテストの右側
// B[i]→i個目まで１回目のコンテストで出題
B[N-1]=Q[N-1][1];
for(int i=N-2;i>=0;i--){
  B[i]= min(B[i+1],Q[i][1]);
}


int ans=0;

for(int i=0;i<N-1;i++){
  //cout<<A[i]<<" "<<Q[i][0]<<" "<<B[i+1]<<" "<<Q[N-1][0]<<endl;;
  ans = max(ans, max(0,A[i]-Q[i][0]+1)+max(0,B[i+1]-Q[N-1][0]+1));
  ans = max(ans, max(0,A[N-1]-Q[N-1][0]+1)+max(0,Q[i][1]-Q[i][0]+1));
//cout<<ans<<endl;
}
cout<<ans<<endl;


}


Measured memory_bytes: 6528
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      k: usize,
      q: usize,
      aa: [i64; q],
    }

    let mut cnt = vec![0; n];
    for a in aa {
        cnt[(a-1) as usize] += 1;
    }
    for i in 0..n {
        let s = (k as i64 - q as i64) as i64 +cnt[i];
        if s > 0 {
            puts!("{}\n", "Yes");
        } else {
            puts!("{}\n", "No");
        }
    }
}


Measured memory_bytes: 6780
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll x,n;
  cin >> x >> n;
  set<ll> st; // unavailable
  rep(i,n) {
    ll v;
    cin >> v;
    st.insert(v);
  }

  ll d = 0;
  while (true) {
    if (st.find(x-d) == st.end()) { // not in st. ok.
      cout << x-d << endl;
      return 0;
    }
    if (st.find(x+d) == st.end()) { // not in st. ok.
      cout << x+d << endl;
      return 0;
    }
    ++d;
  }
}


Measured memory_bytes: 3668
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = list(input().rstrip())
    print(["No", "Yes"][sum(map(int, n))%9==0])
    return


#main
if __name__ == '__main__':
    solve()


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


int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);
    
    int mean;
    if( (a+b)%2 == 0) mean = (a+b)/2;
    else mean = (a+b)/2 +1;

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


    return 0;
} 



Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main()
{
	char s[11],t[11],u[11];
	int a,b,i,len,lan,c,d;
	scanf("%s %s",s,t);
	scanf("%d %d",&a,&b);
	scanf("%s",u);
	len=strlen(s);
	lan=strlen(t);
	c=0;
	d=0;
	for(i=0;i<len;i++){
		if(s[i]==u[i]) c++;
	}
	for(i=0;i<lan;i++){
		if(t[i]==u[i]) d++;
	}
	if(c>=d) a-=1;
	else b-=1;
	printf("%d %d\n",a,b);
	return 0;
}


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

int main() {
  string s1,s2,s3;
  cin >> s1>>s2>>s3;
  cout<<char(s1.at(0)-'a'+'A')<<char(s2.at(0)-'a'+'A')<<char(s3.at(0)-'a'+'A');
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXSIZE 10000000;

bool comp(const pair<int,int> a, const pair<int,int> b) {
    return a.second < b.second;
}

const int MAX = 510000;
const int MOD = 1000000007;


int main(){
    int N,A,B;

    cin >>N>>A>>B;

    cout <<min(B,N*A)<<endl;

    return 0;
}

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;

*/

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//幅優先探索のテンプレ.デフォルトではstartからの距離を返す.
//graphは隣接リスト.startは探索開始地点
vector<int> bfs(vector<vector<int>> &graph, int start){
	queue<int> todo;
	vector<int> dist(graph.size(),-1);
	dist[start] = 0;
	todo.push(start);
	while(!todo.empty()){
		int now = todo.front();
		todo.pop();
		for (int i=0;i<graph[now].size();i++){
			int nxt = graph[now][i];
			if (dist[nxt] != -1) continue;
			dist[nxt] = dist[now] + 1;
			todo.push(nxt);
		}
	}
	return dist;
}

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

	return 0;
}

Measured memory_bytes: 34560
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
#define MAX_M 100
#define MAX_N 100
#define INF (1<<20)

int M,N;
int X1[MAX_M], Y1[MAX_M];
int X2[MAX_N], Z2[MAX_N];

// 多角形をxでスライスしたときの幅を返す
double width(int* X, int* Y, int n, double x) {
    double lb = INF, ub = -INF;
    for(int i=0;i<n;i++) {
        double x1 = X[i], y1 = Y[i], x2 = X[(i + 1) % n], y2 = Y[(i + 1) % n];
        // i番目の辺と交点を持つか調べる
        if ((x1 - x) * (x2 - x) <= 0 && x1 != x2) {
            // 交点の座標を計算
            double y = y1 + (y2 - y1) * (x - x1) / (x2 - x1);
            //double y = y1 + (y2 - y1) * x / (x2 - x1);
            lb = min(lb, y);
            ub = max(ub, y);
        }
    }
    return max(0.0, ub - lb);
}

void solve() {
    int min1 = *min_element(X1, X1 + M), max1 = *max_element(X1, X1 + M);
    int min2 = *min_element(X2, X2 + N), max2 = *max_element(X2, X2 + N);
    vector<int> xs;
    for(int i=0;i<M;i++) xs.push_back(X1[i]);
    for(int i=0;i<N;i++) xs.push_back(X2[i]);
    sort(xs.begin(), xs.end());

    double res = 0;
    for(int i=0;i+1<xs.size();i++) {
        double a = xs[i], b = xs[i+1], c=(a+b)/2;
        // 重なっている
        if(min1 <= c && c <= max1 && min2 <=c && c <= max2) {
            // シンプソンの公式で積分する
            double fa = width(X1, Y1, M, a) * width(X2, Z2, N, a);
            double fb = width(X1, Y1, M, b) * width(X2, Z2, N, b);
            double fc = width(X1, Y1, M, c) * width(X2, Z2, N, c);
            res += (b - a) / 6 * (fa + 4 * fc + fb);
        }
    }
    printf("%.10f\n", res);
}

main() {
    while(scanf("%d %d",&M,&N), M!=0) {
        for(int i=0;i<M;i++) scanf("%d %d",&X1[i], &Y1[i]);
        for(int i=0;i<N;i++) scanf("%d %d", &X2[i] ,&Z2[i]);
        solve();
    }
}

Measured memory_bytes: 1244
//
//  abc148_a.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll INF = 1000000007;
#define PI 3.14159265

const int MAX = 110000;

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

std::vector<int> permutations;

int gcd(int a, int b) {
   if (b == 0)
      return a;
   return gcd(b, a % b);
}

int main() {
  int a, b;
  std::cin >> a >> b;
  std::cout << 6-a-b << std::endl;
  return 0;
}



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

template<class T>
struct disjoint_sparse_table{
  std::vector<std::vector<T>> table;
  size_t sz;
  static size_t msb(size_t c){
  #ifdef __has_builtin
    return 31 - __builtin_clz(c);
  #else
    size_t res = 0;
    if(c>>16)c>>=16,res+=16;
    if(c>>8)c>>=8,res+=8;
    if(c>>4)c>>=4,res+=4;
    if(c>>2)c>>=2,res+=2;
    return res+(c>>1);
  #endif
  }
  T f(T a,T b)const{
    return a<=b?a:b;
  }
  disjoint_sparse_table():table(){}
  disjoint_sparse_table(std::vector<T> const& v):table(){
    table.emplace_back(v);
    const size_t size = table.front().size();
    sz = size;
    for(int i=2;i<size;i<<=1){
      std::vector<T> v;
      v.reserve(size);
      for(int j=i;j<size;j+=i<<1){
        v.emplace_back(table.front()[j-1]);
        for(int k=2;k<=i;++k){
          v.emplace_back(f(table.front()[j-k],v.back()));
        }
        v.emplace_back(table.front()[j]);
        for(int k=1;k<i&&j+k<size;++k){
          v.emplace_back(f(v.back(),table.front()[j+k]));
        }
      }
      table.emplace_back(std::move(v));
    }
  }
  T fold(int a,int b)const{
    assert(a<=b);
    assert(b<sz);
    if(a==b){
      return table.front()[a];
    }
    int p = msb(a^b);
    return f(table[p][a^(static_cast<size_t>(1)<<p)-1],table[p][b]);
  }
  T operator[](int i)const{
    return table.front()[i];
  }
};

signed main(){
  using namespace std;
  int n,l;
  cin>>n>>l;
  vector<int> a(n);
  for(auto& ai:a)cin>>ai;
  disjoint_sparse_table<int> dst(a);
  
  for(int i=0;i<=n-l;++i){
    cout<< dst.fold(i,i+l-1) <<" \n"[i==n-l];
  }

}


Measured memory_bytes: 84992
N, M = map(int, input().split(' '))
number_list = [-1] * N
flag = True
for _ in range(M):
    s, c = map(int, input().split(' '))
    if number_list[s - 1] in [-1, c]:
        number_list[s - 1] = c
    else:
        flag = False
if number_list[0] == 0 and N > 1:
    flag = False
if flag:
    if N > 1 and number_list[0] == -1:
        number_list[0] = 1
    number_list = [x if x != -1 else 0 for x in number_list]
    print(''.join(str(x) for x in number_list))
else:
    print(-1)

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N;
    cin >> N;
    vector<lint> A(N, 0);
    rep(i, N) cin >> A[i];

    rep(i, N) {
        if (A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    lint tmp     = 1;
    const lint x = 1e18;
    rep(i, N) {
        if (A[i] <= x / tmp) {
            tmp *= A[i];
        } else {
            d(A[i]);
            cout << -1 << endl;
            return 0;
        }
    }
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 4052