akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define fgx cerr<<" ---------------------------------------------- "<<endl
#define uint unsigned int 
#define ULL unsigned long long
#define DB long double
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define rint register int 
inline int read(){
	int nm=0; bool fh=true; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) fh^=(cw=='-');
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return fh?nm:-nm;
}
#define M 2002000
#define mod 1000000007
#define inv3 333333336
namespace CALC{
	inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
	inline int mns(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
	inline int mul(int x,int y){return (LL)x*(LL)y%mod;}
	inline void upd(int &x,int y){x=((x+y>=mod)?(x+y-mod):(x+y));}
	inline void dec(int &x,int y){x=((x-y<0)?(x-y+mod):(x-y));}
	inline int qpow(int x,int sq){int res=1;for(;sq;sq>>=1,x=mul(x,x))if(sq&1)res=mul(res,x);return res;}
}using namespace CALC;
int n,iv[M],ans,pw[M];
int main(){	
	iv[1]=1,n=read(),pw[0]=1;
	for(int i=2;i<=n;i++) iv[i]=mul(mod-mod/i,iv[mod%i]);
	for(int i=1;i<=n;i++) pw[i]=mul(pw[i-1],inv3);
	for(int i=1;i<=n;i++) upd(ans,mul(pw[i],iv[n-i+1]));
	ans=mul(ans,iv[n]); printf("%d\n",ans); return 0;
}


Measured memory_bytes: 10496
import sys
input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = input().strip()

    Ts = ["" for _ in range(K)]
    for i, c in enumerate(T):
        Ts[i % K] += c

    ans = 0
    p = {"r": P, "s": R, "p": S}
    for t in Ts:
        c0 = ""
        for c in t:
            if c0 == c:
                c0 = ""
            else:
                ans += p[c]
                c0 = c
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 6260
#include <iostream>
#include <string>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b == c){ cout << "Yes" << endl; }
	else if (b + c == a){ cout << "Yes" << endl; }
	else if (c + a == b){ cout << "Yes" << endl; }
	else{ cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve(string A) {
  const ll n = A.size();
  vector<ll> cnt(26);
  for (char c: A) cnt[c - 'a'] += 1;
  ll res = n * (n - 1) / 2;
  for (ll i: cnt) res -= i * (i - 1) / 2;
  cout << res + 1 << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	string A;
	cin >> A;
	solve(A);
	return 0;
}


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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	string S;
	cin >> N >> S;

	int result = 0;
	for( int i = 1; i < N; ++i ) {
		vector<bool> x( 256 );
		vector<bool> y( 256 );

		for( int j = 0; j < i; ++j ) { x[S[j]] = true; }
		for( int j = i; j < N; ++j ) { y[S[j]] = true; }

		int a = 0;
		for( int j = 'a'; j <= 'z'; ++j ) {
			if( x[j] && y[j] ) { a += 1; }
		}

		if( a > result ) {
			result = a;
		}
	}

	cout << result << endl;
	return 0;
}


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

using namespace std;

#define int ll
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;

template<int MAXN>
struct segtr{
    //To change the purpose of the segtree just redefine the operators
    struct node{
        int x;
        node(int x = 0) : x(x) {}
        node& operator+= (const node& other){
            x = max(x, other.x);
            return *this;
        }
        node operator+ (const node& other){
            node tmp = *this;
            return tmp += other;
        }
    };
    
    node a[2*MAXN];
    
    //Initialize the array
    void init(){
        for(int i = 1; i <= MAXN; ++i){
            a[i+MAXN-1] = node{};
        }
        for(int i = MAXN-1; i > 0; --i){
            a[i] = a[2*i] + a[2*i+1];
        }
    }
    
    //Sets the node and updates the tree
    void set(int pos, node val){
        pos += MAXN-1;
        a[pos] = val;
        
        while(pos > 1){
            pos /= 2;
            a[pos] = a[2*pos] + a[2*pos+1];
        }
    }
    inline void add(int pos, node val){ //Just forwards to set
        set(pos, node{a[pos+MAXN-1]+val});
    }
    
    //Gets the range query
    node get(int l, int r, int pos = 1, int rl = 1, int rr = MAXN){
        if(r < rl || rr < l){ return node{}; }
        if(l <= rl && rr <= r){ return a[pos]; }
        
        int rm = (rl+rr)/2;
        return get(l, r, 2*pos, rl, rm) + get(l, r, 2*pos+1, rm+1, rr);
    }
    
};
segtr<131072 * 4> tr;

signed main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr); 
    cerr.tie(nullptr);    
    tr.init();

    int n;
    cin >> n;

    vi h(n);
    for (auto& i : h)
        cin >> i;

    vi a(n);
    for (auto& i : a)
        cin >> i;

    vi dp(n, 0);
    for (int i = 0; i < n; ++i){
        int maxi = tr.get(1, h[i]).x;
        dp[i] = max(dp[i], maxi + a[i]);
        tr.set(h[i], dp[i]);
    }

    cout << *max_element(dp.begin(), dp.end()) << '\n';
}

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

using namespace std;

typedef long long int lli;

template<typename Integer>
Integer GCD(Integer a, Integer b){
  if(!b)return a;
  else return GCD(b,a%b);
}

template<typename Integer>
inline pair<Integer, pair<Integer, Integer> > ExtendedGCD(Integer a, Integer b){
  pair<Integer, pair<Integer, Integer> > ret,tmp;
  if( b==0 ) return make_pair( a, make_pair( 1, 0 ) );
  tmp = ExtendedGCD(b,a%b);
  ret.first = tmp.first;
  ret.second.first = tmp.second.second;
  ret.second.second = tmp.second.first - (a/b)*tmp.second.second;
  return ret;
}

template<typename Integer>
inline bool SolveModEquation(Integer a, Integer b, Integer n){
  pair<Integer, pair<Integer, Integer> > t;
  t = ExtendedGCD( a, n );
  if( b % t.first == 0 ){
    Integer ini_x = ( t.second.first * ( b / t.first ) ) % n;
    for(int i = 0; i < t.first; ++i){
      Integer I = ( ini_x + i * ( n / t.first ) ) % n;
      if(I<0)I+=n;
      Integer J = (b - a*I) / n;
      if( I >= 0 && J >= 0 && a * I + n * J == b  )
	return true;
    }
  }
  return false;
}

int main(){
  while(true){
    int ableCount = 0;
    lli n,a,b;
    cin >> n >> a >> b;
    if( n==0 && a==0 && b==0 )break;
    for(lli k = 1; k <= n; k++){
      if( SolveModEquation(a,k,b) )
	++ableCount;
    }
    cout << n-ableCount << endl;
  }
  return 0;
}

Measured memory_bytes: 868
import copy


class Dice:
    def __init__(self, eyes):
        self._top = eyes[0]
        self._front = eyes[1]
        self._right = eyes[2]
        self._left = eyes[3]
        self._back = eyes[4]
        self._bottom = eyes[5]

    @property
    def eye(self):
        return self._top

    def roll(self, direction):
        old = copy.copy(self)
        if direction == 'N':
            self._top = old._front
            self._front = old._bottom
            self._back = old._top
            self._bottom = old._back
        elif direction == 'S':
            self._top = old._back
            self._front = old._top
            self._back = old._bottom
            self._bottom = old._front
        elif direction == 'W':
            self._top = old._right
            self._right = old._bottom
            self._left = old._top
            self._bottom = old._left
        elif direction == 'E':
            self._top = old._left
            self._right = old._top
            self._left = old._bottom
            self._bottom = old._right
        else:
            raise ValueError('NEWS箱推し')


eyes = input().split()
dice = Dice(eyes)

direction_text = input()
for d in direction_text:
    dice.roll(d)

print(dice.eye)



Measured memory_bytes: 6312
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int n,k;
bool lk[11];
int main(){
	scanf("%d%d",&n,&k);
	int xb,a;
	fill(lk,lk+11,1);
	for(xb=0;xb<k;xb++) {
		scanf("%d",&a);
		lk[a]=0;
	}
	for(xb=n;;xb++){
		int nx=xb;
		while(nx){
			if(!lk[nx%10])break;
			nx/=10;
		}
		if(nx==0){
			printf("%d\n",xb);
			return 0;
		}
	}
	return 0;
} 

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#pragma warning (disable: 4996)

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 32; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long Div(long long a, long long b, long long m) {
	return (a * modpow(b, m - 2, m)) % m;
}

long long mod = 1000000007;
long long power[10009], inv[10009];
long long N, M;
long long dp[5009][5009], ru[5009][5009];

void init() {
	power[0] = 1;
	for (int i = 1; i <= 10000; i++) power[i] = (2LL * power[i - 1]) % mod;
	for (int i = 0; i <= 10000; i++) inv[i] = Div(1, power[i], mod);
}

int main() {
	init();
	cin >> N >> M;
	dp[N][M] = 1;
	for (int i = N - 1; i >= 0; i--) {
		ru[i][0] = 0;
		for (int j = 1; j <= M; j++) ru[i + 1][j] = dp[i + 1][j] * power[j] % mod;
		for (int j = 1; j <= M; j++) ru[i + 1][j] = (ru[i + 1][j] + ru[i + 1][j - 1]) % mod;
		for (int j = 1; j <= M; j++) {
			long long v1 = 1LL * (j + 1) * dp[i + 1][j];
			long long v2 = ru[i + 1][M] - ru[i + 1][j];
			v2 *= inv[j + 1]; v2 %= mod;
			v2 *= (1LL * j); v2 %= mod;
			dp[i][j] = (v1 + v2) % mod;
		}
	}

	long long Answer = 0;
	for (int i = 1; i <= M; i++) Answer += dp[0][i];
	cout << Answer % mod << endl;
	return 0;
}

Measured memory_bytes: 394988
n,m = map(int,input().split())
l_max,r_min = 0,n
for i in range(m):
    l,r = map(int,input().split())
    l_max = max(l,l_max)
    r_min = min(r,r_min)
print(max(r_min - l_max +1 , 0))


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

using namespace std;

int main()
{
    int n,m;
    cin >>n;
    int count=9;
    if(n<=599)
    {
        cout<<"8" <<endl;
    }else if(n>=600&&n<=799)
    {
        cout<<"7"<<endl;
    }else if(n>=800&&n<=999)
    {
        cout<<"6"<<endl;
    }else if(n>=1000&&n<=1199)
    {
        cout<<"5"<<endl;
    }else if(n>=1200&&n<=1399)
    {
        cout<<"4"<<endl;
    }else if(n>=1400&&n<=1599)
    {
        cout<<"3"<<endl;
    }else if(n>=1600&&n<=1799)
    {
        cout<<"2"<<endl;
    }else if(n>=1800)
    {
        cout<<"1"<<endl;
    }
    return(0);
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<cctype>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef string::const_iterator State;

int ctoi(const char &c)
{
	return c - '0';
}

int expression(State &);
int term(State &);
int factor(State &);
int number(State &);

int expression(State &itr)
{
	int ret=term(itr);

	while (true)
	{
		if (*itr == '+')
		{
			itr++;
			ret = ret + term(itr);
		}
		else if (*itr == '-')
		{
			itr++;
			ret = ret - term(itr);
		}
		else
		{
			break;
		}
	}

	return ret;
}

int term(State &itr)
{
	int ret=factor(itr);

	while (true)
	{
		if (*itr == '*')
		{
			itr++;
			ret = ret*factor(itr);
		}
		else if (*itr == '/')
		{
			itr++;
			ret = ret / factor(itr);
		}
		else
		{
			break;
		}
	}

	return ret;
}

int factor(State &itr)
{
	int ret;

	if (*itr == '(')
	{
		itr++;
		ret = expression(itr);
		itr++;
	}
	else
	{
		ret = number(itr);
	}

	return ret;
}

int number(State &itr)
{
	int ret = 0;

	while (isdigit(*itr))
	{
		ret *= 10;
		ret += ctoi(*itr);
		itr++;
	}

	return ret;
}

int main()
{
	int n;
	cin >> n;
	cin.ignore();
	REP(i, n)
	{
		string str;
		getline(cin, str);
		State begin = str.begin();
		int ans = expression(begin);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=55;
const int M=255;
inline ll read(){ll x=0,f=1;char ch=getchar();for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-48;return x*f;}
inline void write(ll x){if(x>9)write(x/10);putchar('0'+x%10);}
inline void writeln(ll x){write(x);puts("");}
int head[N],tail[M],nxt[M],from[M];
bool b[M],vis[N];
int ans,n,m,t,x,y;
void addto(int x,int y)
{
	nxt[++t]=head[x];
	from[t]=x;
	head[x]=t;
	tail[t]=y;
}
void dfs(int k)
{
	vis[k]=true;
	for(int i=head[k];i;i=nxt[i]){
		if(b[i])continue;
		if(vis[tail[i]])continue;
		dfs(tail[i]);
	}
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;i++){
		x=read();y=read();
		addto(x,y);
		addto(y,x);
	}
	ans=0;
	for(int i=1;i<=t;i+=2){
		b[i]=true;
		b[i+1]=true;
		memset(vis,false,sizeof(vis));
		dfs(1);
		b[i]=false;
		b[i+1]=false;
		for(int j=1;j<=n;j++)
			if(!vis[j]){
				ans++;
				break;
			}
	}
	writeln(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
pii a[100001];
bool comp(pii x, pii y) {
	return x.first < y.first; 
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); /*cout.tie(NULL);*/
	int n, m;
	cin >> n >> m;
	rep(i, m) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a, a + m);
	int x = a[0].first;
	int y = a[0].second;

	for (int i = 1; i < m; i++) {
		if (a[i].first > y) {
			cout << 0 << '\n'; return 0;
		}
		x = max(x, a[i].first);
		y = min(y, a[i].second);
	}
	cout << y - x + 1 << '\n';





}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <list>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int n , q;
	std::string buf;
	std::vector<std::list<long> > lists;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	std::getline(ifs, buf);
#else
	std::getline(std::cin, buf);
#endif
	{
		std::istringstream stream(buf);

		stream >> n >> q;
	}

	lists.resize(n);
	for(int i = 0; i < q; i++){
#if INPUT_FROM_FILE
		std::getline(ifs, buf);
#else
		std::getline(std::cin, buf);
#endif
		std::istringstream stream(buf);
		long tmp, s, t, x;

		if(buf[0] == '0'){
			stream >> tmp >> t >> x;

			lists[t].push_back(x);
		}
		else if(buf[0] == '1'){
			stream >> tmp >> t;

			if(lists[t].empty()){
				std::cout << std::endl;
			}
			else{
				std::cout << lists[t].front();
				std::list<long>::const_iterator it = lists[t].begin();
				it++;
				for(; it != lists[t].end(); it++){
					std::cout << " " << *it;
				}
				std::cout << std::endl;
			}
		}
		else{
			stream >> tmp >> s >> t;
			lists[t].splice(lists[t].end(), lists[s]);
		}

	}

	return 0;
}



Measured memory_bytes: 18772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,v,c,ans=0;
  cin>>n;
  vector<ll> a(n),b(n);
  for(ll i=0;i<n;i++){
	cin>>a[i];
  }
  for(ll i=0;i<n;i++){
	cin>>b[i];
  }
  for(ll i=0;i<n;i++){
	ans+=(a[i]-b[i]>0?a[i]-b[i]:0);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#define MAX_N 20
using namespace std;
/*
struct Human {
    int no;
    int result;
};
 */
//typedef struct Human Human
typedef pair<int, int> Human;

int compareTo(const Human& a, const Human& b) {
    return(a.second > b.second);
}

int main(void) {
    int num = 1; cin >> num;
    Human table[MAX_N];
    for(int r = 0; r < num; r++) cin >> table[r].first >> table[r].second;
    sort(table, table+num, compareTo);
    
    int minNo = INT_MAX, minResult = INT_MAX;
    int topResult = table[0].second;
    for(int r = 0; r < num && (table[r].second == topResult); r++) {
        if(table[r].first < minNo) {
            minNo = table[r].first; minResult = table[r].second;
        }
    }
    cout << minNo << " " << minResult << endl;
    return(0);
}

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

using namespace std;


int main (void) 
{

  int A, B; //整数の範囲（A~B）
  cin >> A >> B;

  vector<int> dig(5);

  int scan_num;
  int digits;
  int div;
  int count; // output

  count = 0;
  for(scan_num = A; scan_num <= B; scan_num++) 
  {

    digits   = 0;
    div = 1;
    while(digits < 5) // 制限より、5桁の数値
    {

      dig.at(digits) = scan_num % (div*10) /div;
      div *= 10;
      digits++;

    }

    if( (dig.at(0) == dig.at(4)) && (dig.at(1) == dig.at(3)) )
    {
      count++;
    }
  }

  cout << count << endl;


  return 0;

}


Measured memory_bytes: 764
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    A, B = LI()

    ans = 0
    for _ in range(2):
        if A > B:
            ans += A
            A -= 1
        else:
            ans += B
            B -= 1

    print(ans)

if __name__ == '__main__':
    resolve()


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



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,x,t;
    cin>>n>>x>>t;
    cout<<(n+x-1)/x *t;
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int a, b;
    cin >> a >> b;
    int N = b - a;
    int h = 0;
    for (int i = 1; i < N; i++) {
        h += i;
    }
    h -= a;
    cout << h << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  long a,b,c=0,d=0,e,n,m,x,y;
  cin>>n>>m;
  int xx[n];
  int yy[n];
  rep(i,0,n){
    cin>>xx[i]>>yy[i];
    if(yy[i]<=m) c++;
  }
  if(c>0){
    a=xx[0];
    rep(i,1,n) if(xx[i]<a && yy[i]<=m) a=xx[i];
    co(a);
  }
  else co("TLE");
  
  return 0;
}

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

typedef long long LL;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;

const int INF = 1000000007;
const LL INFLL = 1000000000000000007;

#define st first
#define nd second
#define pb push_back
#define _boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// ***************************** CODE ***************************** //

const int MAX = 107;
const int MAX2 = 1e5 + 7;

LL waga[MAX], c[MAX];
LL dp[MAX][MAX2];

int main() {
    _boost;

    int n, w;
    cin >> n >> w;
    for(int i = 1; i <= n; i++)
        cin >> waga[i] >> c[i];

    for(int i = 0; i < MAX; i++)
        for(int j = 1; j < MAX2; j++)
            dp[i][j] = INFLL;

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <=  MAX2; j++)
        {
            if(c[i] > j)
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-c[i]]+waga[i]);
        }

    for(int i = MAX2; i >= 0; i--)
    {
        for(int j = 0; j <= n; j++)
            if(dp[j][i] > 0 && dp[j][i] <= w)
            {
                cout << i;
                return 0;
            }
    }
    return 0;
}


Measured memory_bytes: 83840
n,x= map(int,input().split())
a=list(map(int,input().split()))
cnt=0
a.sort()
i=0
while x>0:
	x -= a[i]
	i +=1
	cnt +=1
	if i == n:
		if x!=0:
			cnt -= 1
			x=0
	if x<0:
		cnt -= 1
print(cnt)

Measured memory_bytes: 3064
def binpow(a, b):
    res=1
    while b>0:
        if b&1:
            res=res*a
        a=a*a
        b>>=1
    
    return res


def main():
    a=int(input())
    print(a+binpow(a, 2)+binpow(a, 3))


if __name__=='__main__':
    main()


Measured memory_bytes: 9040
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main() {
  int r;
  cin >> r;
  printf("%.10f\n", r * 2 * acos(-1));
  return(0);
}


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

int main()
{
    long long int a,b,n1,n2;
    int flg=0;

    scanf("%d %d",&a,&b);



    int i;
    for(i=0;i<1000000000;i++){
        n1=abs(a-i);
        n2=abs(b-i);
        if(n1==n2){
            printf("%lld\n",i);
            flg=1;
            break;
        }
    }

    if(flg==0){
         printf("IMPOSSIBLE\n");
    }

    return 0;
}

Measured memory_bytes: 1732
X,K,D = map(int,input().split())
if X>0:
    n = X//D
    if K<=n:
        print(X-K*D)
    else:
        if (K-n)%2==0:
            print(X-n*D)
        else:
            print((n+1)*D-X)
elif X<0:
    n = abs(X)//D
    if K<=n:
        print(abs(X+K*D))
    else:
        if (K-n)%2==0:
            print(abs(X+n*D))
        else:
            print(X+(n+1)*D)
else:
    if K%2==0:
        print(0)
    else:
        print(D)

Measured memory_bytes: 61900
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

int main(){
	ll n , m ; 
	cin >> n >> m ;
	vector<ll> v(n) ;     
	vector<bool> mark(n) ;     
	for(ll &x : v){
		cin >> x ; 
	}
	sort(v.begin(),v.end());
	vector<pair<ll,ll> > choose(m) ; 
	for(ll i=0;i<m;i++){
		ll b , c ; 
		cin >> b >> c ; 
		choose.push_back({c,b}) ; 
	}
	sort(choose.rbegin(),choose.rend());
	debug() << imie(v) ; 
	debug() << imie(choose) ; 
	ll ans = 0 ; 
	ll cur = 0 ; 	
	for(ll i=0;i<n;i++){
		debug() << imie(ans) ; 
		for(ll j=0;j<choose[cur].second;j++){
			if ( i+j < n && v[i+j] < choose[cur].first ){
				ans += choose[cur].first ; 
				mark[i+j] = true ; 
				debug() << imie(mark) ; 
			}
			else{
				// maybe i = j - 1 ; 
				i = i+j ; 
				break ; 
			}
		}
		if ( cur < m ) 
			i = i + choose[cur].second - 1 ; 
		debug() << imie(i) ; 
		cur++ ; 
	}
	for(ll i=0;i<n;i++){
		if ( !mark[i] ) ans += v[i] ; 
	}
	cout << ans << endl;
    return 0 ;
}


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

int main(){

    int n;
    int a[101]={0};
    cin>>n;
    for(int i=0;i<9;i++){
        for(int j=0;j<9;j++){
            a[(i+1)*(j+1)-1]++;
        }
    }

    if(a[n-1]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    






    return 0;
}

Measured memory_bytes: 256
//k_tourist
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 500005
#define non __builtin_popcount
#define ml map<ll, ll> 
#define uml unordered_map<ll, ll>
#define ms map<string , ll> 
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define pl pair<ll, ll>
#define vl vector<ll>
#define vll vector<pl>
#define tpl pair<ll, pl>
#define vlll vector<tpl>
#define vs vector<string>
#define pb push_back
#define mk make_pair
#define M_PI 3.14159265358979323846
#define endl '\n'
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define inf ((ll)1e18 + 1)
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define pow powr
#define sp(a) setprecision(a)
#define rep(i,a,b)  for (i=(a);i<(b);i++)
#define nrep(i,a,b) for (i=(a);i>(b);i--)
using namespace std;
using namespace __gnu_pbds;  

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>  ordered_set;
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void flag(ll fl){

	if(fl)
	cout<<"No";
	else
	cout<<"Yes";
}


void bta_de_yarr(){

	ll n, i, j, m, ans, fl=0;

    string s;

    cin>>s;

    if(s[2] == s[3] && s[4]== s[5])
    fl=0;
    else
    {
        fl= 1;
    }
    

	// cout<<ans;
	flag(fl);
	cout<<endl;
}

int main(){
    fst

	// freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
	ll t, i;
    t= 1;
	// cin>>t;
    
    rep(i, 1, t+1){

        // cout<<"Case #"<<i<<":"<<" ";
        bta_de_yarr();
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
  int X;
  cin >> X;
  for (int64_t i = 0; i < 121; i++) {
    for (int64_t j = i; j < 121; j++) {
      if (j * j * j * j * j - i * i * i * i * i  == X) {
        cout << j << " " << i << endl;
        break;
      }
      if (j * j * j * j * j + i * i * i * i * i  == X) {
        cout << j << " " << -i << endl;
        break;
      }
    }
  }
}
  

Measured memory_bytes: 3620
fn main() {
    let n: usize = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        line.trim().parse().unwrap()
    };
    let b: Vec<i64> = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        line.split_whitespace().map(|a| a.parse().unwrap()).collect()
    };
    let mut a: Vec<i64> = vec![1 << 40; n];
    for i in 0..(n-1) {
        a[i] = std::cmp::min(a[i], b[i]);
        a[i + 1] = std::cmp::min(a[i + 1], b[i]);
    }
    println!("{}", a.iter().fold(0i64, |sum, &a| sum + a));
}


Measured memory_bytes: 4352
main = do
    s <- getLine
    let y = read $ take 4 s :: Int
        m = read $ take 2 $ drop 5 s :: Int
        d = read $ drop 8 s :: Int
        ymd = y*10000 + m*100 + d
    putStrLn $ if ymd <= 20190430 then "Heisei" else "TBD"

Measured memory_bytes: 508
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <functional>
using namespace std;
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#define	ll long long
#define	ull unsigned long long
#define	vi vector<int>
#define	vll vector<long long>
#define	pii pair<int,int>
#define	pll pair<long long,long long>
#define	PB push_back
#define	MP make_pair
#define	ff first
#define	ss second
#define	IT iterator
#define	IOS ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define	LB cout<<"\n"
#define	CS <<" "<<
#define	DB cout<<"> "
#define	endl "\n"
#define	loop(x,y) for(int x=0;x<y;++x)
#define	loop1(x,y) for(int x=1;x<=y;++x)
#define	MS(x,y) memset(x,y,sizeof(x))

int n;
int k;

int main(){

	cin >> n >> k;
	n %= 500;
	if(n<=k) cout << "Yes\n";
	else cout << "No\n";

}

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

int main()
{
  long long X, K, D, i, q, r;
  scanf("%lld%lld%lld", &X, &K, &D);
  
  if (X < 0) {
    X = -X;
  }
  q = X / D;
  r = X % D;
  
  if (K <= q) {
    printf("%lld", X - K*D);
  } else if ((K-q)%2 == 1) {
    printf("%lld", labs(D-r));
  } else {
    printf("%lld", r);
  }
  return 0;
}


Measured memory_bytes: 1732
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }


/*
 <url:https://agc021.contest.atcoder.jp/tasks/agc021_b>
 問題文============================================================
 
 平面上に N 個の穴があります。i 個目の穴の座標は、(xi,yi) です。
 
 R=10^10^10^10 とします。りんごさんは、以下の操作を行います。
 
 原点を中心とする半径 R の円内から無作為に 1 点を選び、すぬけ君を置く。
 すぬけ君は、置かれた点からユークリッド距離が最も近い穴に移動し、落ちる。
 そのような穴が複数ある場合は、添え字の最も小さいものを選ぶ。
 
 全ての 1≤i≤N に対し、すぬけ君が i 番目の穴に落ちる確率を求めてください。
 
 ただし、半径 R の円内から無作為に 1 点を選ぶ操作とは、以下の操作を指します。
 
 [−R,R] 上の独立な一様分布にしたがって実数 x,y を選ぶ。
 もしx2+y2≤R2 なら、座標 (x,y) を選ぶ。そうでないなら、その条件が満たされるまで実数 x,y を選びなおし続ける。
 
 
 =================================================================
 
 解説=============================================================
 
 ================================================================
 */
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-9, pi = acos(-1.0);
namespace std {
    bool operator<(const Point &lhs, const Point &rhs) {
        if (lhs.real() < rhs.real() - eps) return true;
        if (lhs.real() > rhs.real() + eps) return false;
        return lhs.imag() < rhs.imag();
    }
}
Point input_point() {ld x, y; cin >> x >> y; return Point(x, y);} // 点の入力
bool eq(ld a, ld b) {return (abs(a - b) < eps);} // 誤差つき等号判定
ld dot(Point a, Point b) {return real(conj(a) * b);} // 内積
ld cross(Point a, Point b) {return imag(conj(a) * b);} // 外積

void solve(){
    ll N; cin >> N;
    vector<Point> p(N);
    for(int i = 0; i < N;i++){ p[i] = input_point(); }
    if(N == 2){
        cout << 0.5 << endl;
        cout << 0.5 << endl;
        return;
    }
    for(int i = 0; i < N;i++){
        vector<double> area;
        for(int j = 0; j < N; j++){
            if(i == j) continue;
            area.push_back(atan2(p[j].real()-p[i].real(),p[j].imag()-p[i].imag()));
        }
        sort(area.begin(),area.end());
        area.push_back(area[0]+2*pi);
        double ans = 0;
        for(int j = 0; j < area.size()-1;j++){
            if(area[j+1]-area[j]>=pi) ans=area[j+1]-area[j]-pi;
        }
        cout << fixed << setprecision(12) << ans/2/pi << endl;
    }
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair

int main(){
	ll n , t;
	cin>>n>>t;
	queue<ll> q;
	for(int i = 0;i<n;i++){
		ll x;
		cin>>x;
		q.push(x);
	}
	ll ta = 0 , resp = 0;
	while(!q.empty()){
		ll u = q.front();
		q.pop();
		if(u >= ta){
			resp+=t;
			ta = u + t;
		}
		else if(u< ta){
				resp+=u+t-ta;
				ta = max(ta, u + t);
			}

	}
	cout<<resp;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main(){

	vector<VI> dt(24, VI(4));
	rep(i, 24){
		int a; double b;
		cin >>a >>b;
		dt[i][0] = int(b*100);
		dt[i][1] = a;
	}
	
	rep(i, 3){
		sort(dt.begin()+i*8, dt.begin()+i*8+8);
		dt[i*8][2] = dt[i*8+1][2] = 1;
		printf("%d %.2f\n", dt[i*8][1], dt[i*8][0]/100.0);
		printf("%d %.2f\n", dt[i*8+1][1], dt[i*8+1][0]/100.0);
	}
	
	sort(all(dt));
	for(int i=0, ct=2; i<24 && ct>0 ;i++){
		if(dt[i][2] !=1){
			printf("%d %.2f\n", dt[i][1], dt[i][0]/100.0);
			ct--;
		}
	}
	return 0;
}



Measured memory_bytes: 3260
//SAIKH SERAJ FAHIM, CSE-19-HSTU, BANGLADESH.

#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<int>v;
    int n,k,i,a,count=0;
    cin>>n>>k;
    for(i=0; i<n; i++)
    {
        cin>>a;
        v.push_back(a);
    }
    for(i=0; i<n; i++)
    {
        if(v[i]>=k)
            count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
long long inf=2000000000ll;
long long d[500][500];
int main(){
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
     rep(i,0,n-1)rep(j,0,n-1)d[i][j]=inf;
     rep(i,0,n-1)d[i][i]=0;
    rep(i,1,m){
        long long x,y,z;
        cin>>x>>y>>z;
        d[x][y]=z;
    }
    rep(k,0,n-1)rep(i,0,n-1)if(d[i][k]!=inf)rep(j,0,n-1)if(d[k][j]!=inf){
        if(d[i][k]+d[k][j]<d[i][j])d[i][j]=d[i][k]+d[k][j];
    }
    rep(i,0,n-1)if(d[i][i]<0){
        cout<<"NEGATIVE CYCLE"<<endl;
        return 0;
    }
    rep(i,0,n-1){
        if(d[i][0]==inf)cout<<"INF";else cout<<d[i][0];
        rep(j,1,n-1){
            cout<<' ';
            if(d[i][j]==inf)cout<<"INF";else cout<<d[i][j];
        }
        cout<<endl;
    }
}
/* 
4 6
0 1 1
0 2 5
1 2 2
1 3 4
2 3 1
3 2 7

1 ≤ |V| ≤ 100
0 ≤ |E| ≤ 9900
-2 × 107 ≤ di ≤ 2 × 107
 */


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

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

  vector<int>vec(N);
  
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }

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

  sa=vec.at(N-1)-vec.at(0);

  if(sa%2==1){
    cout << sa/2+1 <<endl;
  }
  else {
    cout << sa/2 <<endl;
  }

  
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define INF 2000'000'000

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	//freopen("in", "r", stdin);
	ll n, ans = 0;
	cin >> n;
	vector < int > v(n);
	for(int & i : v)
		cin >> i;
	sort(v.rbegin(), v.rend());
	for(int add = 0, i = 1; i < n; add += i & 1, i++){
		ans += v[add];
	}
	cout << ans << endl;
	return 0;
}


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

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main(){
    int N,A,B;
    cin>>N>>A>>B;
    cout<<min(A*N,B);
    
    return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    A, B, K = LI()

    taka = A
    ao = B

    if A>=K:
        taka = A-K
    else:
        taka = 0
        ao = max(B-(K-A), 0)

    print(taka, ao)

if __name__ == '__main__':
    resolve()

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

#define F first
#define S second
#define gcd __gcd
#define nset __builtin_popcount
#define pb push_back
#define btoe(x) x.begin(), x.end()
#define trim_chains(x) (x).resize(unique(btoe(x)) - (x).begin())
#define remove_dups(x) sort(btoe(x)); trim_chains(x);
#define rep(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define nrep(i, a, b) for (int i = int(a); i >= int(b); i--)
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define circ_inc(i, n) (i + 1) % int(n)
#define circ_dec(i, n) (i + int(n) - 1) % int(n)
#define round(x) (int)((double)int(x) + 0.5)

void println() { cout << '\n'; }
template <typename Head, typename... Tail>
void println(Head H, Tail... T) {
    cout << " " << H;
    println(T...);
}
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef map<string, int> msi;
typedef istringstream iss;

const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main() 
{
    FASTIO;
    int k, a, b;
    cin >> k >> a >> b;
    if(b/k - (a-1)/k > 0) cout << "OK\n";
    else cout <<"NG\n";
    return 0;
}


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
struct Edge {
    ll eid, to, cost;
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    while (cin >> n, n) {
        vector<vector<Edge>> G(n);
        vector<ll> p(n-1), d(n-1); cin >> p >> d;
        rep(i, n-1) --p[i];
        rep(i, 1, n) {
            G[i].pb({i-1, p[i-1], d[i-1]});
            G[p[i-1]].pb({i-1, i, d[i-1]});
        }
        vector<bool> f(n-1, false);
        rep(i, n) {
            if (G[i].size() == 1) {
                f[G[i][0].eid] = true;
            }
        }
        vector<vector<Edge>> g(n);
        rep(i, n) each(e, G[i]) {
            if (!f[e.eid]) {
            // cout << e.eid << " " << i << " -> " << e.to << " " << e.cost << endl;
                g[i].pb(e);
            }
        }
        G = g;
        function<pair<ll,ll>(ll, ll)> dfs = [&](ll v, ll pv) {
            P res(0, v);
            each(e, G[v]) {
                if (e.to == pv) continue;
                auto r = dfs(e.to, v);
                if (r.first + e.cost > res.first) {
                    res = P(r.first + e.cost, r.second);
                }
            }
            return res;
        };
        ll v0 = -1;
        rep(i, n) {
            if (G[i].size() > 0) {
                v0 = i;
                break;
            }
        }
        ll ans = 0;
        rep(i, n) each(e, G[i]) {
            ans += e.cost;
        }
        assert(ans % 2 == 0);
        rep(i, n-1) ans += d[i];
        if (v0 >= 0) {
            auto r1 = dfs(v0, -1);
            auto r2 = dfs(r1.second, -1);
            ans -= r2.first;
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3348
N,M,X,Y = map(int, input().split())
xmax = max(map(int, input().split()))
ymin = min(map(int, input().split()))

if xmax >= ymin:
  print("War")
elif set(range(xmax+1, ymin+1)) & set(range(X+1, Y+1)) != set():
  print("No War")
else:
  print("War")

Measured memory_bytes: 3064
n, y = map(int, input().split())
x = 0
for i in range(n + 1):
  for j in range(n + 1 - i):
    if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
      print(i, j, (n - i - j))
      x = 1
      break
  if x == 1:
    break
else:
  print(-1, -1, -1)

Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

int N;
int id[1010][1010];
vvi A,G;
// G[t][_] = f := path from f to t

int getId(int i,int j) {
  if(i>j) {
    swap(i,j);
  }
  return id[i][j];
}
bool visited[501000];
bool calced[501000];
int dp[501000];

int dfs(int k) {
  if(visited[k]) {
    if(!calced[k]) return -1;
    return dp[k];
  }
  visited[k] = true;
  dp[k] = 1;
  rep(i,sz(G[k])) {
    int t = G[k][i];
    int res = dfs(t);
    if(res==-1) return -1;
    chmax(dp[k],res+1);
  }
  calced[k] = true;
  return dp[k];
}
  
int main() {
  cin >> N;
  A = vvi(N,vi(N-1));
  rep(i,N) {
    rep(j,N-1) {
      cin >> A[i][j];
      A[i][j]--;
    }
  }
  int c=0;
  rep(i,N) {
    rep(j,N) {
      if(i<j) {
        id[i][j] = c;
        c++;
      }
    }
  }
  G = vvi(c);
  rep(i,N) {
    rep(j,N-2) {
      G[getId(i,A[i][j+1])].push_back(getId(i,A[i][j]));
    }
  }
  int ans = 0;
  rep(i,c) {
    int res = dfs(i);
    if(res==-1) {
      cout << -1 << endl;
      return 0;
    }
    chmax(ans,res);
  }
  cout << ans << endl;
  return 0;
}

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

using vi = vector<int>;


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

  int ans = 0;

  for(int i=0; i<=9; i++){
    int xi = -1;
    for (int x=0; x<N; x++){
      if (S[x] == '0' + i) { xi = x; break;}
    } 
    if (xi == -1) continue;

    for(int j=0; j<=9; j++){
      int xj = -1;
      for (int x=xi+1; x<N; x++){
        if (S[x] == '0' + j) { xj = x; break;}
      }
      if (xj == -1) continue;

      for(int k=0; k<=9; k++){
        for (int x=xj+1; x<N; x++){
          if (S[x] == '0' + k) { ans++; break;}
        } 
      }
    }
  }

  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)




using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll Nmax=1e9;
const ll INF=1e9;

int main(){
  ll l,r;
  cin>>l>>r;
  if(r-l>2020){
    cout<<0<<endl;
    return 0;
  }

  ll ans=2019;

  for(ll i=l;i<=r;i++){
    for(ll j=l;j<i;j++){
      ans=min(ans,(i*j)%2019);
    }
  }
  cout<<ans<<endl;




}


Measured memory_bytes: 3624