akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007// prime modulo value 
#define C 1000000001
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
double dist(ll x1, ll y1, ll x2, ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll k, a, b;
	cin >> k >> a >> b;
	string flag = "NG";
	f(i, a, b + 1)
	{
		if (i % k == 0)
		{
			flag = "OK";
		}
	}
	cout << flag;
	return 0;
}

Measured memory_bytes: 3644
// template version 1.14
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;
const int MOD=1e9+7;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

signed main() {
  int h,w;cin>>h>>w;
  dump(h, w);
  vvi d(h, vi(w));
  rep(i,h){
    rep(j,w){
      int a;cin>>a;
      dump(i,j,a);
      d[i][j] = a;
    }
  }
  rep(i,h){
    rep(j, w){
      int a;cin>>a;
      d[i][j] = abs(d[i][j]-a);
    }
  }
  dump(d);
  const int V = 80*180+2;
  vector<vvi> dp(h, vvi(w, vi(V)));
  dp[0][0][d[0][0]] = 1;

  rep(i, h)rep(j, w){
    if (i==0 && j==0) continue;
    rep(v, 0, V){
      if (i-1>=0){
        if (v+d[i][j]<V) chmax(dp[i][j][v+d[i][j]], dp[i-1][j][v]);
        chmax(dp[i][j][abs(v-d[i][j])], dp[i-1][j][v]);
      }
      if (j-1>=0){
        if (v+d[i][j]<V) chmax(dp[i][j][v+d[i][j]], dp[i][j-1][v]);
        chmax(dp[i][j][abs(v-d[i][j])], dp[i][j-1][v]);
      }
    }
  }
  dump(dp[1][1]);
  rep(v, 0, V){
    if(dp[h-1][w-1][v]) {
      cout << v << endl;
      return 0;
    }
  }
  assert(false);

  return 0;
}


Measured memory_bytes: 731776
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        long N = long.Parse(Console.ReadLine());
        long count;
        if(N % 11 == 0){
            count = N / 11 * 2;
        }
        else if(N % 11 <= 6){
            count = N / 11 * 2 + 1;
        }
        else{
            count = N / 11 * 2 + 2;
        }
        sb.Append(count+"\n");
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>

int main(int argc, char *argv[]) {  
	int a, b, c, d;
	std::cin >> a >> b >> c >> d;
	bool yes = 0;
	if (std::abs(a-c) <= d || (std::abs(a-b) <= d && std::abs(b-c) <= d)) {
		std::cout << "Yes";
	} else {
		std::cout << "No";
	}
}

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

max1,max2=-1,-1
alist=[]
for i in range(N):
  a=int(input())
  alist.append(a)
  if max1 <= a:
    max2 = max1
    max1 = a
  elif max2 < a:
    max2 = a
  
for a in alist:
  if a == max1:
    print(max2)
  else:
    print(max1)


Measured memory_bytes: 12532
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

def main():
	N,W=map(int,input().split())
	dp=[[0]*(W+1) for _ in range(N+1)]
	
	for i in range(N):
		w,v=map(int,input().split())
		for j in range(W):
			if j+1-w>=0:
				dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1],dp[i][j+1-w]+v)
			else:
				dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])
			
	print(dp[-1][-1])
	
	
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 120560
//√.
//本代码经过lm开光处理。
#include<bits/stdc++.h>
using namespace std;
int dx[110]={0,0,-1,1,-1,-1,1,1};
int dy[110]={-1,1,0,0,-1,1,-1,1};
long long a[25]={1,2,4,5,8,10,13,14,18,21,26,28,33,36,40,41,46,50,57,60,68};
long long n,m;
map<long long,long long> mp;
long long dfs(long long x)
{
    if(x<=20)
    {
    	return a[x];
    }
    if(mp[x])
    {
    	return mp[x];
    }
    if(x%2)
    {
    	return mp[x]=(2*dfs(x/2)%1000000007+dfs(x/2-1)%1000000007)%1000000007;
    }
    else
    {
    	return mp[x]=(2*dfs(x/2-1)%1000000007+dfs(x/2)%1000000007)%1000000007;
    }  
}
void init()
{
	scanf("%lld",&n);
}
void work()
{
	m=dfs(n);
}
void print()
{
	printf("%lld\n",m);
}
int main() 
{
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	init();
	work();
	print();   
    return 0;
}

Measured memory_bytes: 256
def N(n):
    return (n+1)*(n+2)*(n+3)/6

while True:
    try:
        n = int(raw_input())
        if n > 2000:
            n = 4000 - n
        if n < 1001:
            print N(n)
        else:
            print N(n) - (N(2*(n-1000)) - (n-1000) - 1)/2
    except:
        break

Measured memory_bytes: 4212
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process()throws IOException
    {
        int k=ni();
        String s=nln();
        if(s.length()<=k)
            pn(s);
        else
            pn(s.substring(0,k)+"...");
    }
 
 
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();
 
        long s = System.currentTimeMillis();
        int t=1;
       // t=ni();
        while(t-->0)
            process();
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }
    
    
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    
    static long mod=(long)1e9+7l;
 
    static<T> void r_sort(T arr[],int n){
        Random r = new Random(); 
        for (int i = n-1; i > 0; i--){ 
            int j = r.nextInt(i+1); 
                  
            T temp = arr[i]; 
            arr[i] = arr[j]; 
            arr[j] = temp; 
        } 
        Arrays.sort(arr); 
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 36904
#include <iostream>

using namespace std;

int main(){
    bool isIncluded[26] = {false};
    string str;

    cin >> str;

    for(int i = 0; i < str.size(); i++){
        isIncluded[str[i] - 'a'] = true;
    }

    for(int i = 0; i < 26; i++){
        if(isIncluded[i] == false){
            char ans = 'a' + i;
            cout << ans << endl;
            break;
        }else if(i == 25){
            cout << "None" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N,X,T;cin >> N >> X >> T;
  cout << T*((N+X-1)/X) << endl;
  return 0;
}


Measured memory_bytes: 3620
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
#define mp make_pair
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

vl v,w;
vvl dp(1024,vl(1e5+1,0));//頂点,コスト->価値のまっくす

ll bfs(ll V,ll W,ll c){
  if(W<0){
    return 0;
  }
  else if(V<=1023){
    return c+dp[V][W];
  }
  else{
    ll x=bfs(V/2,W,c);
    ll y=bfs(V/2,W-w[V],c+v[V]);
    return max(x,y);
  }
}

int main() {
  ll N;
  cin >> N;
  v.resize(N+1),w.resize(N+1);
  rep(i,N){
    cin >> v[i+1] >> w[i+1];
  }
  ll q;
  cin >> q;
  ll x;
  dp[1][w[1]]=v[1];
  FOR(i,1,min(N+1,(ll)1024)){
    FOR(j,1,1e5+1){
      if(j!=0&&(i!=1||j!=w[1])){
        dp[i][j]=dp[i][j-1];
      }
      if(i!=1){
        dp[i][j]=max(dp[i][j],dp[i/2][j]);
      }
      if(j>=w[i]&&i>=2){
        dp[i][j]=max(dp[i][j],v[i]+dp[i/2][j-w[i]]);
      }
    }
  }
  rep(i,q){
    ll V,W;
    cin >> V >> W;
    x=bfs(V,W,0);
    cout << x << endl;
  }
}


Measured memory_bytes: 810156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

bool pairCompare(const pair<ll, ll>& firstElof, const pair<ll, ll>& secondElof) {
    return firstElof.second < secondElof.second;
}

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

    vector<pair<ll, ll>> AB(N);
    for(ll i=0;i<N;i++) {
        cin >> AB.at(i).first >> AB.at(i).second;
    }

    sort(AB.begin(), AB.end(), pairCompare);

    ll t = 0;
    for(ll i=0;i<N;i++) {
        if(AB.at(i).second<t+AB.at(i).first) {
            cout << "No" << endl;
            return 0;
        }
        else {
            t+=AB.at(i).first;
        }
    }

    cout << "Yes" << endl;

    return (0);
}


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

using namespace std;
int INF = 1000000000;
int N,A,B,C;
vector<int> l;

int dfs(int cur,int a,int b,int c){
    if(cur == N){
        if(min({a,b,c}) <= 0) return INF;
        return abs(a-A) + abs(b-B) + abs(c-C)- 30;
    }
    int ret0 = dfs(cur+1,a,b,c);
    int ret1 = dfs(cur+1,a+l[cur],b,c)+10;
    int ret2 = dfs(cur+1,a,b+l[cur],c)+10;
    int ret3 = dfs(cur+1,a,b,c+l[cur])+10;
    return min({ret0,ret1,ret2,ret3});
}
int main(){
    cin >> N >> A >> B >> C;
    l.resize(N);
    for(int i = 0; i< N; i++){
        cin >> l[i];
    }
    cout << dfs(0,0,0,0) << endl;
    return 0;

}

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

int main(){
    int A, B, K;
    cin >> A >> B >> K;

    int counter = 0;
    int ans = 0;
    for(int i = min(A, B); i >= 1; i--){
        if(A % i == 0 && B % i == 0){
            counter++;
        }
        if(counter == K){
            ans = i;
            break;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
using namespace std;
/// age ye mosh dp ro baze dashti dp tedad baz shodeye baste nashode yadet nare !!
/// joooob zadam
const int N=2e5+100;
ll h[N];
int32_t main(){
    ll n,a,b;
    cin >> n >> a >> b;
    for (int i=1;i<=n;i++){
        cin >> h[i];
    }
    ll l=-1,r=1e9+100;
    while(r-l>1){
        ll mid=(r+l)/2;
        ll ans=0;
        for (int i=1;i<=n;i++){
            ll z=h[i]-mid*b;
            if (z>0){
                ans+=(z+a-b-1)/(a-b);
            }
        }
        if (ans<=mid){
            r=mid;
        }
        else{
            l=mid;
        }
    }
    cout << r;
}


Measured memory_bytes: 1024
a,b,c=map(int,input().split())
d=a
jol=[]

while True:
    
    if d%b==c:
        print("YES")
        exit()

    elif d%b not in jol:
        jol.append(a%b)
        
    else:
        print("NO")
        exit()
    
    d+=a

Measured memory_bytes: 2940
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//                       _oo0oo_                         //
//                      o8888888o                        //
//                      88" . "88      ------ hzt1       //
//                      (| -_- |)                        //
//                      0\  =  /0                        //
//                    ___/`---'\___                      //
//                  .' \|     |// '.                     //
//                 / \|||  :  |||// \                    //
//                / _||||| -:- |||||- \                  //
//               |   | \  -  /// |     |                 //
//               | \_|  ''\---/''  |_/ |                 //
//               \  .-\__  '-'  ___/-. /                 //
//             ___'. .'  /--.--\  `. .'___               //
//          ."" '<  `.___\_<|>_/___.' >' "".             //
//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |           //
//         \  \ `_.   \_ __\ /__ _/   .-` /  /           //
//     =====`-.____`.___ \_____/___.-`___.-'=====        //
//                       `=---='                         //
//                                                       //
//                                                       //
//     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       //
//                                                       //
//                 God-He Bless All.                     //
//           This Code Will Never Explode.               //
//                                                       //
//                                                       //
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<vector>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,Size,stdin);
        tail=(head=buffer)+l;
    }
    if(head==tail) return -1;
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1000010;
const int mod=1000000007;
int n,f[maxn],s[maxn];
int main() {
	n=read();
	f[0]=1;int ans=0;
	rep(i,0,n-1) {
		if(i>=3) (f[i]+=s[i-3])%=mod;
		if(i) s[i]=s[i-1];
		(s[i]+=f[i])%=mod;
		(f[i+1]+=f[i])%=mod;
		if(i==n-1) (ans+=(ll)f[i]*n%mod)%=mod;
		else {
			(ans+=(ll)f[i]*(n-1)%mod*(n-1)%mod)%=mod;
			(ans+=(ll)f[i]*(n-max(2,n-i-1)+1)%mod)%=mod;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 7936
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e10
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
    const ll MOD = INF + 7;
     
     
     
    int main(){
       ll n, m, k;
       cin >> n >> m >> k;
       vector<ll> a(n), b(m);
       rep(i, n){
          cin >> a[i];
          if(i != 0)a[i] += a[i - 1];
       }
       rep(i, m){
          cin >> b[i];
          if(i != 0)b[i] += b[i - 1];
       }

       b.push_back(INF);
       ll res = 0, sum = 0;
       rep(i, n){
          sum = (i + 1);
          ll l = k - a[i];
         if(k < a[i]){
            sum = 0;
            l = k;
         }
          ll ub = upper_bound(ALL(b), l) - b.begin();
          
          sum += ub;
         //cout << sum << " " << l << endl;
          res = max(res, sum);
       }
       a.push_back(INF);
       rep(i, m){
          sum = (i + 1);
          ll l = k - b[i];
         if(k < b[i]){
            sum = 0;
            l = k;
         }
          ll ub = upper_bound(ALL(a), l) - a.begin();
          
          sum += ub;
         //cout << sum << " " << l << endl;
          res = max(res, sum);
       }
       cout << res << endl;
    }

Measured memory_bytes: 7548
#include<bits/stdc++.h>
#define EM 1000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
LL mod = 1e9+7;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<LL> deq(vector<LL> a, LL k) {
    LL n = a.size();
    vector<LL> b;
    vector<LL> deque(n + 10);
    int s = 0, t = 0;
    for (int i = 0; i < n; i++) {
        while (s < t && a[deque[t - 1]] >= a[i]) t--;
        deque[t++] = i;
        if (i - k + 1 >= 0) {
            b.push_back(a[deque[s]]);
            if (deque[s] == i + 1 - k) s++;
        }
    }
    return b;
}

vector<LL> deq2(vector<LL> a, LL k) {
    LL n = a.size();
    vector<LL> b;
    vector<LL> deque(n + 10);
    int s = 0, t = 0;
    for (int i = 0; i < n; i++) {
        while (s < t && a[deque[t - 1]] <= a[i]) t--;
        deque[t++] = i;
        if (i - k + 1 >= 0) {
            b.push_back(a[deque[s]]);
            if (deque[s] == i + 1 - k) s++;
        }
    }
    return b;
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<LL>  p(N);
    vector<int> noc(N, 0);
    for(int i = 0;i < N;i++)    scanf("%d", &p[i]);
    vector<LL>  bmin = deq(p, K+1);
    vector<LL>  bmax = deq2(p, K+1);
    int cnt = 1;
    LL ans = 0;
    for(int i = 1;i < N;i++){
        if(p[i] > p[i-1]){
            cnt = min(cnt+1, K);
            if(cnt == K){
                noc[i-K+1] = 1;
                ans = 1;
            }
        }else{
            cnt = 1;
        }
    }
    if(noc[0] == 0) ans++;
    for(int i = 0;i+K < N;i++){
        if(noc[i+1] == 1) continue;
        if((bmin[i] != p[i] || bmax[i] != p[i+K]))    ans++;
    }

    printf("%d", ans);
}

Measured memory_bytes: 10936
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
int main() {
	string S;
	cin >> S;
	ll K;
	cin >> K;
	ll cnt = 1;
	for (ll i = 0; i < S.size(); i++) {
		if (S[0] == '1'&&S[i] == S[i + 1])
			cnt++;
	}
	if (K < 100) {
		if (cnt == 1 && K == 1)
			cout << S[0] << endl;
		else if (cnt >= K)
			cout << 1 << endl;
		else if (cnt < K)
			for (ll i = 0; i < S.size(); i++) {
				if (S[i] == '1')continue;
				else
					cout << S[i] << endl;
				return 0;
			}
	}
	else {
		for (ll i = 0; i < S.size(); i++) {
			if (S[i] == '1')continue;
			else if (S[i] != 1)
				cout << S[i] << endl;
			return 0;
		}
	}
}










Measured memory_bytes: 256
s = input()
alp = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

for i in alp:
        if s.count(i)%2 != 0:
                print('No')
                break
else:
        print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s; cin >> s;
    bool ans = true;

    if (s[0] != 'A') ans = false;
    vector<int> c;
    FOR(i,2,s.size()-1) if (s[i] == 'C') c.push_back(i);
    if (c.size() != 1) ans = false;
    if (ans) {
        FOR(i,1,s.size()) {
            if (i == c[0]) continue;
            if (s[i] < 'a' || s[i] > 'z') ans = false;
        }
    }

    if (ans) OUT("AC")
    else OUT("WA")

    return 0;
}

Measured memory_bytes: 256
import copy

import math
import fractions

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

s = input()
n = ip()
addedleft = []
addedright = []
flip = 0
for i in range(n):
    cmd = input().split()
    #print(cmd)
    if len(cmd) == 1:
        flip+=1
        flip%=2
    else:
        if cmd[1] == "1":
            if flip == 0: addedleft.append(cmd[2])
            else: addedright.append(cmd[2])
        else: #cmd[2] == 2
            if flip == 0: addedright.append(cmd[2])
            else: addedleft.append(cmd[2])
#print("left", addedleft)
#print("right", addedright)
addedleft.reverse()
r = ''.join(addedright)
l = ''.join(addedleft)
ans  = ''.join([l,s,r])
if flip==0:
    print(ans)
else:
    for i in range(len(ans)):
        print(ans[-i-1],end='')

Measured memory_bytes: 8800
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N, K;
  cin>>N>>K;
  int x1[50], y1[50], z1[50], x2[50], y2[50], z2[50];
  vector<int> ax, ay, az;
  REP(i, N){
    cin>>x1[i]>>y1[i]>>z1[i]>>x2[i]>>y2[i]>>z2[i];
    ax.push_back(x1[i]); ax.push_back(x2[i]);
    ay.push_back(y1[i]); ay.push_back(y2[i]);
    az.push_back(z1[i]); az.push_back(z2[i]);
  }
  sort(ax.begin(), ax.end());
  ax.erase(unique(ax.begin(), ax.end()), ax.end());
  sort(ay.begin(), ay.end());
  ay.erase(unique(ay.begin(), ay.end()), ay.end());
  sort(az.begin(), az.end());
  az.erase(unique(az.begin(), az.end()), az.end());
  ll ans = 0;
  REP(i, ax.size() - 1)REP(j, ay.size() - 1)REP(k, az.size() - 1){
    int cnt = 0;
    REP(l, N){
      if(ax[i] >= x1[l] && x2[l] >= ax[i + 1] &&
         ay[j] >= y1[l] && y2[l] >= ay[j + 1] &&
         az[k] >= z1[l] && z2[l] >= az[k + 1] ){
        cnt++;
      }
    }
    if(cnt >= K){
      ans += (ll)(ax[i + 1] - ax[i]) * (ay[j + 1] - ay[j]) * (az[k + 1] - az[k]);
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

#define int long long
#define INF 1e18

signed main() {
    int sum = 0;
    int res = 0;
    for(int i = 0; i < 5; i++) {
        int time; cin >> time;
        int dif = 0;
        if(time % 10 != 0) {
            dif = 10 - time % 10;
        }
        sum += time + dif;
        res = max(dif, res);
    }

    cout << sum - res << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    string s;cin>>s;
    
    ll t=0;
    vector<ll> a(200010,0),b(200010,0);
    a[0]=b[0]=1;
    rep(i,n)if(s[i]=='1')t++;
    if(t!=1)rep(i,n)a[i+1]=(a[i]*2)%(t-1);
    rep(i,n)b[i+1]=(b[i]*2)%(t+1);
    ll A=0,B=0;
    rep(i,n){
        if(s[i]=='1'){
            A+=a[n-i-1];
            B+=b[n-i-1];
        }
    }
    rep(i,n){
        if(t==1&&s[i]=='1'){
            cout<<0<<endl;
            continue;
        }
        string ns=s;
        ll buf2=t;
        ll buf=0;
        if(s[i]=='1'){
            ns[i]='0';
            buf2--;
            buf=A-a[n-i-1];
        }
        else{
            ns[i]='1';
            buf2++;
            buf=B+b[n-i-1];
        }
        
        //cout<<buf<<endl;
        buf%=buf2;
        //cout<<buf<<endl;
        int cou=1;
        while(buf!=0){
            cou++;
            ll buf3=buf,x=0;
            while(buf3){
                if(buf3%2==1)x++;
                buf3/=2;
            }
            buf%=x;
        }
        cout<<cou<<endl;
    }
}

Measured memory_bytes: 6868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl 	"\n"

typedef vector< ll > 	vi;
typedef vector< vi > 	vvi;
typedef pair< ll,ll > 	ii;
#define pb 		push_back
#define all(c) 		(c).begin(),(c).end()
#define tr(c,i) 	for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) 	((c).find(x) != (c).end())

#define MOD 	1000000007
#define INF 	(int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

int main()
{	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1; i<=n; i++)
	{
		if( int(floor(log10(i)+1) )%2 != 0 )
			ans++;
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;
//



     signed main(){
  int d;
  clock_t st=clock();
  cin>>d;
    clock_t ed=clock();

  int c[26];
  for(int i=0;i<26;i++)cin>>c[i];
  int t[d],s[d][26],x[26]={};
    vector<int>v[26];
    for(int i=0;i<26;i++)v[i].push_back(-1);

  for(int i=0;i<d;i++)for(int j=0;j<26;j++)cin>>s[i][j];
   // cerr<<'i';
  for(int i=0;i<d;i++){
      for(int j=0;j<26;j++)x[j]+=c[j];
      int k=0;
      for(int j=1;j<26;j++)if(x[k]+s[i][k]<x[j]+s[i][j])k=j;
      t[i]=k;
      x[k]=0;
      v[k].push_back(i);
  }
  for(int i=0;i<26;i++)v[i].push_back(d);
//for(int i=0;i<d;i++)cout<<t[i]+1<<endl;
  // cerr<<double(clock()-st)/CLOCKS_PER_SEC<<endl;
//while(false){
while(double(clock()-st)/CLOCKS_PER_SEC<1.95){
  if(rand()%2){
    int p=rand()%d;
    auto q=find(v[t[p]].begin(),v[t[p]].end(),p);
    q++;
  // int m=(p+(*q))/2;
   int m=p;
   int uu=0;
//cerr<<m<<' '<<p<<endl;
  for(int m2=p+1;m2<(*q);m2++){
   auto r1=find(v[t[m2]].begin(),v[t[m2]].end(),m2);
   auto r0=r1-1,r2=r1+1;
   if((m2-p)*((*q)-m2)*c[t[p]]+s[m2][t[p]]-((m2-(*r0))*((*r2)-m2)*c[t[m2]]+s[m2][t[m2]])>uu){
     m=m2;
     uu=(m2-p)*((*q)-m2)*c[t[p]]+s[m2][t[p]]-((m2-(*r0))*((*r2)-m2)*c[t[m2]]+s[m2][t[m2]]);
   
   }
   
  }
  if(m!=p){
      v[t[p]].insert(q,m);
    v[t[m]].erase(find(v[t[m]].begin(),v[t[m]].end(),m));
    t[m]=t[p];
   }
  }else{
    int u=1;
    if(rand()%2)u++;
    u%=26;
    int p=rand()%(d-u);
    if(t[p]==t[p+u]||p+u==d){continue;}
    auto q1=find(v[t[p]].begin(),v[t[p]].end(),p);
    auto q0=q1-1,q2=q1+1;
      auto r1=find(v[t[p+u]].begin(),v[t[p+u]].end(),p+u);
    auto r0=r1-1,r2=r1+1;
    if((p-(*q0))*((*q2)-p)*c[t[p]]+s[p][t[p]]+(p+u-(*r0))*((*r2)-p-u)*c[t[p+u]]+s[p+u][t[p+u]]-((p+u-(*q0))*((*q2)-p-u)*c[t[p]]+s[p+u][t[p]]+(p-(*r0))*((*r2)-p)*c[t[p+u]]+s[p][t[p+u]])<rand()%signed(100*(1.97-double(clock()-st)/CLOCKS_PER_SEC))){
      (*q1)=p+u;
      (*r1)=p;
      swap(t[p],t[p+u]);
    }
   
  }




}
     for(int i=0;i<d;i++)cout<<t[i]+1<<endl;


     }


 


 






    





      

        


Measured memory_bytes: 3764
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
using namespace std;

int main() {
	string s;
	cin >> s;
	bool f = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '7') f = 1;
	}
	if (f) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define PI 3.14159265358979323846
#define MOD 1000000007
#define INF (int)1e9

using namespace std;
using namespace __gnu_pbds;
//typedef tree<TYPE, null_type, less<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//typedef tree<TYPE, null_type, less_equal<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

int N;
double A[3000], dp[3000][3000];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N;
	for(int i = 1; i <= N; i++) cin >> A[i];
	for(int i = 0; i <= N; i++)
		for(int j = 0; j <= N; j++)
			if(i == 0) dp[i][j] = j > (N - j);
			else dp[i][j] = dp[i - 1][j + 1] * A[i] + dp[i - 1][j] * (1 - A[i]);
	cout << setprecision(9) << fixed << dp[N][0] << "\n";
	return 0;
}


Measured memory_bytes: 70656
#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 n;
    cin >> n;
    int64_t ans = n / 500 * 1000 + (n % 500) / 5 * 5;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處
const int MAXN = 3e5 + 2;

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W, M; cin >> H >> W >> M;
    vector<pair<int, int>> targets;
    int cnt_H[MAXN] {}, cnt_W[MAXN] {};
    for (int i = 0; i < M; ++i) {
        int x, y; cin >> x >> y;
        --x; --y;
        targets.push_back(make_pair(x, y));
        ++cnt_H[x];
        ++cnt_W[y];
    }
    int ma_H = 0, ma_W = 0;
    for (int i = 0; i < H; ++i) {
        ma_H = max(ma_H, cnt_H[i]);
    }
    for (int i = 0; i < W; ++i) {
        ma_W = max(ma_W, cnt_W[i]);
    }
    set<int> bestH, bestW;
    for (int i = 0; i < H; ++i) {
        if (cnt_H[i] == ma_H)  bestH.insert(i);    
    }
    for (int i = 0; i < W; ++i) {
        if (cnt_W[i] == ma_W)  bestW.insert(i);
    }
    int ans = ma_H + ma_W;
    LL inter = 1LL * bestH.size() * bestW.size();
    // cout << "inter " << inter << endl;
    for (int i = 0; i < M; ++i) {
        if (bestH.find(targets[i].first) != bestH.end() && bestW.find(targets[i].second) != bestW.end())  --inter;
    }
    cout << ans + (inter == 0 ? -1 : 0) << endl;
    return 0;
}


Measured memory_bytes: 36136
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 10

int N;
int table[10];

int main(){

	scanf("%d",&N);

	for(int i = 0; i < N; i++){

		table[i] = i;
	}

	do{

		printf("%d",table[0]+1);

		for(int i = 1; i <= N-1; i++){

			printf(" %d",table[i]+1);
		}
		printf("\n");

	}while(next_permutation(table,table+N));

	return 0;
}




Measured memory_bytes: 3204
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int main() {
	int N,M;
	scanf("%d %d",&N,&M);
	int X[M];
	for (int i = 0; i < M; i++) {
		scanf("%d",&X[i]);
	}
	if (N >= M) {
		printf("0\n");
		return 0;
	}
	qsort(X, M, sizeof(int), compare_int);
	int dif[M-1];
	for (int i = 0; i < M-1; i++) {
		dif[i] = X[i+1] - X[i];
	}
	qsort(dif, M-1, sizeof(int), compare_int);
	int sum=0;
	for (int i = 0; i < M-N; i++) {
		sum += dif[i];
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 1396
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#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 n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end());
  ll ans = 0;
  vector<int> b = {0, a[n - 1]};
  for (int i = 1; i < n; ++i) rep(j, 2) b.push_back(a[n - 1 - i]);
  for (int i = 0; i < n; ++i) ans += b[i];

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6160
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		long inf=1000;inf*=inf;inf*=inf;

		int n = sc.nextInt();
		long w_max = sc.nextLong();
		int[] w = new int[n+1];
		int[] v = new int[n+1];
		int sum_vals=0;
		for(int i=1;i<=n;i++)
		{
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
			sum_vals+=v[i];
		}
		long[][] dp = new long[n+1][sum_vals+1];
		//dp[i][j] = w ;  w is the min weight with which
		// you can get total value j using the first
		// i items...
		for(int i=0;i<=sum_vals;i++)
		{
			dp[0][i]=inf;
		}
		for(int i=0;i<=n;i++)
		{
			dp[i][0]=0;
		}
		
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=sum_vals;j++)
			{
				if(v[i]<=j)
				{
					dp[i][j]=Math.min(w[i]+dp[i-1][j-v[i]]
						, dp[i-1][j]); 
				}
				else
				{
					dp[i][j]=dp[i-1][j];
				}
			}
		}
		// for(int i=0;i<=n;i++)
		// {
		// 	for(int j=0;j<=sum_vals;j++)
		// 		System.out.printf(dp[i][j]+" ");
		// 	System.out.printf("\n");
		// }
		long ans=0;
		for(int i=0;i<=sum_vals;i++)
			if(dp[n][i]<=w_max)
				ans=Math.max(ans,i);
		System.out.println(ans);





	}
}

Measured memory_bytes: 126420
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.OtherPractice
{
    class ABC_046_B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);
            Console.WriteLine(k * Math.Pow(k - 1, n - 1));
        }
    }
}


Measured memory_bytes: 11092
# coding: utf-8
# Your code here!

N = int(input())
L = list(map(int,input().split()))
L.sort()

def isOK(key, index):
    if L[index] >= key:
        return True
    else:
        return False
        
def binary_search(key):
    left = -1
    right = len(L)
    
    while right - left > 1:
        mid = left + int((right - left) / 2)
        if isOK(key, mid):
            right = mid
        else:
            left = mid
    return right

count = 0
for a in range(N):
    for b in range(a + 1, N):
        key = L[a] + L[b]
        count += (binary_search(key) - (b + 1))

print(count)

Measured memory_bytes: 45788
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

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

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

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

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

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

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

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

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

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

#[allow(non_snake_case)]
fn main() {
    input! {
        K:usize,
        A:usize,
        B:usize,
    }
    for i in A..(B + 1) {
        if i % K == 0 {
            println!("OK");
            return;
        }
    }
    println!("NG");
}


Measured memory_bytes: 2128
h, w = map(int,input().split())
sx, sy = map(int,input().split())
gx, gy = map(int,input().split())
S = [input() for i in range(h)]

sx-=1
sy-=1
gx-=1
gy-=1

A = [(-1,0),(1,0),(0,-1),(0,1)]
B = []
for i in range(-2,3):
    for j in range(-2,3):
        if i!= 0 or j!=0:
            B.append((i,j))
# print(B)

# O((V + E)log(V))
# Cは [[スタート頂点, ゴール頂点, 重み], ...] のリスト

M = [[] for i in range(h*w)]

for i in range(h):
    for j in range(w):
        if S[i][j] == ".":
            for a in A:
                ai = i+a[0]
                aj = j+a[1]
                if 0 <= ai < h and 0 <= aj < w and S[ai][aj] == ".":
                    M[i*w+j].append((ai*w+aj, 0))
            for b in B:
                bi = i+b[0]
                bj = j+b[1]
                if 0 <= bi < h and 0 <= bj < w and S[bi][bj] == ".":
                    M[i*w+j].append((bi*w+bj,1))


# for i in range(len(C)):

#     M[C[i][0]].append([C[i][1], C[i][2]])  # 無向グラフなら両方追加
#     M[C[i][1]].append([C[i][0], C[i][2]])  # 無向グラフなら両方追加

n = h*w

import heapq

big = 10**9
D = [big] * n  # 頂点0からの距離
P = [-1] * n  # 頂点0からの最短距離において、そこの直前の頂点(経路復元に利用)
D[sx*w+sy] = 0
V = [0] * n  # その頂点のD[i]が最短距離と確定したら1
Q = []  # 優先度付きキュー
# for v in range(n):
#     heapq.heappush(Q, (D[v], v))
heapq.heappush(Q, (0, sx*w+sy))

# le = n
while len(Q) > 0:
    # print(Q,le)
    q = heapq.heappop(Q)
    u = q[1]
    du = q[0]
    if V[u] == 0:
        V[u] = 1
        # le -= 1
        for i in range(len(M[u])):
            v = M[u][i][0]
            luv = M[u][i][1]
            # print(v)
            if V[v] == 0:
                alt = du + luv
                if D[v] > alt:
                    D[v] = alt
                    P[v] = u
                    heapq.heappush(Q, (alt, v))
                    # le += 1
                    # print(Q)
# print(D)
ans = D[gx*w+gy]
if ans > 10**7:
    ans = -1
print(ans)

Measured memory_bytes: 399644
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;


int main(){
    string s1, s2;
    int N, M, A, B, C;
    vector<int> a(5);
    rep(i, 5) cin >> a[i];
    rep(i, 5) if(a[i] == 0) cout << i + 1 << endl;
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int w,h;
int xs,ys,xg,yg;
int data[150][150];
bool searched[150][150];

int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
bool ans;
bool dfs(int x, int y,int col){
	// cout << x << " " << y << endl;
	searched[x][y] = true;
	if(x == xg && y == yg){
		ans = true;
		return true;
	}
	REP(i,4){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
		if(data[nx][ny] == col && searched[nx][ny] == false) dfs(nx,ny,col);
	}
	return ans;
}
int main(){
	while(1){
		cin >> w >> h;
		if(w == 0 && h == 0) break;
		REP(i,150) REP(j,150) data[i][j] = 0;
		REP(i,150) REP(j,150) searched[i][j] = false;
		cin >> xs >> ys >> xg >> yg;
		xs--; ys--; xg--; yg--;
		swap(xs,ys);
		swap(xg,yg);
		int n;
		cin >> n;
		REP(i,n){
			int c,d,x,y;
			cin >> c >> d >> x >> y;
			x--; y--;
			swap(x,y);
			if(d == 0){
				REP(j,4){
					REP(k,2){
						data[x+k][y+j] = c;
					}
				}
			}else{
				REP(j,2){
					REP(k,4){
						data[x+k][y+j] = c;
					} 
				}
			}
		}
		// cout << endl;
		// REP(i,20){
		// 	REP(j,20) cout << data[i][j] << " ";
		// 	cout << endl;
		// }
		ans = false;
		if(dfs(xs,ys,data[xs][ys])) cout << "OK" << endl;
		else cout << "NG" << endl;
	}
}

Measured memory_bytes: 1272
#include <stdio.h>
char judge(int ,int ,int );

int main(void){
  int m,f,r;
  char c;
  
  while(1){
    scanf("%d %d %d",&m,&f,&r);
    if(m+f+r==-3)break;
    c=judge(m,f,r);
    printf("%c\n",c);
  }
  
  return 0;
}

char judge(int M,int F,int R){
  int sum=M+F;
  if(M==-1||F==-1)return 'F';
  else if(sum>=80)return 'A';
  else if(sum>=65) return 'B';
  else if(sum>=50) return 'C';
  else if(sum>=30 && R>=50)return 'C';
  else if(sum>=30)return 'D';
  else return 'F';
}

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

int main(){
    
    int a,b,c;
    int s,ch,e,d;
    s = ch = e = d = 0;
    int tmp,hantei;
    while(1){
        cin >> a >> b >> c;
        if(a>b){
            if(a>c){
                tmp=a;
                a=c;
                c=tmp;
            }
        }else{
            if(b>c){
                tmp=b;
                b=c;
                c=tmp;
            }
        }
        if(c>=a+b) break;
        s++;
        hantei=c*c-a*a-b*b;
        if(hantei>0){
            d++;
        }else if(hantei<0){
            e++;
        }else{
            ch++;
        }
    }
    
    cout << s << " " << ch << " " << e << " " << d << endl;
    
    return 0;
}


Measured memory_bytes: 3064
import Control.Applicative
import Control.Monad
import Data.Functor
import Data.List

f = g 0

g r (a:a':as) (b:bs) = g (r+t1+t2) ((a'-t2):as) bs
  where
    t1 = min a b
    rb = b - t1
    t2 = min a' rb
    
g r _ _ = r

getInts = map read . words <$> getLine :: IO [Int]

main = getLine >> f <$> getInts <*> getInts >>= print

Measured memory_bytes: 93692
import math
n = int(input())
#探索範囲
sqrt_n = int(math.sqrt(n))
num_i = 0
for i in range(1, sqrt_n+1):
    if n % i == 0:
       num_i = i

num_j = n // num_i
ans = (num_i - 1) + (num_j - 1)

print(ans)



Measured memory_bytes: 63532
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Scanner;

public class Main {
	static Scanner sc;

	public static void main(String[] args) throws Exception {
		//InputStream in = new FileInputStream("src/input.txt");
		InputStream in = System.in;

		sc = new Scanner(in);

		String A = sc.next();
		String B = sc.next();
		String C = sc.next();

		String answer = "";
		if(A.equals(B)){
			answer = C;
		}else if(B.equals(C)){
			answer = A;
		}else{
			answer = B;
		}
		System.out.println(answer);


	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <bits/stdc++.h>
#include <vector>

using namespace std;

int main()
{
    char c;
    cin>>c;
    if(c=='A'){
        cout<<"T";
    }
    else if(c=='T'){
        cout<<"A";
    }
    else if(c=='C'){
        cout<<"G";
    }
    else{
        cout<<"C";
    }
}


Measured memory_bytes: 256
X = int(input())

memo = [None]*(2*X)

for i,v in enumerate(memo):
    if i < 2:
        continue
    if v is None:
        memo[i] = True
        for j in range(i*2, 2*X, i):
            memo[j] = False

print(next(i+X for i,v in enumerate(memo[X:]) if v))

Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  ll a;
  double b;
  cin >> a >> b;
  ll b2 = b*100 + 0.5;
  ll ans = (ll)a*b2;  
  ans /= 100;
  cout << ans << endl;
}


Measured memory_bytes: 3712