akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <functional>
#include <cmath>
#define REP(i,n) for(lint i{}, i##_len=(n); i<i##_len; ++i)
#define DBLOOP(i, h, j, w) for(lint i{}; i < (lint)(h); ++i)for(lint j{}; j < (lint)(w); ++j)
#define DBLOOP2(i, j, n) for(lint i{}; i < (lint)(n - 1); ++i)for(lint j{i + 1}; j < (lint)(n); ++j)
#define SZ(x) ((lint)(x).size())
using lint = long long; lint N, M, H, W;
using Graph = std::vector<std::vector<lint>>;
using namespace std;
const long long INF{ 1LL << 60 };
const long long inf{ 1LL << 24 };
const long double PI{ 3.1415926535897932 };
const long long NUM97{ 1000000007 };
template<class T> inline bool chmax(T& x, T y) { if (x < y) { x = y; return 1; } return 0; }
template<class T> inline bool chmin(T& x, T y) { if (x > y) { x = y; return 1; } return 0; }
std::vector<std::string> field;
std::vector<std::vector<bool>> seen(H, std::vector<bool>(W));
const std::vector<int> dx{ 1, 0, -1, 0 };
const std::vector<int> dy{ 0, 1, 0, -1 };

int main() {
	std::string s, t; std::cin >> s >> t;
	std::sort(s.begin(), s.end());
	std::sort(t.begin(), t.end()); std::reverse(t.begin(), t.end());
	bool flag = false;
	for (int i = 0; i < std::min(s.size(), t.size()); ++i) {
		if (s[i] > t[i]) {
			std::cout << "No" << std::endl;
			return 0;
		}
		if (s[i] < t[i]) {
			flag = true;
			break;
		}
	}
	if (s.size() >= t.size() && flag == false) {
		std::cout << "No" << std::endl;
		return 0;
	}
	std::cout << "Yes" << std::endl;

	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int memo[100010];
int solve(int x){
  if(x == 0) return 0;
  if(memo[x]) return memo[x];

  int& res = memo[x];
  res = x;
  mini(res, 1 + solve(x-1));

  int s = 1;
  while(s <= x){
	mini(res, solve(x-s) + 1);
	s *= 6;
  }
  
  s = 1;
  while(s <= x){
	mini(res, solve(x-s) + 1);
	s *= 9;
  }
  return res;
}

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

  int C;
  cin >> C;
  cout << solve(C) << endl;

  return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string s,t;
  cin>>s>>t;
  bool diff;
  int ansi=-1;
  string ans="UNRESTORABLE";
  for(int i=s.size()-t.size();i>=0;i--){
      diff=false;
      for(int j=0;j<t.size();j++){
          if(s[i+j]=='?'||s[i+j]==t[j]){
            continue;
          }
          diff=true;
          break;
      }
      if(diff==true) continue;
      ansi=i;
      break;
  }
  if(ansi==-1){
      cout<<ans<<endl;
      return 0;
  }
  ans=s;
  for(int i=0;i<t.size();i++){
      if(ans[ansi+i]=='?') ans[ansi+i]=t[i];
  }
  for(int i=0;i<ans.size();i++){
      if(ans[i]=='?') ans[i]='a';
  }
  cout<<ans<<endl;
}

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

int main(){
  int N;
  cin >> N;
  int flag = 0;
  for(int i=0;i < 9;i++){
    if( N> i+i*10+i*100 && N<= i+i*10+i*100+111){
      flag = i+1;
    }
  }
  int a = flag * 111;
  cout << a;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
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>
#include<string>
using namespace std;

int main() {
	int N, M, i, a,b,c;
	int ans = 0;
	int *T;
	cin >> N;
	T = new int[N];
	for (i = 0; i < N; i++) cin >> T[i];
	cin >> M;
	for (i = 0; i < M; i++) {
		cin >> a >> b;
		c = T[a - 1];
		T[a - 1] = b;
		for (int n = 0; n < N; n++) ans += T[n];
		cout << ans << endl;
		ans = 0;
		T[a - 1] = c;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() { 
  string s, t;
  int move=0;
  cin>>s>>t;
  for(int i=0;i<s.size();i++) { 
    if(s[i]!=t[i]) move++;
   } cout<<move<<endl;
  return 0;
}


Measured memory_bytes: 3924
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
	int n;cin>>n;
	vector<int>w(n);
	rep(i,n)cin>>w[i];
	int ans=1e9;
	for(int i=1;i<n;i++){
		int l=0,r=0;
		for(int j=0;j<i;j++)l+=w[j];
		for(int j=i;j<n;j++)r+=w[j];
		ans=min(ans,abs(l-r));
	}
	cout<<ans<<endl;
}

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

using namespace std;

map <int, int> mp;

int main() {
    ios :: sync_with_stdio(0);
    cin.tie(nullptr);
    int k, s, nr = 0, sol = 0;

    cin >> k >> s;

    for(int x = 0; x <= k; ++x) {
        for(int y = 0; y <= k; ++y) {
            int z = s - x - y;
            if (z >= 0 && z <= k)
                ++sol;
        }
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int a, b, c;
  //string ;
  cin >> a >> b;

  int ans = 0;
  //string ans = "Yes";
  //string ans = "No";
  //string ans = "YES";
  //string ans = "NO";
  int cnt = 0;
  ans = max({a + b, a - b, a * b});

  cout << ans << endl;
}

Measured memory_bytes: 256
import           Data.Maybe
import           Data.List

main :: IO ()
main = do
    input <- getContents
    let [n, m] : list : _ = map read . words <$> lines input :: [[Int]]
    let f n = (n * (n - 1)) `div` 2
    ( putStrLn
        . show
        . sum
        . map f
        . map length
        . group
        . sort
        . map (`mod` m)
        . scanl (+) 0
        )
        list


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

int main() {
 int a,b,m;
  cin>>a>>b>>m;
  vector<int> s(a);
  vector<int> t(b);
  vector<vector<int>> u(m, vector<int>(3));
  for(int i=0;i<a;i++){
    cin>>s.at(i);
  }
  for(int i=0;i<b;i++){
    cin>>t.at(i);
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<3;j++){
      cin>>u.at(i).at(j);
    }
  }
  int x=1000000;
  for(int i=0;i<m;i++){
    x=min(s.at((u.at(i).at(0)-1))+t.at((u.at(i).at(1)-1))-u.at(i).at(2),x);
  }
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  int y=s.at(0)+t.at(0);
  cout<<min(x,y)<<endl;
}



Measured memory_bytes: 6528
using System;

public class AtCoder{
	public static void Main(){
		int n;
		n = int.Parse(Console.ReadLine().Trim());
		if (n==1) Console.WriteLine("Hello World");
		if (n==2){
			n = int.Parse(Console.ReadLine().Trim());
			n += int.Parse(Console.ReadLine().Trim());
			Console.WriteLine(n);
		}
	}
}


Measured memory_bytes: 11092
#include <stdio.h>

int main()
{
	int a,b;
	char op;
	scanf("%d %c %d", &a,&op,&b);

	if(op=='+')
		printf("%d\n", (a + b));
	else if(op=='-')
		printf("%d\n", (a-b));

	return 0;
}

Measured memory_bytes: 2116
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
#define newline std::cout<<'\n';
#define newlinedx(num) for(int i=0;i<num;i++)std::cout<<'\n';
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ui = uint64_t;

//----------------library in this time--------------------------------
template <class T>
T gcd(const T a,const T b) {
    return (b == 0) ? a : gcd (b, a % b);
}
template <class T>
T lcm(const T a, const T b) {
    return a * b / gcd(a,b);
}
template <class T>
inline T ave(const T a, const T b) {
    return (a + b) / 2.0f;
}

long long squareTwo(const long long a,const long long b) {
    return (b == 1) ? a : squareTwo(a * 2, b - 1);
}


//------------------------main function-------------------------------
void Main(){
    ll a , b;
    cin >> a >> b;
    if((a % 2 == 1 && b % 2 == 0) || (a%2==0&&b%2==1)){
        cout << "IMPOSSIBLE" << endl;
    }else{
        cout << (a+b) / 2 << endl;
    }
}

//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    
    Main();
    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;




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

    int k;
    cin>>k;
    string res ;
    for (int i=0; i<k; i++) {
	res += "ACL";
    }
    out(res);
    
    
    return 0;
}


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


typedef long long ll;

const int maxn=3010;

int a[maxn][maxn];
bool vis[maxn];
ll dp[3005][3005][4];

int main() 
{
    int n,m,k;
    cin>>n>>m>>k;
    
    for( int i=1;i<=k;i++ )
    {
    	int x,y,w;
    	cin>>x>>y>>w;
    	a[x][y]=w;
    }
    
    dp[1][1][1]=a[1][1];
    for( int i=1;i<=n;i++ )
    {
    	for( int j=1;j<=m;j++ )
    	{
    		if( i==1 && j==1 ) continue;
    		
    		ll maxup=max(dp[i-1][j][3],max(dp[i-1][j][2],max(dp[i-1][j][1],dp[i-1][j][0])));
    		dp[i][j][0]=max(maxup,dp[i-1][j][0]);
    		for( int k=1;k<=3;k++ )
    		{
    			dp[i][j][k]=max(dp[i][j-1][k-1]+a[i][j],dp[i][j-1][k]);
    		}
    		dp[i][j][1]=max(maxup+a[i][j],dp[i][j][1]);
    	}
    }
    ll ans=max(dp[n][m][0],max(dp[n][m][1],max(dp[n][m][2],dp[n][m][3])));
    cout<<ans<<endl;
}


Measured memory_bytes: 320524
'use strict'

/////////////////////////////////////
//コピペスペース//////////////////////

//定数
const INF  =  900719925474099 // Math.floor(Number.MAX_SAFE_INTEGER / 10);

//スペース区切りの数字列を数字の配列にして返す
function mapint(line){return line.split(' ').map((v)=>parseInt(v));}

function lower_bound(d,a,b,e){
    for(var c;1<b-a;)
        d[c=0|(a+b)/2]<e ? a=c : b=c;
    return d[a]<e?b:a
};

const MOD = 1000000007;
const N109 = 1000000000;

//コピペスペース//////////////////////
/////////////////////////////////////

function Main(input){
	let temp = input.trim().split('\n');
	let n = parseInt(temp[0]);
	let a = mapint(temp[1]);
	let b = mapint(temp[2]);

	let sum = 0;
	for(let i=0;i<n;i++){
		if(a[i] < b[i]){
			b[i] -= a[i];
			sum += a[i];
			if(a[i+1] < b[i]){
				sum+=a[i+1];
				a[i+1] = 0;
			}else{
				sum+=b[i];
				a[i+1] -= b[i];
			}
		}else{
			sum+=b[i];
		}
	}
	console.log(sum);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 31752
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define lld long long
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s; cin>>s;
    list<char> l;
    for(int i=0;i<s.length();++i)
    	l.push_back(s[i]);
    int cnt=0;
    int q;
    cin>>q;
    int flag=0;
    while(q--)
    {
    	int z; cin>>z;
    	if(z==1)
    	{
    		if(flag)flag=0;
    		else flag=1;
    	}
    	else
    	{
    		int x; cin>>x; char c; cin>>c;
    		if(x==1)
    		{
    			if(flag==0)l.push_front(c);
    			else l.push_back(c);
    		}
    		else
    		{
    			if(flag==0)l.push_back(c);
    			else l.push_front(c);
    		}
    	}
    }
    if(flag)l.reverse();
     list <char> :: iterator it; 
    for(it = l.begin(); it != l.end(); ++it) 
        cout<<*it; 

}

Measured memory_bytes: 10064
#include <iostream>
#include <cstdio>

using namespace std;

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

int count[1001][1001][3];
int m, n, o;
char maps[1000][1001];

int main() {
	char tmp[] = {'J', 'O', 'I'};
	cin >> m >> n >> o;
	REP(i, m) scanf("%s", maps[i]);

	REP(i, m) REP(j, n) {
		REP(k, 3) {
			count[i + 1][j + 1][k] = count[i + 1][j][k] + count[i][j + 1][k] - count[i][j][k];
			if (maps[i][j] == tmp[k]) count[i + 1][j + 1][k]++; 
		}
	}

	REP(i, o) {
		int a, b, c, d, ans[3];
		scanf("%d %d %d %d", &a, &b, &c, &d);
		REP(j, 3) {
			ans[j] = count[c][d][j] 
				- (a > 0 ? count[a-1][d][j] : 0)
				- (b > 0 ? count[c][b-1][j] : 0)
				+ (b > 0 && a > 0 ? count[a-1][b-1][j] : 0);
		}
		printf("%d %d %d\n", ans[0], ans[1], ans[2]);
	}
	return 0;
}

Measured memory_bytes: 13820
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n,k,s; cin >> n >> k >> s;
  vl num(n,s);
  
  if(s <= 1000000){
    rep(i,n-k){
      num[i] = 100000000;
    }
  }
  
  else{
    rep(i,n-k){
      num[i] = 1;
    }
  }
  
  for(ll x : num){
    cout << x << ' ' ;
  }
  
  cout << endl;
  
  
}

Measured memory_bytes: 4080
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <tuple>
using namespace std;

vector<tuple<string, int, int>> tup;
int N;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		string S1; int P1; cin >> S1 >> P1;
		tup.push_back(make_tuple(S1, -P1, i));
	}
	sort(tup.begin(), tup.end());
	for (int i = 0; i < N; i++) cout << get<2>(tup[i]) << endl;
	return 0;
}

Measured memory_bytes: 256
/*
      ___           ___                       ___     
     /\__\         /\  \                     /\  \    
    /:/ _/_       /::\  \       ___          \:\  \   
   /:/ /\__\     /:/\:\  \     /\__\          \:\  \  
  /:/ /:/  /    /:/  \:\  \   /:/__/      _____\:\  \ 
 /:/_/:/  /    /:/__/ \:\__\ /::\  \     /::::::::\__\
 \:\/:/  /     \:\  \ /:/  / \/\:\  \__  \:\~~\~~\/__/
  \::/__/       \:\  /:/  /   ~~\:\/\__\  \:\  \      
   \:\  \        \:\/:/  /       \::/  /   \:\  \     
    \:\__\        \::/  /        /:/  /     \:\__\    
     \/__/         \/__/         \/__/       \/__/    
                    ___                                
                   /|  |          _____                
      ___         |:|  |         /::\  \         ___   
     /\__\        |:|  |        /:/\:\  \       /|  |  
    /:/  /      __|:|__|       /:/  \:\__\     |:|  |  
   /:/__/      /::::\__\_____ /:/__/ \:|__|    |:|  |  
  /::\  \      ~~~~\::::/___/ \:\  \ /:/  /  __|:|__|  
 /:/\:\  \         |:|~~|      \:\  /:/  /  /::::\  \  
 \/__\:\  \        |:|  |       \:\/:/  /   ~~~~\:\  \ 
      \:\__\       |:|__|        \::/  /         \:\__\
       \/__/       |/__/          \/__/           \/__/

*/
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l) for(int i=r;i>=l;i--)
#define IMAX 0x3f3f3f3f
#define LLMAX 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef double db;
inline int read() {
  int x=0,f=1;
  char c=getchar();
  while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
  while(isdigit(c)){x=x*10+c-'0';c=getchar();}
  return x*f;
}
const int N=4100;
int n;
ll ans;
string s;
int tr[4][N];
void add(int pos, int x, int type){
  while(pos<=n){
    tr[type][pos]+=x;
    pos+=pos&-pos;
  }
}
int query(int pos, int type){
  int ans=0;
  while(pos){
    ans+=tr[type][pos];
    pos-=pos&-pos;
  }
  return ans;
}
signed main() {
  n=read();
  cin>>s;
  rep(i,0,n-1){
    // int now=i+1;
    if(s[i]=='R'){
      add(i+1,1,1);
    }else if(s[i]=='G'){
      add(i+1,1,2);
    }else{
      add(i+1,1,3);
    }
  }
  rep(i,0,n-1){
    rep(j,i+2,n-1){
      // int mid=0;
      char cant=' ';
      if((i+j)%2==0) cant=s[(i+j)/2];
      char l=s[i],r=s[j];
      if(l==r)continue;
      else{
        char tofind='R'+'G'+'B'-l-r;
        if(tofind==cant)ans--;
        if(tofind=='R'){
          ans+=query(j+1,1)-query(i,1);
        }else if(tofind=='G'){
          ans+=query(j+1,2)-query(i,2);
        }else{
          ans+=query(j+1,3)-query(i,3);
        }
        // printf("%lld\n",ans);
      }
    }
  }
 printf("%lld\n",ans);
 return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <cmath>

using namespace std;

#define MAX 7368791

int main(){
  int m, n;
  bool flag[MAX];

  while(cin >> m >> n, m||n){
    for(int i = 0 ; i <= MAX ; i++) flag[i] = false;
    for(int i = m ;; i++){
      if(!flag[i]){
    if(n == 0){
      cout << i << endl;
      break;
    }else{
      n--;
      for(int j = i ; j <= MAX ; j+=i){
        flag[j] = true;
      }
    }
      }
    }
  }
}


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

int main(){
    int i,j;
    char ope[100];
    int s[100];
    for(i=0;i<100;i++){
        s[i]=0;
    }
    i=0;

    while( scanf("%s", ope) != EOF ){
        if ( ope[0] == '+' ){
            s[i-2]=s[i-2]+s[i-1];
            i-=1;

        } else if ( ope[0] == '-' ){
            s[i-2]=s[i-2]-s[i-1];
            i-=1;

        } else if ( ope[0] == '*' ){
            s[i-2]=s[i-2]*s[i-1];
            i-=1;

        } else {
            s[i] = atoi(ope);
            i++;
        }

    }
    printf("%d\n",s[0]);
    return 0;
}



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

typedef long long ll;

ll solve(const int n, const vector<int> & in){
  ll lsum = 0, rsum = 0;
  priority_queue<int, vector<int>, greater<int> > lq;
  priority_queue<int> rq;

  for(int i = 0;i < n;i++){
    lq.push(in[i]);
    lsum += in[i];
  }
  for(int i = 2 * n;i < 3*n;i++){
    rq.push(in[i]);
    rsum += in[i];
  }
  ll ans = lsum - rsum;
  vector<ll> forward_sum(3*n, 0);
  vector<ll> backward_sum(3*n, 0);

  forward_sum[n-1] = lsum;
  for(int i = n;i < 2*n;i++){
    if (lq.top() < in[i]){
      lsum = lsum - lq.top() + in[i];
      lq.pop();
      lq.push(in[i]);
    }
    forward_sum[i] = lsum;
  }

  backward_sum[2*n] = rsum;
  for(int i = 2*n-1;i >= n;i--){
    if (rq.top() > in[i]){
      rsum = rsum - rq.top() + in[i];
      rq.pop();
      rq.push(in[i]);
    }
    backward_sum[i] = rsum;
  }


  for(int i = n-1;i < 2*n;i++){
    ans = max(ans, forward_sum[i] - backward_sum[i+1]);
  }
  return ans;
}


int main(){
  int n;
  cin >> n;
  vector<int> in(3*n);
  for(int i = 0;i <3* n;i++){
    cin >> in[i];
  }
  cout << solve(n, in) << endl;
  return 0;
}


Measured memory_bytes: 7032
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n;
   cin >> n;
   vector<int> a(n);
   rep(i, 0, n) cin >> a[i];
   deque<int> d;
   rep(i, 0, n) {
      int p = lower_bound(d.begin(), d.end(), a[i]) - d.begin();
      if (p == 0) {
         d.push_front(a[i]);
      } else {
         d[p - 1] = a[i];
      }
   }
   int ans = d.size();
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 4016
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    int n,m; cin >> n >> m;
    vector<bool> ok(n+1,1); REP(i,m){int a; cin >> a; ok[a]=0;}
    VI dp(n+1,0); dp[0]=1; if(ok[1]) dp[1]=1;
    FOR(i,2,n+1){
        if(ok[i-1]) dp[i] += dp[i-1];
        if(ok[i-2]) dp[i] += dp[i-2];
        dp[i] %= MOD;
    }
    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    vector<ll> AC(N);
    AC[0] = A[0];
    FOR(i, 1, N){
        AC[i] = AC[i-1] + A[i];
    }

    ll min_diff = abs(AC[N-2] - A[N-1]);
    FOR(i, 0, N-1){
        ll x = AC[i];
        ll y = AC[N-1] - AC[i];
        ll diff = abs(x-y);
        min_diff = min(min_diff, diff);
    }

    p(min_diff);
    
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,a,sum=0,ans=0;
  map<long long,int> m;
  cin>>n;
  m[0]++;
  for(int i=0;i<n;++i){
    cin>>a;
    sum+=a;
    ans+=m[sum];
    m[sum]++;
  }
  cout << ans << endl;
  return 0;
}

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

int A[10];
int fa[10]={1,1,2,6,24,120,720,5040,40320};

int DP[362880];
void swap(int i,int j){
  int t=A[i];
  A[i]=A[j];
  A[j]=t;
}

int F(){
  int ans=0,b=0;
  for(int i=8;i>=0;i--){
    ans+=__builtin_popcount(b&((1<<A[i])-1))*fa[8-i];
    b|=1<<A[i];
  }
  return ans;
}
void G(int n){
  int b=0;
  for(int i=0;i<9;i++)A[i]=i;
  for(int i=0;i<9;i++){
    int x=n/fa[8-i];
    n%=fa[8-i];
    for(int j=x;j>0;j--)swap(i+j,i+j-1);
  }
}

int que[363000],quecnt;
void ck(int p,int k){
  int x=F();
  if(!DP[x]){
    DP[x]=k+1;
    que[quecnt++]=x*10+p;
  }
}
int calc(){
  for(int i=0;i<quecnt;i++){
    int x=que[i]/10;
    int p=que[i]%10;
    if(x==0)return DP[x]-1;
    G(x);
    if(p<6)swap(p,p+3),ck(p+3,DP[x]),swap(p,p+3);
    if(p>2)swap(p,p-3),ck(p-3,DP[x]),swap(p,p-3);
    if(p%3<2)swap(p,p+1),ck(p+1,DP[x]),swap(p,p+1);
    if(p%3>0)swap(p,p-1),ck(p-1,DP[x]),swap(p,p-1);
  }
  return -1;
}

int main(){
  int p;
  for(int i=0;i<9;i++){
    int t;
    scanf("%d",&t);
    if(t)A[i]=t-1;
    else{
      A[i]=8;
      p=i;
    }
  }
  ck(p,0);
  printf("%d\n",calc());
}



Measured memory_bytes: 3892
#include <iostream>
#include <algorithm>

int main(void){
  int a[3];
  for(int i = 0; i < 3; i++)std::cin >> a[i];
  std::sort(a,a + 3);
  for(int i = 0; i < 2; i++)std::cout << a[i] << ' ';
  std::cout << a[2] << '\n';
  return 0;
}


Measured memory_bytes: 3160
#include <stdio.h>
#include <string.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))
#define max(X, Y) ((X) > (Y) ? (X) : (Y))
typedef long long ll;

ll ans;

ll n;
char dat[10005][15];

ll suf_a;
ll pre_b;
ll ab;

int main()
{
    scanf("%lld", &n);
    for (ll i = 0; i < n; i++) {
        scanf("%s", dat[i]);

        ll len = strlen(dat[i]);
        for (ll j = 0; j < len; j++) {
            if (dat[i][j] == 'A' && dat[i][j + 1] == 'B') {
                ans++;
            }
        }

        if (dat[i][0] != 'B' && dat[i][len - 1] == 'A') {
            suf_a++;
        }
        else if (dat[i][0] == 'B' && dat[i][len - 1] != 'A') {
            pre_b++;
        }
        else if (dat[i][0] == 'B' && dat[i][len - 1] == 'A') {
            ab++;
        }
    }

    ans += max(0, ab - 1);
    if (ab > 0 && pre_b > 0) {
        ans++;
        pre_b--;
    }
    if (ab > 0 && suf_a > 0) {
        ans++;
        suf_a--;
    }

    ans += min(suf_a, pre_b);
            
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: u32) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: i32 = read();
    let a = n / 25;
    let n = n % 25;
    let b = n / 10;
    let n = n % 10;
    let c = n / 5;
    let d = n % 5;

    println!("{}", a + b + c + d);
}



Measured memory_bytes: 5024
#include <iostream>
#include <cmath>

using namespace std;

bool calc(int a[], int b[], int d) {
  float t = 0;
  for(int di = 0;di<d;di++)
    t += pow(a[di] - b[di], 2.0);
  t = sqrt(t);
  return t == (int)t;
}

int main() {

int n, d, count = 0;
cin >> n >> d;
int points[n][d];

for(int i = 0;i<n;i++)
  for(int j = 0;j<d;j++)
    cin >> points[i][j];

for(int i = 0;i<n-1;i++)
  for(int j = 0;j<n;j++) {
    if (i>=j) continue;
    bool isInteger = calc(points[i], points[j], d);
    if (isInteger) {
      count++;
    }
  }

cout << count << endl;

return 0;
}

Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
ans = deque()
y = 0
while y < H:
  x = 0 if y % 2 == 0 else W-1
  dx = 1 if y % 2 == 0 else -1
  d = 0
  while dx > 0 and x < W-1 or dx < 0 and x > 0:
    if A[y][x] % 2 == 1:
      ans.append("%d %d %d %d"%(y+1, x+1, y+1, x+dx+1))
      A[y][x] -= 1
      A[y][x+dx] += 1
    x += dx
  if A[y][x] % 2 == 1 and y < H-1:
    ans.append("%d %d %d %d"%(y+1, x+1, y+2, x+1))
    A[y][x] -= 1
    A[y+1][x] += 1
  y += 1
print(len(ans))
print("\n".join(ans))

Measured memory_bytes: 91624
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a;
  string b; 
  cin >> a >> b;
  ll bb = (b[0] - '0') * 100;
  bb += (b[2] - '0') * 10;
  bb += (b[3] - '0');
  cout << a*bb/100 << endl;
  return 0;
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  string ans = "";
  int n = s.size();
  for (int i = 0; i < n; i++) {
    if(i % 2 == 0) {
      ans += s[i];
    }
  }
  cout << ans << endl;
  return 0;
}


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  int n,m;
  cin>>n;
  vector<string> s(n);
  r(i,n)cin>>s.at(i);
  cin>>m;
  vector<string> t(m);
  r(i,m)cin>>t.at(i);

  vector<int> cnt_s(n),cnt_t(m);

  r(i,n){
    r(j,n){

    if(s.at(i)==s.at(j))cnt_s.at(i)++;
    }
  }

  r(i,m){
    r(j,m){

    if(t.at(i)==t.at(j))cnt_t.at(i)++;
    }
  }
  
  int maxi=0;int cnt;
  r(i,n){
    cnt=0;
    r(j,m){
    if(s.at(i)==t.at(j)){maxi=max(maxi,cnt_s.at(i)-cnt_t.at(j));cnt++;}
    }
    if(cnt==0)maxi=max(maxi,cnt_s.at(i));
  }

  if(maxi<0)cout<<1<<endl;
  else cout<<maxi<<endl;




return 0;}


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

int n,k,cnt;
long long a[1010],s[1000010],book[1000010],sum[1010],ans;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",&a[i]);
		sum[i]=sum[i-1]+a[i];
	}	
	for(int i=1;i<=n;++i)
	{
		for(int j=i;j<=n;++j)
		s[++cnt]=sum[j]-sum[i-1];
	}
	for(long long i=60;i>=0;--i)
	{
		long long ji=(1ll<<i);
		int shu=0;
		for(int j=1;j<=cnt;++j)
		{
			if(book[j]==0)
			{
				if(s[j]&ji)
				++shu;
			}
		} 
		if(shu>=k)
		{			
			ans+=ji;
			for(int j=1;j<=cnt;++j)
			{
				if(book[j]==0&&(s[j]&ji)==0)
				book[j]=1;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10496
#include <iostream>
using namespace std;
int main() {
	long long int n,m,t;
	cin >> n >> m;
	long long int x = 0;
	long long int pt = -1;
	for (int i = 0; i < n; i++) {
		cin >> t;
		if (pt > -1) {
			if (t-pt < m) {
				x+=t-pt;
			}
			else {
				x+=m;
			}
		}
		else {
			x+=m;
		}
		pt = t;
	}
	cout << x;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int team=0,q,c,a,n;
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>c>>a>>n;
    while(true){
      if(c>=1 && a>=1 && n>=1){
	team++;
	c--;
	a--;
	n--;
      }
      else if(c>=2 && a>=1){
	team++;
	c-=2;
	a--;
      }
      else if(c>=3){
	team++;
	c-=3;
      }
      else{
	cout<<team<<'\n';
	team=0;
	break;
      }
    }
  }
  return(0);
}



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

using namespace std;

const int N = 100005;

int n; 
int ok = 1;
vector <int> g[N];
vector <int> child;

void dfs(int at, int par){
	int cnt = 0, ch = 0;
	for(auto u : g[at]){
		if(u == par) continue;
		if(g[u].size() > 1){
			dfs(u, at);
			++cnt;
		}
		++ch;
	}
	child.push_back(ch);
	ok &= (cnt <= 1);
}

pair <int, int> mx = {-1, 0};

void dfs0(int at, int par, int dep){
	mx = max(mx, {dep, at});
	for(auto u : g[at]){
		if(u == par) continue;
		dfs0(u, at, dep + 1);
	}
}

vector <int> ans;

void check(int S){
	ok = 1;
	child.clear();
	dfs(S, 0);
	reverse(child.begin(), child.end());
	if(!ok) return;
	vector <int> alt;
	int cur = 1;
	for(auto u : child){
		for(int i = cur + 1; i < cur + u; ++i){
			alt.push_back(i);
		}
		alt.push_back(cur);
		cur += u;
	}
	alt.push_back(n);
	if(ans.empty()) ans = alt;
	else ans = min(ans, alt);
}

int main(){
	int x, y;
	scanf("%d", &n);
	for(int i = 2; i <= n; ++i){
		scanf("%d %d", &x, &y);
		g[x].push_back(y);
		g[y].push_back(x);
	}

	dfs0(1, 0, 0);
	int a = mx.second;
	mx = {-1, 0};
	dfs0(a, 0, 0);
	int b = mx.second;

	check(a);
	check(b);
	if(!ans.empty()){
		for(auto u : ans) printf("%d ", u);
		printf("\n");
	}
	else printf("-1\n");
	return 0;
}


Measured memory_bytes: 13680
while n = gets.to_i
  break if n == 0
  arr = []
  arr << [0, 1000000001, -1]
  n.times do
    l = gets.split
    cmd = l.shift
    case cmd
    when "W"
      x, s = l.map(&:to_i)
      arr.size.times do |i|
        p, size, y = arr[i]
        if y == -1
          arr[i][2] = x
          if size <= s
            s -= size
          else
            arr[i][1] = s
            arr.insert(i + 1, [p + s, size - s, -1])
            break
          end
        end
      end
    when "D"
      x = l[0].to_i
      arr.size.times do |i|
        arr[i][2] = -1 if arr[i][2] == x
      end
    when "R"
      sec = l[0].to_i
      arr.size.times do |i|
        p, size, y = arr[i]
        if p <= sec && sec - p < size
          p y
          break
        end
      end
    end
  end
  puts
end

Measured memory_bytes: 8912
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}
void print(vector<int> v){rep(i,0,v.size()){if(i)cout<<" ";cout<<v[i];}cout<<endl;}

signed main (){
    int n;cin>>n;
    int ans=1;
    rep(i,1,n+1){
        ans*=i;
        ans%=1000000007;
    }
    cout<<ans<<endl;
    

    

    
}  
/*
0011
1210

0011001011
1210121210

11011010001011
12123232101012
*/


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int 
using namespace std;
int main(){
    ll n;
    ll a,b;
    cin>>n>>a>>b;
    if(a%n!=0&&b%n!=0 and a/n == b/n){
        cout<<"NG";
    }
    else{
        cout<<"OK";
    }
}


Measured memory_bytes: 3636
// #pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
// #pragma GCC target("popcnt")
// #include <bits/stdc++.h>
// #define maxn 400010
// #define ll long long
// #define ull unsigned long long
// #define ld long double
// #define fi first
// #define se second
// #define pb push_back
// #define eb emplace_back
// #define pob pop_back
// #define pf push_front
// #define pof pop_front
// #define pii pair<int, int>
// #define pil pair<int, ll>
// #define pll pair<ll, ll>
// #define IL inline
// #define ss system
// using namespace std;

// int n;
// char s[maxn];
// ll ans = 0;
// const ll p = 1e9 + 7;
// template <class T>
// void read(T &x)
// {
//     char ch = x = 0;
//     bool fl = false;
//     while (!isdigit(ch))
//         fl |= ch == '-', ch = getchar();
//     while (isdigit(ch))
//         x = x * 10 + ch - '0', ch = getchar();
//     x = fl ? -x : x;
// }
// ll pw(ll a, ll b)
// {
//     ll ret = 1;
//     while (b)
//     {
//         if (b & 1)
//             ret = ret * a % p;
//         a = a * a % p, b >>= 1;
//     }
//     return ret;
// }
// int main()
// {
//     cin >> s + 1, n = strlen(s + 1);
//     int cnt = 0;
//     for (int i = 1; i <= n; i++)
//     {
//         if (s[i] == '1')
//         {
//             ans = (ans + pw(2, cnt) * pw(3, n - i)) % p, cnt++;
//         }
//     }
//     ans = (ans + pw(2, cnt)) % p;
//     cout << ans << endl;
//     return 0;
// }
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
ll mod=1e9+7,dp[2][1<<17];
string s;
main()
{
    cin>>s;
    dp[0][0]=1;
    for(int i=0;i<s.size();i++)
    {
        for(int j=0;j<2;j++)
        {
            int lim=j?1:s[i]-'0';
            for(int k=0;k<=lim;k++)
            {
                (dp[j||k<lim][i+1]+=dp[j][i]*(k?2:1))%=mod;
            }
        }
    }
    printf("%d\n",(dp[0][s.size()]+dp[1][s.size()])%mod);
    return 0;
}

Measured memory_bytes: 2048
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    int N, K;
    cin >> N >> K;
    ll ans = 0;
    for (int k = K + 1; k <= N; k++) {
        ans += ((N + 1) / k) * (k - K);
        if (((N + 1) % k) - K > 0)
            ans += (N + 1) % k - K;
    }

    if (K == 0)
        ans -= N;

    cout << ans << endl;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
 
using namespace std;
 
typedef long long ll;
/*
 * ex.  s = "aaabaaaab"
 * -> z[i]= "*21034210"
 */
vector<int> Z_algorithm(const string &s){
    int sz=s.length();
    vector<int> z(sz,0);
    int i = 1, j = 0;
    while(i < sz) {
        while(i+j<sz && s[j]==s[i+j]) j++;
        z[i] = j;
        if(j==0){ i++; continue; }
        int k = 1;
        while(i+k<sz && k+z[k]<j){ z[i+k] = z[k]; k++; }
        i += k; j -= k;
    }
    return z;
}
 
vector<int> Z_algorithm2(const string &s){
    int sz = s.length();
    vector<int> z(sz);
    int l=0, r=0;
    for(int i=1;i<sz;i++){
        if(i>r){
            l = r = i;
            while(r<sz && s[r-l]==s[r]) r++;
            z[i]=r-l; r--;
        } else{
            int k=i-l;
            if(z[k]<r-i+1) z[i]=z[k];
            else{
                l=i;
                while(r<sz && s[r-l]==s[r]) r++;
                z[i]=r-l; r--;
            }
        }
    }
    return z;
}
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    string s,p; cin>>s>>p;
    int slen = s.length(),plen=p.length();
    string t = p + "$" + s;
    vector<int> z = Z_algorithm(t);
    for(int i=plen+1;i<plen+slen+1;i++){
        int idx=i-plen-1;
        if(z[i]==plen) cout<<idx<<endl;
    }
    /*
    string rs="";
    for(int i=0;i<sz;i++) rs += s[sz-i-1];
    vector<int> z = Z_algorithm2(s), rz = Z_algorithm2(rs);
    ll res=0;
    for(int i=sz/2+1;i<sz;i++){
        int a = min(sz-i-1,z[i]), c = min(sz-i-1,rz[sz-i]);
        res += max(0, a+c-(sz-i)+1);
    }
    cout<<res<<endl;
    */
}


Measured memory_bytes: 3240
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(M)]
AB.sort(key=lambda x:x[1])
last = -1
ans = 0
for a,b in AB:
    if a <= last < b: continue
    last = b-1
    ans += 1
print(ans)

Measured memory_bytes: 18228
#include <stdio.h>
#include <string.h>
#define MAX 200005

void putsinv(char s[], int n)
{
  while (n--) putchar(s[n]);
}

int main(void)
{
  char s[MAX];
  char u[MAX];
  char v[MAX];
  int q, d = 0, i, id = 0, idx = 0;
  
  scanf("%s%d", s, &q);
  
  while (q--) {
    int t;
    scanf("%d", &t);
    if (t == 1)
      d++;
    else {
      int f;
      char c, ch;
      scanf("%d%c%c", &f, &c, &ch);
      if ((d + f) % 2)
        u[id++] = ch;
      else
        v[idx++] = ch;
    }
  }
  
  u[id] = '\0';
  v[idx] = '\0';
  
  if (d % 2 == 0) {
    putsinv(u, id);
    printf("%s%s", s, v);
  } else {
    putsinv(v, idx);
    putsinv(s, strlen(s));
    printf("%s", u);
  }
  
  putchar('\n');
  
  return 0;
}

Measured memory_bytes: 768
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Scan()
	one := strings.Fields(sc.Text())
	N, _ := strconv.Atoi(one[0])
	K, _ := strconv.Atoi(one[1])
	okashis := []string{}
	for i := 1; i <= K; i++ {
		// d := nextInt()
		_ = nextInt()
		sc.Scan()
		A := strings.Fields(sc.Text())
		okashis = append(okashis, A...)
	}
	snukes := map[int]int{}
	for _, okashi := range okashis {
		i, _ := strconv.Atoi(okashi)
		snukes[i]++
	}
	ijime := 0
	for k := 1; k <= N; k++ {
		if snukes[k] == 0 {
			ijime++
		}
	}
	fmt.Print(ijime)
}

Measured memory_bytes: 2800
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("11009 11332");
            //4
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("31415 92653");
            //612
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int A = wkArr[0];
        int B = wkArr[1];

        int Answer = 0;
        for (int I = A; I <= B; I++) {
            string wkStr = I.ToString();
            IEnumerable<char> wkEnum = I.ToString().ToCharArray().Reverse();

            if (wkStr.ToCharArray().SequenceEqual(wkEnum)) {
                Answer++;
            }
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 17376
#include<iostream>

using namespace std;

int N;
int ans = 0;

void dfs(long long int x,int a, int b, int c) {
    if( x > N ) return ;
    if( a == 1 && b == 1 && c == 1) ans++;
    dfs(10 * x + 7, 1, b, c);
    dfs(10 * x + 5, a, 1, c);
    dfs(10 * x + 3, a, b, 1);
}

int main () {
    cin >> N;
    dfs(0,0,0,0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
using namespace std;
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int N;
long long W, weight[110], value[110];

long long dp[110][100100] = {0};

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; i++) cin >> weight[i] >> value[i];

    for (int i = 0; i < N; i++) {
        for (int sum_w = 0; sum_w <= W; sum_w++) {
            if (sum_w - weight[i] >= 0) {
                chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }

            chmax(dp[i + 1][sum_w], dp[i][sum_w]);
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}


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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int counter =0;
  
  for (int i = 0 ; i <= A ; ++i){
    for (int j = 0 ; j <= B ; ++j){
      for (int k = 0 ; k <= C ; ++k){
        if (500*i + 100*j + 50*k == X){
          ++counter;
        }
      }
    }
  }
  cout << counter << endl;
}

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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<int>>;

int main(){
  string T; cin >> T;

  int pd_count;

  for(int i=0;i<T.size();i++){
    if(T[i]=='?'){
      T[i]='D';
    }
  }
  cout << T;
  return 0;
}


Measured memory_bytes: 3756
#include<stdio.h>
#define N 20
#define Q 2000

int solve(int ,int ,int ,int [N],int);

int main(){
  int num,n[N],qu,q[Q],i,S[N];

  scanf("%d",&num);

  for(i=0;i<num;i++) scanf("%d",&n[i]);

  scanf("%d",&qu);

  for(i=0;i<qu;i++) scanf("%d",&q[i]);

  for(i=0;i<qu;i++){
    if(solve(0,q[i],num,n,0)==1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}


int solve(int i,int q,int num,int n[N],int res){
  if(q==0 || res==1) return 1;
  if(i>=num) return 0;
  res = solve(i+1,q,num,n,res);
  res = solve(i+1,q-n[i],num,n,res);
  return res;
}

Measured memory_bytes: 588
import sys
sys.setrecursionlimit(10**7)

def input(): return sys.stdin.readline()[:-1]
mod = 10**9 + 7
def readInt():return int(input())
def readIntList():return list(map(int,input().split()))
def readStringList():return list(input())
def readStringListWithSpace():return list(input().split())
def readString():return input()

n = readInt()
arr = readIntList()
if len(arr) < 3:
    print("0")
    exit()
arr.sort()
count = 0
for i in range(n):
    for j in range(i+1,n):
        if arr[i] == arr[j]:
            continue
        for k in range(j+1,n):
            if arr[i] == arr[k] or arr[j] == arr[k]:
                continue
            if arr[i] + arr[j] > arr[k]:
                count += 1
print(count)

Measured memory_bytes: 9244