akhauriyash/Code-Regression huggingface dataset:
n, m = map(int, input().split())
d = {}
ok = True
for i in range(m):
    s, c = map(int, input().split())
    if s not in d:
        d[s] = c
    elif d[s] != c:
        ok = False
res = ''
if not ok:
    print(-1)
elif n == 1 and m == 0:
    print(0)
else:
    for i in range(1, n+1):
        if i not in d.keys():
            if res == '' or int(res) == 0:
                res += '1'
            else:
                res += '0'
        else:
            res += str(d[i])
    if len(res) == len(str(int(res))):
        print(res)
    else:
        print(-1)

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

int main()

{

    int a,b,c;
    string L,R;

    map<string,int> MAP;
    map<string,int>::iterator l,u,it;
    scanf("%d ",&a);
    string s;

    for(int k=0;k<a;k++){
    scanf("%d",&b);
    if (b==0 ){

            cin >> s >> c;
			MAP[s] = c;

            }
    else if (b==1){

            cin >> s;
			it=MAP.find(s);
            if(it!=MAP.end()){

             printf("%d\n",MAP[s]);
            }
             else{
               cout<<"0"<<endl;
            }



    }
     else if (b==2){

            cin >> s;
			MAP.erase (s);

}
   else if (b==3){

            cin >>L>>R;
            l = MAP.lower_bound(L);
            u = MAP.upper_bound(R);
            for( it = l; it!=u; it++)
                cout<<it->first<<" "<<it->second<<"\n";

}

    }


    return 0;



}


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

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 long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << 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; }

void Main(){
    ll N,V; cin >> N >> V;
    VL a(N), b(N);
    REP(i,N) cin >> a[i];
    REP(i,N) cin >> b[i];

    VL v;
    REP(i,N)REP(j,N){
        v.push_back(a[i]+b[j]);
    }
    SORT(v);

    REP(i,N) cin >> a[i];
    REP(i,N) cin >> b[i];

    ll ans = 0;
    REP(i,N)REP(j,N){
        ll s = a[i]+b[j];
        ll l = LB(v,V-s), r = UB(v,V-s);
        ans += r-l;
    }
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 11292
# AOJ TP2_2_A: Stack
# Python3 2018.6.24 bal4u

from collections import deque
n, q = map(int, input().split())
Q = []
for i in range(n): Q.append(deque())
for i in range(q):
	a = input().split()
	t = int(a[1])
	if   a[0] == '0': Q[t].append(a[2])        # push
	elif a[0] == '1' and Q[t]: print(Q[t][-1]) # top
	elif a[0] == '2' and Q[t]: Q[t].pop()      # pop



Measured memory_bytes: 20828
#include<iostream>
using namespace std;
int main(){
  int n,r;
  int card[50],yama[50];
  while(cin >>n>>r,n||r){
    for(int i=0; i<n; i++) card[i] = n-i;
    for(int i=0,a,b; i<r; i++){
      cin >>a>>b;a--;
      for(int j=0; j<b; j++) yama[j] = card[a+j];
      for(int j=a-1; j>=0; j--) card[j+b] = card[j];
      for(int j=0; j<b; j++) card[j] = yama[j];
     }
    cout <<card[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
# coding: utf-8
# Your code here!
N=int(input())
X=list(input())

ones=X.count("1")
high=ones+1
low=ones-1

mod_h=[1]
mod_l=[1]
for i in range(N-1):
    mod_h.append((mod_h[-1]*2)%high)
    mod_l.append((mod_l[-1]*2)%low if low!=0 else 0) 

mod_h=mod_h[::-1]
mod_l=mod_l[::-1]

ans_high=0
for i in range(N):
    if X[i] == "1":
        ans_high+=mod_h[i]
ans_high%=high

ans_low=0
for i in range(N):
    if X[i] == "1":
        ans_low+=mod_l[i]
ans_low%=low if low!=0 else 1
        
for i in range(N):
    if X[i]=="0":
        ans=ans_high
        ans+=mod_h[i]
        ans%=high
    else:
        if low==0:
            print(0)
            continue
        ans=ans_low
        ans-=mod_l[i]
        ans%=low
    
    count=1
    while ans!=0:
        ans=ans%(bin(ans).count("1"))
        count+=1
    
    print(count)
    
    

Measured memory_bytes: 27672
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,i;
    string s,st,sr;
    cin>>s>>st;
    sr=s+st;
     for (i=0;i<sr.length();i++)
    a=a*10+sr[i]-49+1;
    if (sqrt(a)==float(sqrt(a))) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
#include <queue>
#include <set>

using namespace std;

#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    long long a, count=0, minus_num=0, min_abs=1000000000;
    rep(i, n) {
        cin >> a;
        if (a < 0){
            count -= a;
            minus_num++;
            min_abs = min(min_abs, (- 1) * a);
        }
        else{
            count += a;
            min_abs = min(min_abs, a);
        }
    }
    if (minus_num % 2 == 0) cout << count << endl;
    else cout << count - min_abs * 2 << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np


N = int(input())
S = input()


S_arr = np.array(list(S))

R_idx = np.where(S_arr == 'R')[0]
G_idx = np.where(S_arr == 'G')[0]
B_idx = np.where(S_arr == 'B')[0]

ans_cand = R_idx.shape[0] * G_idx.shape[0] * B_idx.shape[0]


for i in range(N-2):
    first = S[i]
    for j in range(i+1, N-1):
        second = S[j]
        sa = j - i
        k = j + sa
        if first == second:
            continue
        elif k >= N:
            break
        elif S[k] != first and S[k] != second:
            ans_cand -= 1

print(ans_cand)


Measured memory_bytes: 27212
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int x[101],y[101],h[101];
    int x1[101]={},y1[101]={};
    rep(i,n) {
        cin >> x[i] >> y[i] >> h[i];
        x1[x[i]] = 1;
        y1[y[i]] = 1;
    }
    int a=x[0],b=y[0],c=0;
    rep(i,n){
        if(h[i]!=0){
            a = x[i];
            b = y[i];
            c = h[i];
            break;
        }
    }
    // if(c==0){
        // int t,u;
        // rep(i,101){
        //     if(x1[i]!=1){
        //         t = i;
        //     }
        //     if(y1[i]!=1){
        //         u = i;
        //     }
        // }
    //     cout << t << " " << u << " " << 1 << endl;
    //     return 0;

    // }


    rep(i,101){
        rep(j,101){
            // cout << i << " " << j << endl; 
            int p,q;
            if(a==i) p = 0;
            else p = abs(i-a);
            if(b==j) q = 0;
            else q = abs(j-b);
            int H = p + q + c;
            bool flag = false;
            rep(k,n){
                int p1,q1;
                if(x[k]==i) p1 = 0;
                else p1 = abs(i-x[k]);
                if(y[k]==j) q1 = 0;
                else q1 = abs(j-y[k]);
                int H1 = p1 + q1 + h[k];
                if(h[k]!=0){
                    if(H1!=H){
                        flag = true;
                        break;
                    } 
                }
            }
            rep(k,n){
                if(h[k]==0){
                    int tmp = abs(i-x[k]) + abs(j-y[k]);
                    if(H>tmp){
                        flag = true;
                    }
                }
            }
            if(!flag){
                cout << i << " " << j << " " << H << endl; 
                return 0;
            }
        }
    }

    return 0;
}

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

int main()
{
    int h, n;
    cin >> h >> n;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        h -= a;
    }
    cout << (h <= 0 ? "Yes" : "No") << endl;

    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

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 long long LL;
typedef unsigned long long ULL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve()
{
  stack<char> S;
  string in_S; cin >> in_S;
  int ans = 0;
  REP0(i, in_S.length())
  {
    char s = in_S[i];
    if (!S.empty() and S.top() != s)
    {
      S.pop();
      ++++ans;
    } else {
      S.push(s);
    }
  }
  cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    solve();
    return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

int bfs(const vvi& G, int s, int t) {
    int n = G.size();

    vvb seen(n, vb(3, false));
    seen[s][0] = true;

    queue<pair<int, int>> q;
    q.emplace(s, 0);

    while (!q.empty()) {
        auto curr = q.front();
        q.pop();

        int v = curr.first;
        int depth = curr.second;

        for (int u : G[v]) {
            // 終了．
            if (u == t && (depth + 1) % 3 == 0) { return (depth + 1) / 3; }
            if (seen[u][(depth + 1) % 3]) { continue; }

            seen[u][(depth + 1) % 3] = true;
            q.emplace(u, depth + 1);
        }
    }
    return -1;
}

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

    int n, m;
    cin >> n >> m;

    vvi G(n);
    rep(_, 0, m) {
        int u, v;
        cin >> u >> v;
        G[u - 1].push_back(v - 1);
    }
    int s, t;
    cin >> s >> t;
    cout << bfs(G, s - 1, t - 1) << endl;

    return 0;
}

Measured memory_bytes: 12800
def BubbleSort(A, N):
    j = 0
    flag = 1
    k = 0
    while flag:

        flag = 0
        
        for i in range(N-1, 0, -1):
            
            if A[i] < A[i-1]:

                A[i-1], A[i] = A[i], A[i-1]
        
                # a = A[i-1]
        
                # A[i-1] = A[i]
        
                # A[i] = a
        
                flag = 1
        
                j += 1
        # k += 1
    
    print(' '.join([str(x) for x in A]))
    print(j)

N = int(input())
A = [int(x) for x in input().split()]

BubbleSort(A, N)

                
        



Measured memory_bytes: 5608
n=int(input())
lis=[0]*(n+1)
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            k=x**2+y**2+z**2+x*y+y*z+x*z
            if k<=n:
                lis[k]+=1
for i in range(1,n+1):
    print(lis[i])

Measured memory_bytes: 9200
/*input
2 3
1 32
2 63
1 12

*/

#include <bits/stdc++.h>

using namespace std;

vector< tuple<int,int,int> > v;
vector<string> ans;

string intfmt(int i) {
  char s[10];
  sprintf(s, "%06d", i);
  // cerr << string(s) << endl;
  return string(s);
}

int main(int argc, char const *argv[]) {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int p, y;
    scanf("%d%d", &p, &y);
    v.emplace_back(p, y, i);
  }
  sort(v.begin(), v.end());

  int lastp = 0, cnt = 0;
  ans.resize(m);
  for (auto el: v) {
    int p, y, id;
    tie(p, y, id) = el;
    if (p != lastp) cnt = 1;
    lastp = p;
    // cerr << p << y <<id << cnt << endl;
    ans[id] = intfmt(p) + intfmt(cnt);
    cnt++;
  }

  for(auto e : ans) {
    printf("%s\n", e.c_str());
  }

  return 0;
}

Measured memory_bytes: 8180
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int a;
	vector<int> v;

	cin >> a;	v.push_back(a);
	cin >> a;	v.push_back(a);
	cin >> a;	v.push_back(a);
	cin >> a;	v.push_back(a);
	cin >> a;	v.push_back(a);
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	cout << v[0] << " " << v[1] << " " << v[2] << " " << v[3] << " " << v[4] << endl;
}



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

using namespace std;

int main(){
  int N, K;
  string S;
  cin >> N >> S >> K;
  char s;
  s = S[K-1];

  for(int i=0; i<N; i++){
    if(S[i] != s) S[i] = '*';
  }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

import numpy as np
a = list(np.cumsum(a))

ans = 100000000000000000

for i in range(n-1):
    ans = min(ans, abs(a[-1]-a[i]*2))

print(ans)

Measured memory_bytes: 28688
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int dys[] = {-1, -1, 0, 0, 1, 1};
    int dx_odd[] = {-1, 0, -1, 1, -1, 0};
    int dx_even[] = {0, 1, -1, 1, 0, 1};
    int n, m;
    while(cin >> m >> n, m){
        vector<vector<int>> v(n+2, vector<int>(m+2, -1));
        auto ddist = v;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                v[i+1][j+1] = 0;
                ddist[i+1][j+1] = INF<int>;
            }
        }
        int s;
        cin >> s;
        vector<int> ys(s), xs(s);
        for (int i = 0; i < s; ++i) {
            cin >> xs[i] >> ys[i];
        }
        int ans = 0;
        int q;
        cin >> q;
        for (int i = 0; i < q; ++i) {
            int xx, yy;
            cin >> xx >> yy;
            ys.emplace_back(yy);
            xs.emplace_back(xx);
            auto vv = v, dist = ddist;
            queue<pair<int, int>> Q;
            for (int j = 0; j < ys.size(); ++j) {
                Q.emplace(ys[j], xs[j]);
                vv[ys[j]][xs[j]] = j+1;
                dist[ys[j]][xs[j]] = 0;
            }
            while(!Q.empty()){
                int y, x; tie(y, x) = Q.front(); Q.pop();
                for (int k = 0; k < 6; ++k) {
                    int ya = y + dys[k], xa = x + (y&1 ? dx_odd :dx_even)[k];
                    if(!~v[ya][xa]) continue;
                    if(dist[ya][xa] > dist[y][x]+1){
                        dist[ya][xa] = dist[y][x]+1;
                        vv[ya][xa] = vv[y][x];
                        Q.emplace(ya, xa);
                    }else if(dist[ya][xa] == dist[y][x]+1) {
                        if(vv[ya][xa] != vv[y][x]){
                            vv[ya][xa] = -1;
                        }
                    }
                }
            }
            int val = 0;
            for (int j = 0; j < n; ++j) {
                for (int k = 0; k < m; ++k) {
                    val += (vv[j+1][k+1] == ys.size());
                    // cout << vv[j+1][k+1] << " ";
                }
                // puts("");
            }
            ans = max(ans, val);
            ys.pop_back();
            xs.pop_back();
        }
        cout << ans << "\n";
    }
    return 0;
}


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


using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 1e5 + 5;
bool isPrime[MAXN];

void sevie() {
    memset(isPrime, 1, sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for (ll i = 2; i * i <= MAXN; i++) {
        if (isPrime[i]) {
            for (ll j = i * 2; j <= MAXN; j += i) {
                isPrime[j] = 0;

            }
        }
    }
}

ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (!(b & 1)) {
        return fastPow(x * x, b / 2);
    } else
        return x * fastPow(x * x, (b - 1) / 2);
}

//__builtin_popcount ();
bool isPrim(int n) {
    if (n == 1 || n == 0)
        return false;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0)
            return false;
    }
    return true;
}


int main() {
    FAST
    ll n, k;
    cin >> n >> k;
    vector<ll> v;
    ll arr[k];
    for (int i = 0; i < k; i++) {
        cin >> arr[i];
    }
    sort(arr, arr + k);
    for (int i = 1; i < k; i++) {
        v.push_back(arr[i] - arr[i - 1]);
    }
    v.push_back(n - arr[k - 1] + arr[0]);
    sort(v.begin(), v.end());
    ll sum = 0;
    for (int i = 0; i < v.size(); i++) {
        sum += v[i];
    }
    cout << sum - v[v.size() - 1] << endl;
    return 0;
}

Measured memory_bytes: 3956
ini=input("").split(" ")
x=abs(int(ini[0]))
k=int(ini[1])
d=int(ini[2])
if(k%2==1):
    k-=1
    x=abs(x-d)
if((x-k*d)>=0):
    print(x-k*d)
else:
    c=int(x/(2*d))
    if(abs(x-c*2*d)<abs(x-c*2*d-2*d)):
        print(x-c*2*d)
    else:
        print(abs(x-c*2*d-2*d))



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

#define MAX 100000

std::vector<int>Graph[MAX];
bool visited[MAX];

int N;

int prenum[MAX], parent[MAX], lowest[MAX], timer;

void dfs(int current, int prev) {

    prenum[current] = lowest[current] = timer;
    timer++;

    visited[current] = true;

    int next;

    for (int i = 0; i < Graph[current].size(); i++) {
        next = Graph[current][i];
        if (!visited[next]) {
            parent[next] = current;
            dfs(next, current);

            lowest[current] = std::min(lowest[current], lowest[next]);
        }
        //ha a szomszedos vertex (next) mar vizsgalt, es az elter a szulo vertextol (ez a back edge jele)
        else if (prev != next) {
            lowest[current] = std::min(lowest[current], prenum[next]);
        }
    }
}

void art_points() {
    for (int i = 0; i < N; i++) visited[i] = false;

    timer = 1;

    dfs(0, -1); //0 == root

    std::set<int> ap; //ebbe mentjuk a tagolasi pontokat, kerulve az ismetlodest

    int np = 0;

    for (int i = 1; i < N; i++) {
        int p = parent[i]; //i hez tartozo szulo meghatarozasa
        if (p == 0) np++; //ha a parentnek min. ket gyereke van, akkor o is art point
        else if (prenum[p] <= lowest[i]) { ap.insert(p); } //art pont alap keplete
    }

    if (np > 1) ap.insert(0);

    for(std::set<int>::iterator it = ap.begin(); it != ap.end(); it++) {
        std::cout << *it << std::endl;
    }

}


int main()
{
    int Edges;
    std::scanf("%d %d", &N, &Edges);
    int start, target;


    for (int i = 0; i < Edges; i++) {
        std::scanf("%d %d", &start, &target);
        Graph[start].push_back(target);
        Graph[target].push_back(start);
    }

    art_points();


return 0;
}



Measured memory_bytes: 6940
from collections import deque
n,k = map(int,input().split())
a = deque(map(int,input().split()))
a.appendleft(0)

stop = False
#行き止まりcheck
used = set()
current = 1
old = -1
route = []
route_b4 = []
neverloop = True
#bagunoもと
for i in range(n):
    if old == current:
        stop == True
    if current in used:
        for i,city in enumerate(route):
            if city == current:
                route = route[i:]
                neverloop = False
            route_b4.append(city)

        break
    route.append(current)
    used.add(current)
    old = current
    current = a[current]
if neverloop == True:
    route_b4 = []
if stop==True:
    if len(route_b4) + len(route) >= k:
        if len(route_b4) > k:
            #自信ない
            print(route_b4[k])
        else:
            print(route[k-len(route_b4)])
    else :
        print(route[len(route)-1])
else:
    if len(route_b4) + len(route) >= k:
        if len(route_b4) > k:
            print(route_b4[k])
        else:
            print(route[k-len(route_b4)])
    else:
        total = k + len(route_b4)
        print(route[(k-len(route_b4))%len(route)])

#print(stop)
#print(route_b4)
#print(route)
#巡回路チェック

Measured memory_bytes: 145684
#include<stdio.h>
//int ca[500],cb[500],a[500],b[500],n,m;
int g(int t,int r){
  int i=t;
  if(t<r){
    t=r;
    r=i;
  }
  if(r==0)return t;
  return g(r,t%r);
}   
int main(){
  int i,j,min,mi,mj,c;
  int a[500],b[500],n,m;
  while(scanf("%d %d",&n,&m),n||m){
    int d[500][500]={0};
    int ca[500]={0};
    int cb[500]={0};
    for(i=c=0;i<n;i++)scanf("%d",&a[i]);
    for(j=0;j<m;j++)scanf("%d",&b[j]);
    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
	if(g(a[i],b[j])-1){//printf(":%d %d\n",a[i],b[j]);
	  d[i][j]=1;
	  ca[i]++;
	  cb[j]++;
	}//printf("%d ",d[i][j]);
      }//printf("\n");
    }
    //for(i=0;i<n;i++)printf("%d ",ca[i]);printf("\n");
    //for(j=0;j<m;j++)printf("%d ",cb[j]);printf("\n");
    while(1){
      min=2100000000;
      mj=-1;
      for(i=0;i<n;i++){
	if(ca[i]==0)continue;
	if(min>ca[i]){
	  min=ca[i];
	  mi=i;
	}
      }
      for(j=0;j<m;j++){
	if(cb[j]==0)continue;
	if(min>cb[j]){
	  min=cb[j];
	  mj=j;
	}
      }
      if(mj==-1){
	for(j=0;j<m;j++){
	  if(d[mi][j])break;
	}
	mj=j;
      }
      else{
	for(i=0;i<n;i++){
	  if(d[i][mj])break;
	}
	mi=i;
      }
      //printf("%d %d\n",ca[mi],cb[mj]);
      if(min==2100000000)break;
      c++;
      //d[mi][mj]=0;
      for(i=0;i<n;i++){
	if(d[i][mj]){
	  d[i][mj]=0;
	  ca[i]--;
	  cb[mj]--;
	}
      }
      for(j=0;j<m;j++){
	if(mj==j)continue;
	if(d[mi][j]){
	  d[mi][j]=0;
	  ca[mi]--;
	  cb[j]--;
	}
      }
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 1592
n=int(input())
Range=[]
ans,end=0,-1*(10**9+1)
for i in range(n):
  x,y=list(map(int,input().split()))
  Range.append([x-y,x+y])
Range.sort(key=lambda X: X[1])

for R in Range:
  if end <= R[0]:
    ans += 1
    end=R[1]
  else:
    continue
print(ans)

Measured memory_bytes: 21800
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
A = [input().rstrip() for _ in range(H)]
dp = [[float('inf') if A[i][j] == '.' else 0 for j in range(W)] for i in range(H)]
for i in range(H):
    for j in range(W):
        if i > 0:
            dp[i][j] = min(dp[i][j], dp[i-1][j] + 1)
        if j > 0:
            dp[i][j] = min(dp[i][j], dp[i][j-1] + 1)
for i in range(H)[::-1]:
    for j in range(W)[::-1]:
        if i < H-1:
            dp[i][j] = min(dp[i][j], dp[i+1][j] + 1)
        if j < W-1:
            dp[i][j] = min(dp[i][j], dp[i][j+1] + 1)
for i in range(H):
    for j in range(W)[::-1]:
        if i > 0:
            dp[i][j] = min(dp[i][j], dp[i-1][j] + 1)
        if j < W-1:
            dp[i][j] = min(dp[i][j], dp[i][j+1] + 1)
for i in range(H)[::-1]:
    for j in range(W):
        if i < H-1:
            dp[i][j] = min(dp[i][j], dp[i+1][j] + 1)
        if j > 0:
            dp[i][j] = min(dp[i][j], dp[i][j-1] + 1)
print(max(max(row) for row in dp))


Measured memory_bytes: 132188
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);
    
    int N;
	cin >> N;
	int P[2020] = {};//i番目のマスにおかれている駒
	int A[2020];//i番目の駒が置かれている位置
	for(int i=0; i<N; i++){
		int X;
		cin >> X;
		A[i+1] = X;
		P[X] = i+1;
	}

	int M;
	cin >> M;
	for(int i=0; i<M; i++){
		int a;
		cin >> a;
		if(A[a] != 2019 && P[A[a]+1] == 0){
			P[A[a]] = 0;
			P[A[a]+1] = a;
			A[a]++;
		}
	}

	for(int i=1; i<=N; i++){
		cout << A[i] << endl;
	}
    
    return 0;
}



Measured memory_bytes: 3192
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, k;

	cin >> a >> b >> k;
	if (b - a + 1 >= 2 * k) {
		rep(i, a, a + k) {
			cout << i << endl;

		}
		rep(j, b - k + 1, b + 1) {
			cout << j << endl;
		}
	}
	else {
		
		rep(i, a, b + 1) {

			cout << i << endl;
		}
	}
	

}
	

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int n,m,tmp,l;

  scanf("%d%d",&n,&m);
  if(n<m){
    tmp = n;
    n = m;
    m = tmp;
  }

  l = n%m;

  while(l != 0){
    n = m;
    m = l;
    l = n%m;
  }
  printf("%d\n",m);

  return 0;
}


Measured memory_bytes: 2064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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 DD = double; // 精度が足りないときはlong double
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

struct Point {
    DD x, y, z;
    Point (DD x = 0, DD y = 0, DD z = 0): x(x), y(y), z(z) {}

    Point& operator+=(const Point &p) { x += p.x; y += p.y; z += p.z; return *this;}
    Point operator+(const Point &p) const { return Point(*this) += p;}
    Point& operator-=(const Point &p) { x -= p.x; y -= p.y; z -= p.z; return *this;}
    Point operator-(const Point &p) const { return Point(*this) -= p;}
    Point& operator*=(DD a) { x *= a; y *= a; z *= a; return *this;}
    Point operator*(DD a) const { return Point(*this) *= a;}
    Point& operator/=(DD a) { x /= a; y /= a; z /= a; return *this;}
    Point operator/(DD a) const { return Point(*this) /= a;}
    bool operator== (const Point &p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;}
    friend istream& operator >>(istream& is, Point& p) { is >> p.x >> p.y >> p.z; return is;}
    friend ostream& operator <<(ostream& os, const Point& p) { os<< p.x <<" "<< p.y << " " << p.z; return os;}
};

typedef Point Vector;
inline DD norm(const Vector &a) { return a.x * a.x + a.y * a.y + a.z * a.z;}
inline DD abs(const Vector &a) { return sqrt(norm(a));}
inline DD dot(const Vector &a, const Vector &b) { return a.x * b.x + a.y * b.y + a.z * b.z;}
inline DD cross(const Vector &a, const Vector &b) { return 0.5 * sqrt(norm(a)*norm(b) - dot(a,b)*dot(a,b));}

struct Segment {
    Point p1,p2;
    Segment() = default;
    Segment(Point p1, Point p2) : p1(p1),p2(p2) {}
};

typedef Segment Line;

Point project(const Segment &s, const Point &p) {
    Vector base = s.p2 - s.p1;
    DD r = dot(p - s.p1, base) / norm(base);
    return s.p1 + base * r;
}

inline DD getDistanceLP(const Line &l, const Point &p) { return abs(project(l,p) - p);}
DD getDistanceSP(const Segment &s, const Point &p) {
    if (dot(s.p2 - s.p1,p - s.p1) < 0.0) return abs(p - s.p1);
    if (dot(s.p1 - s.p2,p - s.p2) < 0.0) return abs(p - s.p2);
    return getDistanceLP(s, p);
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,Q; cin >> N >> Q;
    vector<Point> A(N);
    vector<ll> r(N),l(N);
    rep(i,N) cin >> A[i] >> r[i] >> l[i];

    rep(i,Q) {
        Point s,t; cin >> s >> t;
        Segment S = {s,t};
        ll ans = 0;
        rep(j,N) {
            if (r[j] > getDistanceSP(S,A[j]) - EPS) ans += l[j];
        }
        cout << ans << ln;
    }
}



Measured memory_bytes: 3292
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	string S;
	map<char,int> map_c;

	cin >> S;	

	for (int ci = 0; ci < 4; ci++){
		map_c[S[ci]]++;
	}

	int flag = 1;
	for(auto pc : map_c){
		if (pc.second != 2){
			flag = 0;
			break;
		}
	}

	if (flag == 1){
		printf("Yes");
	}else{
		printf("No");
	}


	return 0;
}



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

int main(){
    double W,H,x,y;
    cin >> W >> H >> x >> y;
    cout << W*H/2.0 << " ";
    if(x==W/2&&y==H/2){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int max = 0;
    for(int i=1;i<=k;++i){
        if(i<=a){
            max++;
        }else if(i<=a+b){

        }else{
            max--;
        }
    }
    cout << max << endl;
}

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

template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
const int N = 2333;
int dfn[N], low[N], dfs_clock = 0;
int S[N], top = 0, scc_cnt = 0, sccno[N];
int c[N], d[N], a[N][N];
int n, m, ans[N * N];
vector<int> g[N];

inline void tarjan(int u, int fat) {
  dfn[u] = low[u] = ++ dfs_clock;
  S[++ top] = u;
  for (int v : g[u]) {
    if (!dfn[v]) {
      tarjan(v, u);
      low[u] = min(low[u], low[v]);
    }
    else if (!sccno[v])
      low[u] = min(low[u], dfn[v]);
  }
  if (low[u] == dfn[u]) {
    ++ scc_cnt;
    for (;;) {
      int v = S[top --];
      sccno[v] = scc_cnt;
      if (v == u) break;
    }
  }
}

inline void dfs1(int u, int cl) {
  if (c[u]) return ;
  c[u] = cl;
  for (int v : g[u])
    dfs1(v, cl);
}

inline void dfs2(int u, int cl) {
  if (d[u]) return ;
  d[u] = cl;
  for (int v : g[u])
    dfs2(v, cl);
}

main(void) {
  read(n); read(m);
  for (int i = 1; i <= m; i ++) {
    int x, y; read(x); read(y);
    a[x][y] = i; g[x].push_back(y);
  }
  for (int i = 1; i <= n; i ++)
    if (!dfn[i]) tarjan(i, 0);
  // for (int i = 1; i <= n; i ++)
  //   cout << sccno[i] << " "; puts("");
  for (int i = 1; i <= n; i ++) {
    memset(c, 0, sizeof c); 
    sort(g[i].begin(), g[i].end());
    c[i] = i;
    for (int v : g[i])
      dfs1(v, v);
    
    memset(d, 0, sizeof d);
    reverse(g[i].begin(), g[i].end());
    d[i] = i;
    for (int v : g[i])
      dfs2(v, v);
    
    // cout << i << "qwq\n";
    // for (int v = 1; v <= n; v ++)
    //   cout << c[v] << " "; puts("");
    // for (int v = 1; v <= n; v ++)
    //   cout << d[v] << " "; puts("");
    for (int v : g[i])
      ans[a[i][v]] = (sccno[i] == sccno[v]) ^ (c[v] != d[v]);
  }
  for (int i = 1; i <= m; i ++)
    puts(ans[i] ? "diff" : "same");
}


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

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

    int answer=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int a=0;
            for(int k=0;k<d;k++){
                a+=pow(x[i][k]-x[j][k],2);
            }
            double b=sqrt(a);
            int  c=b;
            if(b==c){
                answer++;
            }
        }
    }
    printf("%d",answer);
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, k;
  cin >> n >> k;
  vll as(n);
  rep(i, n) cin >> as[i];

  vll dp(k + 1, 0);
  vll csum;
  dp[k] = 1;
  repLRE(i, 1, n) {
    vll ndp(k + 1, 0);
    csum.assign(k + 2, 0);
    rep(j, k + 1) csum[j + 1] = (dp[j] + csum[j])%mod;
    rep(j, k + 1) {
      ll bp = min(k + 1, j + as[i-1] + 1);
      ndp[j] = (csum[bp] - csum[j] + mod)%mod;
    }
    dp = ndp;
  }

  cout << dp[0] << endl;

  return 0;
}


Measured memory_bytes: 2560
n, m = gets.split.map(&:to_i)


# factorize m
fs = []
2.upto(Math.sqrt(m).ceil) do |i|
  cnt = 0
  while m % i == 0
    m /= i
    cnt += 1
  end

  fs << cnt if cnt != 0
end

if m != 1
  fs << 1
end

total = 1
fs.each do |f|
  comb = Array.new(n + 1, 1)

  fmax = f

  fmax.times do
    1.upto(comb.size - 1) do |i|
      comb[i] = comb[i] + comb[i - 1]
    end
  end

  total *= comb[n - 1]
  total %= 1_000_000_007
end

p total


Measured memory_bytes: 51964
def main():
    h, w, k = map(int, input().split())
    MOD = 10 ** 9 + 7

    patterns = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
    x = [0] * (w - 1)
    for i in range(w-1):
        x[i] = patterns[i] * patterns[max(0, w-i-2)]

    y = [0] * w
    for i in range(w):
        y[i] = patterns[i] * patterns[max(0, w-i-1)]

    dp = [[0] * w for _ in range(h+1)]
    dp[0][0] = 1
    for j in range(h):
        for i in range(w):
            d = dp[j][i] * y[i]
            if i - 1 >= 0:
                d += dp[j][i-1] * x[i-1]
            if i + 1 < w:
                d += dp[j][i+1] * x[i]
            dp[j+1][i] = d % MOD
    print(dp[h][k-1])


main()


Measured memory_bytes: 3064
#!/usr/bin/env python3

N = int(input())

for x in range(N // 7 + 1):
    if (N - 7 * x) % 4 == 0:
        print('Yes')
        break
else:

    print('No')

# 7x + 4y = N
# y = (N - 7x) / 4 (4で割り切れる)


Measured memory_bytes: 2940
n,m,q=map(int,input().split())
import numpy as np
dim2=np.zeros((n+1,n+1),dtype='int8')

for _ in range(m):
    l,r=map(int,input().split())
    dim2[l][r]+=1

dim2=np.cumsum(dim2,axis=0)

dim2=np.cumsum(dim2,axis=1)
for _ in range(q):
    p,q=map(int, input().split())
    ans=dim2[q][q]-dim2[q][p-1]-dim2[p-1][q]+dim2[p-1][p-1]
    print(ans)

Measured memory_bytes: 30936
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

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

int main(){
  // 入力
  ll D; cin >> D;
  ll N = 26;
  vector<ll> c(N); rep(i,N) cin >> c[i];

  vector<vector<ll> > s(D , vector<ll>(N));
  rep(i,D) rep(j,N) cin >> s[i][j];

  vector<ll> t(D); rep(i,D) {cin >> t[i]; t[i]--;};

  // score計算
  ll score = 0;
  map<ll,ll> m;
  rep(i,N) m[i] = 0;
  rep(i,D){
    score += s[i][t[i]];
    m[t[i]] = i + 1;

    rep(j,N){
      score -= (i - m[j] + 1) * c[j];
    }
    cout << score << endl;
  }

}


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

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

  vector<int> dp(s.size());
  dp[0] = 1;
  if (2 <= s.size()) dp[1] = (s[0] == s[1] ? 1 : 2);
  if (3 <= s.size()) dp[2] = (s[0] != s[1] && s[1] != s[2] ? 3 : 2);

  for (int i = 3; i < s.size(); i++) {
    if (s[i - 1] != s[i]) {
      dp[i] = dp[i - 1] + 1;
    } else {
      dp[i] = dp[i - 3] + 2;
    }
  }

  cout << dp[s.size() - 1] << endl;
  return 0;
}


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

int main(){
    int N,K; cin>>N>>K;
    vector<ll> A(N+1,0);
    rep(i,N) cin>>A[i+1];

    for(int i=K; i<N; i++){
        if(A[i-K+1]<A[i+1]){
            cout << "Yes"<< endl;
        }else{
            cout << "No" <<endl;
        }
    }
}


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

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; }

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

int main() {
  int n,m;
  cin>>n>>m;
  
  int ma=0,mi=100010;
  
  rep(i,m){
    int x,y;
    cin>>x>>y;
    chmax(ma,x);
    chmin(mi,y);
  }
  cout << max(0,mi-ma+1)<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if (a>b){
	printf("a > b\n");
	}else if (a<b){
	printf("a < b\n");
	}else{
	printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
n, w = map(int, input().split())
lst = [[0,0]]
vmax = 0
for _ in range(n):
    a, b = map(int, input().split())
    lst.append([a,b])
    vmax += b

dp = [[w+1] * (vmax+1) for _ in range(n+1)]
dp[0][0] = 0
ans = 0

for i in range(0, n):
    for sum_v in range(0, vmax+1):
        if sum_v  >= lst[i+1][1]:
            dp[i+1][sum_v] = min(dp[i][sum_v -  lst[i+1][1]] + lst[i+1][0], dp[i][sum_v])
        else:
            dp[i+1][sum_v] = dp[i][sum_v]
        if dp[i+1][sum_v] <= w:
            ans = max(ans, sum_v)

print(ans)

Measured memory_bytes: 120684
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int a = sc.nextInt();
	if (n % 500 <= a) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


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

const int maxk = 100002;

int k;
int64_t a[maxk];

int main() {
    //freopen("icerink.inp", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> k;
    for (int i=1; i<=k; ++i)
        cin >> a[i];
    int64_t l=2, r=2;
    for (int i=k; i>=1; --i) {
        if (l>r) {
            cout << -1;
            return 0;
        }
        l = (l/a[i]+(l%a[i]!=0))*a[i];
        r = r/a[i]*a[i]+a[i]-1;
    }
    if (l>r) {
        cout << -1;
        return 0;
    }
    cout << l << ' ' << r << '\n';
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define I64 "%I64d"
#define RAN(v)v.begin(),v.end()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
using namespace std;
typedef long long ll;
template<class T>
inline void upd1(T&a,T b){a>b?a=b:0;}
template<class T>
inline void upd2(T&a,T b){a<b?a=b:0;}
struct ano{
	operator ll(){
		ll x=0,y=0,c=getchar();
		while(c<48)
			y=c==45,c=getchar();
		while(c>47)
			x=x*10+c-48,c=getchar();
		return y?-x:x;
	}
}buf;
int main(){
	string a,b;
	deque<int>c;
	int s=0;
	cin>>a,a="x"+a+"x";
	for(char e:a)
		if(e=='x')++s;
		else
			b+=e,c.pb(s),s=0;
	c.pb(s),s=0;
	if(b!=string(b.rbegin(),b.rend()))
		return!~puts("-1");
	while(c.size()>1)
		s+=abs(c.front()-c.back()),c.pop_front(),c.pop_back();
	printf("%d\n",s);
}

Measured memory_bytes: 1020
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    int n,m; cin >> n >> m;
    unordered_map<int, int> mp;
    unordered_map<int, int> keys;

    rep(i, 1<<n) mp[i] = -1;
    
    rep(i,m){
        int a,b; cin >> a >> b;
        int x = 0;
        rep(j,b){
            int c; cin >> c; --c;
            x += (1<<c);
        }

        if(keys[x]==0) keys[x] = a;
        else keys[x] = min(keys[x], a);
    }

    mp[0] = 0;

    rep(i, 1<<n){
        for(auto const& x: keys){
            if(mp[i] == -1) continue;
            
            int new_key = i | x.first;

            if(mp[new_key] == -1) mp[new_key] = mp[i]+x.second;
            else mp[new_key] = min(mp[new_key], mp[i]+x.second);
        }
    }

    cout << mp[(1<<n)-1] << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
using namespace std;
#pragma endregion
signed main() {
	int A,B;
	cin >> A >> B;
	cout << CEIL(A+B,2);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int n,b,f,r,v;
int room[5][4][11];
for(int i=0; i<5; i++){
for(int j=0; j<4; j++){
for(int k=0; k<11; k++){
room[i][j][k]=0;
}
}
}
cin >> n;
for(int i=0; i<n; i++){
cin >> b >> f >> r >> v;
room[b][f][r]+=v;
}
for(int i=1; i<5; i++){
for(int j=1; j<4; j++){
for(int k=1; k<11; k++){
cout << " " << room[i][j][k];
}
cout <<endl;
}
if(i!=4) cout << "####################" <<endl;
}
return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

void print(int y, int x){
	for(int i = 0; i < y; i++){
		cout<<"U";
	}
	for(int i = y; i < 0; i++){
		cout<<"D";
	}
	for(int i = 0; i < x; i++){
		cout<<"R";
	}
	for(int i = x; i < 0; i++){
		cout<<"L";
	}
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int sx, sy, tx, ty;
	
	cin>>sx>>sy>>tx>>ty;
	
	
	print(ty-sy, 0);
	print(0, tx-sx);
	print(sy-ty, 0);
	print(0, sx-tx);
	print(0,-1);
	print(ty-sy+1,0);
	print(0, tx-sx+1);
	print(-1,0);
	print(0,1);
	print(sy-ty-1, 0);
	print(0, sx-tx-1);
	print(1,0);

	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
const int inf = 1012345678;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    string s; cin >> s;
    int ans = 0;
    int tmp = 0;

    rep(i,s.size()){
        if(s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T'){
            tmp++;
            chmax(ans, tmp);
        }
        else tmp = 0;
    }
    cout << ans << ln;
    return 0;
}

Measured memory_bytes: 256