akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var << std::endl;
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;


int main(){


    int N; std::cin >> N;
    std::vector<ll> A(N + 1);
    std::vector<ll> B(N + 1, 0);
    rep(i, N + 1)std::cin >> A[i];
    rep(i, N)std::cin >> B[i];

    ll ans = 0;
    rep(i, N + 1){
        if(B[i] > A[i]){
            if(i < N){
                int tmp = A[i + 1];
                A[i + 1] -= (B[i] - A[i]);
                A[i + 1] = std::max(A[i + 1], 0ll);
                ans += (tmp - A[i + 1]);
            }
            ans += A[i];
        }else{
            ans += B[i];
        }
    }

    std::cout << ans;


    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N); 
  for(int i=0; i<N; i++) cin >> a.at(i);
  vector<int> b;
  vector<int> c;
  for(int i=0; i<N; i++){
    if(i%2==0) b.push_back(a.at(i));
    else c.push_back(a.at(i));
  }

  if(N%2==0){
    for(int i=0; i<c.size(); i++) cout << c.at(c.size()-i-1) << ' ';
    for(int i=0; i<b.size(); i++) cout << b.at(i) << ' ';
    cout << endl;
  }
  else{
    for(int i=0; i<b.size(); i++) cout << b.at(b.size()-i-1) << ' ';
    for(int i=0; i<c.size(); i++) cout << c.at(i) << ' ';
    cout << endl;
  }
}

Measured memory_bytes: 3956
local n = io.read("*n")
local t, bsum = {}, 0
for i = 1, n do
  local a, b = io.read("*n", "*n")
  t[i] = a + b
  bsum = bsum + b
end
table.sort(t, function(x, y) return x > y end)
local ret = 0
for i = 1, n, 2 do
  ret = ret + t[i]
end
print(ret - bsum)


Measured memory_bytes: 2424
#include <iostream>

using namespace std;

#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, s, n) for(int i = s; i < (int)(n); ++i)

int main() {
  int n;
  cin >> n;
  Rep(i, n) {
    int a;
    cin >> a;
    if (a % 2 != 0) continue;
    if (a % 3 != 0 && a % 5 != 0) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}


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

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

vector<string> S(N);
vector<int> T(N);
for (int i = 0; i < N; i++) {
    cin >> S.at(i) >> T.at(i);
}
string X;
cin >> X;
int sec;
for (int j = 0; j < N; j++) {
    if (X == S.at(j)) {
    for (int k = j + 1; k < N; k++) {
        sec += T.at(k);
    }    
    }
}
cout << sec << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 1123456789012345
using namespace std;

int main(){
	ll n; cin >> n;
	vl color(9);
	rep(i, n){
		ll temp; cin >> temp;
		ll a = temp / 400;
		if (a > 8) a = 8;
		color[a]++;
	}ll ans = 0;
	rep(i, 8) if (color[i]) ans++;
	if (!ans && color[8] > 0) cout<<1<<" ";
	else cout << ans << " ";
	ans += color[8];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
ok = True
for i in range(H):
  for j in range(W):
    if s[i][j] == "#":
      if i < H-1:
        if s[i+1][j] == "#": continue
      if i > 0:
        if s[i-1][j] == "#": continue
      if j < W-1:
        if s[i][j+1] == "#": continue
      if j > 0:
        if s[i][j-1] == "#": continue
      ok = False
      break
print("Yes" if ok else "No")

Measured memory_bytes: 3064
#include <stdio.h>

int A[200000000];
int nmber;

void maxHeapify(int i){
    int l, r;
    int  largest, temp;
    

    l = i * 2;
    r = i * 2 + 1;

    if(l <= nmber && A[l] > A[i]) 
        largest = l;
    else 
        largest = i;

    if(r <= nmber && A[r] > A[largest])
        largest = r;
    
    if(largest != i){
        temp = A[i];
        A[i] = A[largest];
        A[largest] = temp;
        maxHeapify(largest);
    }
}

void buildMaxHeap(void){
    int i;
    for(i = nmber/2; i >= 1; i--){
        maxHeapify(i);
    }
}

int main(){
    int i;
  
    scanf("%d", &nmber);

    for(i = 1; i <= nmber; i++) scanf("%d", &A[i]);
    buildMaxHeap();

    for(i = 1; i <= nmber; i++) printf(" %d", A[i]);
    printf("\n");

    return 0;
}



Measured memory_bytes: 3652
unittest{
	assert(solve([2L, 1L, 1L], 3L) == 2L);
	assert(solve([1L, 2L, 3L], 4L) == 0L);
	assert(solve([2000000000, 0, 0], 2000000000) == 2000000000);
}

long solve(long[3] v, long k){
	long[3] w = [1, 0, -1];
	long ans;

	foreach(i, elm; v){
		if(elm <= k){
			ans += elm*w[i];
			k -= elm;
		}else{
			ans += k*w[i];
			break;
		}
	}
	return ans;
}

void main(){
	long[3] v;
	long k;
	readf("%d %d %d %d\n", &v[0], &v[1], &v[2], &k);

	writeln( solve(v, k) );
}
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.format;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

int main(){
  int N;
  cin >> N;
  pair<int, int> first(0,-1),second(-1,-1);
  
  int k;
  for (int i=0;i<N;i++){
    cin >> k;
    if(k<second.first){
      continue;
    }else if((k>=second.first)&&(k<first.first)){
      second=make_pair(k,i);
    }else{
      second=first;
      first=make_pair(k,i);
    }
  }
  for(int i=0;i<N;i++){
    if(i==first.second){
	  cout << second.first << endl;
    }else{
      cout << first.first << endl;
    }
  }
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld PI = acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
//const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    string s;
    int n, m; cin >>n>>m ;

    cout << (n==m? "Yes" : "No") << '\n';
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

typedef pair<int, int> pp;
typedef pair<pp, char> ppp;

const int W = 0, T = 1, L = 1, MAXN = 11;


int main()
{
    int n;
    while(cin >> n && n)
    {

        vector<ppp> ans;
            int w[MAXN] = {}, l[MAXN] = {};
            bool used[MAXN] = {};
            char t[MAXN];

        REP(n)
        {
            int r;//, w = 0, l = 0;
            cin >> t[i];
            rep(j,n - 1)
            {
                cin >> r;
                if(r == W)w[i]++;
                if(r == L)l[i]++;
            }
        }
        rep(j,n)
        {
            int maxw = 0, minl = n, f = n;
            REP(n)
               if(!used[i] &&( (maxw < w[i] ) || (maxw == w[i] && minl > l[i]))){ f = i; maxw = w[i]; minl = l[i];}
            used[f] = true;
            cout << t[f] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include <cstdio>

int v[200009], u[200009];
bool fr[200009];

int main() {
    int n;
    scanf("%d", &n);

    long long ans = 0;
    int last = n + 1;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &v[i]);

        if (v[i] == 0)
            last = i;
        else if (i - last < v[i])
            ans = -1;
    }

    if (ans == -1) {
        printf("-1\n");
        return 0;
    }

    int cnt = 0, best = n + 1;
    for (int i = n; i > 0; i--) {
        if (v[i] == 0) {
            for (int j = 1; j <= u[0]; j++)
                fr[u[j]] = 0;
            u[0] = 0;
            cnt = 0;
            best = n + 1;
        } else {
            if (fr[i - v[i]] == 0) {
                u[++u[0]] = i - v[i];
                fr[i - v[i]] = 1;
                if (i - v[i] < best)
                    best = i - v[i];
            }
            if (i - best > v[i]) {
                printf("-1\n");
                return 0;
            }
            cnt += fr[i];
            ans += u[0] - cnt;
        }
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int d;cin>>d;
    vin c(26);rep(i,26)cin>>c[i];
    vvin s(d,vin(26));
    rep(i,d)rep(j,26)cin>>s[i][j];
    vvin last(d,vin(26,0));int sum,tmp;ll m;
    vin ans(d);
    rep(i,d){
        m=-INF;tmp=0;
        if(i>0)rep(j,26)last[i][j]=last[i-1][j];
        rep(j,26){
            sum=0;
            sum+=s[i][j];
            rep(k,26){
                if(k==j)continue;
                sum-=c[k]*(i+1-last[i][k]);
            }
            if((ll)sum>m){
                tmp=j;
                m=(ll)sum;
            }
        }
        ans[i]=tmp;
        last[i][tmp]=i+1;
    }
    int res,l;
    rep(i,30){
        rep(j,d){
            m=0;
            rep(k,26){
                sum=0;
                res=ans[j];
                rep2(l,j,d){
                    if(ans[l]==k){
                        sum+=c[k]*(j+1-last[j][k])*(l-j);
                        break;
                    }
                }
                rep2(l,j,d){
                    if(ans[l]==res){
                        sum-=c[res]*(j+1-last[j][res])*(l-j);
                    }
                }
                if(m<sum){
                    m=sum;
                    tmp=k;
                }
            }
            if(m==0)continue;
            ans[j]=tmp;
            l=last[j][tmp];
            rep2(k,j,d){
                if(last[k][tmp]!=l)break;
                last[k][tmp]=j+1;
            }
        }
    }
    rep(i,d)cout<<ans[i]+1<<endl;
}

Measured memory_bytes: 3748
/*====Corycle====*/
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<vector>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const int Mod=1e9+7;
const int N=3e5+5;
int read(){
	int s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
	return s*f;
}
char s[N];
int n,Ans,f[N][3][3];
int mod(int x){return x>=Mod?x-Mod:x;}
int main(){
//	freopen("_.in","r",stdin);
//	freopen("_.out","w",stdout);
	scanf("%s",s+1);n=strlen(s+1);f[0][0][0]=1;
	for(int i=0;i<n;i++){
		for(int x=0;x<=2;x++){
			for(int y=0;y<=2;y++){
				if(!f[i][x][y])continue;
				if(s[i+1]=='1'||s[i+1]=='?'){
					if(y)f[i+1][x][y-1]=mod(f[i+1][x][y-1]+f[i][x][y]);
					else f[i+1][min(x+1,2)][y]=mod(f[i+1][min(x+1,2)][y]+f[i][x][y]);
				}
				if(s[i+1]=='0'||s[i+1]=='?'){
					if(y==2)f[i+1][x][y-1]=mod(f[i+1][x][y-1]+f[i][x][y]);
					else f[i+1][x][y+1]=mod(f[i+1][x][y+1]+f[i][x][y]);
				}
			}
		}
	}
	for(int x=0;x<=2;x++){
		for(int y=0;y<=x;y++)Ans=mod(Ans+f[n][x][y]);
	}
	printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 14640
#include <iostream>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll gcd(ll a,ll b)
{
    if (a%b==0)
        {
        return(b);
        }
    else
        {
        return(gcd(b,a%b));
        }
}
int main(void){
    ll a,b; cin >> a >> b;
    ll g = gcd(a,b);
    cout << (a*b)/g << endl;
}



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

#include <atcoder/all>
typedef long long ll;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (ll i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (ll i = ((ll)(n)-1); i >= 0; --i)
#define rreps(i, n) for (ll i = ((ll)(n)); i > 0; --i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repc2(i, s, n) for (ll i = (s); i <= (ll)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
using namespace atcoder;

int n, m;

int main() {
    cin >> n >> m;
    dsu d(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        d.merge(a, b);
    }
    auto v = d.groups();
    cout << v.size() - 1 << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int ans;
  if(N<4) ans=1;
  else{
    ans=2;
    while(ans*ans<=N){
      ans++;
    }
    ans--;
  }
  cout << ans*ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
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...));}
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);}
/*
 <url:https://atcoder.jp/contests/abc131/tasks/abc131_e>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,K; cin >> N >> K;
    ll MaxK = (N-1)*(N-2)/2;
    if(MaxK < K) {
        cout << -1 << endl;
        return res;
    }
    
    vector<pll> E;
    for(ll v = 2; v <= N; v++){
        E.push_back({1,v});
    }
    ll NK = MaxK;
    [&](){
        if(NK == K) return;
        for(ll u = 2; u < N; u++){
            for(ll v = u+1; v <= N; v++){
                E.push_back({u,v});
                NK--;
                if(NK == K) return;
            }
        }
    }();
    cout << E.size() << endl;
    for(auto e:E){
        cout << e.first << " " << e.second << endl;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    int n;
    cin>>n;
    vector<int> p(n),q(n);
    rep(i,n) cin>>p[i];
    rep(i,n) cin>>q[i];

    const int N = n;
    int a,b =0;
    int cnt =0;
    vector<int> v(N);
    iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
    do {cnt++;
        if (v==p) a =cnt;
        if (v==q) b =cnt;
    } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成
    int ans =abs(a-b);
    cout << ans <<endl;
}

Measured memory_bytes: 256
import bisect
n,q=map(int,input().split())
s=input()
slst=[]
cnt=[]
for i in range(n-1):
  slst.append(s[i:i+2])
for a,b in enumerate(slst):
  if b=='AC':
    cnt.append(a)
l=[]
for i in range(q):
  x,y=map(int,input().split())
  M=bisect.bisect_left(cnt,x-1)
  N=bisect.bisect_right(cnt,y-2)
  print(N-M)

Measured memory_bytes: 12048
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;

signed main(){
	cin>>N;
	cout<<ceil2(N,1000)*1000-N<<endl;
	return 0;
}


Measured memory_bytes: 3616
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int64)
B = np.array(input().split(), dtype=np.int64)
C = np.array(input().split(), dtype=np.int64)

A.sort()
B.sort()
C.sort()

# 各bに対して使えるaの個数
cnt_A = np.searchsorted(A,B,side='left')
# 各bに対して使えないcの個数
cnt_C = np.searchsorted(C,B,side='right')
# 各bに対して使えるcの個数
cnt_C = N - cnt_C

answer = (cnt_A * cnt_C).sum()
print(answer)

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

using namespace std;
const int mod=1e9+7;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=2e5+100;

ll qpow(ll x,ll y){
    ll sum=1;
    while(y){
        if(y&1)
            sum=sum*x%mod;
        y/=2;
        x=x*x%mod;
    }
    return sum;
}
ll fac[maxn];
ll C(ll m,ll n){
    return fac[n]*qpow(fac[m],mod-2)%mod*qpow(fac[n-m],mod-2)%mod;
}
int main()
{
    ll x,y;
    fac[0]=1;
    for(int i=1;i<=2e5;i++){
        fac[i]=fac[i-1]*i%mod;
    }
    scanf("%lld%lld",&x,&y);
    ll low=min(y,x-1);
    ll ans=0,sum1=1,sum2=1;
    for(ll i=1;i<=low;i++){
        ans=(ans+(C(i,x)*C(i,x-1))%mod)%mod;
        //cout<<ans<<endl;
    }
    cout<<(ans+1)%mod<<endl;
    //cout<<tot<<endl;
    return 0;
}
/*


*/



Measured memory_bytes: 1792
#include<map>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define Fi first
#define Se second
#define inf 0x7f7f7f7f
#define sqr(x) ((x)*(x))
#define cub(x) ((x)*(x)*(x))
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc()
{
	static char buf[1000000], *p1 = buf, *p2 = buf;
	return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++;
}
inline int frd()
{
	int x = 0, f = 1;
	char ch = gc();
	for(; ch < '0' || ch > '9'; ch = gc())   if(ch == '-')    f = -1;
	for(; ch >= '0' && ch <= '9'; ch = gc()) x = (x << 3) + (x << 1) + ch - '0';
	return x * f;
}
inline int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	for(; ch < '0' || ch > '9'; ch = getchar())  if(ch == '-')    f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar())    x = (x << 3) + (x << 1) + ch - '0';
	return x * f;
}
inline void print(int x)
{
	if(x < 0)    putchar('-'), x = -x;
	if(x > 9)    print(x / 10);
	putchar(x % 10 + '0');
}
const int N = 1e5;
ll A[N + 10], B[N + 10];
map<ll, int>Mp;
int main()
{
	int n = read();
	for(int i = 1; i <= n; i++)
	{
		ll x, y = 1;
		scanf("%lld", &x);
		for(ll j = 2; cub(j) <= x; j++)  while(x % cub(j) == 0) x /= cub(j);
		map<ll, int>::iterator it = Mp.find(x);
		if(it == Mp.end())   Mp.insert(map<ll, int>::value_type(x, 1));
		else    it->Se++;
		A[i] = x;
		for(ll j = 2; cub(j) <= x; j++)
		{
			if(x % j == 0)
			{
				y *= (x % sqr(j) == 0) ? j : sqr(j);
				while(x % j == 0)  x /= j;
			}
		}
		y *= (sqr((ll)sqrt(x)) == x) ? (ll)sqrt(x) : sqr(x);
		B[i] = y;
	}
	int Ans = 0;
	map<ll, int>::iterator it = Mp.find(1);
	if(it != Mp.end())   Ans++, it->Se = 0;
	for(int i = 1; i <= n; i++)
	{
		int res = 0;
		map<ll, int>::iterator x = Mp.find(A[i]);
		map<ll, int>::iterator y = Mp.find(B[i]);
		if(x != Mp.end())    res = max(res, x->Se), x->Se = 0;
		if(y != Mp.end())    res = max(res, y->Se), y->Se = 0;
		Ans += res;
	}
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int c[10]={100,2,5,5,4,5,6,3,7,6};
int main(){
    int n,m;cin >> n >> m;
    vector<bool> b(10);
    for(int i=0;i<m;i++){
        int a;cin >> a;
        b[a]=true;
    }
    vector<vector<bool>> dp(n+1,vector<bool>(n/2+1));
    dp[0][0]=true;
    for(int i=0;i<n;i++){
        for(int j=0;j<n/2;j++){
            if(dp[i][j]){
                for(int k=1;k<=9;k++){
                    if(i+c[k]<=n&&b[k]){
                        dp[i+c[k]][j+1]=true;
                    }
                }
            }
        }
    }
    int t=0;
    for(int i=0;i<n/2+1;i++){
        if(dp[n][i]){
            t=max(t,i);
        }
    }
    int num=n;
    vector<int> v;
    for(int i=t;i>0;i--){
        for(int j=9;j>=1;j--){
            if(b[j]&&num-c[j]>=0&&dp[num-c[j]][i-1]){
                v.push_back(j);
                num-=c[j];
                break;
            }
        }
    }
    sort(v.begin(),v.end(),greater<int>());
    for(int i=0;i<v.size();i++){
        cout << v[i];
    }
    cout << endl;
}

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

int main(){
  while(1){
    int H, W;
    cin>>H>>W;
    if(H == 0 && W == 0) break;

    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cout<<"#";

      }
      cout<<endl;
    }
    cout<<endl;
  }

    return 0;
  }
  



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
char a[28];
vector<char>v;
int main(){

 long long int n,k,m,i,c=0;
        cin>>n;
char p='a';
for(i=1;i<=26;i++)
{
    a[i]=p;
    p++;
}
 k=n%26;
 if(k==0)
 {
     n=n-26;
     v.push_back(a[26]);
 }
 else
 {
      n=n-k;
    v.push_back(a[k]);
 }

 while(n!=0)
 {
     n=n/26;
      k=n%26;
 if(k==0)
 {
    v.push_back(a[26]);
     n=n-26;
 }
 else
 {
    v.push_back(a[k]);
     n=n-k;
 }
 }
for(i=(v.size()-1);i>=0;i--)
{
    cout<<v[i];
}
   return 0;

}

Measured memory_bytes: 3576
#include<iostream>
using namespace std;
int main() {
int N,A;
cin>>N>>A;
int L=A;
int R=A+N-1;
int eat;
if(R<=0)eat=R;
else if(L>=0)eat=L;
else eat=0;
int answer=(R+L)*(R-L+1)/2-eat;
cout<<answer<<endl;
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.next());
        int k = Integer.parseInt(s.next());
        boolean sun[] = new boolean[n];

        for(int i = 0; i < n;i++) {
            sun[i] = false;
        }

        for(int i = 0; i < k;i++) {
            int d = Integer.parseInt(s.next());
            for(int j = 0; j < d;j++) {
                int h = Integer.parseInt(s.next());
                sun[h-1] = true;
            }
        }

        int res = 0;
        for(int i = 0; i < n;i++) {
            if (!sun[i]) {
                res++;
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 41364
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
vector<int>grp[200005];
int val[200005];
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	memset(val,0,sizeof(val));
	int n,q;
	cin>>n>>q;
	for(int i=0;i<n-1;i++){
		int u,v;
		cin>>u>>v;
		grp[u].push_back(v);
	}
	for(int i=0;i<q;i++){
		int p,x;
		cin>>p>>x;
		val[p]+=x;
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<grp[i].size();j++){
			val[grp[i][j]]+=val[i];
		}
	}
	for(int i=1;i<=n;i++){
		cout<<val[i]<<" ";
	}
	cout<<endl;
}

Measured memory_bytes: 14080
#include <algorithm>
#include <cstring>
#include <iostream>
#include <random>
#include <string>
#include <vector>

int main()
{
    int n;
    long long ans = 0;
    std::cin >> n;
    int array[n + 1];
    for (int i = 0; i < n; i++) { std::cin >> array[i]; }
    std::sort(array, array + n);
    int index = 0;
    int c = 0, f = 0;
    while (index < n)
    {
        c = array[index];
        f = 0;
        while (index < n && array[index] == c)
        {
            index++;
            f++;
        }
        ans += f % 2;
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 640
pay = [int(input()) for i in range(4)]
# print(pay)
if(pay[0] < pay[1]):
    train = pay[0]
else:
    train = pay[1]
    
if(pay[2] < pay[3]):
    bus = pay[2]
else:
    bus = pay[3]

print("{0}".format(train + bus))


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#define fo(i,a,b) for (i=a; i<=b; i++)
using namespace std;

const int N=(1<<18)+5;
int n, m, i, ans;
int a[N], b[18], p[N], q[N];

void dg(int x,int i)
{
	if (p[x]) return;
	if (a[p[x]]<a[x+1]) q[x]=p[x], p[x]=x+1; else
	if (a[q[x]]<a[x+1]) q[x]=x+1;
	while (b[i]<=x) 
	{
		if (b[i]&x) 
		{
			int y=x^b[i]; dg(y,i+1); 
			if (a[p[x]]<a[p[y]])
			{
				q[x]=p[x], p[x]=p[y];
				if (a[q[x]]<a[q[y]]) q[x]=q[y];
			}
			else
			if (a[q[x]]<a[p[y]] && p[y]!=p[x]) q[x]=p[y]; else
			if (a[q[x]]<a[q[y]] && q[y]!=p[x]) q[x]=q[y];
		}
		i++;
	}
	//printf("%d %d %d\n",x,p[x],q[x]);
}

int main()
{
	//freopen("e.in","r",stdin); freopen("e.out","w",stdout);
	
	fo(i,0,18) b[i]=1<<i;
	scanf("%d",&n), m=b[n]-1;
	fo(i,1,m+1) scanf("%d",&a[i]);
	fo(i,1,m)
	{
		dg(i,0), ans=max(ans,a[p[i]]+a[q[i]]), printf("%d\n",ans);
	}
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=100+10;
int main(){
   ios_base::sync_with_stdio(0);
   int t,q;
   string s,op;
   char ch;
   cin>>t;
   while(t--){
      getline(cin,s);
      getline(cin,s);
      cin>>q;
      int ix=0;
      while(q--){
         cin>>op;
         if(op[0]=='f'){
            cin>>op;
            if(op[0]=='c')ix=min(ix+1,int(s.size()));
            else{
               while(ix<int(s.size()) && s[ix]==' ')ix++;
               while(ix<int(s.size())&&s[ix]!=' ')ix++;
            }
         }
         else if(op[0]=='b'){
            cin>>op;
            if(op[0]=='c')ix=max(0,ix-1);
            else{
               while(ix-1>=0 && s[ix-1]==' ')ix--;
               while(ix-1>=0 && s[ix-1]!=' ')ix--;
            }            
         }
         else if(op[0]=='i'){
            string x="";
            while(cin>>ch,ch!='"') {}
            while(cin>>noskipws>>ch,ch!='"') x+=string(1,ch);                                    
            s.insert(ix,x);
            ix=ix+int(x.size());
            cin>>skipws;
         }
         else if(op[0]=='d'){
            cin>>op;
            if(op[0]=='c')s.erase(ix,1);
            else if(op[0]=='w'){
               int j=ix;
               while(j<int(s.size()) && s[j]==' ')j++;
               int ch=0;
               while(j<int(s.size()) && s[j]!=' ')j++,ch++;

               if(ch>0){
                  j--;
                  s.erase(ix,j-ix+1);
               }
            }
         }

//         cout<<s.substr(0,ix)<<"^"<<s.substr(ix)<<'\n';
      }
      cout<<s.substr(0,ix)<<"^"<<s.substr(ix)<<'\n';
   }
   return 0;
}

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

#define ll long long

int main()
{
    ll N;
    std::cin >> N;

    std::vector<ll> A(N+1);
    std::map<ll, ll> mp;

    for(ll i=2; i <= N; i++) {
        std::cin >> A[i];
    }

    for(ll i=2; i <= N; i++) {
        mp[A[i]]++;
    }

    for(ll i=1; i<= N; i++) {
        std::cout << mp[i] << std::endl;
    }
}

Measured memory_bytes: 17260
#include<bits/stdc++.h>
#define ll long long
#define nes ios_base :: sync_with_stdio(0); cin.tie(0);
using namespace std;
ll mo=1e9+7;
ll mod(ll n){
	return (n%mo+mo)%mo;
}
ll modadd(ll a,ll b){
	return mod(mod(a)+mod(b));
}
map<ll,ll>ma;
ll dfs(ll n){
	if(ma.count(n)) return ma[n];
	else{
		int total=0;
		for(int i=3;i<=n-3;++i) total=mod(total+dfs(n-i));
		ma[n]=mod(total+1);
		return ma[n];
	}
}
int main(){
	nes;
	int n;
	cin>>n;
	ma[3]=1;ma[4]=1;ma[5]=1;
	ma[1]=0;ma[2]=0;
	cout<<dfs(n);
	//cout<<"\n";
	//for(auto it=ma.begin();it!=ma.end();++it) cout<<it->first<<" "<<it->second<<"\n";
	return 0;
}

Measured memory_bytes: 3660
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_075_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(14).
    01 A      PIC S9(3).
    01 B      PIC S9(3).
    01 C      PIC S9(3).
    01 ans    PIC X(4).

    01 ZS     PIC -(4)9.
    01 DUMMY  PIC X(1).

PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO A B C.

    IF A = B THEN
        MOVE C TO ZS
    ELSE
        IF B = C THEN
            MOVE A TO ZS
        ELSE
            MOVE B TO ZS
        END-IF
    END-IF.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 508
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main{
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

		try{
			List<String> dispList = new ArrayList<String>();
			while(true){

				String strPeople = insBR.readLine();
				if("0".equals(strPeople)){
					break;
				}
				double dbPeople = Double.parseDouble(strPeople);

				//文字列を読み取る。
				String[] strLine = insBR.readLine().split(" ");

				//小数点を鑑みて、double型に変換する。
				List<Double> list = new ArrayList<Double>();
				for(int i = 0; i < strLine.length; i++){
					list.add(Double.parseDouble(strLine[i]));
				}

				//平均値。
				double dbSum = 0.0;
				for(int i = 0; i < list.size(); i++){
					dbSum += list.get(i);
				}
				double dbAverage = dbSum / dbPeople;
				//System.out.println("平均 " + dbAverage);

				//偏差。
				List<Double> devList = new ArrayList<Double>();
				for(int i = 0; i < list.size(); i++){
					double dbAct = list.get(i) - dbAverage;
					devList.add(dbAct);
				}

				//偏差合計。
				dbSum = 0.0;
				for(int i = 0; i < devList.size(); i++){
					double dbAct = devList.get(i);
					dbSum += dbAct * dbAct;
				}
				double dbDisp = dbSum / dbPeople;
				dbDisp = Math.sqrt(dbDisp);
				String strDevation = String.format("%1$.5f", dbDisp);
				dispList.add(strDevation);

			}

			//出力。
			for(int i = 0; i < dispList.size(); i++){
				System.out.println(dispList.get(i));
			}

		}catch(IOException e){
			e.printStackTrace();
		}catch(NumberFormatException e){
			e.printStackTrace();
		}

	}

}



Measured memory_bytes: 26824
def add(a, b, k, l, r, node)
  return 0 if r <= a || b <= l
  return node[k] if a <= l && r <= b
  m = (l+r)/2
  vl = add(a, b, 2*k+1, l, m, node)
  vr = add(a, b, 2*k+2, m, r, node)
  return vl + vr
end

n, q = gets.split.map(&:to_i)

m = 1
while m < n
  m *= 2
end
node = Array.new(2*m-1){0}

q.times{
  com, x, y = gets.split.map(&:to_i)
  x -= 1
  case com
  when 0
    k = x + m - 1
    node[k] += y
    while k > 0
      k = (k-1)/2
      node[k] += y
    end
  when 1
    puts add(x, y, 0, 0, m, node)
  end
}

Measured memory_bytes: 10896
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
#define MAX 50

int brigde[MAX][MAX]={0};
int visited[MAX]={0};
int n, m;
int a[MAX], b[MAX];
void dfs(int a);

int main(void) {
    ll n, m, k=0;
    double A, B, ans=0;
    cin >> n >> m;
    
    A=100*(n-m)+1900*m;
    B=pow(2, m);
    
    cout << A*B << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int H, W, N;
    cin >> H >> W >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];

    auto ans = vector<vector<int>>(H, vector<int>(W));
    pair<int, int> that;
    that.first  = 1;
    that.second = a[that.first - 1];
    REP(i, H) {
        if (i % 2 == 0) {
            REP(j, W) {
                ans[i][j] = that.first;
                that.second--;
                if (that.second == 0) {
                    that.first++;
                    that.second = a[that.first - 1];
                }
            }
        } else {
            RREP(j, W - 1) {
                ans[i][j] = that.first;
                that.second--;
                if (that.second == 0) {
                    that.first++;
                    that.second = a[that.first - 1];
                }
            }
        }
    }

    REP(i, H) {
        REP(j, W) { cout << ans[i][j] << " "; }
        cout << '\n';
    }

    return 0;
}

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

int main() {
  int H,W,i,j;
  cin >> H >> W;
  vector<vector<char>> v(H,vector<char>(W));
  vector<int> h(H),w(W);
  for(i=0;i<H;i++)for(j=0;j<W;j++)cin >> v[i][j];
  bool flag;
  for(i=0;i<H;i++){
    flag=1;
    for(j=0;j<W;j++){
      if(v[i][j]=='#'){
        flag=0;
        break;
      }
    }
    if(flag)h[i]=1;
  }
  for(i=0;i<W;i++){
    flag=1;
    for(j=0;j<H;j++){
      if(v[j][i]=='#'){
        flag=0;
        break;
      }
    }
    if(flag)w[i]=1;
  }
  for(i=0;i<H;i++){
    if(!h[i]){
      for(j=0;j<W;j++){
        if(!w[j])cout << v[i][j];
    }
    cout << endl;
    }
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long ll;

const int maxn = 1e5 + 5;
vector<int>G[maxn];
ll ans[5];
int vis[maxn];
bool ok = true;

void dfs(int u,int fa,int k){
	if(vis[u] == -1) vis[u] = k;
	else if(vis[u] != k){
		ok = false;
		return;
	}
	else return;
	for(int i = 0;i < G[u].size();i++){
		int v = G[u][i];
		if(v != fa){
			dfs(v,u,k ^ 1);
		}
	}

}

int main(){
	ll n,m;
	scanf("%lld %lld",&n,&m);
	memset(vis,-1,sizeof(vis));
	for(int i = 1;i <= m;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1,0,1);
	for(int i = 1;i <= n;i++){
		if(vis[i] == 1) ans[1]++;
		else ans[0]++;
	}
	if(ok){
		printf("%lld\n",ans[0] * ans[1] - m);
	}
	else printf("%lld\n",n * (n - 1) / 2 - m);
}

Measured memory_bytes: 7296
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def main():
    N , K = map(int, input().split())
    H = [int(c) for c in input().split()]
    num = 0
    for i in range(N):
        if H[i] >= K:
            num += 1
    print(num)


if __name__ == '__main__':
    main()

Measured memory_bytes: 21348
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n):
    b[i]= i-a[0]-a[i]
d = defaultdict(int)
for i in range(1,n):
    d[b[i]] += 1
ans = 0
x = 0
for i in range(n-1):
    ans+=d[x]
    d[b[i+1]]-=1
    x -= -1+(a[i]-a[i+1])
print(ans)

Measured memory_bytes: 63160
/**
 *    author:  FromDihPout
 *    created: 2020-05-26
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    
    long long ans = 0;
    for (int i = 0; i < n - k; i++) {
        ans += a[i];
    }
    cout << ans;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0 ; i < n ; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vector<int> c;
  int cnt = 1;
  for(int i = 0 ; i < n - 1 ; i++){
    if(a[i] == a[i+1]){
      cnt++;
    }else{
      c.push_back(cnt);
      cnt = 1;
    }
  }
  c.push_back(cnt);
  sort(c.rbegin(), c.rend());
  int ans = 0;
  for(int i = k ; i < c.size() ; i++){
    ans += c[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
int main () {
    ios_base::sync_with_stdio(false);
    int X;
    cin>>X;
    int ans=0;
    ans += (X/500)*1000;
    X%=500;
    ans += (X/5)*5;
    cout<<ans<<"\n";
    return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define f(i,n) for(int i=0;i<n;i++) 
#define FASTO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define F first 
#define S second 
#define all(c) c.begin(),c.end()
#define mp make_pair 
#define pb push_back 
#define ull unsigned long long
#define ll long long int
#define va vector<long long int> a
#define vb vector<long long int> b
#define M 1000000007
void prb()

{
	ll k,a,b,p=0;
	cin>>k>>a>>b;
	for(ll i=a;i<=b;i++)
	{
		if(i%k==0) {cout<<"OK\n";p=1;break;}
	}
	if(p==0) cout<<"NG\n";

}

int main()
{
	FASTO;
	prb();
	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void warshall_floyd(Graph &graph) {
    int V = graph.size();
    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < V; ++j) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
}

ll to_id(ll x, ll y) {
    return 21 * x + y;
}

void solve() {
    ll H, W;
    cin >> H >> W;
    vector<string> grid(H);
    rep(i, H) cin >> grid[i];
    Graph graph(500, vector<ll>(500, INF));
    rep(i, H) {
        rep(j, W) {
            if (grid[i][j] == '.') {
                graph[to_id(i, j)][to_id(i, j)] = 0;
                graph[to_id(j, i)][to_id(j, i)] = 0;
                rep(k, 4) {
                    ll x = i + dx[k];
                    ll y = j + dy[k];
                    if (x >= 0 & x < H && y >= 0 && y < W && grid[x][y] == '.') {
                        graph[to_id(i, j)][to_id(x, y)] = 1;
                        graph[to_id(x, y)][to_id(i, j)] = 1;
                    }
                }
            }
        }
    }
    warshall_floyd(graph);
    ll ans = 0;
    rep(i, 500) {
        rep(j, 500) {
            if (graph[i][j] >= INF) continue;
            ans = max(ans, graph[i][j]);
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 2176
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), x.end()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;

struct node {
  int v, lz;
} seg[N];

void merge(node& x, node& y, node& z) {
  x.v = min(y.v, z.v);
}

void build(int l, int r, int k) {
  seg[k].lz = 0;
  if (l == r) {
    seg[k] = {-l, 0};
    return;
  }
  int m = (l+r) / 2;
  build(l, m, k*2);
  build(m+1, r, k*2+1);
  merge(seg[k], seg[k*2], seg[k*2+1]);
}

void prop(int l, int r, int k) {
  if (l != r) {
    seg[k*2].lz += seg[k].lz;
    seg[k*2+1].lz += seg[k].lz;
  }
  seg[k].v += seg[k].lz;
  seg[k].lz = 0;
}

void upd(int l, int r, int k, int a, int b) {
  if (seg[k].lz) prop(l,r,k);
  if (b < l || r < a) return;
  if (a <= l && r <= b) {
    seg[k].lz--;
    prop(l,r,k);
    return;
  }
  int m = (l+r) / 2;
  upd(l, m, k*2, a, b);
  upd(m+1, r, k*2+1, a, b);
  merge(seg[k], seg[k*2], seg[k*2+1]);
}

int qry(int l, int r, int k, int a, int b) {
  if (seg[k].lz) prop(l,r,k);
  if (b < a || b < l || r < a) return N;
  if (a <= l && r <= b) return seg[k].v;
  int m = (l+r) / 2;
  return min(qry(l,m,k*2,a,b), qry(m+1,r,k*2+1,a,b));
}

array<int,2> a[N], b[N];

int main() {
  int n, m; scanf("%d %d", &n, &m);
  int nn = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &a[i][0], &a[i][1]);
    if (a[i][0] != 0 || a[i][1] != m+1)
      b[++nn] = a[i];
  }
  build(1, m, 1);
  sort(b+1, b+nn+1);
  int ans = m - nn;
  int j = 1;
  for (int i = 0; i < m; i++) {
    while (j <= nn && b[j][0] == i)
      upd(1, m, 1, 1, b[j][1]), j++;
    ans = min(ans, i + m+1 + qry(1, m, 1, i+1, m));
  }
  printf("%d\n", max(-ans, 0) + n-nn);
  return 0;
}

/*
4 4
0 3
2 3
1 3
3 4
*/

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

int d[53] = {0};

int main(){
    int n;
    cin >> n;
    string s[2];
    cin >> s[0] >> s[1];
    for(int i=0;i<n;++i){
        if(s[0][i] == s[1][i])
            d[i] = 1;
        else{
            d[i] = 2;
            d[i+1] = 2;
            i++;
        }
    }
    long long int ans=(d[0] == 1 ? 3 : 6);
    for(int i=(d[0] == 1 ? 1 : 2);i<n;++i){
        if(d[i] == 1){
            if(d[i-1] == 1)
                ans = (ans * 2) % 1000000007;
        }else{
            if(d[i-1] == 1)
                ans = (ans * 2) % 1000000007;
            else
                ans = (ans * 3) % 1000000007;
            i++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int sum=0;
    int l,r;
    for(int i=0;i<N;i++){
        cin>>l>>r;
        sum+=(r-l+1);
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
n = '0' + input()
l = len(n) - 1
n = n[::-1]
cnt = 0
num = 0
now = 0

for x in range(l):
    now = int(n[x]) + num
    num = now // 10
    now %= 10

    if now == 5 and int(n[x + 1]) >= 5:
        cnt += (10 - now)
        num += 1
    elif now <= 5:
        cnt += now
    else:
        cnt += (10 - now)
        num += 1

print(cnt + num)

Measured memory_bytes: 7012
#include<iostream>

using namespace std;

int main(void)
{
	char S[4], T[4];
	cin >> S;
	cin >> T;

	int n = 0;
	for (int i = 0; i < 3; i++) {
		if (S[i] == T[i])
			n++;
	}

	cout << n << endl;
  
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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

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


int main(void) {
	int x[5] = {};
	int y[5] = {};
	int ox, oy;

	cin >> x[1] >> y[1];
	cin >> x[2] >> y[2];

	ox = x[2] - x[1];
	oy = y[2] - y[1];

	x[3] = x[2] - oy;
	y[3] = y[2] + ox;
	x[4] = x[3] - ox;
	y[4] = y[3] - oy;

	cout << x[3] <<" "<< y[3] << " " << x[4] << " " << y[4] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int K;
  cin >> K;
  vector<int> board = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << board.at(K - 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main() {
    int N;
    int A[210000];
    // int res[210000] = {0};
    map<int,int> m;
    int sameAll = 0;

    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        m[A[i]]++;
    }
    for(auto k:m)
	{
		sameAll+=(k.second*(k.second-1))/2;
	}

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

}


Measured memory_bytes: 11136