akhauriyash/Code-Regression huggingface dataset:
import bisect
N = 10**6
dp = [1] * (N+1)
dp[0] =  dp[1] =  0
prime = []
for i in range(2,N+1):
    if dp[i]:
        for j in range(i*i, N+1, i):
            dp[j] = 0
for n in range(N+1):
    if dp[n]:
        prime.append(n)

like2017 = []
for p in prime:
    query = (p+1)//2
    idx = bisect.bisect_left(prime, query)
    if prime[idx] == query:
        like2017.append(p)
    

Q = int(input())
for q in range(Q):
    l, r = map(int,input().split())
    l = bisect.bisect_left(like2017, l)
    r = bisect.bisect_right(like2017, r)
    print (r-l)

Measured memory_bytes: 14452
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int ll
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i >= (b); i--)
#define M 32
int32_t main(){
  string s1, s2, s3;
  cin>>s1>>s2>>s3;
  stack<char> st1, st2, st3;
  rep(i, s1.size() - 1, 0){
      st1.push(s1[i]);
  }
  rep(i, s2.size() - 1, 0){
      st2.push(s2[i]);
  }
  rep(i, s3.size() - 1, 0){
      st3.push(s3[i]);
  }
  int a, b, c;
  a= b= c = 1;
  int turn = 1;
  while( a && b && c){
    if(turn == 1){
        //cout<<"i am 1 "<<endl;
        if(st1.empty()){
            a = 0;
            break;
        }
        char ch = st1.top();
        if(ch == 'a')turn = 1;
        else if(ch == 'b')turn = 2;
        else if(ch == 'c')turn = 3;
        st1.pop();
        //cout<<ch<<endl;
        //cout<<turn<<endl;

    }
    else if(turn == 2){
        //cout<<"i am 2 "<<endl;
        if(st2.empty()){
            b = 0;
            break;
        }
        char ch = st2.top();
        if(ch == 'a')turn = 1;
        else if(ch == 'b')turn = 2;
        else if(ch == 'c')turn = 3;
        st2.pop();

    }
    else if(turn == 3){
        //cout<<"i am 3 "<<endl;
        if(st3.empty()){
            c = 0;
            break;
        }
        char ch = st3.top();
        if(ch == 'a')turn = 1;
        else if(ch == 'b')turn = 2;
        else if(ch == 'c')turn = 3;
        st3.pop();

    }
  }
  if(a == 0)cout<<'A'<<endl;
  else if(b == 0)cout<<'B'<<endl;
  else cout<<'C'<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}




int main(){
  string s;
  cin>>s;
  if(s=="25"){
    cout<<"Christmas"<<endl;
  }else if(s=="24"){
    cout<<"Christmas Eve"<<endl;
  }else if(s=="23"){
    cout<<"Christmas Eve Eve"<<endl;
  }else{
    cout<<"Christmas Eve Eve Eve"<<endl;
  }





  

  



}


  
  

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

int main()
{
    long long int n,t;
    cin>>n;
    t=n*2;
    vector<long long int> v;
    while(t--)
    {
        long long int k;
        cin>>k;
        v.push_back(k);
      
    }
    sort(v.rbegin(),v.rend());
    
    long long int sum=0;
    for(long long int i=1;i<(2*n);i+=2)
    {
      
        sum+=v[i];
    }
    cout<<sum;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

int main(){
    ll N;
    string S;
    cin >> S;
    N = S.size();
    //map<ll,ll> mp;
    ll ans = 0;
    for(ll i=0;i<(ll(1)<<N-1);i++){
        ll cur = 0;
        ll sum = 0;
        for(ll j=0;j<N;j++){
            cur = cur*10 + ll(S[j]-'0');
            if((i >> j) & ll(1)){
                sum += cur;
                cur=0;
            }
        }
        sum += cur;
        //cout << sum << " ";
        ans += sum;
    }
    //cout << endl;
    cout << ans << endl;
}

Measured memory_bytes: 256
object Main extends App {
  val md1 = scala.io.StdIn.readLine()
  val md1Array = md1.split(" ").map(_.toInt).toVector
  val md2 = scala.io.StdIn.readLine()
  val md2Array = md2.split(" ").map(_.toInt).toVector

  if(md1Array(0) == md2Array(0)) {
    println(0)
  } else {
    println(1)
  }
}

Measured memory_bytes: 27100
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin>>N>>M;
    vector<int> a(N+1,true);
    int x;
    for(int i=0;i<M;i++){
        cin>>x;
        a.at(x)=false;
    }
    int mod=1000000007;
    vector<int> dp(N+1);
    dp.at(0)=1;
    for(int now=0;now<N;now++){
        for(int next=now+1;next<=min(now+2,N);next++){
            if(a.at(next)==true){
                dp.at(next)+=dp.at(now);
                dp.at(next)%=mod;
            }
        }
    }
    cout<<dp.at(N)<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 500000
ll MOD=1e9+7;
int dp[1<<26+2];
main(){
    int n=in();
    ll ans=1;
    rep(i,n)ans*=3;
    ll d=1;
    rep(i,n){
        int a=in();
        if(a%2==0)d*=2;
    }
    cout<<ans-d;
    return 0;
}



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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
    double n;
    cin>>n;
    int ok=fmod(n,2);
    if(ok==0)
    {
        cout<<(n/2)/n<<endl;
    }
    else if(ok==1){
        cout<<(n/2-0.5+1)/n<<endl;
    }
    }

Measured memory_bytes: 256
//package com.company;
import java.io.*;
import java.util.*;
//public class Aatc {
    public class Main {
    public static void main(String[] args) {

        out = new PrintWriter(new BufferedOutputStream(System.out));
        MyScanner sc = new MyScanner();//start
        int a=sc.nextInt();
        Map<String,Integer> ver = new HashMap<String, Integer>();
        ver.put("AC",0);
        ver.put("WA",0);
        ver.put("TLE",0);
        ver.put("RE",0);
        for (int i = 0; i <a; i++) {
            String temp=sc.nextLine();
            ver.merge(temp,1,Integer::sum);
        }
        System.out.println("AC" + " x "+ ver.get("AC"));
        System.out.println("WA" + " x "+ ver.get("WA"));
        System.out.println("TLE" + " x "+ ver.get("TLE"));
        System.out.println("RE" + " x "+ ver.get("RE"));
        out.close();
    }


    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            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();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    //--------------------------------------------------------

}


Measured memory_bytes: 45864
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

class Face{
	int[] colors;
	int[][] colorAlts;
	ulong count;
	int weight;
	string key;
	this(int[] x){
		count = 1;
		colors = x.toPreKey;
		key = colors.toKey;
		weight = key.weight;
		if(weight == 4) colorAlts = [colors];
		if(weight == 2) colorAlts = [colors, colors[1 .. 4] ~ colors[0 .. 1]];
		if(weight == 1) colorAlts = [colors, colors[1 .. 4] ~ colors[0 .. 1],
				colors[2 .. 4] ~ colors[0 .. 2], colors[3 .. 4] ~ colors[0 .. 3]];
		}
	debug string toString(){
		return weight.to!string ~ " [" ~ key ~ "] " ~ count.to!string;
		}
	}
Face[string] cset;

void main(){
	int n = readln.chomp.to!int;
	
	foreach(i; 0 .. n){
		int[] x = readln.chomp.split.map!(to!int).array;
		string k = x.toKey;
		if(k in cset) cset[k].count += 1;
		else cset[k] = new Face(x);
		}
	
	debug cset.values.map!(f => f.toString).join("\n").writeln;
	
	cset.rehash;
	
	ulong ans = 0;
	foreach(a; cset.values){
		foreach(b; cset.values){
			foreach(cs; b.colorAlts){
				ans += fn(a.colors, cs, a, b);
				}
			}
		}
	
	ans /= 6;
	ans.writeln;
	
	}

int[] toPreKey(int[] x){
	while(x[0] > x[1] || x[0] > x[2] || x[0] > x[3]) x = x[1 .. $] ~ x[0];
	if(x[0] == x[3]) x = x[3] ~ x[0 .. 3];
	if(x[0] == x[3]) x = x[3] ~ x[0 .. 3];
	if(x[0] == x[3]) x = x[3] ~ x[0 .. 3];
	if(x[0] == x[2] && x[1] > x[3]) x = x[2 .. 4] ~ x[0 .. 2];
	return x;
	}
string toKey(int[] x){
	return x.toPreKey.map!(to!string).join(" ");
	}

int weight(string k){
	int[] x = k.split.map!(to!int).array;
	if(x[0] == x[2] && x[1] == x[3]){
		if(x[0] == x[1]) return 4; else return 2;
		}
	else return 1;
	}

ulong fn(int[] x, int[] y, Face a, Face b){
	string[] ks = [
		[x[0], y[0], y[3], x[1]].toKey,
		[x[1], y[3], y[2], x[2]].toKey,
		[x[2], y[2], y[1], x[3]].toKey,
		[x[3], y[1], y[0], x[0]].toKey
		];
	foreach(k; ks) if(!(k in cset)) return 0;
	Face[] fs = [a, b] ~ ks.map!(k => cset[k]).array;
	
	ulong[] ns = fs.map!(f => f.count).array;
	
	foreach(i, f; fs) foreach(ii, ff; fs){
		if(i < ii) if(f.key == ff.key){
			ns[ii] -= 1;
			if(ns[ii] <= 0) return 0;
			}
		}
	
	ulong ans = 1;
	foreach(i, f; fs) ans *= ns[i] * f.weight;
	ans /= fs[0].weight;
	
	debug if(ans > 0){
		writeln(x, " ", y);
		writeln(ns, " ", ans);
		}
	
	return ans;
	
	}

Measured memory_bytes: 1404
//Keep Working Hard
  // I__Like__Food
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #pragma comment(linker, "/stack:200000000")
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define f first
  #define s second
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 998244353
  #define N 100005
  #define INF 1e10
  const double PI = acos(-1);


int32_t main()
{




    int n,k;
    cin >> n >> k;

    int arr[n+1];

    for(int i = 1; i <= n; i++)cin >> arr[i];

  vector<int> dp(k+1,0);
  // dp[i] denotes the winner if there are i stones remaining
  // dp[i] = 0 if Taro loses , = 1 if Taro wins


  for(int i = 0; i <= k; i++)
  {
    for(int j = 1; j <= n; j++)
    {
      if(dp[i] == 0 and i + arr[j] <= k)dp[i+arr[j]] = 1;
    }
  }


  bool(dp[k]) ? cout << "First" : cout << "Second";
  return 0;
  
}  

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
from collections import deque,defaultdict
sys.setrecursionlimit(10**5)

H,W,K=map(int, sys.stdin.readline().split())
ichigo=[]
cnt=0   #イチゴに番号を振るための変数
h_visit=[0 for h in range(H)]  #縦軸にイチゴがない箇所は0、ある箇所は1

L=[ [] for h in range(H) ]
for h in range(H):
    s=sys.stdin.readline().strip()
    for w,x in enumerate(s):
        if x==".":
            L[h].append(0)
        elif x=="#":
            cnt+=1
            L[h].append(cnt)
            ichigo.append((h,w))
            h_visit[h]=1

D=(1,-1)    #マスの横移動、または縦移動に使用

def yoko_dfs(h,w):  #縦座標、横座標
    for dw in D:
        if 0<=w+dw<=W-1 and L[h][w+dw]==0:
            L[h][w+dw]=L[h][w]
            yoko_dfs(h,w+dw)
    return

#横方向に空マスなら、自分のイチゴ番号で埋めていく
for h,w in ichigo:
    yoko_dfs(h,w)

def tate_dfs(h):  #縦座標
    for dh in D:
        if 0<=h+dh<=H-1:
            if h_visit[h+dh]==1: continue
            h_visit[h+dh]=1 #訪問済みにする
            L[h+dh]=L[h]    #行のコピー
            tate_dfs(h+dh)

#縦方向にdfs。イチゴがない行を探して、イチゴがある行を行ごとコピーする
for h,w in ichigo:
    tate_dfs(h)

for l in L:
    for x in l:
        print x,
    print

Measured memory_bytes: 47132
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define vec vector <int>
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define bg begin()
#define en end()
#define endl "\n"
#define ff first
#define ss second
#define all(x) x.bg,x.en
#define fill(a,b) memset(a,b,sizeof(a))
#define fr(i,n) for(int i=0;i<n;i++)
#define rp(i,a,b) for(int i=a;i<b;i++)
#define rr(i,a,b) for(int i=a;i>=b;i--)
#define ft(it,x) for(auto it : x)
#define dbg(x) cout<<#x<<" "<<x<<endl;
#define dbga(arr,n) cout<<#arr<<": "; rp(tt,0,n) cout<<tt<<" "<<arr[tt].ff<<" "<<arr[tt].ss<<endl; cout<<endl;
#define mapi map<int,int>
#define test(t) int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long
const int mod=1e9+7,mex=1e12,md=998244353;
signed main()
{
	fast
	int k,n;
	cin>>k>>n;
	int a[n];
	fr(i,n) cin>>a[i];
	int ans=a[0]+k-a[n-1];
	fr(i,n-1) ans=max(ans,a[i+1]-a[i]);
	cout<<k-ans;
}

Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=4e6+10;
const int mod7=1e9+7;
const int mod=1e9+7;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
ll f[2005][2005],fac[N],ifac[N];
ll quickmod(ll x,ll y)
{
    ll res=1,base=x;
    while(y)
    {
        if(y&1) res=res*base%mod;
        base=base*base%mod;
        y>>=1;
    }
    return res;
}
void init(int n)
{
    fac[0]=1;
    for(re ll i=1;i<=n;i++) fac[i]=i*fac[i-1]%mod;
    ifac[n]=quickmod(fac[n],mod-2);
    for(re ll i=n-1;~i;i--) ifac[i]=ifac[i+1]*(i+1)%mod;
}
ll C(int n,int m) {return n<m?0:((fac[n]*ifac[m]%mod)*ifac[n-m])%mod;}
int main()
{
    int n,k;
    read(n),read(k);
    if(k==1) return puts("1"),0;
    init(4000000);
    f[0][0]=1;
    for(re int i=1;i<=n;i++)
    {
        for(re int j=0;j<=i;j++)
        {
            if(!j)
            {
                f[i][j]=f[i-1][j];
                continue;
            }
            f[i][j]=f[i-1][j]+f[i][j-1]*(n-j+1)%mod*C(n*k-i-1-(j-1)*(k-1),k-2)%mod;
            f[i][j]%=mod;
        }
    }
    printf("%lld\n",f[n][n]);
    return 0;
}

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

const int N = 3e5 + 10;

int ans[N];

int main(){
	int n, a, b, now, rec, pos, l, r;
	scanf("%d %d %d",&n,&a,&b);
	if (a > n || b > n || (n - 1) / a + 1 > b || a + b > n + 1){
		printf("-1\n");
		return 0;
	}
	now = n;
	for (int i = 1; i <= n; i += a){
		for (int j = min(n, i + a - 1); j >= i; j--) ans[now--] = j;
		b--;
	}
	for (int i = n - a; i >= 1 && b > 0; i -= a){
		rec = min(b, min(i, a) - 1);
		pos = max(i - a + 1, 1);
		l = ans[pos]; r = ans[i];
		for (int j = pos; j <= pos + rec - 1; j++) ans[j] = r - j + pos;
		for (int j = pos + rec; j <= i; j++) ans[j] = l + j - pos - rec;
		b -= rec;
	}
	for (int i = 1; i <= n; i++){
		printf("%d", ans[i]);
		if (i < n) printf(" ");
		else printf("\n");
	}
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void solve()
{
    int k,a,b;
    cin>>k>>a>>b;
    for(int i=1;i<=1000;++i){
        if(a<=i*k&&i*k<=b) {
            printf("OK");
            return ;
        }
    }
    puts("NG");
}
int main()
{
	///int _;cin>>_;while(_--)
	solve();
}


Measured memory_bytes: 3676
#include <iostream>
using namespace std;
double dabs(double x){
	return x < 0 ? -x : x;
}
int main(){
  int n, t, a, h;
  cin >> n >> t >> a;
  int out;
  double min = 1e9;
  for(int i = 0; i < n; i++){
    cin >> h;
    if(min > dabs(a - (t - (0.006 * h)))) {min = dabs(a - (t - (0.006 * h))); out = i + 1;}
  }
  cout << out << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define F(i,n) for (int i = 0; i < n; ++i)
#define pb push_back
using namespace std;
typedef vector<int> vi;
int main () {
	int n, a[2]; cin >> n;
	a[1] = 0;
	while(n --> 0) {
		int t; cin >> t; a[t & 1]++; 
	}
	cout << ((a[1] & 1) ? "NO\n" : "YES\n"); 
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

double dp[1<<15];

int main(){
	int n,m;
	double p;
	cin >> n >> m >> p;
	vector<pair<int,int> >g;
	p /=100.0;
	for(int i=0;i<m;i++){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		g.PB(MP(a,b));
	}
	for(int i=0;i<n;i++){
		dp[1<<i]=1.0;
	}
	for(int i=1;i<(1<<n);i++){
		dp[i]=1.0;
		for(int S=(1<<n)-1;S>=0;S--){
			double tmp = 1.0;
			S &= i;
			int T = i-S;
			if(S<T)break;
			if(S==0||T==0)continue;
			for(int j=0;j<m;j++){
				if(S>>g[j].first&1&&T>>g[j].second&1){
					tmp*=p;
				}
				if(T>>g[j].first&1&&S>>g[j].second&1){
					tmp*=p;
				}
			}
			dp[i] -= dp[S]*tmp;
		}
	}
	cout << fixed << setprecision(20) << dp[(1<<n)-1] << endl;
	return 0;
}


Measured memory_bytes: 3416
#include<iostream>
#include<cmath>
#include<algorithm>
using Int = long long;
const Int INF = 1 << 30;

//桁数の計算
Int f(Int n) {
	Int digit = 0;

	while (n != 0) {
		n /= 10;
		digit++;
	}
	return digit;
}

int main() {

	Int N;
	std::cin >> N;

	Int ans = INF;
	long double A_max = std::sqrt(N);

	for (int i = 1; i <= A_max; i++) {

		if (N % i == 0) {
			Int B = N / i;
			Int res = std::max(f(i),f(B));
			ans = std::min(ans, res);
		}
	}

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


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
using namespace std;
typedef pair<int,int> P;

//for vector
inline int norm(const P &a){ return a.fs*a.fs + a.sc*a.sc; }
inline int dot(const P &a, const P &b){return a.fs*b.fs + a.sc*b.sc;}
inline int cross(const P &a, const P &b){return a.fs*b.sc - a.sc*b.fs;}

inline int ccw(const P &a,P b,P c){
  b.fs -= a.fs; b.sc -= a.sc;
  c.fs -= a.fs; c.sc -= a.sc;
  if (cross(b,c)>0) return 1;   //counter clockwise
  if (cross(b,c)<0) return -1; //clockwise
  if (dot(b, c)<-0) return 2;   //c--a--b on line
  if (norm(b)<norm(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

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

  int n,m;
  P b[110],w[110];
  while(cin >> n >> m){
    if(n==0 && m==0)break;
    rep(i,n)cin >> b[i].fs >> b[i].sc;
    rep(i,m)cin >> w[i].fs >> w[i].sc;

    bool ans = false;
    rep(i,n)rep(j,i){
      bool f = true;
      set<int> dirb;
      rep(k,n){
	if(k==i || k==j)continue;
	int tmp = ccw(b[i],b[j],b[k]);
	if(tmp == 0){f = false; break;}
	if(abs(tmp)==1){
	  dirb.insert(tmp);
	  if(dirb.size()==2){f = false; break;}
	}
      }

      if(f){
	set<int> dirw;
	rep(k,m){
	  int tmp = ccw(b[i],b[j],w[k]);
	  if(abs(tmp) != 1){f = false; break;}
	  dirw.insert(tmp);
	  if(dirw.size()==2){f = false; break;}
	}
	if(f && (dirb.size()==0 || dirw.size()==0
		 || *dirb.begin() != *dirw.begin()))ans = true;
      }
      if(ans)break;
    }

    if(!ans){
      rep(i,m)rep(j,i){
	bool f = true;
	set<int> dirw;
	rep(k,m){
	  if(k==i || k==j)continue;
	  int tmp = ccw(w[i],w[j],w[k]);
	  if(tmp == 0){f = false; break;}
	  if(abs(tmp)==1){
	    dirw.insert(tmp);
	    if(dirw.size()==2){f = false; break;}
	  }
	}
	
	if(f){
	  set<int> dirb;
	  rep(k,n){
	    int tmp = ccw(w[i],w[j],b[k]);
	    if(abs(tmp) != 1){f = false; break;}
	    dirb.insert(tmp);
	    if(dirb.size()==2){f = false; break;}
	  }
	  if(f && (dirb.size()==0 || dirw.size()==0
		   || *dirb.begin() != *dirw.begin()))ans = true;
	}
	if(ans)break;
      }
    }

    if(!ans){
      rep(i,n)rep(j,m){
	bool f = true;
	set<int> dirb;
	rep(k,n){
	  if(k==i)continue;
	  int tmp = ccw(b[i],w[j],b[k]);
	  if(tmp == 0 || tmp == -2){f = false; break;}
	  if(abs(tmp)==1){
	    dirb.insert(tmp);
	    if(dirb.size()==2){f = false; break;}
	  }
	}
	
	if(f){
	  set<int> dirw;
	  rep(k,m){
	    if(k==j)continue;
	    int tmp = ccw(b[i],w[j],w[k]);
	    if(tmp == 0 || tmp == 2){f = false; break;}
	    if(abs(tmp)==1){
	      dirw.insert(tmp);
	    if(dirw.size()==2){f = false; break;}
	    }
	  }	
	  if(f && (dirb.size()==0 || dirw.size()==0
		   || *dirb.begin() != *dirw.begin()))ans = true;
	}
	if(ans)break;
      }
    }

    cout << (ans?"YES":"NO") << endl;
  }
}

Measured memory_bytes: 1200
# -*- coding: utf-8 -*-
n,k = list(map(int,input().split()))
red = n-k
blue = k
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
for i in range(1,k+1):
    if red+1 < i:
        print(0)
        continue
    else:
        print(combination(red+1,i)*combination(blue-1,i-1)%(10**9+7))


Measured memory_bytes: 3316
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	void run() throws Exception {
		int n = sc.nextInt();
		for (int t = 0; t < n; t++) {
			char[] str = sc.next().toCharArray();
			Parser p = new Parser(str);
			System.out.println(p.parse().min());
		}
	}
}

class Node {
	List<Node> ns;

	Node() {
		ns = new ArrayList<Node>();
	}

	public void add(Node n) {
		ns.add(n);
	}

	public int min() {
		int[] is = new int[ns.size()];
		for (int i = 0; i < ns.size(); i++) {
			is[i] = ns.get(i).min();
		}
		Arrays.sort(is);
		int sum = 0;
		for (int i = 0; i < Math.ceil((1.0 * ns.size()) / 2); i++) {
			sum += is[i];
		}
		return sum;
	}

	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("[");
		for (Node n : ns) {
			if (n instanceof Leaf) {
				n = (Leaf) n;
			}
			sb.append(n.toString());
		}
		sb.append("]");
		return sb.toString();
	}
}

class Leaf extends Node {
	int i;

	Leaf(int i) {
		this.i = i;
	}

	public int min() {
		return (i + 1) / 2;
	}

	public String toString() {
		return "Leaf(" + i + ")";
	}
}

class Parser {
	int pos;
	char str[];

	Parser(char[] str) {
		this.str = str;
		pos = 0;
	}

	public Node parse() throws Exception {
		if (str[pos] == '[') {
			pos++;
		} else {
			throw new Exception();
		}
		if (str[pos] == '[') {
			Node n = new Node();
			while (str[pos] != ']') {
				n.add(parse());
			}
			pos++;
			return n;
		} else {
			StringBuilder sb = new StringBuilder();
			while (str[pos] != ']') {
				sb.append(str[pos]);
				pos++;
			}
			pos++;
			int i = Integer.parseInt(sb.toString());
			return new Leaf(i);
		}
	}
}

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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

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

const int MAX_N = 1e5 + 10;
struct Edge { ll to, cost; };
vector<Edge> es[MAX_N];

ll val[MAX_N], d[MAX_N];
bool f = true;
int root;

bool dfs(int cur, int prv) {
	if (cur == root) return true;
	bool ret = true;
	for (auto& e : es[cur]) {
		if (e.to == prv || e.to == root) continue;
		if (abs(d[e.to] - d[cur]) != 1) return false;
		ret &= dfs(e.to, cur);
	}
	return ret;
}

int main() {
	rep(i, MAX_N) d[i] = 1e18, val[i] = -1;
	int n;
	cin >> n;
	rep(i, n - 1) {
		ll a, b, c;
		cin >> a >> b;
		a--; b--; c = 1LL;
		es[a].pb({b, c});
		es[b].pb({a, c});
	}
	root = n;
	int k;
	cin >> k;
	rep(i, k) {
		int a, b;
		cin >> a >> b;
		a--;
		val[a] = b;
		es[a].pb({root, b});
		es[root].pb({a, b});
	}
	auto dijkstra = [&] () {
		typedef pair<int, int> P; //dist, from
		priority_queue<P, vector<P>, greater<P> > q;
		d[root] = 0LL;
		q.push({0LL, root});
		while (!q.empty()) {
			auto p = q.top(); q.pop();
			int prv = p.se;
			ll cost = p.fi;
			if (d[prv] < p.fi) continue;
			for (auto& e : es[prv]) {
				int to = e.to;
				ll dist = e.cost + cost;
				if (dist < d[to]) {
					d[to] = dist;
					q.push({dist, to});
				}
			}
		}
	};
	dijkstra();
	rep(i, n) {
		if (val[i] == -1) continue;;
		if (((val[i] & 1) ^ (d[i] & 1)) || val[i] != d[i]) {
			f = false;
			break;
		}
	}
	f &= dfs(0, -1);
	cout << (f ? "Yes" : "No") << endl;
	if (f) {
		rep(i, n) cout << d[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 19028
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }

int main() {
    cout << setprecision(20);
    int h, w;
    cin >> h >> w;

    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            string s;
            cin >> s;
            if (s == "snuke") {
                cout << char('A'+x) << y+1 << endl;
            }
        }
    }
    return 0;
}


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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    int h,w;
    while(cin>>w>>h){
        if(h==0) break;
        string s[h];
        for(int i=0;i<h;i++){
            cin>>s[i];
        }
        int n = h*w;
        int dp[n][n]={};
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(j==i) continue;
                dp[i][j] = 1e9;
            }
        }
        int dx[4] = {0,1,0,-1};
        int dy[4] = {1,0,-1,0};
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(s[i][j] == 'x') continue;
                for(int k=0;k<4;k++){
                    int x = dx[k] + i , y = dy[k]+j;
                    if(x<0 || x>=h || y<0 || y>=w) continue;
                    if(s[x][y] == 'x') continue;
                    dp[i*w+j][x*w+y]=1;
                }
            }
        }
        for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++){
            dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
        }
        vector<int> v;
        int now = 0;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(s[i][j]=='*'){
                    v.push_back(i*w+j);
                }
                if(s[i][j] == 'o') now = i*w+j;
            }
        }
        sort(v.begin(),v.end());
        int ans = 1e9;
        bool pos = true;
        do{
            int t = now;
            int ret = 0;
            for(int i:v){
                if(dp[t][i]==1e9){
                    pos = false;
                    break;
                }
                ret += dp[t][i];
                t = i;
            }
            if(pos == false) break;
            ans = min(ans,ret);
        }while(next_permutation(v.begin(),v.end()));

        if(ans == 1e9)ans = -1;
        cout << ans << "\n";
    }
}



Measured memory_bytes: 3592
//
// Created by yuu on 2019-06-22.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;


int main(void){
    int N,L;

    cin>>N>>L;

    int sum = 0;

    for (int i = 0; i < N; ++i) {
        sum += L + (i+1) -1;
    }

    int saiteki;
    int min = 1000000000;
    for (int i = 0; i < N; ++i) {
        int temp = 0;
        for (int j = 0; j < N; ++j) {
            if(i==j){
                continue;
            }
            temp += L + (j+1) -1;
        }

        if(min > abs(sum - temp)) {
            min = abs(sum - temp);
            saiteki = temp;

        }
    }


    cout<<saiteki<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll long long int
#define endl "\n"
#define db(x) cout<<#x<<" ->"<<x<<endl
#define db2(x,y) cout<<#x<<"->"<<x<<", "<<#y<<" -> "<<y<<endl
#define db3(x,y,z) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define db4(w,x,y,z) cout<<#w <<" -> " << w << " , " << #x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define prt(x) for(auto it = x.begin(); it!=x.end(); it++) { cout<<*it<<" "; } cout<< endl
#define IN freopen("input.txt","r",stdin)
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = (int)1e5+4;
const int lim = (int)1e9;

int32_t main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
//    IN;
    vector< ll > V;
    ll n , m;
    cin >>  n >> m;
    for(int i = 0;i < n; i++){
        ll x;
        cin >> x;
        x/=2;
        V.push_back(x);
    }

    ll lcm = V[0];
    bool fl = 1;
    bool lol = 0;
    for(int i = 1; i < V.size(); i++){
        lcm = (1LL * V[i] * lcm) / __gcd(V[i],lcm);
        if(lcm > m){ fl = 0; break ;}
    }
    if(fl==0){
        cout << 0 << endl;
        return 0;
    }
    for(auto &x : V){
        if( ( lcm / x ) % 2 == 0 ){ fl = 0; break ;}
    }
    if(fl==0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0LL;
    ll cur = m / lcm;
    ans+=(cur+1) / 2;
//    for(int i = 1; lcm * i <= m; i+=2){
//        ++ans;
//    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>


int main () {
    int n;
    std::cin >> n;
    int a[n], b[n], c[n - 1];
    for(int i = 0; i < n; ++i){
        std::cin >> a[i];
    }
    for(int i = 0; i < n; ++i){
        std::cin >> b[i];
    }
    for(int i = 0; i < n - 1; ++i){
        std::cin >> c[i];
    }
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        ans += b[a[i] - 1];
        if(a[i] == a[i - 1] + 1) {
            ans += c[a[i] - 2];
        }
    }
    std::cout << ans << std::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:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int H,W; cin >> H >> W;

    vector<vector<char>> masu(H+2,vector<char>(W+2,'#'));
    for(int i = 1; i <= H;i++){
        for(int j = 1; j <= W;j++){
            cin >> masu[i][j];
        }
    }

    for(int i = 0; i <= H+1;i++){
        for(int j = 0; j <= W+1;j++){
            cout << masu[i][j];
        }cout << endl;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    solve<ll>(0);
    // cout << fixed << setprecision(12) << solve<ll>() << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdint>

using namespace std;

int main()
{
    int_least32_t a, b;
    cin >> a >> b;

    if(a + b >= 24) {
        cout << a + b - 24 << endl;
    }
    else {
        cout << a + b << endl;
    }
}

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

int gcd(int a,int b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}

int main(){
    int n,a,b,c,d,h=0;
    vector<int>e(2);
    vector<int>f(2);
    vector<int>g(2);
    string s="+-";
    cin>>n;
    a=n/1000;
    b=(n/100-a*10);
    d=n%10;
    c=(n%100-d)/10;
    e[0]=b;
    e[1]=-b;
    f[0]=c;
    f[1]=-c;
    g[0]=d;
    g[1]=-d;
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                h=e[i]+f[j]+g[k]+a;
                if(h==7){
                    cout<<a<<s[i]<<b<<s[j]<<c<<s[k]<<d<<"=7"<<endl;
                    break;
                }
                else{
                    h=0;
                }
            }
            if(h==7){
                break;
            }
        }
        if(h==7){
                break;
            }
    }

  return 0;
}

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

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;

    if(a >= 13){
        cout << b << endl;
    }else if(a >= 6){
        cout << b / 2 << endl;
    }else{
        cout << 0 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
bool check(string &str) {
    set<char> st;
    for (auto e : str) {
        st.insert(e);
    }
    return st.size() == 1;
}
int main() {
    string s;
    cin >> s;
    if (s.size() == 1) {
        cout << 0 << endl;
        return 0;
    }
    int ans = INT_MAX;
    for (char ch = 'a'; ch <= 'z'; ch++) {
        string prev = s;
        string now = s;
        while (!check(now)) {
            now = "";
            for (int i = 0; i < prev.size() - 1; i++) {
                if (prev[i] == ch || prev[i + 1] == ch) {
                    now.push_back(ch);
                } else {
                    now.push_back(prev[i + 1]);
                }
            }
            prev = now;
        }
        ans = min(ans, (int)s.size() - (int)now.size());
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int M,D;
    int sum=0;
    cin >> M >> D;
    for(int i=4;i<=M;i++)
        for(int j=22;j<=D;j++)
        {
            if(j%10>=2&&(j%10)*(j/10)==i)
                sum++;
        }
        cout << sum;
    return 0;
}

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

int main(){
    int64_t n, x; cin >> n >> x;

    int64_t ans = x + (n - x);
    int64_t a = x, b = (n - x);

    while(a) {
        if(a > b) swap(a, b);
        int64_t tmp = b % a;
        ans += 2 * a * (b / a);
        if(tmp == 0) ans -= a;
        b = a; a = tmp;
    }

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

Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
int main()
{
    double a,b,c,d,n,m;
    std::cin >> a >> b >> c >> d;
    if(a>c){
        if(b>d){
            m=(a-c)*(a-c)+(b-d)*(b-d);
            n=sqrt(m);
            printf("%.8f", n);
        }else if(b<d){
            m=(a-c)*(a-c)+(d-b)*(d-b);
            n=sqrt(m);
            printf("%.8f", n);
        }else{
            m=a-c;
            //n=sqrt(m);
            printf("%.8f", m);
        }
    }else if(a<c){
        if(b<d){
            m=(c-a)*(c-a)+(d-b)*(d-b);
            n=sqrt(m);
            printf("%.8f", n);
        }else if(b>d){
            m=(c-a)*(c-a)+(b-d)*(b-d);
            n=sqrt(m);
            printf("%.8f", n);
        }else{
            m=c-a;
            //n=sqrt(m);
            printf("%.8f", m);
        }
    }else if(a==c){
        if(b<d){
            printf("%.8f", d-b);
        }else{
            printf("%.8f", b-d);
        }
    }
    return 0;
}

//printf("%.8f", n);

Measured memory_bytes: 3264
from collections import defaultdict

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

dic = defaultdict(int)

for i in range(N):
    dic[(i + 1) - A[i]] += 1

ans = 0
for i in range(N):
    dic[(i + 1) - A[i]] -= 1
    ans += dic[(i + 1) + A[i]]

print (ans)

Measured memory_bytes: 61572
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<map>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,i,j,x;
map<int,int> cnt;
long long mx1,mx; 
string st;
int main()
{
	ios::sync_with_stdio(0);
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>x;
		cnt[x]++;
	}
	for (map<int,int>::iterator it=cnt.begin();it!=cnt.end();it++)
	{
		if (it->second>=2)
		{
		 	if (mx<it->first)
			{
				 mx=it->first;
				 it->second-=2;
			} 
		}
		if (it->second>=2)
		{
		 	if (mx1<it->first)
			{
				 mx1=it->first;
				 it->second-=2;
			} 
		}
		if (mx>mx1) swap(mx,mx1);
	}
	cout<<mx*mx1;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    int ans=0;
    for(int i=0;i<n;i++){
        int l,r;
        cin>>l>>r;
        ans+=(r-l+1);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;


int main() {
   int n,m;
   cin >> n >> m;
   vector<int> a(n);
   rep(i,n) a.at(i)=i;
   set<pp> s;
   rep(i,m){
      int aa,b;
      cin >> aa >> b;
      s.insert(make_pair(aa,b));
      s.insert(make_pair(b,aa));
   }
   int ans=0;
   do {
      if (a.at(0)!=0) break;
      int u=0;
      rep(i,n-1){
         auto it=s.find(make_pair(a.at(i)+1,a.at(i+1)+1));
         if (it==s.end()) u=1;
      }
      if (u==0) ans++;
   } while(next_permutation(a.begin(),a.end()));
  cout << ans << endl;
  }

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,j,count=0,n,q,key;
  int a[10000],b[10000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d",&a[i]);
}
scanf("%d",&q);
for(i=0;i<q;i++){
scanf("%d",&b[i]);
}
for(j=0;j<q;j++){
  i=0;
  key=b[j];
  a[n]=key;
while(1){
  if(a[i]==b[j]){
    count++;
    break;
  }
  i++;
  if(i==n){
    break;
  }
}
}
printf("%d\n",count);
return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n;
	string s,t;
	cin >> n >> s >> t;
	for(int i = 0;i < n;i++){
		cout << s[i] << t[i];
	}
	cout << endl;
}

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

int main() {
  string S;
  cin >> S;
  reverse(S.begin(), S.end());
  int start = 0;
  bool can = true;
  while (true) {
    if (S.substr(start, 5)=="maerd"||S.substr(start, 5)=="esare") start += 5;
    else if (S.substr(start, 6)=="resare") start += 6;
    else if (S.substr(start, 7)=="remaerd") start += 7;
    else {
      can = false;
      break;
    }
    if (start==S.size()) break;
  }
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 512
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
 
    int n = sc.nextInt();
    int[] vs = new int[n];
    int[] cs = new int[n];
    
    for(int i = 0; i < n; i++){
        vs[i] = sc.nextInt();
    }
    
    for(int i = 0; i < n; i++){
        cs[i] = sc.nextInt();
    }
    
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(vs[i] > cs[i]){
            ans += vs[i] - cs[i];
        }
    }
 
    System.out.println(ans);
 
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 22484