akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// 
ll N;
ll K;
ll h[101000];
ll s[101000];
ll ans = 5000000000;

int main(){
    cin >> N >> K;
    rep(i, 0, N){
        cin >> h[i];
    }
    sort(h, h+N);
    rep(i, 0, N-K+1){
        ans = min(ans, h[i+K-1] - h[i]);
    }


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




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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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

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

#define HW_MAX 500


struct ansst{
    ll y1, x1, y2, x2;
};

ll ansv;
vector<ansst> ans;

int H, W;
int a[HW_MAX][HW_MAX];
pair<ll, ll> yx[HW_MAX*HW_MAX];
ll v[HW_MAX*HW_MAX];
ll ruiseki_v[HW_MAX*HW_MAX];


int main(){
    ios::sync_with_stdio(false);
    cin >> H >> W;
    REP(i, H) REP(j, W) cin >> a[i][j];
    
    
    REP(i, H) REP(j, W) {
        ll w = i % 2 == 0 ? j : W - 1 - j;
        yx[i*W+j] = pair<ll, ll>(i, w);
        v[i*W+j] = a[i][w];
    }
    
    REP(i, H*W-1) {
        if (v[i] % 2) {
            v[i]--;
            v[i+1]++;
            ans.pb(ansst{yx[i].first, yx[i].second, yx[i+1].first, yx[i+1].second});
        }
    }
    
    cout << ans.size() << endl;
    REP(i, ans.size()) {
        cout << ans[i].y1+1 << " " << ans[i].x1+1 << " " << ans[i].y2+1 << " " << ans[i].x2+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 13296
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE



void solve(void)
{
  string S,T;
  cin>>S>>T;
  if(T.size() >S.size())
  {
    cout<<"UNRESTORABLE"<<endl;
    return;
  }
  string ANS ="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
  for (int i = 0; i < S.size() - T.size() + 1; i++)
  {
    int ok = 1;
    auto tmp = S;
    for (int j = 0; j < T.size(); j++)
    {
      if(S[i+j] != T[j] && S[i+j] != '?')ok = 0;
      tmp[i+j] = T[j];
    }
    // DEBUG(tmp);
    if(ok == 1)
    {
      for (int k = 0; k < tmp.size(); k++)
      {
        if(tmp[k] == '?') tmp[k] = 'a';
      }
      
      chmin(ANS,tmp);
    }

  }
  if(ANS == "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz")
  {
    cout<<"UNRESTORABLE"<<endl;
    return;
  }
  cout<<ANS<<endl;

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

using namespace std;

string S;
long long D, N;

int main() {
  cin >> S;
  for(int i = 0; i < (int)S.size(); ++i) {
    if(S[i] == 'W') { D += i; ++N; }
  }
  cout << D - (N - 1) * N / 2 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
	vector<int> yen (3);
	cin >> yen.at(0) >> yen.at(1) >> yen.at(2);
	sort(yen.begin(),yen.end());
	cout << yen.at(0) + yen.at(1) << endl;
	return 0;
}

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

using namespace std;

int NN = 1;
struct Node{
  int f, g, l, r;
  int lazy;
};
Node segT[2*(1<<17)-1]; // =131072

class LazySegT{
public:
  LazySegT(){
	for(int i=0;i<2*NN-1;++i){
	  segT[i].f = segT[i].g = segT[i].l = segT[i].r = 0;
	  segT[i].lazy = -1;
	}
  }

  void eval(int k, int l, int r){
	if(segT[k].lazy < 0) return;
	
	segT[k].f = (r-l) * segT[k].lazy;
	segT[k].g = (r-l-1) * segT[k].lazy;
	segT[k].l = segT[k].r = segT[k].lazy;

	if(k < NN-1){ // not leaf
	  segT[2*k+1].lazy = segT[2*k+2].lazy = segT[k].lazy;
	}
	segT[k].lazy = -1;
  }

  void update(int a, int b, int bit, int k=0, int l=0, int r=NN){
	eval(k,l,r);
	if(r <= a || b <= l) return;

	if(a <= l && r <= b){
	  segT[k].lazy = bit;
	  eval(k,l,r);
	}
	else{
	  int m = (l+r) / 2;
	  update(a, b, bit, k*2+1, l, m);
	  update(a, b, bit, k*2+2, m, r);

	  segT[k].f = segT[k*2+1].f + segT[k*2+2].f;
	  segT[k].g = segT[k*2+1].g + segT[k*2+2].g + segT[k*2+1].r * segT[k*2+2].l;
	  segT[k].l = segT[k*2+1].l;
	  segT[k].r = segT[k*2+2].r;
	}
  }

  int query(){
	eval(0, 0, NN);
	return segT[0].f - segT[0].g;
  }
};

int main(){
  int N; cin >> N;
  while(NN < N) NN <<= 1;
  string X; cin >> X;
  int Q; cin >> Q;

  LazySegT seg;
  for(int i=0;i<X.size();++i){
	seg.update(i, i+1, X[i]-'0');
  }

  for(int q=0;q<Q;++q){
	int l, r, b;
	cin >> l >> r >> b;
	--l;
	seg.update(l, r, b);
	cout << seg.query() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 8420
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.Reader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        H_Grid solver = new H_Grid();
        solver.solve(1, in, out);
        out.close();
    }

    static class H_Grid {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int h = in.ni(), w = in.ni();
            char[][] map = in.nm(h, w);
            long[][] dp = new long[h + 1][w + 1];
            long mod = (int) 1e9 + 7;
            dp[0][0] = 1;
            for (int r = 0; r < h; r++) {
                for (int c = 0; c < w; c++) {
                    if (map[r][c] == '.') {
                        if (r > 0) {
                            dp[r][c] += dp[r - 1][c];
                        }
                        if (c > 0)
                            dp[r][c] += dp[r][c - 1];
                        dp[r][c] %= mod;
                    }
                }
            }
            out.println(dp[h - 1][w - 1]);

        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

        public char[] ns(int n) {
            char[] buf = new char[n];
            try {
                in.read(buf);
            } catch (IOException e) {
                throw new RuntimeException();
            }
            return buf;
        }

        public char[][] nm(int n, int m) {
            char[][] map = new char[n][];
            for (int i = 0; i < n; i++) {
                map[i] = ns(m);
                readLine();
            }
            return map;
        }

        public String readLine() {
            try {
                return in.readLine();
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }

    }
}



Measured memory_bytes: 35412
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int a,b;cin>>a>>b;
    int area = a*b; int length = a*2+b*2;
    printf("%d %d\n", area,length);
    return 0;
}


Measured memory_bytes: 3132
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	s <- getLine
	putStrLn $ ( head s ) : ( show $ length s - 2 ) ++ [ last s ]


Measured memory_bytes: 380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9

#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

const ll inf = 1LL << 60;

int main(){
    //cin.tie(nullptr);
	//ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int N; cin>>N;
    map<string,int> ans;
    REP(i,N){
        string S;
        cin>>S;
        ans[S]++;
    }
    printf("AC x %d\n", ans["AC"]);
    printf("WA x %d\n", ans["WA"]);
    printf("TLE x %d\n", ans["TLE"]);
    printf("RE x %d\n", ans["RE"]);
}

Measured memory_bytes: 3728
# coding: utf-8
from bisect import bisect_left, bisect_right
def check(x):
    flag = True
    for i in range(2, int(x**0.5) + 1):
        if x % i == 0:
            flag = False
            break
    return flag

def primes(n):  
    is_prime = [True] * (n + 1)  
    is_prime[0] = False  
    is_prime[1] = False  
    for i in range(2, int(n**0.5) + 1):  
        if not is_prime[i]:  
            continue  
        for j in range(i * 2, n + 1, i):  
            is_prime[j] = False  
    return [i for i in range(n + 1) if is_prime[i]]
def primes_plus(l):
    # l: 素数の配列
    L = []
    for p in l:
        if check((p+1)//2):
            L.append(p)
    return L
l_primes = primes(10**6)
l_primes = primes_plus(l_primes)[1:]
# print(len(l_primes))
Q = int(input())
for i in range(Q):
    ans = 0
    l, r = map(int, input().split())
    r += 1
    l_idx = bisect_left(l_primes, l)
    r_idx = bisect_left(l_primes, r)
    # print(l_idx, r_idx)
    if l == r and l_idx == r_idx and l == l_primes[l_idx]:
        print(1)
    else:
        print(r_idx - l_idx)
# print(l_primes)

Measured memory_bytes: 61052
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  int n,ii;
  vector<string> shiri;
  set<string> set;
  cin >> n;
  shiri.resize(n);

  for(ii=0;ii<n;ii++){
	cin >> shiri[ii];
  }
  bool flg=true;
  set.insert(shiri[0]);

  for(ii=1;ii<n;ii++){
	if(shiri[ii-1][shiri[ii-1].size()-1] == shiri[ii][0] &&
	   set.find(shiri[ii]) == set.end()){
	  set.insert(shiri[ii]);
	}
	else{
	  //cout << "ii:" << ii << "  "<< shiri[ii] << endl;
	  flg = false;
	  break;
	}
  }
  
  if(flg){
	cout << "Yes" << endl;
  }
  else{
	cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio> 
#include<cstring>
using namespace std;
int main()
{
	string s;int len,flag=0;
	cin>>s;
	len=s.length();
	for(int i=0;i<len;i++)
	{
		if(s[i]=='C') 
		{
			for(int j=i+1;j<len;j++)
				if(s[j]=='F')
				{
					cout<<"Yes";
					return 0;
				}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc161
{
    class Program
    {
        static void Main(string[] args)
        {
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc161C();
        }
        public static void solve_abc161C()
        {
            long[] nk = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            long n = nk[0];
            long k = nk[1];
            long r = n % k;
            if (n < k)
            {
                Console.WriteLine(Math.Min(n , Math.Abs(n - k)));
            }
            else if (r == 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(Math.Abs(r - k));
            }
        }

        public static void solve_abc161B()
        {
            int[] nm = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int n = nm[0];
            int m = nm[1];
            int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                sum += a[i];
            }
            int cnt = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[i] >= (double)sum / (4 * m))
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt >= m ? "Yes" : "No");
        }

        public static void solve_abc161A()
        {
            int[] xyz = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Console.WriteLine("{0} {1} {2}", xyz[2], xyz[0],xyz[1]);
        }
    }
}


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

int main() {
    int N; cin >> N;
    vector<long long> C(N + 1, 0);
    for(int i=0; i<N; ++i) {
        int a; cin >> a;
        C[a] += 1;
    }
    vector<long long> D(N + 1, 0);
    for(int i=0; i<=N; ++i) {
        D[C[i]] += 1;
    }
    vector<long long> sum1(N + 1, 0), sum2(N + 1, 0);
    for(int i=1; i<=N; ++i) {
        sum1[i] = sum1[i - 1] + D[i];
        sum2[i] = sum2[i - 1] + i * D[i];
    }

    vector<long long> F(N + 1, 0);
    for(int x=1; x<=N; ++x) {
        F[x] = (sum2[x] + x * (sum1[N] - sum1[x])) / x;
    }

    for(int k=1; k<=N; ++k) {
        auto it = lower_bound(rbegin(F), rbegin(F) + N, k);
        if(it == rbegin(F) + N) cout << 0 << endl;
        else cout << N - (it - rbegin(F)) << endl;
    }
}

Measured memory_bytes: 12544
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 2 * 105000;

int n;
int a[MAXN];
int ans;
int mn = (int) 1e9;

int main() { 

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

  for (int i = 0; i < n; i++) {
    if (a[i] <= mn) {
      ans++;
    }
    mn = min(mn, a[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using plll=pair<ll,pll>;
using graph=vector<vector<int>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modInv(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modInv(fact))%p;
}

void pushHeap(vector<int>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

int popHeap(vector<int>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  int i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

vector<int> ver;
void dfs(const graph &g,int v){
  ver[v]=1;
  for(auto i:g[v]){
    if(ver[i]!=1)continue;
    dfs(g,i);
  }
}

bool cmp(int a,int b,int c,int d){
  if(a<c && b<d)return true;
  else return false;
}

int main(){
  int i,j,k,cnt=0;
  int n,m,q;
  cin>>n>>m>>q;
  int l[m],r[m];
  for(i=0;i<m;i++){
    cin>>l[i]>>r[i];
  }
  int s[q],t[q];
  for(i=0;i<q;i++)cin>>s[i]>>t[i];
  int b[n+1][n+1],c[n+1][n+1];
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      b[i][j]=0;
      c[i][j]=0;
    }
  }
  for(i=0;i<m;i++)b[l[i]][r[i]]++;
  for(i=n;i>=1;i--){
    for(j=1;j<=n;j++){
      c[i][j]=c[i][j-1]+b[i][j];
    }
  }
  for(j=1;j<=n;j++){
    for(i=n-1;i>=1;i--){
      c[i][j]+=c[i+1][j];
    }
  }
  for(i=0;i<q;i++){
    cout<<c[s[i]][t[i]]<<endl;
  }
}

Measured memory_bytes: 5248
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int N, M;
    cin >> N >> M;
    vector<P> path(M);
    rep(i,M) {
        cin >> path[i].second >> path[i].first;
        --path[i].second;
        --path[i].first;
    }

    sort(all(path));
    int ans = 0;
    int t = 0;
    rep(i, M) {
        if (t <= path[i].second) {
            ++ans;
            t = path[i].first;
        }
    
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
def solve():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]
    ans = []
    for i in range(K, N):
        if A[i - K] < A[i]:
            ans.append('Yes')
        else:
            ans.append('No')
    print('\n'.join(ans))


if __name__ == "__main__":
    solve()

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

int main() {
	int a,b,c;
	cin >> a>>b>>c;
	int ans;
	if (a == b) {
		ans = c;
	}
	else if(b==c)
	{
		ans = a;
	}
	else {
		ans = b;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
N,M=map(int,input().split())
i=N


gcd=1
while(1):
    if(M%i==0):
        print(M//i)
        sys.exit(0)
    if(i**2 >M):
        break
    i+=1

i=M//N
while(1):
    if(M%i==0):
        print(i)
        sys.exit(0)
    i-=1

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

inline int popcount(uint x)
{
	x=(x&0x55555555)+(x>>1&0x55555555);
	x=(x&0x33333333)+(x>>2&0x33333333);
	x=(x&0x0f0f0f0f)+(x>>4&0x0f0f0f0f);
	x=(x&0x00ff00ff)+(x>>8&0x00ff00ff);
	return (x&0x0000ffff)+(x>>16&0x0000ffff);
}

// 長さnの11..11
uint one(int n)
{
	return (1<<n)-1;
}

template<typename T>
void chmax(T& a,const T& b)
{
	a=max(a,b);
}

int main()
{
	for(int h,w;cin>>h>>w && h|w;){
		vs ss(h);
		rep(i,h) cin>>ss[i];
		
		ss.insert(begin(ss),string(w,'#'));
		h++;
		
		vector<vvi> dp(1,vvi(w,vi(1<<w,-INF)));
		dp[0][w-1][(1<<w)-1]=0;
		
		repi(i,1,h){
			dp.push_back(vvi(w,vi(1<<w,-INF)));
			rep(j,w){
				int pi=i,pj=j-1;
				if(pj<0) pi--,pj+=w;
				rep(k,1<<w){
					int al=popcount(k&one(j+1)),ar=ss[i].size()-al;
					int br=popcount(k>>j+1&one(w-j-1)),bl=ss[i-1].size()-br;
					if(al<0 || j+1<al || ar<0 || w-j-1<ar
					   || bl<0 || j+1<bl || br<0 || w-j-1<br) continue;
					if(k>>j&1){
						if(bl<j+1)
							chmax(dp[i][j][k],dp[pi][pj][k^1<<j]);
						if(bl>0)
							chmax(dp[i][j][k],dp[pi][pj][k]+2*(ss[i][al-1]==ss[i-1][bl-1]));
						if(al>=2 && (k>>j-1&1) && ss[i][al-2]==ss[i][al-1])
							dp[i][j][k]+=2;
					}
					else{
						if(bl<j+1)
							chmax(dp[i][j][k],dp[pi][pj][k]);
						if(bl>0)
							chmax(dp[i][j][k],dp[pi][pj][k^1<<j]);
					}
				}
			}
			vvi().swap(dp[i-1]);
		}
		
		cout<<*max_element(all(dp[h-1][w-1]))<<endl;
	}
}

Measured memory_bytes: 9712
#include<iostream>
 
using namespace std;
 
int main(){
  long A,B;
  cin >> A >>B;
  
  for(long i = 1;i<=B; i++){
    if((A*i)%B == 0){
      cout << A*i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

d = {"r":p, "s":r, "p":s}

prev = [None for _ in range(k)]
flag = [False for _ in range(k)]    # if consective

ind = 0
ans = 0
for char in t:
    if char == prev[ind]:
        if flag[ind]:
            flag[ind] = False
        else:
            ans += d[char]
            flag[ind] = True
    else:
        ans += d[char]
        flag[ind] = True

    prev[ind] = char
    ind = (ind + 1) % k


print(ans)

Measured memory_bytes: 4596
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		String t = sc.next();
		
		int len = s.length();
		
		for(int i = 0; i < len; i++){
			String s1 = s.substring(0, i);
			String s2 = s.substring(i, len);
			
			String rot = s2 + s1;
			
//			System.out.println(s2+" + "+s1+ " = "+rot);
			if(rot.equals(t)){
				System.out.println("Yes");
				return;
			}
		}
		
		System.out.println("No");
	}
}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		no3();
	}

	static void no3() {
		try (Scanner sc = new Scanner(System.in)) {
			String strN = sc.nextLine();
			int N = Integer.parseInt(strN);

			int min = 0;
			int max = N - 1;
			int mid;

			System.out.println(min);
			System.out.flush();

			String minStr = sc.nextLine();
			if (minStr.equals("Vacant")) {
				return;
			}

			String midStr;

			for (int i = 1; i < 20; i++) {
				mid = min + ((max - min) / 2);
				if (mid % 2 != 0) {
					mid--;
					if (mid == min) {
						System.out.println(mid + 1);
						System.out.flush();

						midStr = sc.nextLine();
						if (midStr.equals("Vacant")) {
							return;
						}
						System.out.println(mid + 2);
						System.out.flush();
						midStr = sc.nextLine();
						return;
					}
				}

				System.out.println(mid);
				System.out.flush();

				midStr = sc.nextLine();
				if (midStr.equals("Vacant")) {
					return;
				}

				if (midStr.equals(minStr)) {
					min = mid;
				} else {
					max = mid;
				}
			}
		}
	}

}


Measured memory_bytes: 24100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const double PI  =3.141592653589793238463;
long long mod = 1000000007;
int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}
ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}
bool prime[100005];
void seive()
{  memset(prime,true,sizeof(prime));
    for(int i=2;i*i<=100005;i++)
    {
         if(prime[i]==true) {
        for(int j=2*i;j<=(100005);j+=i)
           { prime[j]=false;}
           }

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

	set<string>st;
	int n;
	cin>>n;
	vector<string>v(n);
	for(int i=0;i<n;i++)
    {

        cin>>v[i];
    }
        st.insert(v[0]);
    int f=0;
    for(int i=1;i<n;i++)
    {
        if(v[i-1][v[i-1].length()-1]!=v[i][0])
        {

                f=1;
                break;

        }
        if(st.find(v[i])!=st.end())
        {
            f=1;
                break;
        }
        st.insert(v[i]);
    }
    if(f==1)
    {
    cout<<"No"<<endl;
    }
    else
        cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;

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

int main(void) {
	int n; cin >> n;
	vi p(n); rep(n) cin >> p[i];
	sort(all(p));
	cout << p[n / 2] - p[n / 2 - 1]  << endl;
	return 0;
}

Measured memory_bytes: 1024
from collections import deque

n=int(input())

a=[int(i) for i in input().split()]

b=deque()

for i in range(n):
    if i%2==0:
      b.append(a[i])
    else:
      b.appendleft(a[i])

if n%2==1:
    b.reverse()

n_int = map(str, b)
answer = " ".join(n_int)
print(answer)

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


int ODD(int n){

  int dp[202][9][2][2];
  
  memset(dp,0,sizeof(dp));
  
  dp[0][0][0][0]=1;
  dp[0][1][1][1]=1;
  
  for(int i=0;i<n;i++){
    for(int j=0;j<9;j++){
      for(int k=0;k<2;k++){
	for(int l=0;l<2;l++){
	  if(j<8&&k==0) dp[i+1][j+1][1][l] += dp[i][j][k][l];
	  dp[i+1][j][0][l] += dp[i][j][k][l];
	}
      }
    }
  }
  return (dp[n-1][8][0][1] + dp[n-1][8][0][0] + dp[n-1][8][1][0])*40320;
}

int EVEN(int n){

  n>>=1;

  int dp[202][9][3][3];
  
  memset(dp,0,sizeof(dp));
  
  dp[0][0][0][0]=1;
  dp[0][1][1][1]=1;
  dp[0][1][2][2]=1;
  
  for(int i=0;i<n;i++){
    for(int j=0;j<9;j++){
      for(int k=0;k<3;k++){
	for(int l=0;l<3;l++){
	  if(j<8&&k==0){
	    dp[i+1][j+1][1][l] += dp[i][j][k][l];
	    dp[i+1][j+1][2][l] += dp[i][j][k][l];
	  }
	  else if(j<8&&k==1){
	    dp[i+1][j+1][2][l] += dp[i][j][k][l];
	  }
	  else if(j<8&&k==2){
	    dp[i+1][j+1][1][l] += dp[i][j][k][l];
	  }
	  dp[i+1][j][0][l] += dp[i][j][k][l];
	}
      }
    }
  }
  return (dp[n-1][8][0][0] + dp[n-1][8][1][0] + dp[n-1][8][2][0] + dp[n-1][8][0][1] + dp[n-1][8][1][1] + dp[n-1][8][0][2] + dp[n-1][8][2][2] )*40320;
  
}

signed  main(){
  int n;
  while(cin>>n,n){
    if(n%2)cout<<ODD(n)<<endl;
    else cout<<EVEN(n)<<endl;
  }
}


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

//#define int long long

#define ll long long
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define P pair<ll,ll>
#define ld long double
ll INF = (1LL << 60);
int mod = 1000000007;

ll H, W;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> H >> W;
	// first -> 終点, second -> 始点
	map<int, int>now_place;
	multiset<int>diff;
	rep(i, W) {
		now_place[i] = i;
		diff.insert(0);
	}
	rep(i, H) {
		int A, B; cin >> A >> B; A--;
		auto itr = now_place.lower_bound(A);
		int ma = -1;
		while (itr != now_place.end() && itr->first <= B) {
			ma = max(ma, itr->second);
			int x = itr->first - itr->second;
			diff.erase(diff.find(x));
			now_place.erase(itr++); 
		}
		if (ma != -1 && B < W) {
			diff.insert(B - ma);
			now_place[B] = ma;
		}
		int ans = -1;
		if (diff.size() > 0) {
			ans = i + 1 + *diff.begin();
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 22356
#include <iostream>
#include <string>
#include <string.h>
#include <cstdio>
using namespace std;

int main()
{
    string s, a = "apple", p = "peach";
    getline(cin, s);
    for (int i = 0; i < s.length()-4; i++) {
        string sub = s.substr(i, 5);
        if (sub == a) {
            for (int j = 0; j < 5; j++) {
                s[i+j] = p[j];
            }
        } else if (sub == p) {
            for (int j = 0; j < 5; j++) {
                s[i+j] = a[j];
            }
        }
    }
    cout << s << endl;
    return 0;
}
        

Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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

  string ans = "No";

  for (int i = 0; i < s.size() - 1; ++i) {
    if (s[i] == 'A' && s[i + 1] == 'C') {
      ans = "Yes";
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import math

EPS = 1e-10

def equals(a, b):
    return abs(a - b) < EPS


class Point:
    def __init__(self, x=0, y=0):
        self.x = x
        self.y = y

    def __add__(self, p):
        return Point(self.x + p.x, self.y + p.y)

    def __sub__(self, p):
        return Point(self.x - p.x, self.y - p.y)

    def __mul__(self, a):
        return Point(self.x * a, self.y * a)

    def __rmul__(self, a):
        return self * a

    def __truediv__(self, a):
        return Point(self.x / a, self.y / a)

    def norm(self):
        return self.x * self.x + self.y * self.y

    def abs(self):
        return math.sqrt(self.norm())

    def __lt__(self, p):
        if self.x != p.x:
            return self. x < p.x
        else:
            return self.y < p.y

    def __eq__(self, p):
        return equals(self.x, p.x) and equals(self.y, p.y)


class Segment:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2


class Circle:
    def __init__(self, c=Point(), r=0):
        self.c = c
        self.r = r


def dot(a, b):
    return a.x * b.x + a.y * b.y


def cross(a, b):
    return a.x * b.y - a.y * b.x


def arg(p):
    return math.atan2(p.y, p.x)


def polar(r, a):
    return Point(math.cos(a) * r, math.sin(a) * r)


def getCrossPoints(c1, c2):
    d = (c1.c - c2.c).abs()
    a = math.acos((c1.r*c1.r + d*d - c2.r*c2.r) / (2 * c1.r * d))
    t = arg(c2.c - c1.c)
    return (c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a))


if __name__ == '__main__':
    c1x, c1y, c1r =  [int(v) for v in input().split()]
    c2x, c2y, c2r =  [int(v) for v in input().split()]
    c1 = Circle(Point(c1x, c1y), c1r)
    c2 = Circle(Point(c2x, c2y), c2r)
    v1, v2 = getCrossPoints(c1, c2)
    if v2 < v1:
        v1, v2 = v2, v1
    ans = [v1.x, v1.y, v2.x, v2.y]

    print('{0[0]:.8f} {0[1]:.8f} {0[2]:.8f} {0[3]:.8f}'.format(ans))


Measured memory_bytes: 5820
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int maxl(vector<int> seq){
  FOR(i,1,seq.size()) seq[i] += (seq[i])?seq[i-1]:0;
  int ret = 0;
  REP(i,seq.size()) ret = max(ret,seq[i]);
  return ret;
}
int main(void){
  int n;
  while(cin>>n){
    if(n==0) break;
    vector<string> grid(n);
    int ans = 0;
    REP(i,n) cin>>grid[i];
    REP(i,n){
      vector<int> seq;
      REP(j,n)seq.push_back(grid[i][j]-'0');
      ans = max(ans,maxl(seq));
    }
    REP(i,n){
      vector<int> seq;
      REP(j,n)seq.push_back(grid[j][i]-'0');
      ans = max(ans,maxl(seq));
    }
    REP(i,n){
      int x=i,y=0;
      vector<int> seq,seq2,seq3,seq4;
      REP(j,i+1)seq.push_back(grid[x--][y++]-'0'); 
      ans = max(ans,maxl(seq));
      x = n-1; y = n-1-i;
      REP(j,i+1)seq2.push_back(grid[x--][y++]-'0');
      ans = max(ans,maxl(seq2));
      x = n-1-i; y=0;
      REP(j,i+1)seq3.push_back(grid[x++][y++]-'0');
      ans = max(ans,maxl(seq3));
      x = i; y=n-1;
      REP(j,i+1)seq4.push_back(grid[x--][y--]-'0');
      ans = max(ans,maxl(seq4));
    }
    cout<<ans<<endl;
  }

  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<ll, ll>> vpll;

//mt19937 random(566);
//uniform_int_distribution<ll> distr;
//ll rnd(ll a, ll b) {return a + distr(random) % (b - a + 1);}

const int N = 2e5 + 1;
const ll MOD = 1e9 + 7;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int ans = 1000 * (n / 500);
    n %= 500;
    ans += 5 * (n / 5);
    cout << ans << "\n";
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int k=0;
  bool ans=false;
  if(m<10){k=10*n+m;}
  else if(m<100){k=100*n+m;}
  else {k=1000*n+100;}
  for(int i=1;i*i<=k;i++){
    if(i*i==k){ans=true;}}
  if(ans){cout<<"Yes"<<endl;}
  else cout<<"No"<<endl;
}

Measured memory_bytes: 384
#define _USE_MA_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string s;
    int k;
    cin>>s>>k;
    set<string> set;
    REP(i,1,k){
        rep(j,s.length()-i+1){
            string t;
            Rep(l,j,j+i)t+=s[l];
            set.insert(t);
        }
    }
    int i=0;
    for(string t:set){
        i++;
        if(i==k)cout<<t<<endl;
    }
}

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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[262521];

int main(){
  scanf("%d",&n);
  n = 1<<n;
  REP(i,n)scanf("%d",a+i);
  while(n!=1){
    REP(i,n/2){
      int x = a[2*i];
      int y = a[2*i+1];
      a[i] = (x==y)?x:abs(x-y);
    }
    n>>=1;
  }
  printf("%d\n",a[0]);
  return 0;
}


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

int main(){
    string s; cin >> s;
    if(s[0]=='S') cout << "Cloudy" << endl;
    else if(s[0]=='C') cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
signed main(void){
    int n,k; cin>>n>>k;
    vector <int> a(n);
    rep(i,n) { cin>>a[i]; a[i]--;}
    vector <int> cum(n+1);
    rep(i,n){
        cum[i+1] = (cum[i] + a[i]) % k;    
    }
    /*rep(i,cum.size()){
        cout<<cum[i]<<' ';
    }*/
    map <int,int> mp;
    int ans = 0;
    rep(i, cum.size()){
        if(i >= k){
            mp[cum[i-k]]--;
        }
        ans += mp[cum[i]];
        mp[cum[i]]++;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 15872
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    a,v=map(int, readline().rstrip().split())
    b,w=map(int, readline().rstrip().split())
    t=int(readline())
    if v <= w:
        print("NO")
        return
    s=v-w
    z=s*t

    if abs(a-b) <= z:
        print("YES")
    else:
        print("NO")

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16216
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 100000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	ans := 0
	for i := 1; i*i <= n; i++ {
		if (n-1)%i == 0 {
			if i*i == n-1 {
				ans += 1
			} else {
				ans += 2
			}
		} else if n%i == 0 && i != 1 {
			x := n
			for x%i == 0 {
				x /= i
			}
			if x%i == 1 {
				ans++
			}
			x = n
			j := n / i
			if i != j {
				for x%j == 0 {
					x /= j
				}
				if x%j == 1 {
					ans++
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
class BinaryIndexTree:  # 1-indexed
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


if __name__ == "__main__":
    N = int(input())
    S = list(input())
    d = {x: i for i, x in enumerate("abcdefghijklmnopqrstuvwxyz")}
    BIT = [BinaryIndexTree(N) for _ in range(26)]

    # initialize
    for i, s in enumerate(S, start=1):
        BIT[d[s]].add(i, 1)

    Q = int(input())
    ans = []
    for _ in range(Q):
        query, x, y = input().split()
        if query == "1":
            i = int(x)
            c_new = y
            c_old = S[i - 1]
            BIT[d[c_new]].add(i, 1)
            BIT[d[c_old]].add(i, -1)
            S[i - 1] = c_new
        else:
            cnt = 0
            l = int(x) - 1
            r = int(y)
            for b in BIT:
                tmp = b.sum(r) - b.sum(l)
                if tmp:
                    cnt += 1
            ans.append(cnt)

    print(*ans, sep="\n")


Measured memory_bytes: 168604
#include <stdio.h>

int main(void)
{
    int a , b , c;

    do {
        scanf("%d %d %d" , &a ,&b ,&c);
    } while (a < 0 || a > 100 || b < 0 || b > 100 || c < 0 || c > 100);

   if ( a < b && b < c) 
        printf("Yes\n");

    else
        printf("No\n");

    return 0;

}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	ll n,a,b;
	cin >> n >> a >> b;
	if(b<a)
	{
		cout<<0<<endl;
		return 0;
	}
	ll range = (n-1)*b+a-((n-1)*a+b);
	cout<<max(range+1,0LL)<<endl;
	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int a,b;
	cin >> a >> b;
	cout << max(a-b*2, 0) << endl;
	return 0;
}


Measured memory_bytes: 256