akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
typedef long long int Int;

Int gcd(Int a, Int b) { return a > 0 ? gcd(b % a, a) : b; }
Int lcm(int a, int b){ return a / gcd(a, b) * b; }

struct rational {
  Int p, q;
  void normalize() {
    if (q < 0) p *= -1, q *= -1;
    Int d = gcd(p < 0 ? -p : p, q);
    if (d == 0) p = 0,  q = 1;
    else        p /= d, q /= d;
  }
  rational(Int p, Int q = 1, bool norm = true) : p(p), q(q) {
    if(norm) normalize();
  }
};

bool operator < (const rational &a, const rational &b) { return (long double) a.p * b.q < (long double) a.q * b.p; }

void solve(int N, vector<string> &v){
  map<rational, int> M;
  REP(n, N){
    string s = v[n];
    for(int i = 0; i + 1 < s.length(); i += 2){
      int num = strtol(s.substr(i, 2).c_str(), NULL, 16);
      if(num) M[rational((i + 1) / 2, (int)(s.length()) / 2)] += num;
    }
  }
  if(M.size() == 0) { cout <<"00" <<endl; return ; }
  Int L = 1;
  for(auto i : M){
    L = lcm(i.first.q, L);
    if(L * 2 > 2049) { cout <<"Too complex." <<endl; return ; }
  }
  if(L * 2 > 2049) { cout <<"Too complex." <<endl; return ; }
  map<rational, int> ans;
  for(auto i : M){
    int p = i.first.p, q = i.first.q, n = i.second, m = L / q;
    ans[rational(p * m, L)] = n;
  }
  REP(i, L){
    if(ans[rational(i, L)] != 0) cout <<setfill('0') << setw(2) << hex  << uppercase << ans[rational(i, L)];
    else cout <<"00";
  }
  cout <<endl;
}

int main() {
  int T; cin >>T;
  REP(t, T){
    int N; cin >>N;
    vector<string> v(N);
    REP(i, N) cin >>v[i];
    solve(N, v);
  }
  return 0;
}

Measured memory_bytes: 1572
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
using namespace std;
//整形Shift + alt + f　2回
//int x[101],y[101],h[101];
//int koya[100001][];
/*
//ユークリッドの互除法
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
*/

/*
//桁数取得
unsigned GetDigit(unsigned num)
{
    unsigned digit = 0;
    while (num != 0)
    {
        num /= 10;
        digit++;
    }
    return digit;
}
*/

long long int n, h, w;

long long int a, b;

int main()
{
    cin >> n >> h >> w;

    int res = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> a >> b;
        if (h <= a && w <= b)
            res++;
    }

    cout << res;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
int n;
int a[100005];
vector <int> vec;
int b[100005];
int sum[100005];
ll bit[400005];
int nn;

ll query(int x)
{
	ll res=0;
	while(x)
	{
//		cout<<x<<endl;
		res+=bit[x];
		x&=x-1;
	}
	return res;
}

void add(int x,int delta)
{
	while(x<=nn)
	{
		bit[x]+=delta;
		x+=x&-x;
	}
}

bool check(int x)
{
	for(int i=0;i<=400000;i++)
	{
		bit[i]=0;
	}
//	memset(sum,0,sizeof(bit));
//	bool debug=(x==30);
	for(int i=0;i<n;i++)
	{
		b[i]=(a[i]>=x?1:-1);
	}
//	for(int i=0;i<n;i++)
//	{
//		if(debug) cout<<b[i]<<' ';
//	}
//	if(debug) cout<<endl;
	sum[0]=b[0];
	for(int i=1;i<n;i++)
	{
		sum[i]=sum[i-1]+b[i];
	}
	ll res=0;
	for(int i=0;i<n;i++)
	{
		res+=(sum[i]>=0);
		sum[i]+=100000;
	}
	for(int i=0;i<n;i++)
	{
//		if(debug) cout<<query(sum[i])<<endl;
		res+=query(sum[i]);
		add(sum[i],1);
	}
//	for(int i=0;i<n;i++)
//	{
//		res+=(sum[i]>=0);
//		for(int j=i+1;j<n;j++)
//		{
//			if(sum[i]<=sum[j]) res++;
//		}
//	}
//	for(int i=0;i<n;i++)
//	{
//		if(debug) cout<<b[i]<<' ';
//	}
//	if(debug) cout<<endl;
//	for(int i=0;i<n;i++)
//	{
//		sum[i]+=100000;
//	}
//	ll res=0;
//	for(int i=0;i<n;i++)
//	{
////		if(debug) cout<</*query(131071)-*/query(sum[i])<<endl;
//		res+=query(131071)-query(sum[i]-1);
//		add(sum[i],1);
//	}
//	cout<<x<<' '<<res<<endl;
//	cout<<query(400000)<<endl;
//	cout<<x<<' '<<(res>=(ceil(n*(n+1)/2,2)))<<endl;
	return (res>=(ceil(1LL*n*(n+1)/2,2)));
}

int main()
{
//	freopen("input.txt","r",stdin);
//	ios_base::sync_with_stdio(false);
	cin>>n;
	nn=1;
	while(nn<n+100000)
	{
		nn<<=1;
	}
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
//		cin>>a[i];
		vec.push_back(a[i]);
	}
	sort(all(vec));
	vec.erase(unique(all(vec)),vec.end());
	int l=0,r=vec.size()-1,m,ans=3;
	while(l<=r)
	{
		m=l+r>>1;
		if(check(vec[m]))
		{
			ans=m;
			l=m+1;
		}
		else
		{
			r=m-1;
		}
	}
	cout<<vec[ans];
	return 0;
}

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

int main(){
//srandom((unsigned long)time(NULL));

//何回2でわれるか
long long n;
cin>>n;
long long ans=0;
for(long long i=0;i<n;i++){
    long long x;
    cin>>x;
    for(long long j=0;1;j++){
        if(x%2==0){
            ans++;
            x=x/2;
        }
        if(x%2==1){
            break;
        }
    }
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
 int a,b;
  scanf("%d%d",&a,&b);
  
  if(a>=13){
    printf("%d\n",b);
  }else if(a>=6){
    printf("%d\n",b/2);
  }else{
    printf("%d\n",b-b);
  }
  return 0;
}


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

string SwapStringFrontAndBack(string s) {

	string swap;
	vector<char> tmp(s.size());

	for (int i = 0; i < s.size(); i++) { tmp[i] = s[i]; }

	sort(tmp.begin(), tmp.end());

	for (int i = 0; i < s.size(); i++) { swap += tmp[i]; }

	return swap;
}

int main()
{
	int size = 10;
	int n;  cin >> n;

	vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; }

	for (int i = 0; i < n; i++) { 
		
		s[i] = SwapStringFrontAndBack(s[i]);

	}

	sort(s.begin(), s.end());
		
	long long ans = 0;
	for (int i = 0; i < n - 1; ) {
	
		long long tmp_ans = 0;
		long long tmp_cnt;
		for (int j = 1; i + j < n; j++) {

			if (s[i] == s[i + j]) {

				if (j == 1) {
					tmp_ans = 1;
					tmp_cnt = 2;
				}
				else {
					tmp_ans += tmp_cnt;
					tmp_cnt++;
				}
			}
			else {
				ans += tmp_ans;
				i += j;
				break;
			}
			
			if (i + j == n - 1) {
				ans += tmp_ans;
				i += j;
			}
		}	

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

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

    vector<ll> A(N), B(N);
    priority_queue<pair<ll, int>> que;
    for(int i=0;i<N;i++){
        cin >> A[i] >> B[i];
        que.emplace(A[i] + B[i], i);
    }

    ll first = 0, second = 0;
    for(int i=0;i<N;i++){
        if(i % 2 == 0){
            first += A[que.top().second];
        }else{
            second += B[que.top().second];
        }
        que.pop();
    }
    cout << first - second << endl;

    return 0;
}

Measured memory_bytes: 3956
#include<stdio.h>

int main(void)
{
   int n, k, d[100], a[100][100], i, f, x[100]={0}, z=0;

   scanf("%d%d",&n,&k);
   for(i=0;i<k;i++){
      scanf("%d",&d[i]);
      for(f=0;f<d[i];f++){
         scanf("%d",&a[i][f]);
         if(x[a[i][f]-1]==0)
            z++;
         x[a[i][f]-1]=1;
      }
   }

   printf("%d\n",(n-z));
   return 0;
}

Measured memory_bytes: 1772
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int main()
{
	int len=0,i,a,b,p,q,f[100][2][2],d[100]={},ans=0;
	for (i=gi();i;i/=10) d[++len]=i%10;
	for (;len<=20;len++) {
		memset(f,0,sizeof(f));
		for (a=1;a<=9;a++)
			for (b=a;b<=9;b++)
				if (a+d[len]==b||a+d[len]+1==b)
					if (b+d[1]==a||b+d[1]-10==a)
						f[1][a+d[len]!=b][b+d[1]!=a]++;
		for (i=2;i<=len/2;i++)
			for (p=0;p<2;p++)
				for (q=0;q<2;q++)
					if (f[i-1][p][q]) {
						d[i]+=q,d[len-i+1]-=10*p;
						for (a=0;a<=9;a++)
							for (b=0;b<=9;b++)
								if (a+d[len-i+1]==b||a+d[len-i+1]+1==b)
									if (b+d[i]==a||b+d[i]-10==a)
										f[i][a+d[len-i+1]!=b][b+d[i]!=a]+=f[i-1][p][q];
						d[i]-=q,d[len-i+1]+=10*p;
					}
		if (~len&1)
			ans+=f[len/2][0][0]+f[len/2][1][1];
		else
			if (d[len/2+1]==9)
				ans+=f[len/2][1][1]*10;
			else if (!d[len/2+1])
				ans+=f[len/2][0][0]*10;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
    int a[3],x=0,y=0,z=0;
    while(scanf("%d%d%d",&a[0],&a[1],&a[2])!=EOF){
        sort(a,a+3);
        if(a[0]+a[1]<=a[2])break;
        if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2])x++;
        else if(a[0]*a[0]+a[1]*a[1]<a[2]*a[2])y++;
        else z++;
    }
    printf("%d %d %d %d\n",x+y+z,x,z,y);
}


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

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

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


int main(void){
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> x(N);
  REP(i, N){cin >> x[i];}

  int ans = INF;
  REP(i, 200){
    int tmp = 0;
    REP(j, N){
      int val = x[j] - i;
      tmp += pow(val, 2);
    }
    if (ans > tmp){ans = tmp;}
  }

  cout << ans << endl;


  return 0;
}



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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int X;
cin>>X;
set<int> t{7,5,3};
string ans;
if(t.count(X))ans="YES";
else ans="NO";
cout<<ans<<endl;

//system("pause");
return 0;
}

Measured memory_bytes: 256
import sys
#input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))

# rstrip().decode('utf-8')

#####segfunc#####
def segfunc(x, y):
    return x*y
#################

#####ide_ele#####
ide_ele = 1
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

def main():
	n=II()
	s=input()
	S=[]
	for i in s:
		S.append(ord(i)-ord("a"))
	
	seg=[SegTree([1]*n,segfunc,ide_ele) for _ in range(26)]
	
	#print(S)
	#print(seg)
	for i in range(n):
		seg[S[i]].update(i,0)
	
	q=II()
	for _ in range(q):
		a,b,c=input().split()
		if int(a)==1:
			b=int(b)
			seg[S[b-1]].update(b-1,1)
			seg[ord(c)-ord("a")].update(b-1,0)
			S[b-1]=ord(c)-ord("a")
		
		else:
			#print(S)
			b=int(b)
			c=int(c)
			cnt=0
			for se in seg:
				if se.query(b-1,c)==0:
					cnt+=1
			print(cnt)
			
	
	

if __name__=="__main__":
	main()


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

int main() {
string S;
cin>>S;
int count=0;
if(S.at(2)==S.at(3)){
count+=1;
}
if(S.at(4)==S.at(5)){
count+=1;
}
if(count==2){
    cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
}


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

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)

int a[200005];
int num[200005];
const int INF=1000000007;

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int n;
	cin>>n;
	int sum=0;
	forn(i,0,n){
		cin>>a[i];
		sum+=a[i];
	}
	num[0]=sum-a[0];
	forn(i,1,n)
		num[i]=num[i-1]-a[i];
	int ans=0;
	forn(i,0,n){
		num[i]%=INF;
		ans+=a[i]*num[i];
		ans%=INF;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6792
// traP is kyopuro circle
// -> true

#include <stdio.h>

int main(){
  int n,k,p;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d%d",&k,&p);
    k %= p;
    if(k==0)k=p;
    printf("%d\n",k);
  }
  return 0;
}

Measured memory_bytes: 1024
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ios>
#include <iomanip>

using namespace std;

long long int binary_search(vector<long long int> v, long long int x){
	long long int head=0, mid, tail=v.size()-1;
	
	while(head<=tail){
		//cout<<head<<" "<<tail<<endl;
		mid = (head+tail)/2;
		if(v[mid]==x){
			return mid+1;
		}
		if(v[mid]<x){
			head=mid+1;
		}else{
			tail=mid-1;
		}
	}
	return -1;
}

string func(long long int x){
	int cnt=0;
	while(x>0){
		x/=10;
		cnt++;
	}
	string ret ="";
	for(int i=0;i<6-cnt;i++){
		ret += "0";
	}
	return ret;
}

int main(){
	int N,M;
	cin>>N>>M;
	vector<int> P(M);
	vector<long long int> Y(M);
	vector<vector<long long int>> A(N);

	for(int i=0;i<M;i++){
	//	cout<<i<<endl;
		cin>>P[i]>>Y[i];
		A[P[i]-1].push_back(Y[i]);
	}
	for(int i=0;i<N;i++){
		sort(A[i].begin(),A[i].end());
	}
	
	for(int i=0;i<M;i++){
	//	const long long int *val = &Y[i];
	//long long int tmp = binary_search(A[P[i]-1], Y[i]);
	auto tmp = lower_bound(A[P[i]-1].begin(),A[P[i]-1].end(), Y[i]);
	cout << setfill('0') << right << setw(6) << P[i];
    cout << setfill('0') << right << setw(6) << distance(A[P[i]-1].begin(),tmp)+1;
    cout << endl;
  
	}
	
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    vector<vi> adj(3*n);
    rep(i,m){
        int a,b; cin>>a>>b; a--; b--;
        adj[a].pb(b+n);
        adj[a+n].pb(b+n*2);
        adj[a+n*2].pb(b);
    }
    int s,t; cin>>s>>t; s--; t--;
    queue<int> que;
    que.push(s);
    vi dist(3*n,-1);
    dist[s] = 0;
    while(que.size()){
        int v = que.front(); que.pop();
        for(auto u:adj[v]){
            if (dist[u]!=-1) continue;
            dist[u] = dist[v]+1;
            que.push(u);
        }
    }
    if (dist[t]==-1){
        cout<<"-1\n";
    }else{
        cout<<dist[t]/3<<endl;
    }
    return 0;
}


Measured memory_bytes: 17792
N = int(input())
*A, = map(int, input().split())


d = {}


for i in range(N):
    if A[i] in d:
        d[A[i]] += 1
        continue
    d[A[i]] = 1

d = sorted(d.items(), reverse=True)

a = []

for key, data in d:
    if data>=4:
        a.append(key)
        a.append(key)
    elif data>=2:
        a.append(key)

if len(a)>=2:
    print(a[0]*a[1])
else:
    print(0)

Measured memory_bytes: 21128
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<map>
#include<set>
//#include <Eigen/Dense>
//#include <Eigen/Geometry>
//using namespace Eigen;

using namespace std;

int main() 
{
	
	int k, a, b;
	cin >> k >> a >> b;
	for (int i = a; i <= b; i++)
	{
		if (i%k == 0)
		{
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3636
//#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>
#include <bitset>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) for(auto (a): v )   cerr << a << endl
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl


LL aho(string S) {

  //cerr << S << endl;
  LL cnt = 0;
  if (S.length() < 2) {
    return 0;
  }
  if (S[0] == S[1]) {
    cnt++;
    S[1] = '-';
  }
  for (LL i = 2; i < S.length(); i++) {
    if (S[i] == S[i - 1] && S[i] != S[i - 2]) {
      S[i] = '-';
      cnt++;
    }
  }
  //cerr << S <<" "<< cnt<<endl;
  return cnt;
}
void func() {
  string S;
  LL K;
  cin >> S;
  cin >> K;
  //K = 15;
  //cerr << S << endl;
  //cerr << K << endl;
  
  
  LL cnt1 = aho(S);
  LL cnt2 = aho(S + S);
  LL cnt3 = aho(S + S + S);

  //cerr << cnt1 << " " << cnt2 << " " << cnt3 << endl;
  LL odd =  (LL)((K + 1-1) / 2);
  LL even = (LL)((K   -1)  / 2);
  
  LL cnt = cnt1 + (cnt3-cnt2)* odd + (cnt2-cnt1) * even;
  cout << cnt;
#if 0
  cerr << cnt << endl;
  LL c = 0;
  c += cnt1;
  for (LL i = 2; i <= K; ++i) {
    if (i % 2 == 0) {
      c += cnt2 - cnt1;
    }
    else {
      c += cnt3 - cnt2;
    }
  }
  cerr << c << endl;
#endif
  
/*
  string SK = "";
  for (LL i = 1; i < 11;i++) {
    SK += S;
    cerr << SK << endl;
    cerr << i << " : " << aho(SK) << " ";
    LL odd = (LL)((i + 1) / 2);
    LL even = (LL)((i) / 2);
    LL cnt = (cnt3-cnt2)* odd + (cnt2-cnt1) * even;
    cerr << cnt << endl;
  }
  */


}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<stdio.h>
using namespace std;

#define rep(i,n) for(long long i = 0; i < n; i++)

typedef long long ll;
typedef unsigned long long int ulli;

const ll INF = ll(1e18) + 1;

//--------------------------------------------------

ulli gcd(ulli a, ulli b) {
	return (b <= 0) ? a : gcd(b, a % b);
}

ulli lcm(ulli a, ulli b) {
	return a * b / gcd(a, b);
}



//---------------------------------------------------
typedef pair<int, int> P;
 
const int WIDTH_MAX = 20;
const int HEIGHT_MAX = 20;

class ff {
public:
	int x;
	int y;
	int steps;
	ff(int _x, int _y, int _steps) {
		x = _x;
		y = _y;
		steps = _steps;
	}
};


void Main()
{
	int height, width, ans = 0; cin >> height >> width;
	char s[HEIGHT_MAX + 2][WIDTH_MAX + 2];
	rep(i, HEIGHT_MAX + 2)rep(j, WIDTH_MAX+2) {
		s[i][j] = '#';
	}
	for (int i = 1; i <= height; i++)for (int j = 1; j <= width; j++) {
		cin >> s[i][j];
	}


	for (int i = 1; i <= height; i++)for (int j = 1; j <= width; j++) {
		if (s[i][j] == '#') continue;
		int map[HEIGHT_MAX + 2][WIDTH_MAX + 2];
		rep(ii, HEIGHT_MAX + 2)rep(jj, WIDTH_MAX+2) {
			map[ii][jj] = -1;
		}
		map[i][j] = 0;

		queue<ff> que;
		ff a(i,j,0);

		que.push(a);
		while (!que.empty()) {
			//4方向にたいして確認
			ff temp = que.front();
			auto check = [&](int _x, int _y, int _steps) {
				if (s[_x][_y] == '.' && map[_x][_y] == -1) {
					map[_x][_y] = _steps + 1;
					ff _temp(_x,_y,_steps+ 1);
					que.push(_temp);
				}
			};
			
			check(temp.x + 1, temp.y, temp.steps);
			check(temp.x - 1, temp.y, temp.steps);
			check(temp.x, temp.y + 1, temp.steps);
			check(temp.x, temp.y - 1, temp.steps);

			
			que.pop();
		}

		for (int i = 1; i <= height; i++)for (int j = 1; j <= width; j++) {
			ans = (ans < map[i][j]) ? map[i][j] : ans;
		}
		

	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	Main();
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from fractions import gcd

def readln():
    _res = list(map(int,str(input()).split(' ')))
    return _res

def push(k,v):
    if k in f:
        f[k] = min(f[k],v)
    else:
        f[k] = v

def add(k,v):
    es = []
    for e in f:
        es.append([e,f[e]])
    for ee in es:
        push(ee[0]+k,ee[1]+v)
    push(k,v)

a = readln()
n,x,y = a[0],a[1],a[2]
f = {}
for i in range(0,n):
    a = readln()
    add(a[0]*y-a[1]*x,a[2])
if 0 in f:
    print(f[0])
else:
    print('-1')


Measured memory_bytes: 5460
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;

int main() {
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n, m;
	cin >> n >> m;
	if (n >= 13) { cout << m; }
	else if (n >= 6) { cout << m / 2; }
	else {
		cout << 0;
	}
	
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <stack>
#include <queue>

#define NUM 128
#define INF 256

using namespace std;

int main(void) {
	while(1) {
		int n, m;
		int taro[NUM], hanako[NUM];
		int min = INF;
		int sum_taro = 0, sum_hanako = 0;
		int t, h;
		int gap;

		scanf("%d %d", &n, &m);
		if(n == 0 && m == 0) break;
		for(int i = 0; i < n; i++) {
			int p;
			scanf("%d", &p);
			taro[i] = p;
			sum_taro += p;
		}
		for(int i = 0; i < m; i++) {
			int p;
			scanf("%d", &p);
			hanako[i] = p;
			sum_hanako += p;
		}
		if((sum_taro + sum_hanako) % 2) {
			printf("%d\n", -1);
			continue;
		}
		gap = (sum_taro - sum_hanako) / 2;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				if(taro[i] - hanako[j] == gap && taro[i] + hanako[j] < min) {
					min = taro[i] + hanako[j];
					t = taro[i];
					h = hanako[j];
				}
			}
		}
		if(min == INF) printf("%d\n", -1);
		else printf("%d %d\n", t, h);
	}
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
	string s;
	cin>>s;
	int f=0;
	if(s.length()%2!=0) f=1;
	else{
		for(int i=0;i<s.length();i+=2){
			if(s[i]!='h'||s[i+1]!='i'){
				f=1;
				break;
			}
		}
	}
	if(f==0) cout<<"Yes\n";
	else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, l;
    cin >> n >> m >> l;
    struct edge {
        ll to, cst;
    };
    vector<vector<edge>> G(n);
    for (int i = 0; i < m; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }
    vector<vector<ll>> ds(n);
    for (int i = 0; i < n; i++) {
        priority_queue<pair<P, int>, vector<pair<P, int>>,
                       greater<pair<P, int>>>
            q;
        vector<P> d(n, P(LINF, LINF));
        d[i] = P(0, 0);
        q.push(make_pair(P(0, 0), i));
        while (!q.empty()) {
            int v = q.top().second;
            q.pop();
            for (auto &e : G[v]) {
                ll nf, ns;
                if (d[v].second + e.cst <= l) {
                    nf = d[v].first;
                    ns = d[v].second + e.cst;
                } else {
                    nf = d[v].first + 1;
                    ns = e.cst;
                }
                if (ns > l) {
                    continue;
                }
                if (d[e.to].first > nf ||
                    (d[e.to].first == nf && d[e.to].second > ns)) {
                    d[e.to] = make_pair(nf, ns);
                    q.push(make_pair(d[e.to], e.to));
                }
            }
        }
        for (int j = 0; j < n; j++) {
            ds[i].push_back(d[j].first);
        }
    }
    int q;
    cin >> q;
    while (q--) {
        int s, t;
        cin >> s >> t;
        --s;
        --t;
        if (ds[s][t] == LINF) {
            cout << -1 << endl;
        } else {
            cout << ds[s][t] << endl;
        }
    }
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,ans,a[5010],cnt,f[5010],p=1e9+7;
ll ksm(ll x,ll y){
	ll xlh=1;
	while(y){
		if(y%2==1)xlh=xlh*x%p;
		x=x*x%p;
		y/=2;
	}
	return xlh;
}
int main(){
	ll i,j;
	scanf("%lld%lld",&n,&m);
	for(i=1;i*i<=n;i++)if(n%i==0){
		a[++cnt]=i;
		if(n/i!=i)a[++cnt]=n/i;
	}
	sort(a+1,a+cnt+1);
	for(i=1;i<=cnt;i++){
		f[i]=ksm(m,(a[i]+1)/2)%p;
		for(j=1;j<i;j++)if(a[i]%a[j]==0)f[i]=(f[i]-f[j]+p)%p;
		if(a[i]%2==1)ans=(ans+a[i]*f[i]%p)%p;
		 else ans=(ans+a[i]*f[i]%p*ksm(2,p-2)%p)%p;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first
#define S second

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//-------------------------------------------------------------------------------

#define MAX 11111

ll a[MAX];
int main(void) {
  ll x;
  cin >> n >> m >> x;
  FOR(i, 0, m) {
	cin >> temp;
	a[temp] = 1;
  }

  FOR(i, x + 1, n + 1) {
	cnt += a[i];
  }

  ans = min(m - cnt, cnt);

  cout << ans << endl;

  return 0;
}

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

if N % 10 == 2 or N % 10 == 4 or N % 10 == 5 or N % 10 == 7 or N % 10 == 9:
    print("hon")
elif N % 10 == 0 or N % 10 == 1 or N % 10 == 6 or N % 10 == 8:
    print("pon")
elif N % 10 == 3:
    print("bon")


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

int main() {
  int N;
  cin >> N;
  vector<int> x(N), y(N), h(N);
  int idx = -1;
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] > 0) idx = i;
  }

  
  for (int Cx = 0; Cx <= 100; Cx++) {
    for (int Cy = 0; Cy <= 100; Cy++) {
      int H = h[idx] + abs(x[idx] - Cx) + abs(y[idx] - Cy);
      bool ok = true;
      for (int i = 0; i < N; i++) {
        int hight = max(H - abs(x[i] - Cx) - abs(y[i] - Cy), 0);
        if (h[i] != hight) ok = false;
      }
      if (ok) {
        cout << Cx << " " << Cy << " " << H << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>

using namespace std;

int a[3];

int main(){
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    sort(a,a+3);
    printf("%d\n",a[2]-a[0]);
    
    
    
}


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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long

int main(){
  ll n;
  cin >> n;
  ll tmp, x[n], xx[n];
  rep(i, n){
    cin >> tmp;
    x[i] = tmp;
    xx[i] = tmp;
  }
  sort(x, x+n);
  ll left = x[n/2-1], right = x[n/2];
  rep(i, n){
    if (xx[i] >= right) {
      puts(left)
    }else{
      puts(right)
    }
  }

}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    string s;
    cin >> s;
    for(auto c:s){
        ans += (c - '0');
    }
    if(ans % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

inline void work() {
    string s, t;
    cin >> s >> t;
    int res = 0;
    for (int i = 0; i < s.size(); ++i) {
        res += (s[i] != t[i]);
    }
    cout << res;
}

int main() {
    // freopen(".txt", "r", stdin);
    quickread();
    work();
    return 0;
}

Measured memory_bytes: 3792
#!/usr/bin/env python3
import math

N = int(input().split()[0])
s = ""

for i in range(math.ceil(math.log2(10 ** 10)) + 1):
    s = str(N % 2) + s
    N = -(N // 2)

ans = s.lstrip("0")
ans = "0" if ans == "" else ans
print(ans)


Measured memory_bytes: 3188
#include<stdio.h>
#include<math.h>
int main(){
    long n, k;
    scanf("%ld", &n);
    k = sqrt(n);
    for(long i = k; i >= 1; i--){
        if(n % i == 0){
            k = i;
            break;
        }
    }
    printf("%ld\n", k + n / k - 2);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

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

    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(s<t)cout << "Yes" << endl;
    else cout << "No" << endl;
}


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


int main() {
  int n;
  cin >> n;
  vector<ll> a(n+ 1, 0);
  ll ans = 0;
  for (int i = 1; i <= n; i++){
    for (int j = i; j <= n; j += i){
      a[j]++;
    }
  }
  for (int i = 1; i <= n; i++){
    ans += a[i] * i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 81328
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int n;

int main(){
    int k,s; cin >> k >> s;
    
    int ans = 0;
    for(int i=0 ; i<=k ; i++){
        for(int j=0 ; j<=k ; j++){
            int z = s-i-j;
            if(z>= 0 and z<=k) ans++;
        }
    }
    
    cout << ans << endl;
}







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

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

  int r = 0;
  int l = 0;
  
  bool flag = true;
  rep(i,n-1) if (s[i] != s[i+1]) flag = false;
  if (flag) {
    cout << 0 << endl;
    return 0;
  }

  rep(i,n) if (s[i] == '.') r++;
  int ans = r;
  rep(i,n) {
    if(s[i] == '#') {
      l++;
    } else {
      r--;
    }
    ans = min(ans,l+r);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3740
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	const int sz = (int)s.size();

	if (s.back() != '0' || s.front() != '1' || s[sz - 2] != '1') {
		cout << -1 << "\n";
		return 0;
	}

	for (int i = 0; i < sz / 2; i++) {
		if (s[i] != s[sz - i - 2]) {
			cout << -1 << "\n";
			return 0;
		}
	}

	auto mk_star = [](int &now, const int size) {
		const int center = now++;
		for (int i = 1; i < size; i++, now++) {
			cout << center << " " << now << "\n";
		}
		return center;
	};

	int now = 1;
	for (int i = 1; i < sz / 2; i++) {
		if (s[i] == '1') {
			DMP(i, now);
			const int c = mk_star(now, i + 2 - now);
			cout << c << " " << now << "\n";
		}
	}
	mk_star(now, sz - now + 1);

	return 0;
}

Measured memory_bytes: 1616
x = int(input())
g_happy = 0

# 500で割った商*1000happy
g_happy += 1000 * (x // 500)
# 500で割った商*500をｘから引く
x -= 500 * (x // 500)
# 5で割った商*5happy
g_happy += 5 * (x // 5)
print(g_happy)

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

int main() {

    const ll mod = 1000000007;
    ll n, k; cin >> n >> k;
    ll ans = 0;
    for (ll i = k; i <= n + 1; i++) {
        ll tmpLeft = (i - 1) * i / 2;
        ll tmpRight = n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2;
        ans+= tmpRight - tmpLeft + 1;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, n) for(ll i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}

int main()
{
    int k;
    cin >> k;
    ll sum = 0;
    rep(i, 1, k+1){
        rep(j, 1, k+1){
            rep(l, 1, k+1){
                sum += gcd(gcd(i, j), l);
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3632
from itertools import combinations
from bisect import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i, j in combinations(range(1,N), 2):
    # a <= b <= c
    b, c = L[i], L[j]
    k = bisect(L, c-b)
    ans += max(0, i-k)

print(ans)


Measured memory_bytes: 44012
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int L,R,d; cin>>L>>R>>d;
    int ans=0;
    for(int i=L; i<=R; i++){
        if(i%d==0) ans++;
    }
    cout<<ans<<endl;

    return 0;
}

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

int main(){
	int A, B, C, D, N;
	cin >> N;
	
	D=N%10;
	C=((N-D)/10)%10;
	B=((N-(10*C+D))/100)%10;
	A=((N-(100*B+10*C+D))/1000)%10;
	
	string op[4];
	int x[4];			//0で負数、1で正数
	
	int a, b, c, d, i;
		x[0]=1;	a=A;
		for(x[1]=0; x[1]<=1; x[1]++){
			if(x[1]==0)	b=-B;
			else		b=B;
			for(x[2]=0; x[2]<=1; x[2]++){
				if(x[2]==0)	c=-C;
				else		c=C;
				for(x[3]=0; x[3]<=1; x[3]++){
					if(x[3]==0)	d=-D;
					else		d=D;
					if(a+b+c+d==7){
						for(i=0; i<4; i++){
							if(x[i]==0)	op[i]="-";
							else		op[i]="+";
						}
						cout  <<  A << op[1] << B << op[2] << C << op[3] << D << "=7" << endl;
						return 0;
					}
				}
			}
		}
	return 0;
}


Measured memory_bytes: 256
<?php

while ($stdin = fgets(STDIN)) {
    $line[] = trim($stdin);
}
foreach ($line as $key => $value) {
    $data[] = explode(' ', $value);
}

foreach ($data as &$line) {
    $line = array_map(function($val) { return (int)$val; }, $line);
}

$X = $data[0][0];
$A = $data[0][1];

if ($X < $A) {
    $ans = 0;
} else {
    $ans = 10;
}
printf('%s', $ans);

?>


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

typedef long long LL;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

#define fast ios_base::sync_with_stdio(0),cin.tie(0)
#define temp template<typename T>
#define debug(x) cerr<<"Line "<<__LINE__<<": "<<#x<<" = "<<x<<'\n'
#define itr(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define rep(i,a,b) for(int i=a;i<=(int)b;i++)
#define repr(i,a,b) for(int i=a;i>=(int)b;i--)
#define cas(n) printf("Case %d:",(int)n)
#define mem(x,v) memset(x,v,sizeof(x))
#define read(x) freopen(x,"r",stdin)
#define write(x) freopen(x,"w",stdout)
#define all(x) x.begin(),x.end()
#define aut(x,v) for(auto &x:v)
#define ini(n) scanf("%d",&n)
#define inl(n) scanf("%lld",&n)
#define ind(n) scanf("%lf",&n)
#define ins(n) scanf("%s",n)
#define insn(n) scanf(" %[^\n]",n)
#define outi(n) printf("%d",(int)n)
#define outl(n) printf("%lld",(LL)n)
#define outd(n,p) printf("%.*lf",p,(double)n)
#define outs(n) printf("%s",n)
#define sz(x) (int)x.size()
#define nl printf("\n")
#define sp printf(" ")
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

const int inf=0x3f3f3f3f;
const int mod=1000000007;
const int mx=1000005;
const LL  infL=0xf3f3f3f3f3f3f3f;
const double eps=1e-9;
const double pi=acos(-1.0);

bool is_prime[mx];
vl prime;

void sieve()
{
    mem(is_prime,1);
    int sq=sqrt(mx);
    rep(i,2,sq)
    if(is_prime[i])
        for(int j=i*i; j<=mx-2; j+=i)
            is_prime[j]=0;
    rep(i,2,mx-2) if(is_prime[i])
        prime.pb((LL)i);
}

int main()
{
    //read("in.txt"),write("out.txt");
    sieve();
    LL n,p,ans=1;
    inl(n),inl(p);
    for(int i=0; prime[i]*prime[i]<=p; i++)
    {
        if(p%prime[i]==0)
        {
            int cnt=0;
            while(p%prime[i]==0)
                cnt++,p/=prime[i];
            int x=cnt/n;
            while(x--)
                ans*=prime[i];
        }
    }
    if(p>1&&n==1)
            ans*=p;
    outl(ans),nl;
    return 0;
}


Measured memory_bytes: 2424
import copy
import heapq
import math

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

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

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

n = ip()
a = []
s=0
for i in range(n):
    a.append(iprow())
adder = math.factorial(n)*2//n
#print(adder)
for i in range(n-1):
    for k in range(i,n):
        x = a[i]
        y = a[k]
        dist = math.sqrt( (x[0] - y[0])**2 + (x[1] - y[1])**2 )
        s+=dist*adder
print(s/math.factorial(n))

Measured memory_bytes: 3440
t = input()

ans = t
tem = ''
if '?' in t :  
    if len(t) == 1 :
        ans = 'D'
    elif len(t) == 2 :
        if t[0] == '?' and t[1] == '?' :
            ans = 'PD'
        elif t[0] == '?' and t[1] == 'D':
            ans = 'PD'
        elif t[0] == '?' and t[1] == 'P':
            ans ='DP'
        elif t[1] == '?' and t[0] == 'P':
            ans = 'PD'
        elif t[1] == '?' and t[0] == 'D':
            ans = 'DD'
    else:
        for i in range(0,len(t)):
            if i == 0 :
                if t[i] == '?' and t[i+1] == 'P':
                    ans = 'D'
                elif t[i] == '?' :
                    ans = 'P'
                else :
                    ans = t[i] 
                    
            elif i == len(t)-1 :
                if t[i] == '?' :
                    ans += 'D'
                else:
                    ans += t[i]
            else:
                if t[i] == '?':
                    if ans[i-1] == 'P':
                        ans += 'D'
                    elif t[i+1] == 'D' or t[i+1] == '?':
                        ans += 'P'
                    else:
                        ans += 'D'
                else:
                    ans += t[i]
print(ans)

Measured memory_bytes: 9656
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
const int INF = 1e9;
const int MOD = 1e9+7;

vi f(10), inv(10);

void trans(string &n)
{
    REP(i, n.length())
    {
        n[i] = f[n[i]-'0'] + '0';
    }
}

void invtrnas(string &n)
{
    REP(i, n.length())
    {
        n[i] = inv[n[i]-'0'] + '0';
    }
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    vector<vi> A(3, vi(3));
    REP(i, 3) REP(j, 3) cin >> A[i][j];
    int N; cin >> N;
    vi b(N); REP(i, N) cin >> b[i];
    vector<vb> B(3, vb(3, false));
    REP(i, 3)
    {
        REP(j, 3)
        {
            REP(k, N)
            {
                if(A[i][j] == b[k]) B[i][j] = true;
            }
        }
    }

    bool bingo = false;
    REP(i, 3)
    {
        bool all = true;
        REP(j, 3)
        {
            if(B[i][j] == false) all = false;
        }
        if(all) bingo = true;
    }
    REP(j, 3)
    {
        bool all = true;
        REP(i, 3)
        {
            if(B[i][j] == false) all = false;
        }
        if(all) bingo = true;
    }
    if(B[0][0] && B[1][1] && B[2][2]) bingo = true;
    if(B[0][2] && B[1][1] && B[2][0]) bingo = true;
    if(bingo) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
  int N, X;
  cin >> N >> X;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  sort(a, a + N);
  
  int64_t sum = 0;
  for (int i = 0; i < N; i++) {
    sum += a[i];
  }
  int ans = 0;
  if (X == sum) {
    ans = N;
  }
  else if (X > sum) {
    ans = N - 1;
  }
  else {
    for (int i = 0; i < N; i++) {
      X -= a[i];
      if (X < 0) {
        break;
      }
      else {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
i=0
N=int(input())

#N, L=input().split()
#S=input()
#T=input()
#S_list=list(S)
ST_list=  list(input().split(" "))
S_list=list(ST_list[0])
T_list=list(ST_list[1])
#print(S_list)
#print(T_list)
sentence=""

for i in range(N):
 sentence=sentence+S_list[i]+T_list[i]

print(sentence)


Measured memory_bytes: 3060
main=getContents>>=putStrLn.g.map(map read.words).lines
g((w:d:_):s)=let v=foldr1(zipWith o)$map(m w d)s;k=minimum$map fst v in if k<0 then"No"else show$sum.map snd$v
m w d[x,y,z]=[let u=abs(i-x)+abs(j-y)in(u,z-u)|j<-[1..d],i<-[1..w]]
o(0,z)(_,u)=if z<u then(-1,z)else(0,z)
o(a,z)(0,u)=o(0,u)(a,z)
o(_,z)(a,u)=(a,max z u)



Measured memory_bytes: 38320
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    cout << (n+1)/2 << endl;
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> l(N), r(N);
    int sum =0;
    
    for(int i=0; i<N; i++){
        cin >> l[i] >> r[i];
        
        sum += r[i]-l[i]+1;
    }
    
    cout << sum << endl;
}


Measured memory_bytes: 256