akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

 int main() {
   int a,b,c;
   cin >> a >> b >> c;
   //cout << a << b << c << endl;
   
   int d;
   
   if(c * c == (a * a) + (b * b)){
     d = (a * b)/2;
   }
   cout << d << endl;
} 

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int x;
  cin>>x;
  int count=0;
  
  while(a>=b){
    count++;
    b=b*2;
    }
   while(b>=c){
     count++;
     c=c*2;
   }
  if(count<=x){
    cout<<"Yes"<<endl;}
   else{
     cout<<"No"<<endl;
   }
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	cin >> N;
	int num = mod;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		if (A < num)  ans++;
		num = min(num, A);
	}
	cout << ans << endl;
}


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

void solve() {
  string s, t;
  cin >> s >> t;
  cout << ((s == t.substr(0, t.size() - 1)) ? "Yes" : "No") << endl;
}

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

Measured memory_bytes: 3616
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)

int max=0;
int n,m,q;
int *a,*b,*c,*d;
void dfs(int depth,int num,int *req){
  if(depth==n){
    int sum=0;
    F(i,0,q){
      if(req[b[i]-1] - req[a[i]-1] == c[i]) sum += d[i];
    }
    if(max<sum) max=sum;
    return;
  }
  req[depth]=num;
  while(num<=m){
    //req[depth]=num;
    dfs(depth+1,num,req);
    num++;
    req[depth]++;
  }  
}

int main(){
  scanf("%d%d%d",&n,&m,&q);
  a=(int*)malloc(sizeof(int)*q);
  b=(int*)malloc(sizeof(int)*q);
  c=(int*)malloc(sizeof(int)*q);
  d=(int*)malloc(sizeof(int)*q);
  F(i,0,q){
    scanf("%d%d%d%d",a+i,b+i,c+i,d+i);
  }
  int A[n];
  F(i,0,n)A[i]=0;
  dfs(0,1,A);
  printf("%d\n",max);
  return 0;
}




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

#include <iostream>
#include <algorithm>

#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>

#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>


using namespace std;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> lists;
    bool checked[300000 + 1] = {};
    for (int i = 6; i <= 300000; i += 7) {
        if (checked[i]) continue;
        lists.push_back(i);
        int k = 0;
        while (i * (7 * k + 1) <= 300000) {
            checked[i * (7 * k + 1)] = true;
            k++;
        }
        k = 0;
        while (i * (7 * k + 6) <= 300000) {
            checked[i * (7 * k + 6)] = true;
            k++;
        }
    }
    for (int i = 8; i <= 300000; i += 7) {
        if (checked[i]) continue;
        lists.push_back(i);
        int k = 0;
        while (i * (7 * k + 1) <= 300000) {
            checked[i * (7 * k + 1)] = true;
            k++;
        }
        k = 0;
        while (i * (7 * k + 6) <= 300000) {
            checked[i * (7 * k + 6)] = true;
            k++;
        }
    }
    sort(all(lists));
    while (true) {
        int n;
        cin >> n;
        if (n == 1) break;
        vector<int> ans;
        for (auto p : lists) {
            if (n % p == 0) {
                ans.push_back(p);
            }
        }
        cout << n << ':';
        rep(i, ans.size()) {
            cout << " " << ans[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3676
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
MD2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
MD3 = lambda d1,d2,d3: [MD2(d2,d3) for _ in range(d1)]
## math
DIVC = lambda x,y: -(-x//y)
DIVF = lambda x,y: x//y

def main():
    a,b,c,d = MII()
    ta = DIVC(c,b)
    ao = DIVC(a,d)
    if ta <= ao: print('Yes')
    else: print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9224
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define pii pair < ll , ll >
#define vi vector < int >
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define vll vector < long long int >
#define sll set < long long int >
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
/*int main()
{
    fastIO;
    ll a,b,n,i,j,k;
    cin>>a>>b;
    i = min(a,b);
    a -= i;
    b -= i;
    k = 16-2*i;
    if(a>k/2 or b>k/2)
    {
        cout<<":("<<endl;
        return(0);
    }
    cout<<"Yay!"<<endl;
    return(0);
}*/
/*int main()
{
    fastIO;
    ll n,m;
    cin>>n>>m;
    cout<<m*(pow(100,n));
    return(0);
}*/
int main()
{
    fastIO;
    ll ans=0,n,i,j,k,l,m,temp,a[10001];
    cin>>n;
    fo(i,n)
    {
        cin>>a[i];
        j = 0;k = pow(2,32);
        temp = 0;
        while(j<=k)
        {
            l = j + (k-j)/2;
            m = pow(2,l);
            if(a[i]%m==0)
            {
                temp = max(temp,l);
                j = l+1;
            }
            else k = l-1;
        }
        ans += temp;
    }
    cout<<ans;
    return(0);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define next tipa_next
#define prev tipa_prev
#define ll long long

using namespace std;
const int mod = 998244353;
const int half = (mod + 1) / 2;


string s;
int main()
{
	cin >> s;
	if(s.size() < 4)
	{
		cout << "No";
		return 0;
	}
	if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
		cout << "Yes";
	else
		cout << "No";
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int koiwaikotori, sakuraayane, asumikana, murakawarie, nadukakaori;
	int fukuennmisato;
	if (scanf("%d", &koiwaikotori) != 1) return 1;
	if (scanf("%d", &sakuraayane) != 1) return 1;
	if (scanf("%d", &asumikana) != 1) return 1;
	if (scanf("%d", &murakawarie) != 1) return 1;
	if (scanf("%d", &nadukakaori) != 1) return 1;
	fukuennmisato = nadukakaori <= asumikana ? sakuraayane : sakuraayane + murakawarie * (nadukakaori - asumikana);
	printf("%d\n", fukuennmisato < koiwaikotori * nadukakaori ? fukuennmisato : koiwaikotori * nadukakaori);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }



void solve(long long N, long long K){
	N = N%K;
	ll min = abs(N-K);
	while(true) {
		if (N > min) {
			N = min;
			min = abs(N-K);
		} else break;
	}
	cout << N << "\n";
}

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


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

using lli = long long;
int main(){
  lli  N,S;
  std::cin >> N >> S;

  lli ns = std::sqrt(N);

  for(int i = 2; i <= ns; i++){
    lli s = 0, n = N;
    while(n > 0){
      s += n%i;
      n /= i;
    }
    if(s == S){
      std::cout << i << std::endl;
      return 0;
    }
  }
  for(int i = ns+1; i >= 1; i--){
    lli s0 = S-i;
    if(s0 < 0) continue;
    if((N-s0)/i <= i) continue;
    if((N-s0)%i == 0 && (N-s0)/i > s0){
      std::cout << (N-s0)/i << std::endl;
      return 0;
    }
  }
  if(N == S){
    std::cout << S+1 << std::endl;
    return 0;
  }

  std::cout << "-1" << std::endl;

  return 0;
}



Measured memory_bytes: 256
#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> b(n);
  for(int i = 0; i < n; i++){
    cin >> b[i];
  }

  vector<int> a;
  for(int i = 0; i < n; i++){
    for(int j = b.size()-1; j >= 0; j--){
      if(b[j] == j+1){
        a.push_back(b[j]);
        b.erase(b.begin() + j);
        break;
      }
      if(j == 0){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  reverse(a.begin(),a.end());
  for(int p : a){
    cout << p << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from collections import deque

def OpeList():
    L = deque()
    num_command = int(input())

    for i in range(num_command):
        input_command = input()
        if input_command == 'deleteFirst':
            L.popleft()
        elif input_command == 'deleteLast':
            L.pop()
        else:
            com, num =  input_command.split()
            if com == 'insert':
                L.appendleft(num)
            elif com == 'delete':
                try:
                    #ここでLの中身を全部見るからってfor i in range(len(L))とすると
                    #C[i][1]が全部消える(∵C[i][1]を発見した時点で止まらないから)
                    L.remove(num)
                except:
                    pass
    print(' '.join(L))

OpeList()



Measured memory_bytes: 69736
#include <bits/stdc++.h>
#define maxn 100086

using namespace std;

int n, m, q;
int x, y;
map<pair<int, int>, bool> mp, tag;
long long ans[10];
int tot;

inline void check(int x, int y){
	if(x <= 0 || y <= 0 || x + 2 > n || y + 2 > m) return;
	if(tag[{x, y}]) return;
	tag[{x, y}] = true;
	int sum = 0;
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 3;j++){
			sum += mp[{x + i, y + j}];
		}
	}
	ans[sum]++;
	tot++;
}

vector<pair<int, int> > v;


int main(){
	scanf("%d%d%d", &n, &m, &q);
	while(q--){
		scanf("%d%d", &x, &y);
		mp[{x, y}] = true;
		for(int i = 0;i < 3;i++){
			for(int j = 0;j < 3;j++){
				v.push_back({x - i, y - j});
			}
		}
	}	
	for(int i = 0;i < v.size();i++){
		check(v[i].first, v[i].second);
	}
	ans[0] += 1ll * (n - 2) * (m - 2) - tot;
	for(int i = 0;i <= 9;i++) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 222720
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;


#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz(x)           (int)x.size()
#define db(x)           cout<<x<<"\n";

const int N = 2e5 + 5;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif

	
//////////////////////////////code//////////////////////////////
int n,k;
vi arr;


bool check(int val)
{  
    int curr = 0;
    
    for(int i = 0; i < n ; i++)
    {
        int now = 0;
        
        if(arr[i]>val)
        now = arr[i]/val;
        
        curr+=now;
    }
    
    return curr<=k;
    
}

void solve()
{
  //  cout << "-------------------" << "\n";
    
 
    cin>>n;

    cin>>k;
    
    arr = vi(n);
    
    for(int i=0;i<n;i++)
    cin>>arr[i];
    
    sort(all(arr));
    
    int ans = arr[n-1],l=1,h=arr[n-1];
    
    while(l<=h)
    {
        int mid = (l+h)/2;
        
        if(check(mid))
        {
            ans = mid;
            h = mid-1;
        }
        else
        l = mid+1;
    }
    
db(ans)
  
 
 //   cout << "-------------------" << "\n";

}

int32_t main()
{

    LETS_GET_SCHWIFTY;

    int t = 1;
   // cin >> t;

    while (t--)
        solve();

}

// check out for following mistakes-
// if using pb operation on vector and then trying to access index..check if sizeof that vec could remain 0 only
// is using prime sieve make sure it fits
// when using factorial template or combinatorics make sure that you edit fillfac fun values and array values


Measured memory_bytes: 4764
#include<stdio.h>
#include<string.h>

int main(void){

    char A[11],B[11],C[11];
    int A_len,B_len,C_len;

    scanf("%s %s %s",A,B,C);
    A_len = strlen(A);
    B_len = strlen(B);

    if(A[A_len - 1] == B[0] && B[B_len - 1] == C[0]){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
n,m=map(int,input().split())
g=(1<<n)

dp=[float("inf")]*g
dp[0]=0
for i in range(m):
    a,b=map(int,input().split())
    c_l=list(map(int,input().split()))
    f=0
    for c_i in c_l:
        f+=1<<(c_i-1)
    for j in range(g-1, -1, -1):
        dp[j|f]=min(dp[j]+a, dp[j|f])

print(-1 if dp[-1]==float("inf") else dp[-1])


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

using namespace std;

vector<int> mate;
vector<vector<int>> g;
vector<bool> used;

bool tyan(int u)
{
	if (used[u])
		return false;
	used[u] = true;
	for (int v : g[u])
		if (mate[v] == -1 || tyan(mate[v]))
		{
			mate[u] = v;
			mate[v] = u;
			return true;
		}
	return false;
}

int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<pair<int, int>> r(n);
	vector<pair<int, int>> b(n);
	for (auto& x : r)
		cin >> x.first >> x.second;
	for (auto& x : b)
		cin >> x.first >> x.second;
	g.resize(2 * n);
	used.resize(2 * n);
	mate.resize(2 * n, -1);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			if (r[i].first < b[j].first && r[i].second < b[j].second)
				g[i].push_back(n + j), g[n + j].push_back(i);
	for (int i = 0; i < n; ++i)
	{
		fill(used.begin(), used.end(), 0);
		for (int j = 0; j < n; ++j)
			if (mate[j] == -1)
				tyan(j);
	}
	int ans = (mate.size() - count(mate.begin(), mate.end(), -1)) / 2;
	cout << ans << '\n';
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = [1] * n
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if h[a] < h[b]:
        ans[a] = 0
    elif h[a] > h[b]:
        ans[b] = 0
    else:
        ans[a] = 0
        ans[b] = 0

print(sum(ans))

Measured memory_bytes: 19976
h, w = [int(i) for i in input().split()]
n = int(input())
A = [int(i) for i in input().split()]

grid = [[None] * w for _ in range(h)]

cnt = 0
i, j = 0, 0
direction = 0  # 0:right, 1:left
ptr = 0
res = A[ptr]
while cnt < h * w:
    cnt += 1
    # fill grid
    if res > 0:
        grid[i][j] = ptr + 1
        res -= 1
    elif res == 0:
        ptr += 1
        grid[i][j] = ptr + 1
        res = A[ptr] - 1
    # next cell
    if direction == 0 and j < w - 1:
        j += 1
    elif direction == 0 and j == w - 1:
        i += 1
        direction = 1
    elif direction == 1 and j > 0:
        j -= 1
    elif direction == 1 and j == 0:
        i += 1
        direction = 0

for line in grid:
    print(" ".join((str(i) for i in line)))


Measured memory_bytes: 74116
#include<bits/stdc++.h>                                                         
using namespace std;
int main(){
    int a[100],flag=0,x;
    cin >> x;
    a[0]=x%10;
    x/=10;
    a[1]=x%10;
    x/=10;
    a[2]=x%10;
    x/=10;
    a[3]=x%10;
    for(int i=0;i<4;i++){
        if(i>0 && a[i]==a[i-1]) flag=1;
    }   
    if(flag==1) cout << "Bad" << '\n';
    else cout << "Good" << '\n';
}


Measured memory_bytes: 256
s = input()
t = input()

dict_s = {}
for i in range(len(s)):
    if s[i] not in dict_s:
        dict_s[s[i]] = t[i]
    else:
        if dict_s[s[i]] != t[i]:
            print('No')
            exit()
        else:
            continue

dict_t = {}
for i in range(len(t)):
    if t[i] not in dict_t:
        dict_t[t[i]] = s[i]
    else:
        if dict_t[t[i]] != s[i]:
            print('No')
            exit()
        else:
            continue

print('Yes')


Measured memory_bytes: 3632
#include <cstdio>

int main (){
    int N;
    scanf("%d",&N);
    int value[N];
    for (int i = 0; i < N; i++){
        scanf("%d",&value[i]);
    }
    int cost[N];
    for (int i = 0; i < N; i++){
        scanf("%d",&cost[i]);
    }
    int count=0;
    for (int i = 0; i < N; i++){
        if (value[i]>cost[i]){
            count+=value[i]-cost[i];
        }
    }
    printf("%d",count);
}

Measured memory_bytes: 128
N = int(input())

dp = [[0] * 10 for _ in range(10)]
for x in range(1, N + 1):
    j = x % 10
    while x >= 10:
        x //= 10
    i = x % 10
    dp[i][j] += 1
    
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += dp[i][j] * dp[j][i]
        
print(ans)


Measured memory_bytes: 64488
#include<bits/stdc++.h>
using namespace std;
int a[6],ans=0,mi=10;
int main(){
	for(int i=1;i<=5;i++){
		cin>>a[i];
		if(a[i]%10==0){
			ans+=a[i];
		}else{
			ans+=a[i]+10-a[i]%10;
			mi=min(mi,a[i]%10);
		}
//		cout<<ans;
	}
	if(mi==10){
		cout<<ans;
	}else{
		cout<<ans+mi-10;
	}
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
m = min(A)
DP = [False] * (K+1)

for i in range(m, K+1):
    for a in A:
        if i - a >= 0 and DP[i-a] == False:
            DP[i] = True
            break
if DP[-1]:
    print('First')
else:
    print('Second')

Measured memory_bytes: 74180
#include <iostream>

int main(){

int x,y;
 while(1){
 std::cin>>x>>y;
 if(x==0 && y==0){break;}
 else if(x<=y){std::cout << x << " " << y << std::endl;}
 else {std::cout << y << " " << x << std::endl;}
 }
return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

template<typename T>
class tRMQ {
  vector<T> data;
  T unit;

public:
  int n;
  function<T(const T &, const T &)> f;

  tRMQ(int _, T u, function<T(T, T)> bi) {
    unit = u;
    f = bi;
    n = 1;
    while (n < _) {
      n <<= 1;
    }
    data.resize(n * 4);
    for (int i = 0; i < n * 4; i++)
      data[i] = unit;
  }

  tRMQ(vector<T> &v, T u, function<T(T, T)> bi) {
    unit = u;
    f = bi;
    n = 1;
    while (n < v.size())
      n <<= 1;
    data.resize(n * 4, u);
    for (int i = 0; i < v.size(); i++) {
      data[n + i - 1] = v[i];
    }
    for (int i = n - 2; i >= 0; i--) {
      data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }

  void update(int index, T val) {
    int i = index + n - 1;
    data[i] = val;
    while (i > 0) {
      i = (i - 1) / 2;
      data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }

  // [a, b)
  T query(int a, int b, int k, int l, int r) {
    if (a < 0 || r <= a || b <= l)
      return unit;
    if (a <= l && r <= b)
      return data[k];
    else
      return f(query(a, b, k * 2 + 1, l, (l + r) / 2),
               query(a, b, k * 2 + 2, (r + l) / 2, r));
  }

  T query(int a, int b) { return query(a, b, 0, 0, n); }
};

tRMQ<ll> minrmq(int n) {
  return tRMQ<ll>(n, 10000000000000000LL, [](ll r, ll l) { return min(l, r); });
}

tRMQ<ll> maxrmq(int n) {
  return tRMQ<ll>(n, 0,
                  [](ll r, ll l) { return max(l, r); });
}

tRMQ<ll> sumrmq(int n) {
  return tRMQ<ll>(n, 0, [](ll l, ll r) { return l + r; });
}


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int ans = 0;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  int all = 0;

  auto r = sumrmq(n);

  ll diff = 0;
  for (int i = 0; i < k; i++) {
    diff += r.query(p[i], n);
    r.update(p[i], 1);
  }
  if (diff) {
    ans++;
  } else {
    all++;
  }

  for (int i = k; i < n; i++) {
    bool is_change = false;
    ll minus = r.query(0, p[i - k]);
    if (minus) is_change = true;
    r.update(p[i - k], 0);
    ll plus = r.query(p[i], n);
    r.update(p[i], 1);
    if (plus) is_change = true;
    diff += plus - minus;
    if (is_change) {
      if (diff == 0) {
        all++;
      } else {
        ans++;
      }
    }
  }

  if (all) ans++;
  cout << ans << endl;
  return 0;
}


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

const int N=1e5+1e3+7;

int a[N],use[N],ans,n,cnt;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]==i)
		{
			cnt++;
		}
		else
		{
			ans+=(cnt+1)/2;
			cnt=0;
		}
	}
	ans+=(cnt+1)/2;
	cout<<ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define maxn 2005
using namespace std;
typedef long long LL;
int read()
{
	char c=getchar();int f=1,sum=0;
	while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
	return sum*f;
}
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
int n,a[maxn];
int head[maxn],to[maxn<<1],nex[maxn<<1],cnt;
bool li[maxn][maxn],vis[maxn];
int deg[maxn];
void add(int u,int v)
{
	deg[v]++;to[++cnt]=v;nex[cnt]=head[u];head[u]=cnt;
}
void dfs(int x)
{
	vis[x]=1;
	for(int i=1;i<=n;i++)
	if(li[x][i] && !vis[i])
	{
		add(x,i);
		dfs(i);
	}
}
struct node{
	int val,id;
    friend bool operator <(node a,node b){
        return a.val<b.val;
    }
};
priority_queue<node> q;
int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+1+n);
	for(int i=1;i<n;i++)
	for(int j=i+1;j<=n;j++)
	if(gcd(a[i],a[j])>1) li[i][j]=li[j][i]=1;
	for(int i=1;i<=n;i++)
	if(!vis[i])
	dfs(i);
	for(int i=1;i<=n;i++)
	if(!deg[i])
	q.push((node){a[i],i});
	for(int i=1;i<=n;i++)
	{
		node now=q.top();
		q.pop();
		printf("%d ",a[now.id]);
		for(int j=head[now.id];j;j=nex[j])
		{
			deg[to[j]]--;
			if(!deg[to[j]])
			q.push((node){a[to[j]],to[j]});
		}
	}
	return 0;
}


Measured memory_bytes: 4352
from statistics import median

N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

m = median(A)
M = median(B)

if N % 2 == 0:
    m *= 2
    M *= 2

print(int(M-m+1))


Measured memory_bytes: 28900
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////


signed main(){
  double h;cin>>h;
  double a = 1,b = 0;
  while(a <= h){
    a *= 2;
    b++;
  }
  int c = pow(2,b)-1;
  cout << fixed << c << endl;
}



Measured memory_bytes: 512
/*
ID: zhaowei10
TASK:
LANG: C++
*/
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define mp make_pair
#define eb emplace_back
#define pb push_back
#define MOD 1000000007
#define NDIG(x) floor(log10(x)) + 1
#define FOR(i, j, k, l) for (s32 i = j; i < k; i += l)
#define RFOR(i, j, k, l) for (s32 i = j; i >= k; i -= l)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(x) x.begin(), x.end()
#define MEAN(a, b) min(a, b) + (abs(b - a) >> 1)
#define FASTIO()    \
  cin.tie(nullptr); \
  ios::sync_with_stdio(false);

typedef long long ll;
typedef int64_t s64;
typedef uint64_t u64;
typedef int32_t s32;
typedef uint32_t u32;
typedef float f32;
typedef double f64;
typedef long double f80;
typedef pair<s32, s32> II;
typedef pair<s64, s64> LL;
typedef vector<s32> VI;
typedef vector<II> VII;
typedef vector<char> VC;
typedef vector<VII> VVII;
typedef priority_queue<s32> PQI;
typedef priority_queue<s32, VI, greater<s32>> PQIA;
typedef priority_queue<s64> PQL;
typedef priority_queue<II> PQII;
typedef priority_queue<II, VII, greater<II>> PQIIA;
typedef priority_queue<LL> PQLL;
typedef unordered_set<s32> USI;
typedef unordered_set<s64> USL;
typedef set<II> SII;
typedef multiset<s32> MSI;

int main() {
  FASTIO();

  int a, b;
  cin >> a >> b;

  for (int i = 0; i <= 1250; ++i) {
    if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
	int i,count=0,add;
	long long int x,y;
	cin >> x >> y;
	add=x;
	for(i=0;i<=60;i++){
		if(x>y) break;
		x*=2;
		count++;
	}
	cout  << count << endl;
}

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

using vec = complex<double>;
using line = pair<vec,vec>;

double inner_product(vec u,vec v){
    return real(u*conj(v));
}
double cross_product(vec u,vec v){
    return imag(conj(u)*v);
}

double norm(vec& u){
    return abs(u);
}

vec projection(line l,vec p){//p???l???????°???±
    vec s=l.first, t=l.second;
    double k = inner_product(t-s,p-s)/inner_product(t-s,t-s);
    return (1.0-k)*s+k*t;
}


int main(void){
    int xp1,yp1,xp2,yp2;
    cin>>xp1>>yp1>>xp2>>yp2;
    line l(vec(xp1,yp1),vec(xp2,yp2));
    int q;
    cin>>q;
    cout<<fixed;
    cout.precision(10);
    for(int i=0;i<q;i++){
        int xp,yp;
        cin>>xp>>yp;
        vec X=projection(l,vec(xp,yp));
        cout<<X.real()<<' '<<X.imag()<<endl;
    }

    return 0;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

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

  int count = 0;

  for (int i = 0; i < n; i++) {
    if(s[i] == '(') count++;
    if(count > 0 && s[i] == ')') count--;
  }
  if(count > 0){
    for (int i = 0; i < count; i++) {
      s += ')';
    }
  }
  n = int(s.size());
  count = 0;

  for (int i = n-1; i >= 0; i--) {
    if(s[i] == ')') count++;
    if(count > 0 && s[i] == '(') count--;
  }
  if(count > 0){
    for (int i = 0; i < count; i++) {
      string tmp = s;
      s = '(' + tmp;
    }
  }
  cout << s << endl;


}


Measured memory_bytes: 256
def solve(N, A, B):
    if sum(A) < sum(B):
        print(-1)
        return

    diff = [a - b for a, b in zip(A, B)]
    changed = [False for _ in range(N)]
    diff.sort()
    l, r = 0, N - 1

    while diff[l] < 0:
        if diff[l] + diff[r] >= 0:
            changed[l] = True
            changed[r] = True
            diff[r] += diff[l]
            l += 1
        else:
            changed[l] = True
            changed[r] = True
            diff[l] += diff[r]
            r -= 1
    print(sum(changed))
    return


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split(' ')))
    B = list(map(int, input().split(' ')))

    solve(N, A, B)

Measured memory_bytes: 85484
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long int ll;

int main() {
  string S;
  cin>>S;
  
  bool can_step=true;
  
  for(int i=0;i<S.size();i=i+2){
    if(S[i]=='L'){
      can_step=false;
      break;
    }
  }
  
  for(int i=1;i<S.size();i=i+2){
    if(S[i]=='R'){
      can_step=false;
      break;
    }
  }
  
  if(can_step)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int k=scan.nextInt(),s=scan.nextInt(),a=0,i,j;
		scan.close();
		for(i=0;i<=k;i++) {
			for(j=0;j<=k;j++) {
				if(i+j>s) break;
				if(k>=s-i-j) a++;
			}
		}
		System.out.print(a);
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<math.h>


int main(void){

  int n;
  double x[3], y[3];
  double px, py, r;
  double a, b, c, theta;

  scanf("%d", &n);

  while(n>0){
    scanf("%lf %lf %lf %lf %lf %lf", &x[0], &y[0], &x[1], &y[1], &x[2], &y[2]);

    a=pow(x[0]-x[1], 2)+pow(y[0]-y[1], 2);
    b=pow(x[1]-x[2], 2)+pow(y[1]-y[2], 2);
    c=pow(x[2]-x[0], 2)+pow(y[2]-y[0], 2);

    px=(x[0]*x[0]+y[0]*y[0])*(y[1]-y[2])+(x[1]*x[1]+y[1]*y[1])*(y[2]-y[0])+(x[2]*x[2]+y[2]*y[2])*(y[0]-y[1]);
    px/=2*(x[0]*(y[1]-y[2])+x[1]*(y[2]-y[0])+x[2]*(y[0]-y[1]));

    py=(x[0]*x[0]+y[0]*y[0])*(x[2]-x[1])+(x[1]*x[1]+y[1]*y[1])*(x[0]-x[2])+(x[2]*x[2]+y[2]*y[2])*(x[1]-x[0]);
    py/=2*(x[0]*(y[1]-y[2])+x[1]*(y[2]-y[0])+x[2]*(y[0]-y[1]));
    
    theta = acos((b+c-a)/(2*sqrt(b)*sqrt(c)));
    r = sqrt(a)/sin(theta) / 2;
    printf("%.3f %.3f %.3f\n", px, py, r);

    n--;
  }

  return(0);
}



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

using namespace std;

bool prime_check(int N)
{
	if (N == 1) { return false; }

	for (int i = 2; i <= sqrt(N); i++)
	{
		if (N % i == 0)
		{
			return false;
		}
	}

	return true;
}

int main()
{
	int N;

	while (cin >> N)
	{
		for (int i = (N - 1); i > 1; i--)
		{
			if (prime_check(i) == true)
			{
				cout << i << ' '; goto Exit1;
			}
		}

	Exit1:;

		for (int i = (N + 1); i < 50022; i++)
		{
			if (prime_check(i) == true)
			{
				cout << i << endl; goto Exit2;
			}
		}

	Exit2:;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#ifndef ONLINE_JUDGE
#include <custom/prettyprint.hpp>
#endif
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b) - 1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rb(i,x) for (auto& i : x)
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define UNIQUE(x) (x).resize(unique(all(x)) - begin(x))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define pow10(n) stoll("1"+string(n,'0'))
#define dbg(x) cout << ">>> " << #x << ": " << x << '\n'

const int MOD = 1e9+7; //998244353
const int inf = 1e9+3;
const ll INF = ll(3e18)+3;
const ld PI = acos((ld)-1);
const int dx[8] = {1,0,-1,0,1,1,-1,-1}, dy[8] = {0,1,0,-1,-1,1,1,-1};
mt19937_64 rng((uint64_t)chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll n) { return uniform_int_distribution<ll>(0, n)(rng); }
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 

void setIO(const string& s) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen((s+".in").c_str(),"r",stdin);
//	freopen((s+".out").c_str(),"w",stdout);
#endif
}

int main() {
    
    setIO("input");
    int n,k; cin >> n >> k;
    vl grades(n);
    for(auto& i : grades) cin >> i;

    for(int i=k; i<n; ++i) {
        cout << (grades[i] > grades[i-k] ? "Yes\n" : "No\n");
    }
    
}

/*  ! CHECK THIS IF YOU GET IT WRONG !
	* int overflow, array bounds, NO VLAs
	* uninitialized local variables, rounding errors
	* intermediate result type, scientific
	* special cases (n = 0 or 1?)
	* reset your variables in scope
	* INF not large enough for ans, adding value to _MAX
	* using wrong variables, sorting extra 0s in global array
	* comment out input from file
	* operator precedence
*/

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

int main()
{
    int H, N;
    std::cin >> H >> N;
    std::vector<int> A(N);
    std::vector<int> B(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> A[i] >> B[i];
    }

    std::vector<int> dp(H + 1, 1e9);
    dp[0] = 0;
    for (int i = 1; i <= H; i++)
    {
        for (int j = 0; j < N; j++)
        {
            int p = (i - A[j] < 0 ? B[j] : dp[i - A[j]] + B[j]);
            dp[i] = std::min(dp[i], p);
        }
    }

    std::cout << dp[H] << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
	int n; cin >> n;
	vector<pair<pair<string, int>, int>> sp;
    rep(i, n) {
        string s; int p;
        cin >> s >> p;
        p=-p;
        sp.push_back(make_pair(make_pair(s, p), i+1));
    }
    sort(sp.begin(), sp.end());
    rep(i, n){
        cout << sp[i].second << endl;
    }
}

Measured memory_bytes: 384
/*
貪欲
後ろから見る
DP
順位表をチェック
二分探索


*/
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
using namespace std;
#define INF 3e18+7
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<double,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());

bool dp[90][90][6500];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int ans=0;
    for(int i=0;i<3;i++){
        int a;
        cin>>a;
        ans+=a;
    }
    if(ans>=22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}

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

using namespace std;
const long mod = 1000000007;
typedef long long lint;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(N) for(int i = 0; i < (int)(N); i++)
#define all(x) (x).begin(),(x).end()
#define length(x) ((int)(x).size())
#define prln(s) cout<<s<<endl;

#define str(s) string s;cin>>s;
#define int1(x) int x;cin>>x;
#define int2(x,y) int x,y;cin>>x>>y;

int main() {
  int1(n);
  int dp[n][3];
  repi(n){
    int2(a,b);
    int1(c);
    if(i==0){
      dp[0][0]=a;
      dp[0][1]=b;
      dp[0][2]=c;
      continue;
    }
    dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=c+max(dp[i-1][1],dp[i-1][0]);
  }
  prln(max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])));
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;

const int INF = 1001001001;

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

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	int a,b,d[101]={0},i;
	while(~scanf("%d%d",&a,&b)){
		if(a){
			d[a]++;
			d[b]++;
		}else{
			if(d[1]%2==0 || d[2]%2==0) {
				puts("NG");
			} else {
				for(i=3;i<=100;i++){
					if(d[i]%2==1) {
						puts("NG");
						break;
					}
				}
				if(i==101)
					puts("OK");
			}
			memset(d,0,sizeof(d));
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<queue>
using namespace std;
int main (void){
	int n,m;
	cin>>n>>m;
	int a,b;
	unordered_map<int,int> lmost;
	while (m--){
		cin>>a>>b;
		if (!lmost[a]) lmost[a]=b;
		else lmost[a]=min(lmost[a],b);
	}
	vector<pair<int,int>> quest;
	for (auto i:lmost) quest.push_back(make_pair(i.first,i.second));
	sort(quest.begin(),quest.end());
	priority_queue<int,vector<int>,greater<int>> pq;
	int ans=0;
	for (auto i:quest){
		if (!pq.empty()&&pq.top()<=i.first){
			++ans;
			while (!pq.empty()) pq.pop();
		}
		pq.push(i.second);
	}
	++ans;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

long long n, a[111111];

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

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long u = 2, d = 2;
	for (int i = n-1; i >= 0; i--) {
		if (u < a[i]) {
			cout << -1 << endl;
			return 0;
		}
		u = u/a[i]*a[i];
		if (d%a[i] != 0) d+=(a[i] - (d%a[i]));
		if (d > u) {
			cout << -1 << endl;
			return 0;
		}
		u = u+a[i]-1;
	}
	cout << d << ' ' << u << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int a,b;
		cin >> a >> b;
		rep(i,0,10000){
			if((int)(i*0.08)==a and (int)(i*0.1)==b){
				cout<<i;
				r0;
			}
			
		}
		cout<<-1;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String sArray [] = s.split("");
		String t = sc.next();
		String tArray [] = t.split("");
		String a = "";
		boolean judge = false;
		for(int k = 0; k < sArray.length; k++) {
			a = sArray[sArray.length - 1];
			for(int i = sArray.length - 1; i > 0; i--){
				sArray[i] = sArray[i - 1];
			}
			sArray[0] = a;
			if(Arrays.equals(sArray, tArray)) {
				judge = true;
				break;
			}
		}
		if(judge) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}


Measured memory_bytes: 22740
import math
import sys

N = int(input())
X = list(map(int, input().split()))

X.sort()
ans = sys.maxsize

for i in range(X[0], X[-1]+1):
    sum = 0
    for x in X:
        sum += (x-i)**2
    ans = min(ans, sum)  

print(ans)

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

#define mod 1000000007

using namespace std;

int main()
{

    long long n,k,i,j,r=0,mins,maxs;

  //  long long s[2000001];

    cin>>n>>k;



    for(i=k;i<=n+1;i++)
    {
        mins=(i*(i-1))/2;

        maxs=(((2*n)-i+1)*i)/2;

        r=r+(maxs-mins)+1;

    }

        r=r%mod;

    cout<<r<<endl;
    return 0;
}


Measured memory_bytes: 3620
import os, sys
if os.environ.get("DEBUG") is not None:
    sys.stdin = open("in.txt", "r")
rl = sys.stdin.readline

h = int(rl())
i = 1
while True:
    if h <= 2**i - 1:
        print(2**i - 1)
        break
    i += 1


Measured memory_bytes: 9176
n,u,v=map(int,input().split())
u-=1
v-=1

import heapq
def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

#n,w = map(int,input().split()) #n:頂点数　w:辺の数
edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(n-1):
    z=1
    x,y = map(int,input().split())
    x-=1;y-=1
    edge[x].append([z,y]) #有向辺
    edge[y].append([z,x]) #有向辺
A=dijkstra_heap(u)
B=dijkstra_heap(v)
l=[]
for i in range(n):
    l.append([B[i],A[i]])
l.sort()
l=l[::-1]
#print(A)
#print(B)
#print(l)
for i in range(n):
    if l[i][0]>l[i][1]:
        print(l[i][0]-1)
        break

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

using namespace std;

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

    int l, r;
    cin >> l >> r;

    int answer = 0;
    for(int i = l; i <= r; ++i)
    {
        int rev = 0, t = i, ten = 10000;

        for(int j = 1; j <= 5; ++j)
        {
            rev += (t % 10) * ten;
            ten /= 10;
            t /= 10;
        }

        if(rev == i)
            ++answer;
    }

    cout << answer << '\n';
}


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

typedef long long ll;
const ll mod=1000000007;

ll qpow(ll a,ll n){
    ll res=1;
    while(n){
        if(n&1){
            res=res*a%mod;
        }
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

ll fac[2000005],inv[2000005];

inline ll f(ll r,ll c){
    return ((ll)fac[r+c]*inv[r]%mod*inv[c]%mod);
}

inline ll g(ll r,ll c){
    ll res=0;
    for(ll i=1;i<=r+1;i++){
        res+=f(i,c);
    }
    return (res%mod);
}

int main(){

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

    fac[0]=1;
    inv[0]=1;
    for(ll i=1;i<=2000002;i++){
        fac[i]=(ll)fac[i-1]*i%mod;
        inv[i]=qpow(fac[i],mod-2);
    }
    ll r1,c1,r2,c2;
    cin>>r1>>c1>>r2>>c2;
    cout<<((g(r2,c2)-g(r2,c1-1)-g(r1-1,c2)+g(r1-1,c1-1))%mod+mod)%mod<<endl;

    return 0;
}

Measured memory_bytes: 31488
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;

int main(){
	string s;
	int a,b;
	cin>>s;
	a=(s[0]-'0')*10+s[1]-'0';
	b=(s[2]-'0')*10+s[3]-'0';
	if(a>=1&&a<=12){
		if(b>=1&&b<=12) cout<<"AMBIGUOUS";
		else cout<<"MMYY";
	}
	else{
		if(b>=1&&b<=12) cout<<"YYMM";
		else cout<<"NA";
	}
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():


    H, W = map(int, input().split())
    N=int(input())
    A = list(map(int,input().split()))

        


    route = []
    for h in range(H):
        if h % 2 == 0:
            route.extend([(h, w) for w in range(W)])
        else:
            route.extend([(h, w) for w in reversed(range(W))])
    
    ans=[[0]*W for _ in range(H)]
    val=1
    i=0
    cnt=0
    for i in range(N):
        for j in range(A[i]):
            ans[route[cnt][0]][route[cnt][1]]=i+1
            cnt+=1
    for i in ans:
        print(*i)



resolve()

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

#define INF 1e9
using namespace std;

int main() {

    int N; cin >> N;

    vector<int> h(N);
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }

    int ans = 0;
    bool line = false;
    bool all_zero = false;

    while (!all_zero) {
        line = false;
        all_zero = true;

        for (int j = 0; j < h.size(); ++j) {
            if (h[j] == 0) {
                line = false;
                continue;
            } else {
                --h[j];
                if (!line) {
                    ++ans;
                }
                line = true;
                all_zero = false;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;


int main() {
	int n;
	string w[110];
	cin >> n;
	for (int i = 1; i <= n;i++) {
		cin >> w[i];
	}
	for (int i = 2; i <= n;i++) {
		if (w[i-1][w[i-1].size()-1]!=w[i][0]) {
			cout << "No" << endl;
			return 0;
		}
		for (int j = 1; j < i;j++) {
			if (w[j]==w[i]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256