akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

template <class T>
struct SegTree{
	int n;
	vector<T> lazy, Min;

	SegTree(int size){
		n = 1;
		while (n < size) n *= 2;

		lazy = Min = vector<T>(n * 2, 0);
	}

	void add(int i, T val){
		add_range(i, i + 1, val);
	}
	void add_range(int a, int b, T val){
		add_range(a, b, val, 0, 0, n);
	}
	void add_range(int a, int b, T val, int k, int l, int r){
		if (r <= a || b <= l) return;
		if (a <= l && r <= b){
			Min[k] += val;
			lazy[k] += val;
			return;
		}

		add_range(a, b, val, k * 2 + 1, l, (l + r) / 2);
		add_range(a, b, val, k * 2 + 2, (l + r) / 2, r);

		Min[k] = min(Min[k * 2 + 1], Min[k * 2 + 2]) + lazy[k];
	}

	T query_min(int a, int b){
		return query_min(a, b, 0, 0, n);
	}

	T query_min(int a, int b, int k, int l, int r){
		if (r <= a || b <= l) return 1e9;
		if (a <= l && r <= b) return Min[k];
		return min(query_min(a, b, k * 2 + 1, l, (l + r) / 2), query_min(a, b, k * 2 + 2, (l + r) / 2, r)) + lazy[k];
	}
};

const ll INF = 1e9;

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

	int n;
	cin >> n;

	SegTree<ll> pseg(n), mseg(n);

	vector<P> v(n);
	rep(i, n){
		cin >> v[i].first;
		v[i].second = i;
	}

	rep(i, n) pseg.add(i, v[i].first);
	mseg.add_range(0, mseg.n, INF);

	int q;
	cin >> q;
	vector<tuple<int, int, int, int>> query(q);
	rep(i, q){
		int a, b, c;
		cin >> a >> b >> c;
		query[i] = MT(c, a, b, i);
	}

	sort(ALL(v));
	sort(ALL(query));

	vector<int> ans(q);

	int idx = 0;

	ll prv = 0;
	rep(i, q){
		int a, b, c, id;
		tie(c, a, b, id) = query[i];
		while (idx < n && v[idx].first <= c){
			ll tmp = mseg.query_min(v[idx].second, v[idx].second + 1);
			//cout << pseg.query_min(v[idx].second, v[idx].second + 1) << endl;
			mseg.add(v[idx].second, -tmp - pseg.query_min(v[idx].second, v[idx].second + 1));
			//cout << mseg.query_min(v[idx].second, v[idx].second + 1) << endl;
			pseg.add(v[idx].second, 1e9);
			//cout << pseg.query_min(v[idx].second, v[idx].second + 1) << endl;
			idx++;
		}

		mseg.add_range(0, mseg.n, c - prv);
		pseg.add_range(0, mseg.n, prv - c);
		prv = c;
		ans[id] = min(mseg.query_min(a, b + 1), pseg.query_min(a, b + 1));
	}

	rep(i, q) cout << ans[i] << '\n';	

	return 0;
}


Measured memory_bytes: 12880
# 解説みたよ
import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
n, m = map(int, input().split())
es = [[] for i in range(n)]
l, r, d = [0] * m, [0] * m, [0] * m
for i in range(m):
    l[i], r[i], d[i] = map(int, input().split())
    l[i] -= 1
    r[i] -= 1
    es[l[i]].append((r[i], d[i]))
    es[r[i]].append((l[i], -d[i]))
INF = 1000000000000
value = [INF] * n


def dfs(v):
    for i, di in es[v]:
        if value[i] == INF:
            value[i] = value[v] + di
            dfs(i)


for i in range(n):
    if value[i] == INF:
        value[i] = 0
        dfs(i)

for i, j, k in zip(l, r, d):
    if value[j] - value[i] != k:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 130896
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N,A,B;






int main()
{

	cin >> N >> A >> B;



	if(!(abs(A-B)%2)){
		cout << "Alice" << endl;
	} else {
		cout << "Borys" << endl;
	}





}



Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

typedef pair<ll, ll> Edge;

vector<bool> visited(100000, false);
vector<ll> dp(100000, -1);
vector<Edge> G[100000];

bool result = true;

// 入次数が2以上でかつそこまでの距離が異なる場合 No.
ll dfs(ll v) {
  ll &cc = dp[v];
  if (visited[v] and cc == -1) {
    result = false;
    return 0;
  }
  if (~cc) return dp[v];
  visited[v] = true;
  
  ll res = 0;
  for (auto&& edge: G[v]) {
    ll u = edge.first, d = edge.second;
    ll dd = dfs(u) + d;
    if (res != 0 && res != dd) result = false;
    res = dd;
  }
  return cc = res;
}

int main() {
  int n,m; in(n),in(m);
  loop(i,0,m) {
    ll l, r, d; in(l),in(r),in(d);
    l--;r--;
    G[r].emplace_back(l, d);
  }
  
  loop(i,0,n) dfs(i);
  // loop(i,0,n) cout << dp[i] << " ";
  // cout << endl;
  
  if (result) print("Yes");
  else print("No");
  return 0;
}


Measured memory_bytes: 13280
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
const int inf=1e9,dx[]={-1,0,1,0},dy[]={0,-1,0,1};
int n,cnt,a[300005],b[300005],ans;
char c[300005];
int main(){
	ans=inf;
	for(int i=1;i<300005;i++)
		a[i]=b[i]=-1;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
		a[i]=a[i-1];
		if(c[i]=='W')
			a[i]++,cnt++;
	}
	if(cnt==n)
	{
		cout<<0;
		return 0;
	}
	for(int i=n;i>=1;i--)
		if(c[i]=='E')
			b[i]=b[i+1]+1;
		else
			b[i]=b[i+1];
	for(int i=1;i<=n;i++)
	{
		int x,y;
		if(a[i]>=0)
			x=a[i];
		else
			x=0;
		if(b[i]>=0)
			y=b[i];
		else
			y=0;
		ans=min(ans,x+y);
	}
	cout<<ans;
	return 0;
}


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

const int maxn=57;
int n,t[maxn];
string s[maxn],st;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin>>n;
    for (int i=1;i<=n;++i){
        cin>>s[i]>>t[i];
    }
    cin>>st;
    for (int i=1;i<=n;++i){
        if (s[i]==st){
            int ret=0;
            for (int j=i+1;j<=n;++j) ret+=t[j];
            cout<<ret<<endl;
            return 0;
        }
    }
    return 0;
}

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

#define pb push_back
#define ll long long
#define inf 1e18+9

using namespace std;

void merge(vector<vector<float > >& a, int start, int mid, int end){
	// printf("%d %d %d\n", start, mid , end);
	int i = 0, j = 0 , k = start;
	vector<vector<float > > temp1, temp2;
	for (int i = start; i <= mid; ++i)
	{
		temp1.pb(a[i]);
	}
	for (int i = mid+1; i <= end; ++i)
	{
		temp2.pb(a[i]);
	}
	i = 0;
	while(i < temp1.size() && j < temp2.size()){
		if(temp1[i][2] > temp2[j][2]){
			a[k]=temp1[i];
			i++;
		}
		else{
			a[k] = temp2[j];
			j++;
		}
		k++;
	}
	while(i<temp1.size()){
			a[k]=temp1[i];
			i++;
			k++;
	}
	while(j< temp2.size()){
			a[k]=temp2[j];
			j++;
			k++;
	}
	// for (int i = 0; i < a.size(); ++i)
	// {
	// 	for (int j = 0; j < 3; ++j)
	// 	{
	// 		printf("%f ",a[i][j]);
	// 	}
	// 	printf("\n");
	// }
}

void mergeSort(vector<vector<float > >& a, int start, int end){
	if(start < end){
		int mid =( start + end)/2;
		mergeSort(a, start, mid);
		mergeSort(a, mid+1, end);
		merge(a, start, mid, end);
	}
}

int main(int argc, char const *argv[])
{
	int n, wght, profit,weight;

	scanf("%d%d", &n, &wght);
	// vector<vector<float> > p;
	vector<int> profits, weights;
	
	for (int i = 0; i < n; ++i)
	{
		scanf("%d%d", &weight, &profit);
		weights.pb(weight);
		profits.pb(profit);
	}

	int profitfull = 0;
	for (int i = 0; i < profits.size(); ++i)
	{
		profitfull += profits[i];
	}
	vector<ll> dp(profitfull+1, inf); // 0- profitfull 
	dp[0]=0;
	for (int m = 0; m < n; ++m)
	{
		for (int i = profitfull; i >= 0; --i)
		{
			if (i >= profits[m])
			{
				dp[i] = min(dp[i], dp[i-profits[m]] + weights[m]);
			}
		}
	}

	int reqd = 0;
	for(int i = 0 ; i<= profitfull; i++){
		// printf("%d %lld\n", i, dp[i]);
		if (dp[i]<=wght)
		{
			reqd = max(reqd, i);
		}
	}
	printf("%d", reqd);
	

	// vector<ll> dp(profitfull, inf);
	// dp[0] = 0;
	// for(int item = 0 ; item < n ; item++){
	// 	for(int i = profitfull - profits[item] ; i>=0 ; i++){
	// 		dp[i] = min(dp[i+profits[item]] + weights[item], dp[i]);
	// 	}
	// }

	// printf("%d", profitfull);


	// for (int i = 0; i <= n; ++i)
	// {
	// 	for (int j = 0; j <= w; ++j)
	// 	{
	// 		printf("%lld ", dp[i][j]);
	// 	}
	// 	printf("\n");
	// }

	// printf("s\n");
	// for (int i = 0; i < 7; ++i)
	// {
	// 	for (int j = 0; j < 7; ++j)
	// 	{
	// 		printf("%d ", s[i][j]);
	// 	}
	// 	printf("\n");
	// }
	// printBrac(1,6);
	return 0;
}




Measured memory_bytes: 1024
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

#include <iostream>
 
int main(void)
{
  int a, b;
  std::cin >> a >> b;
  
  int fare;
  
  if (a <= 5) fare = 0;
  else if (a <= 12) fare = b/2;
  else fare = b;
  
  std::cout << fare << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
MOD = 10**9 + 7

N, M = map(int,input().split())
A = set()
for _ in range(M):
    A.add(int(input()))

dp = [1] * (N+1)

if 1 in A:
    dp[1] = 0

for i in range(N-1):
    if i+2 in A:
        dp[i+2] = 0
    else:
        dp[i+2] = (dp[i] + dp[i+1]) % MOD
    
print(dp[N])

Measured memory_bytes: 17188
#include <stdio.h>
#define MAX 100
#define NIL -1
#define INF 200000
#define WHITE 0
#define BLACK 2
#define GRAY 1
int n,A[MAX][MAX];
void prim(){
  int sum=0,u,v,i,d[MAX],mincost;
  int color[MAX];
  for(i=0;i<n;i++){
    d[i]=INF;
    color[i]=WHITE;
  }
  d[0]=0;
  color[0]=GRAY;
  while(1){

    mincost=INF;
    u=-1;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK&&d[i]<mincost){
        mincost=d[i];
        u=i;
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK&&A[u][v]!=INF){
        if(A[u][v]+d[u]<d[v]){
          d[v]=A[u][v]+d[u];
          color[v]=GRAY;
        }

      }


    }
  }
  for(i=0;i<n;i++){
    if(d[i]==INF)d[i]=-1;
    printf("%d %d\n",i,d[i]);
  }

}
int main(){
  int i,j,u,k,c,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=INF;

}
  }
    for(i=0;i<n;i++){
      scanf("%d %d",&u,&k);
      for(j=0;j<k;j++){
	scanf("%d %d",&v,&c);
      A[u][v]=c;
    }
  }

  prim();



  return 0;
  }



Measured memory_bytes: 2108
N, K=[int(i) for i in input().split()]
h=[int(i) for i in input().split()]

cost=[0]
for i in range(1,N):
    m_cost=99999999999
    for j in range(1,min(K,i)+1):
        if m_cost>=cost[i-j]+abs(h[i]-h[i-j]):
            m_cost=cost[i-j]+abs(h[i]-h[i-j])
    cost.append(m_cost)
print(cost.pop()) 

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

string s;
int num, cnt;
map<int, bool> ok[2];
map<int, int> res;

int main()
{
  while(getline(cin, s) && s != ""){
    sscanf(s.c_str(), "%d,%d", &num, &cnt);
    ok[0][num] = true;
    res[num] += 1;
  }

  while(getline(cin, s)){
    sscanf(s.c_str(), "%d,%d", &num, &cnt);
    ok[1][num] = true;
    if(ok[0][num]) res[num] += 1;
  }

  vrep(v, res) if(ok[1][v->first]) cout << v->first << " " << v->second << endl;

  return 0;
}

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

int main(){
int a=0,b=0,c,d,t,e,n,i,j,s,m;
cin>>n>>m;
if(n>=2){
    a=(n&1)?(n-1)/2*n:n/2*(n-1);
}
if(m>=2){
    b=(m&1)?(m-1)/2*m:m/2*(m-1);
}
cout<<a+b<<endl;

}



Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)] #所与の竹の長さを格納したリスト
INF = 10 ** 9

def dfs(cur, a, b, c): #curは深さ、a~cはA~Cの暫定的な長さ
    if cur == N: #再帰の脱出条件
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF 
    #abs(a-A)は伸縮魔法に使うMP量、-30は最後の処理
    #→このアルゴリズムだと無から1本出す時もMP10使っているので30だけ多めになっている
    #DFSするので、min(a,b,c)>0でA~Cのいずれかが0になる最小コストを除外
    #Pythonはreturnの時点で下の処理は行われない(?)ので模範解答ではelseが書かれていない
    else:
        ret0 = dfs(cur + 1, a, b, c) #使わない場合
        ret1 = dfs(cur + 1, a + l[cur], b, c) + 10 #l[cur]をAの合成に使う場合
        ret2 = dfs(cur + 1, a, b + l[cur], c) + 10 #l[cur]をBの合成に使う場合
        ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10 #l[cur]をCの合成に使う場合
        return min(ret0, ret1, ret2, ret3) #分岐の選択

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 43996
#!/usr/bin/env python3

import numpy as np
from collections import Counter

YEAR = 2019


def solve(S: str):
    # S の各桁を modYear 計に修正する
    mod_year = np.arange(1, 10)
    mod_s = []
    for Si in map(int, reversed(S)):
        mod_s.append(mod_year[Si - 1])
        mod_year = (mod_year * 10) % YEAR
    # print(mod_s)
    # mod_s を累積和にする
    cum_sum = 0
    cum_sums = [cum_sum]
    for x in mod_s:
        cum_sum = (cum_sum + x) % YEAR
        cum_sums.append(cum_sum)

    # 場合分けの数を足し合わせる
    answer = 0
    for _, num in Counter(cum_sums).items():
        answer += (num * (num - 1)) // 2  # 1 の時0なので場合分けはいらない
    return answer


def main():
    S = input().strip()
    answer = solve(S)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 43068
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
int mod=(int)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct

int main(void){
    int n=in(),i;
    while(n){
        rep(i,n+1){
            if(i*(i+1)/2>=n){
                print(i);
                n-=i;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

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



		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
	
		
		if(N == 1){
			System.out.println("Hello World");
		}else{
			int A = scanner.nextInt();
			int B = scanner.nextInt();
			System.out.println(A+B);
		}



	}


}

class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



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

double solve( double a[], int n){

    int m=(n+1)/2;

    double dp[n+1][m+1];
    dp[0][0]=1;
    for(int i=1;i<=m;i++){
        dp[0][i]=0;
    }

    for(int i=1;i<=n;i++){
        dp[i][0]=1;
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){

            dp[i][j]=a[i-1]*dp[i-1][j-1]+(1-a[i-1])*dp[i-1][j];
        }
    }

    return dp[n][m];


}

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

    double a[n];

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


    cout<<fixed<<setprecision(10)<<solve(a,n);





}


Measured memory_bytes: 38932
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define pb(x)                       push_back(x)
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(all(v))
#define maxe(v)                     *max_element(all(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"
inline ll input(){ll n; cin >> n ; return n;}
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const int MAXN = 2e5 + 10;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const ll INF = 8e18;

ll n,q,ans;
ll arr[MAXN];
vector<pll> que;

bool check1(ll x){
    ll pos = x;
    for(int i = 0;i < que.size();i++){
        ll ch = que[i].F;
        ll act = que[i].S;
        if(arr[pos] == ch)
            pos += act;
        if(pos == 0)
            return true;
    }
    return false;
}

bool check2(ll x){
    ll pos = n - x + 1;
    for(int i = 0;i < que.size();i++){
        ll ch = que[i].F;
        ll act = que[i].S;
        if(arr[pos] == ch)
            pos += act;
        if(pos == n + 1)
            return true;
    }
    return false;
}

int main()
{
    fast_io;
    cin >> n >> q;
    string s;
    cin >> s;
    for(int i = 1;i <= n;i++){
        arr[i] = s[i - 1] - 'A';
    }
    char c1,c2;
    ll tmp,act;
    for(int i = 1;i <= q;i++){
        cin >> c1 >>  c2;
        tmp =(ll)c1 - 'A';
        if(c2 == 'L')
            act = -1;
        else
            act = 1;
        que.push_back({tmp,act});
    }
    ll l,mid,r;
    l = 0;
    r = n + 2;
    while (r - l > 1) {
        mid = (l + r) / 2;
        if(check1(mid)){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    ans += l;
    l = 0;
    r = n + 2;
    while (r - l > 1) {
        mid = (l + r) / 2;
        if(check2(mid)){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    ans += l;
    ans = n - ans;
    cout << ans << endl;
}



Measured memory_bytes: 8200
import sys
sys.setrecursionlimit(10 ** 9)
t = int(input())
for _ in range(t):
    n, a, b, c, d = map(int, input().split())
    memo = {}
    def f(x):
        if x in memo:
            return memo[x]
        if x == 0:
            return 0
        if abs(x) == 1:
            return d

        ans = [x * d]
        if x % 2 == 0:
            ans.append(f(x // 2) + a)
        else:
            ans.append(f((x+1) // 2) + a + d)
            ans.append(f((x-1) // 2) + a + d)

        if x % 3 == 0:
            ans.append(f(x // 3) + b)
        elif x % 3 == 1:
            ans.append(f((x-1) // 3) + b + d)
        elif x % 3 == 2:
            ans.append(f((x+1) // 3) + b + d)

        if x % 5 == 0:
            ans.append(f(x // 5) + c)
        elif x % 5 == 1:
            ans.append(f((x-1) // 5) + c + d)
        elif x % 5 == 2:
            ans.append(f((x-2) // 5) + c + 2 * d)
        elif x % 5 == 3:
            ans.append(f((x+2) // 5) + c + 2 * d)
        elif x % 5 == 4:
            ans.append(f((x+1) // 5) + c + d)

        memo[x] = min(ans)
        return memo[x]

    print(f(n))

Measured memory_bytes: 10972
# include <bits/stdc++.h>
#define flash ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define ll long long int
#include <tr1/unordered_map>
#define ld long double
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define f(i,a,b)  for(long long i=a;i<b;i++)
#define all(c) (c).begin(),(c).end()
#include <map>
using namespace std;



int main()
{


     flash;
     ///////////////////////////////////////////////////////////////////////////////////////

     

ll arr[32] ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
ll k;
cin>>k;
cout<<arr[k-1]<<endl;




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

     return 0;

}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[]L = new int[N];
    
      int all = 0;
      for(int i=0; i<N; i++){
		L[i]= sc.nextInt();
        all += L[i];	
}
    Arrays.sort(L);
    int hiku = 0;
    int a = N-K;
    for(int j=0; j<a; j++){
       hiku += L[j];
    }
    System.out.println(all-hiku);
    }
}

Measured memory_bytes: 35728
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N+1):
  if i >= 1:
    p = min(A[i], B[i-1])
    ans += p
    A[i] -= p
  if i < N:
    p = min(A[i], B[i])
    ans += p
    B[i] -= p
print(ans)

Measured memory_bytes: 97640
Uses Math,A52,Xqc;
Const int_MAX=2147483647;
Var maxx,minn,i,x,n:Longint;
Begin{main}
   minn:=int_MAX;
   maxx:=-int_MAX;
   readln(n);
   for i:=1 to n do
     begin
        read(x);
        maxx:=max(maxx,x);
        minn:=min(minn,x);
     end;
     write(maxx-minn);
End.

Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

string S;
ll dp[100010][4]={};
int main(){
    cin>>S;
    ll ans=0;
    dp[0][0]=1;
    for(ll i=0;i<S.length();i++){
        for(ll j=0;j<4;j++){
          dp[i+1][j]=(dp[i+1][j]+dp[i][j]*(S[i]=='?'?3:1))%MOD;
        }
        if(S[i]=='A' || S[i]=='?'){
          dp[i+1][1]=(dp[i+1][1]+dp[i][0])%MOD;
        }
        if(S[i]=='B' || S[i]=='?'){
          dp[i+1][2]=(dp[i+1][2]+dp[i][1])%MOD;
        }
        if(S[i]=='C' || S[i]=='?'){
          dp[i+1][3]=(dp[i+1][3]+dp[i][2])%MOD;
        }
    }
    cout<<dp[S.length()][3]<<endl;
    return 0;
}

Measured memory_bytes: 3584
from copy import copy
import random
import math
import sys
input = sys.stdin.readline
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
last = [0]*26
ans = [0]*D
score = 0
for i in range(D):
    ps = [0]*26
    for j in range(26):
        pl = copy(last)
        pl[j] = i+1
        ps[j] += s[i][j]
        for k in range(26):
            ps[j] -= c[k]*(i+1-pl[k])
    idx = ps.index(max(ps))
    last[idx] = i+1
    ans[i] = idx+1
    score += max(ps)
for k in range(1,41001):
    na = copy(ans)
    x = random.randint(1,365)
    y = random.randint(1,365)
    na[x-1] = na[y-1]
    last = [0]*26
    ns = 0
    for i in range(D):
        last[na[i]-1] = i+1
        ns += s[i][na[i]-1]
        for j in range(26):
            ns -= c[j]*(i+1-last[j])
    if k%100 == 1:
        T = 300-(298*k/41000)
    p = pow(math.e,-abs(ns-score)/T)
    if ns > score or random.random() < p:
        ans = na
        score = ns
for a in ans:
    print(a)


Measured memory_bytes: 88188
#include<iostream>
#include<cmath> //abs() for float
using namespace std;

int D;
double V[16];
double interpolate(int n, int E) //f(n)???(n,v_n), (E, v_E)????????????????±???????
{
	double sum=0.0;
	for(int k=0;k<D+3;++k){
		if(k==n||k==E) continue;
		double p=V[k];
		for(int i=0;i<D+3;++i){
			if(!(i==k||i==n||i==E)){
				p*=(n-i)/(double)(k-i);
			}
		}
		sum+=p;
	}
	return sum;
}

bool outlier(int E)
{
	for(int i=0;i<D+3;++i){
		if(i==E) continue;
		double p=interpolate(i,E);
		if(abs(p-V[i])>0.1){
			return false;
		}
	}
	return true;
}

int main()
{
	while(cin>>D){
		for(int i=0;i<D+3;++i) cin>>V[i];
		for(int i=0;i<D+3;++i){
			if(outlier(i)){
				cout<<i<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3152
#define  _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cmath>
using namespace std;
int main() {
	long long a, b;
	scanf("%lld%lld", &a, &b);
	if ((a%2==1 && b%2==1)|| (a % 2 == 0 && b % 2 == 0)) {
		printf("%lld", (a+b)/2);
	}
	else {
		printf("IMPOSSIBLE");
	}
	return 0;
}

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

using namespace std;
typedef long long LL;

int main() {
  int MAXN = 3010;

  vector<int> dp(MAXN, -100000000);
  vector<int> remain(MAXN, -100000000);
  dp[0] = 0;
  int ans = 0;

  int N, T;
  cin >> N >> T;

  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    for (int j = 1; j + a < MAXN; j++) {
      remain[j] = max(remain[j], remain[j + a] + b);
    }
    for (int j = MAXN - 1; j >= 0; j--) {
      if (j + a < T) dp[j + a] = max(dp[j + a], dp[j] + b);
      if (T - j >= 0) {
        remain[T - j] = max(remain[T - j], dp[j] + b);
      }
    }
    for (int j = 0; j < 100; j++) {
    }
  }
  for (auto val : dp) ans = max(ans, val);
  for (auto val : remain) ans = max(ans, val);
  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main(){
    char a,b;
    cin>>a>>b;
    if(a==b)cout<<'H'<<endl;
    else cout<<'D'<<endl;
}


Measured memory_bytes: 256
import math
a, b, C = map(float, input().split())
print(0.5*a*b*math.sin(math.radians(C)))
print(math.sqrt((a-b*math.cos(math.radians(C)))**2
                + (-b*math.sin(math.radians(C)))**2) + a + b)
print(b*math.sin(math.radians(C)))


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

int main() {
    int H = 0;
    int W = 0;

    while (1)
    {
        cin >> H >> W ;
        
        if(H == 0 && W == 0){
            break;
        }

        for(int h = 1 ; h <= H ; h ++){
            if(h % 2 == 1){
                for(int w = 1 ; w <= W ; w ++){
                    if(w % 2 == 1){
                        cout << "#";
                    }else{
                        cout << ".";
                    }
                }
            }else{
                for(int w = 1 ; w <= W ; w ++){
                    if(w % 2 == 1){
                        cout << ".";
                    }else{
                        cout << "#";
                    }
                }
            }
            cout << "\n";
        }

        cout << "\n";
    }
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;

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

  auto calc = [&](ll x) {
    x++;
    ll mask = 0;
    for (int d = 0; d < 60; d++) {
      ll l = (1LL << (d + 1));
      ll cnt = (x / l) * (l / 2);
      cnt += max(0LL, (x % l) - (l / 2));
      if (cnt % 2 == 1) mask += (1LL << d);
    }
    return mask;
  };
  auto res = calc(b) ^ calc(a - 1);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

string s;
int i;

bool isnum(char c){
	return c >= '0' && c <= '9';
}

int num(){
	int x = 0;
	while (isnum(s[i])){
		x = 10 * x + s[i] - '0';
		i++;
	}
	return x;
}

int dfs(){
	if (isnum(s[i])){
		return num();
	}
	VI c;
	i++;
	while (1){
		c.push_back(dfs());
		if (s[i] == ']'){
			break;
		}
	}
	i++;
	if (c.size() == 1) return (c[0]+1)/2;
	sort(c.begin(),c.end());
	int res = 0;
	REP(i,(c.size()+1)/2){
		res += c[i];
	}
	return res;
}

int main(){
	int n;
	cin >> n;
	while (n--){
		cin >> s;
		i = 0;
		cout << dfs() << endl;
	}

    return 0;
}

Measured memory_bytes: 3212
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
typedef long long int ll;
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EFOR(i,a,b) for (int i=(a);i<=(b);i++)
const ll MOD = (10*10*10*10*10*10*10*10*10+7);

typedef long long ll;
ll N,a,b,ans=1,temp,buff[510],alw=0,c=0;
char ms[510][510];
bool flag=false,lp=false;
int main(){
    scanf("%lld",&N);
    REP(i,N){
        scanf("%s",&ms[i]);
    }
    REP(i,N){
        REP(j,N){
            if(ms[j][i]=='.'){
                if(lp==false){
                    c++;
                    lp=true;
                }
                alw++;
            }

        }
        lp=false;
    }
    if(alw==N*N){
        printf("-1");
        return 0;
    }
    REP(i,N){
        REP(j,N){
            if(ms[j][i]=='#'){
                flag=true;
            }
            if(ms[i][j]=='.'){
                buff[i]++;
            }

        }
        if(!flag)buff[i]++;
        else flag=false;
        if(i!=0){
            if(buff[i]<temp){
                temp=buff[i];
            }
        }else temp=buff[i];
    }
    ans=temp+c;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(){
  int x,y,i;
  scanf("%d%d",&x,&y);
  if(x>y){
	x=x % y;	
	for(i=x;i>0;i--){
	  if(x%i==0 && y%i==0){
		printf("%d\n",i);
		break;
	  }
	}
  }else if(x<y){
	y=y % x;
	for(i=y;i>0;i--){
	  if(x%i==0 && y%i==0){
		printf("%d\n",i);
		break;
	  }
	}
  }else printf("%d\n",x);
  return 0;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
//#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll &b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll &b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 500010;
ll num, ans=0, sum=0;
int main() {
  ll N, X, Y;
  cin >> N >> X >> Y;
  
  vl count(N-1);
  rep(i, N) rep2(j, i+1, N-1) count[min(j-i-1,abs(X-1-i)+abs(Y-1-j))]++;
  rep(i, N-1) cout << count[i] << endl;
}

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

#define mp make_pair
#define pb push_back

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int MAX_N = 300000;
int n;
string s;
int l[MAX_N], r[MAX_N];

int main()
{
  cin >> n >> s;
  l[0] = 0;
  for (int i = 1; i < n; i++) {
    l[i] = l[i-1] + (s[i-1] == 'W' ? 1 : 0);
  }

  r[n-1] = 0;
  for (int i = n-2; i >= 0; i--) {
    r[i] = r[i+1] + (s[i+1] == 'E' ? 1 : 0);
  }

  int m = INT_MAX;
  for (int i = 0; i < n; i++) {
    m = min(m, l[i] + r[i]);
  }

  cout << m << endl;

  return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
 
#define ll int64_t
#define pii pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define lim 100000
#define f(k) k.first
#define s(k) k.second
#define bcnt __builtin_popcount

ll powerMOD(ll a,ll b){
    ll ans = 1;
    ll k = a;
    while(b > 0){
        if(b & 1) ans *= k;
        k = (k*k)%MOD;
        b = b >> 1;
        ans %= MOD;
    }
    return ans;
}

ll power(ll a,ll b){
    ll ans = 1;
    ll k = a;
    while(b > 0){
        if(b & 1) ans *= k;
        k = k*k;
        b = b >> 1;
    }
    
    return ans;
}

void solve(){
    int n;
    cin>>n;
    int *arr = new int[n+1];
    for(int i = 1;i<=n;i++) cin>>arr[i];
    
    int *dp = new int[n+1];
    for(int i = 0;i<=n;i++) dp[i] = 0;
    
    dp[1] = 0;
    dp[2] = abs(arr[2] - arr[1]);
    
    for(int i = 3;i<=n;i++){
        int a = dp[i-1] + abs(arr[i] - arr[i-1]);
        int b = dp[i-2] + abs(arr[i] - arr[i-2]);
        dp[i] = min(a,b);
    }
    cout<<dp[n]<<endl;
}
 
int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	solve();
    return 0;
}

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

int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<int> v(s.size());
  int cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    v.at(i) = cnt;
    if (s[i] == 'A' && s[i + 1] == 'C') {
      cnt++;
    }
  }

  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    cout << v.at(r - 1) - v.at(l - 1) << endl;
  }
}


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	int x, y;
	cin >> x >> y;

	for(int i = 0;i <= x;i++){
		int j = x-i;
		if(i*2 + j*4 == y){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3632
using System;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int s, h, m;
            s = int.Parse(Console.ReadLine());
            h = s / 3600;
            s = s % 3600;
            m = s / 60;
            s = s % 60;
            Console.WriteLine(h + ":" + m + ":" + s);
        }
    }
}


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

c = {"hi", "hihi", "hihihi", "hihihihi", "hihihihihi"}

def main():
    s = input().strip()
    ans = s in c
    print("Yes" if ans else "No")


if __name__ == '__main__':
    main()


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

void Main()
{
    int n;
    cin >> n;
    map<string, int> m;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        m[s]++;
    }
    vector<pair<int, string>> v;
    for (auto i: m) {
        v.push_back(make_pair(i.second, i.first));
    }
    sort(v.rbegin(), v.rend());
    for (auto i: m)
    {
        if(i.second == v[0].first){
            cout << i.first << endl;
        }
    }
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 29308
#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
#include <variant>
#define endl codeforces
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t... Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t... Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

bool solve() {
    ll k, a, b;
    std::cin >> k >> a >> b;
    for (ll i = a; i <= b; i++) if (i % k == 0) return true;
    return false;
}

int main() {
    std::cout << (solve() ? "OK" : "NG") << "\n";
    return 0;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  int L[M];
  int R[M];
  for (int i=0;i<M;i++){
    cin >> L[i] >> R[i];
  }
  int a,b;
  a=L[0];
  b=R[0];
  for (int i=1;i<M;i++){
    if (a<L[i]){
      a=L[i];
    }
    if (b>R[i]){
      b=R[i];
    }
  }
  if (b-a+1<0) a=b+1;
  cout << b-a+1;
  /*
  int card[N][M];
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      card[i][j]=0;
    }
  }
  for(int i=0;i<M;i++){
    for(int j=i;j<M;j++){
      card[L[j]][i]=1;
    }
    for(int j=0;j<=i;j++){
      card[R[j]][i]=1;
    }
  }
  int ans=0;
  for(int i=0;i<N;i++){
    int chk=0;
    for(int j=0;j<M;j++){
      if (card[i][j]!=1){
        chk=1;
      }
    }
    if (chk!=1) ans++;
  }
  */
}


Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define mp make_pair
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front

using namespace __gnu_pbds;
using namespace std;

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int h,w,a,b;
    cin>>h>>w>>a>>b;
    for(int i=1;i<=h;i++,cout<<"\n")
        for(int j=1;j<=w;j++)
            cout<<((i<=b)^(j<=a));
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll i,j,t;
	t=1;
	for(i=0;i<t;i++)
	{
		string x;
		cin>>x;
		string y;
		cin>>y;
		ll l1,l2,mini=1000000,k,c;
		l1=x.length();
		l2=y.length();
		for(j=0;j<l1;j++)
		{
			c=0;
			for(k=0;k<l2;k++)
			{
				if(j+k>=l1)
				break;
				if(x[j+k]!=y[k])
				{
					c++;
					
				}
			}
			if(k==l2)
			mini=min(mini,c);
		}
		cout<<mini;
	}
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll N, M;
    cin >> N >> M;

    if (2*N >= M) {
        cout << M/2 << endl;
    } else {
        M += 2*N;
        cout << M/4 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}


signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	unordered_map<string,bool> mp;
	string s;
	cin >> s;
	char lc = s[s.size()-1];
	mp[s] = true;
	rep(i,n-1){
		cin >> s;	
		if(mp[s] || s[0] != lc) return cout << "No\n",0;
		lc = s[s.size()-1];
		mp[s] = true;
	}
	cout << "Yes\n";

	return 0;	
}


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

long DIV = 998244353;

int main(void) {
   int N;
   cin>>N;
   vector<int> Ball[3];
   Ball[0].reserve(N);
   Ball[1].reserve(N);
   Ball[2].reserve(N);
   char s;
   for (int i = 0; i < 3*N;i++) {
      cin>>s;
      if (s == 'R') Ball[0].push_back(i);
      if (s == 'G') Ball[1].push_back(i);
      if (s == 'B') Ball[2].push_back(i);
   }
   long long ans = 1;
   vector<int> Center;
   Center.reserve(N);
   for (int i = 0; i < N;i++) {
      int ord[3] = {0,0,0};
      if (Ball[0][i] < Ball[1][i] && Ball[1][i] < Ball[2][i]) {
         ord[0] = 0;ord[1] = 1;ord[2] = 2;
      }
      if (Ball[0][i] < Ball[2][i] && Ball[2][i] < Ball[1][i]) {
         ord[0] = 0;ord[1] = 2;ord[2] = 1;
      }
      if (Ball[1][i] < Ball[0][i] && Ball[0][i] < Ball[2][i]) {
         ord[0] = 1;ord[1] = 0;ord[2] = 2;
      }
      if (Ball[1][i] < Ball[2][i] && Ball[2][i] < Ball[0][i]) {
         ord[0] = 1;ord[1] = 2;ord[2] = 0;
      }
      if (Ball[2][i] < Ball[0][i] && Ball[0][i] < Ball[1][i]) {
         ord[0] = 2;ord[1] = 0;ord[2] = 1;
      }
      if (Ball[2][i] < Ball[1][i] && Ball[1][i] < Ball[0][i]) {
         ord[0] = 2;ord[1] = 1;ord[2] = 0;
      }
      auto itr = Ball[ord[0]].begin();
      itr = lower_bound(Ball[ord[0]].begin()+i, Ball[ord[0]].end(),Ball[ord[1]][i]);
      ans *= (itr - (Ball[ord[0]].begin()+i));
      ans = ans%DIV;
      Center.push_back(Ball[ord[1]][i]);
   }
   for (int i = 0; i < N;i++) {
      int ord[3] = {0,0,0};
      if (Ball[0][i] < Ball[1][i] && Ball[1][i] < Ball[2][i]) {
         ord[0] = 0;ord[1] = 1;ord[2] = 2;
      }
      if (Ball[0][i] < Ball[2][i] && Ball[2][i] < Ball[1][i]) {
         ord[0] = 0;ord[1] = 2;ord[2] = 1;
      }
      if (Ball[1][i] < Ball[0][i] && Ball[0][i] < Ball[2][i]) {
         ord[0] = 1;ord[1] = 0;ord[2] = 2;
      }
      if (Ball[1][i] < Ball[2][i] && Ball[2][i] < Ball[0][i]) {
         ord[0] = 1;ord[1] = 2;ord[2] = 0;
      }
      if (Ball[2][i] < Ball[0][i] && Ball[0][i] < Ball[1][i]) {
         ord[0] = 2;ord[1] = 0;ord[2] = 1;
      }
      if (Ball[2][i] < Ball[1][i] && Ball[1][i] < Ball[0][i]) {
         ord[0] = 2;ord[1] = 1;ord[2] = 0;
      }
      auto itr2 = Center.begin();
      itr2 = lower_bound(Center.begin()+i, Center.end(),Ball[ord[2]][i]);
      // cout<<itr2 - (Center.begin()+i)<<endl;
      ans *= (itr2 - (Center.begin()+i));
      ans = ans%DIV;
   }
   for (int i = 0; i < N;i++) {
      ans *= (i+1);
      ans = ans%DIV;
   }
   cout<<ans<<endl;
   return 0;
}

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (a - b >= 0)
    cout << "delicious" << endl;
  else if (a + x - b >= 0)
    cout << "safe" << endl;
  else
    cout << "dangerous" << endl;
}


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

using namespace std;

int main()
{
  int n, m; cin >> n >> m;
  int a[n], sum = 0;
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
    sum += a[i];
  }
  double ppty = sum / double(m*4);
  int cnt = 0;
  for(int i = 0; i < n; i++)
    if(a[i] >= ppty)
      cnt++;
  if(cnt >= m)
    cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3580