akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <stdlib.h> //rand() 0~RAND_MAX2147483647
#include <math.h>
#include <time.h>   //srand((unsigned int)time(NULL));
#include <unistd.h> //sleep
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <set>
#include <cassert> //assart
#include <numeric>
#include <iterator>
#include <list>

using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
#define FORREVeq(i,max,min) for(int i=(max);i>=(min);i--)
const int MOD=1e9+7;
const int MOD2=998244353;

const int INF=2000000001;
const ll INFll=2e18;
//const int MAX_V=10000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INFll || MOD2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}
#define elif else if

#define issame(a,b,c,d) ((a)==(b) and (b)==(c) and (c)==(d))
#define isdiff3(a,b,c) ((a)!=(b) and (b)!=(c) and (c)!=(a))
#define isdiff4(a,b,c,d) ((a)!=(b) and (b)!=(c) and (c)!=(a) and (d)!=(a) and (d)!=(b) and (d)!=(c))
inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
inline ll  gcd(ll a,ll b){ if(b==0)return a;else return gcd(b,a%b);}//最大公約数 なお一方が0なら答えは他方になるので番兵は０で良い また、負の数もOK -4%3=-1となるため
inline ll  lcm(ll a,ll b){return a*b/gcd(a,b);}//MODやオーバーフローには注意！



//Eと名のつくのはデバッグ用！
int EintN(ll array[],const int num){
    for(int i=0;i<num;i++){cerr<<array[i]<<" ";}
    br;
    return 0;
}
int EintNN(const int heighth,const int width,int array[heighth][width]){
    FOR(i, 0, heighth){
        FOR(k, 0, width){
            {cerr<<array[i][k]<<" ";}
        }
        br;
    }
    br;
    return 0;
}
int Eint(string str,const ll num){
    cerr<<str<<" is "<<num<<" now."<<endl;
    return 0;
}


int Ap(){
    int a;a=0;
    string s;
    cin>>a>>s;
    if(a>=3200){OutputAndReturn0(s);}
    OutputAndReturn0("red");
    return 0;
}

ll Bp(){
    ll ans;ans=0;
    
    return 0;
}

int Cp(){
    int ans;ans=0;
    
    return 0;
}

int Dp(){
    long long int N=0;
    
    OutputAndReturn0(N);
    return 0;
}

signed main(){
    //test();
    Ap();
    //Bp();
    //Cp();
    //Dp();
    return 0;
}


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

int main(void) {
	// your code goes here
	char s[11];
	int flagc=0,i;
	cin >> s;
	if(s[0]!='A') {
		cout << "WA" << endl;
		return 0;
	}
	for(i=2;i<strlen(s)-1;i++) {
		if(s[i]=='C') {
			flagc++;
			s[i]='c';
		}
	}
	if(flagc!=1) {
		cout << "WA" << endl;
		return 0;
	}
	for(i=1;i<strlen(s);i++){
		if('a'-s[i]>0) {
			cout << "WA" << endl;
			return 0;
		}
	}
	cout << "AC" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int X;
    cin >>X;
    for(int i=0;i<=1000;i++){
        if(i*100<=X&&X<=i*105){
            cout <<1<<endl;
            return 0;
        }
    }
  cout <<0<<endl;
}

Measured memory_bytes: 3640
N=int(input())
cards=list(map(int,input().split()))
cards.sort(reverse=True)

Alice_score=0
Bob_score=0

isAliceTurn=True
for i in range(N):
    if(isAliceTurn):
        Alice_score+=cards.pop(0)
    else:
        Bob_score+=cards.pop(0)
    isAliceTurn = not isAliceTurn

print(Alice_score-Bob_score)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define clear(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


class BipatiteGraph
{
	vector<bool> used;

	bool _dfs(int v)
	{
		used[v] = true;
		for (int i = 0; i < edges[v].size(); ++i)
		{
			int u = edges[v][i];
			int m = match[u];
			if (m < 0 || !used[m] && _dfs(m))
			{
				match[v] = u;
				match[u] = v;
				return true;
			}
		}
		return false;
	}

public:
	int vertices;
	vector<vector<int> > edges;
	vector<int> match;

	BipatiteGraph(int n)
		: vertices(n), edges(n), match(n), used(n)
	{
	}

	void add_edge(int a, int b)
	{
		edges[a].push_back(b);
		edges[b].push_back(a);
	}

	bool dfs(int v)
	{
		fill(used.begin(), used.end(), false);
		return _dfs(v);
	}

	int matching()
	{
		fill(match.begin(), match.end(), -1);
		int res = 0;
		for (int i = 0; i < vertices; ++i)
		{
			if (match[i] < 0)
			{
				if (dfs(i))
					++res;
			}
		}
		return res;
	}
};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main()
{
	int m, n, b[512], r[512];
	while (scanf("%d%d", &m, &n), m)
	{
		for (int i = 0; i < m; ++i)
			scanf("%d", b + i);
		for (int i = 0; i < n; ++i)
			scanf("%d", r + i);

		BipatiteGraph bg(m + n);
		for (int i = 0; i < m; ++i)
			for (int j = 0; j < n; ++j)
				if (gcd(b[i], r[j]) != 1)
					bg.add_edge(i, m + j);
		printf("%d\n", bg.matching());
	}
}

Measured memory_bytes: 0
def main():
    N = input().strip()
    all_nine = True
    for i in range(1, len(N)):
        if N[i] != "9":
            all_nine = False
    ans = int(N[0]) + 9 * (len(N) - 1)
    if all_nine:
        print(ans)
    else:
        print(ans - 1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		scan.close();
		int check=0;
		if(s.charAt(0)=='A') {
			for(int i=1;i<s.length();i++) {
				if(s.charAt(i)=='C') {
					if(2<=i&&i<s.length()-1)check+=1;
				}else if(s.charAt(i)<'a') {
					check=-1;
					break;
				}
			}
		}
		if(check==1)System.out.println("AC");
		else System.out.println("WA");
	}
}


Measured memory_bytes: 23252
#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 all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbgvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	string S; cin >> S;
	int N = S.size();
	int re = 0, ro = 0, le = 0, lo = 0;
	vi Re(N), Ro(N), Le(N), Lo(N);
	rep(i, N) {
		if (S.at(i) == 'R') {			
			if (i % 2 == 0) {
				re++;
			} else if (i % 2 == 1) {
				ro++;
			}
		} else if (S.at(i) == 'L') {
			Re.at(i) = re;
			re = 0;
			Ro.at(i) = ro;
			ro = 0;
		}
	}
	for (int i = N - 1; i >= 0; i--) {
		if (S.at(i) == 'L') {
			if (i % 2 == 0) {
				le++;
			} else {
				lo++;
			} 
		} else {
			Le.at(i) = le;
			le = 0;
			Lo.at(i) = lo;
			lo = 0;
		}
	}
	dbv(Re); dbv(Ro); dbv(Le); dbv(Lo);
	vi a(N);
	rep(i, N) {
		if (i % 2 == 0) {
			a.at(i) += Re.at(i);
			a.at(i) += Le.at(i);
			if (i > 0) a.at(i - 1) += Ro.at(i);
			if (i < N - 1) a.at(i + 1) += Lo.at(i);			
		} else if (i % 2 == 1) {
			a.at(i) += Ro.at(i);
			a.at(i) += Lo.at(i);
			if (i > 0) a.at(i - 1) += Re.at(i);
			if (i < N - 1) a.at(i + 1) += Le.at(i);
		}
	}
	dbv(a);
	rep(i, N) {
		if(i) cout << " ";
		cout << a.at(i);
	}
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef long long ll;
typedef pair<ll,ll> pint;
int main(){
    ll n;cin>>n;
    vector<int> a(n);rep(i,n)cin>>a[i];
    vector<pint> ans(n-1);
    ll res;
    sort(a.begin(),a.end());
    if(n==2){
        cout<<a[1]-a[0]<<endl;
        cout<<a[1]<<" "<<a[0]<<endl;
    }
    else{
        int jud=lower_bound(a.begin(),a.end(),0)-a.begin();
        //cout<<jud<<endl;
        if(jud==0){
            res=a[0]-a[1];
            ans[0]={a[0],a[1]};
            int cnt=1;
            if(3<n){
                REP(i,2,n-1){
                    ans[cnt]={res,a[i]};
                    res-=a[i];
                    cnt++;
                }
            }
            ans[n-2]={a[n-1],res};
            res=a[n-1]-res;
        }
        else if(jud==n){
            res=a[n-1]-a[0];
            ans[0]={a[n-1],a[0]};
            int cnt=1;
            REP(i,1,n-1){
                ans[cnt]={res,a[i]};
                res-=a[i];
                cnt++;
            }
        }
        else if(0<jud<n){
            if(jud<n-1){
                res=a[0]-a[jud];
                ans[0]={a[0],a[jud]};
                int cnt=1;
                REP(i,jud+1,n-1){
                    ans[cnt]={res,a[i]};
                    res-=a[i];
                    cnt++;
                }
                ans[cnt]={a[n-1],res};
                res=a[n-1]-res;
                cnt++;
                for(int i=jud-1;0<i;i--){
                    ans[cnt]={res,a[i]};
                    res-=a[i];
                    cnt++;
                }
            }
            else{
                res=a[jud]-a[0];
                ans[0]={a[jud],a[0]};
                int cnt=1;
                for(int i=jud-1;0<i;i--){
                    ans[cnt]={res,a[i]};
                    res-=a[i];
                    cnt++;
            }
        }
        }
        cout<<res<<endl;
        rep(i,n-1){
            cout<<ans[i].first<<" "<<ans[i].second<<endl;
        }
}
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(int i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

int main(void){
  int N;cin >> N;
  ll a[N];
  REP(i,N) cin >> a[i];

  //区間dp
  //dp[l][r]:[l,r)のスライムを全て合体させる，コストの最小
  ll dp[N+1][N+1];
  REP(l,N+1)REP(r,N+1) dp[l][r] = MAX_LL;
  ll s[N+1];
  s[0] = 0;
  REP(i,N){
    s[i+1] = s[i] + a[i];
    dp[i][i+1] = 0;
  }

  for(int section=2; section<=N; section++){
    REP(l,N+1-section){
      int r = l+section;
      for(int k = l+1;k<r;k++){
        dp[l][r] = min(dp[l][r],dp[l][k]+dp[k][r]+s[r]-s[l]);
      }
    }
  }
  cout << dp[0][N] << endl;
  return 0;
}


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

ll solve (string S) {
  int res = 0, i = 0, j = S.size()-1;
  while (i<j) {
    if (S[i]==S[j]) i++, j--;
    else if (S[i]=='x') res++, i++;
    else if (S[j]=='x') res++, j--;
    else return -1;
  }
  return res;
}

int main() {
  string s;
  while (cin >> s) cout << solve(s) << endl;  
}

Measured memory_bytes: 512
n,m=map(int,input().split())
dp=[0 for i in range(n+1)]
dp[0]=1
for i in range(m):
    dp[int(input())]="b"
for i in range(1,n+1):
    if(dp[i]=="b"):
        dp[i]=0
    else:
        dp[i]=dp[i-1]+dp[i-2]
print(dp[n]%1000000007)

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

using namespace std;

template <typename T, T MOD_>
class ModInt {
public:
	ModInt() = default;
	ModInt(T num)
		: num_(num)
	{ }

	const ModInt &operator=(T num) {
		num_ = num % MOD_;
		return *this;
	}
	ModInt operator+(T num) {
		return ModInt((num_ + num) % MOD_);
	}
	ModInt operator-(T num) {
		return ModInt((num_ + MOD_ - num) % MOD_);
	}
	ModInt operator*(T num) {
		return ModInt((num_ * (num % MOD_)) % MOD_);
	}
	ModInt operator/(T num) {
		const auto inv = inverse(num);
		return ModInt((num_ * inv) % MOD_);
	}
	const ModInt &operator+=(T num) {
		num_ = (*this + num).num_;
		return *this;
	}
	const ModInt &operator-=(T num) {
		num_ = (*this - num).num_;
		return *this;
	}
	const ModInt &operator*=(T num) {
		num_ = (*this * num).num_;
		return *this;
	}
	const ModInt &operator/=(T num) {
		num_ = (*this / num).num_;
		return *this;
	}
	bool operator==(T num) {
		return num_ == num;
	}

	friend std::ostream &operator<<(std::ostream &os, const ModInt &modint) {
		os << modint.num_;
		return os;
	}

	T num() const {
		return num_;
	}

private:
	T inverse(T num) const {
		return modpow(num, MOD_ - 2);
	}
	T modpow(T num, T n) const {
		T result = 1;
		while(n > 0) {
			if(n & 1) {
				result = result * num % MOD_;
			}
			num = num * num % MOD_;
			n >>= 1;
		}
		return result;
	}


	T num_;
};

const int MOD = 1'000'000'007;
using Mod = ModInt<long long, MOD>;

int main() {
	Mod mod = 1237;
	for(int i = MOD - 100000; i <= MOD - 1; i++) {
		const auto before = mod.num();
		mod *= i;
		mod /= i;
		const auto after = mod.num();
		if(before != after) {
			cout << i << endl;
		}
	}

	int X, Y;
	cin >> X >> Y;

	if((X + Y) % 3 != 0
		|| X * 2 < Y
		|| Y * 2 < X) {
		cout << 0 << endl;
		return 0;
	}

	// 移動回数
	const int n = (X + Y) / 3;
	// 右の方に跳ぶ回数
	const int right = X - n;

	Mod result = 1;
	const int t = max(right, n - right);
	for(int i = 0; i < t; i++) {
		result *= (n - i);
	}
	for(int i = 0; i < t; i++) {
		result /= (i + 1);
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1000000007;
signed main() { int n, ok = 0, ans = 1; string s, t; cin >> n >> s >> t;
	for (int h = 0; h < n; h++) {
		if (s[h] == t[h]) { if (ok == 0) { ans *= 3; } if (ok == 1) { ans *= 2; } ok = 1; }
		else { if (ok == 0) { ans *= 6; } if (ok == 1) { ans *= 2; } if (ok == 2) { ans *= 3; } ok = 2; h++;} ans %= mod; } cout << ans % mod << endl; return 0;
}

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

typedef long long LL;

int x,y;

void into(){
  scanf("%d%d",&x,&y);
}

void work(){
}

void outo(){
  printf("%d\n",(x<=3?(4-x)*100000:0)+(y<=3?(4-y)*100000:0)+(x==1&&y==1)*400000);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	
	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}
	
	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	
	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}
	
	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main (void)
{
	//INPUT
	llint N,M;
	cin >> N;
  
  	rep(i,1,10) {
      rep(j,1,10) {
        if (N== i*j) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  	cout << "No" << endl;
	return 0;
}






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

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

  vector<int> p(N);
  rep( i, 0, N ) cin >> p.at(i);

  int Count = 0;
  rep( i, 0, N ) {
    if ( p.at(i) != i+1 ) Count++;
  }
  cout << ( Count <= 2 ? "YES" : "NO" ) << endl;
}


Measured memory_bytes: 384
#include <cstdio>
using namespace std;

int main() {
    int n, m, k, t;
    scanf("%d %d", &n, &m);
    int a[m] = {};
    for (int i = 0; i < n; i++) {
        scanf(" %d", &k);
        for (int j = 0; j < k; j++) {
            scanf(" %d", &t);
            a[t-1]++;
        }
    }
    int c = 0;
    for (int i = 0; i < m; i++) {
        if (a[i]==n) c++;
    }
    printf("%d\n", c);
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString.Lazy.Builder as BLB
import Data.List
import Data.Char

main = do
  [n, k] <- (map read) <$> words <$> getLine
  s <- getLine
  putStrLn $ solve k 1 s


solve :: Int -> Int -> String -> String
solve _ _ [] = []
solve k i (c:cs)
  | k == i = toLower c : cs
  | otherwise = c:(solve k (i+1) cs)

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

int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int yen = a * x + b * y;
    rep(i, 100000){
        yen = min(yen, 2 * i * c + max(x-i, 0) * a + max(y-i, 0) * b);
    }
    cout << yen << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var k = ReadLineInt();
            var a = ReadLineIntSpilit();

            if(a[0] % k == 0 || a[1] % k == 0) {
                Console.WriteLine("OK");
                return;
            }

            for(int i = a[0]; i < a[1]; i++) {
                if(i % k == 0) {
                    Console.WriteLine("OK");
                    return;
                }
            }

            Console.WriteLine("NG");
        }

        //最大公約数
        static int gcd(int a, int b)
        {
            if (a > b) {
                return gcd(b, a);
            }

            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }

        //最小公倍数
        static int lcm(int a, int b) => a * b / gcd(a, b);

        /// <summary>
        /// コンビネーション
        /// </summary>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        public static string ReadLine() => Console.ReadLine();
        public static int ReadLineInt() => int.Parse(Console.ReadLine());
        public static long ReadLineLongInt() => long.Parse(Console.ReadLine());
        public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray();
        public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        public static long[] ReadLineLongSpilit(char a = ' ') => ReadLine().Split(a).Select(x => long.Parse(x)).ToArray();
        static string[] GetAplhaLowerArray() => new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}


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

int main(){
    int n;
    scanf("%d",&n);
    int p[10],q[10],t[10];
    for(int i = 1;i <= n;i++)
    	scanf("%d",&p[i]);
    for(int i = 1;i <= n;i++)
    	scanf("%d",&q[i]);
    for(int i = 1;i <= n;i++){
    	t[i] = i;
	}
    int cnt = 0;
    int cnt1 = 0,cnt2 = 0;
    while(next_permutation(t+1,t+1+n)){
    	cnt++;
    	int fl1 = 0,fl2 = 0;
    	for(int i = 1;i <= n;i++){
    		if(t[i] != p[i]) fl1 = 1;
    		if(t[i] != q[i]) fl2 = 1;
    		if(fl1 && fl2) break;
		}
		if(!fl1) cnt1 = cnt;
		if(!fl2) cnt2 = cnt;
		if(cnt1 && cnt2) break;
	}
	cout << abs(cnt1 - cnt2) << endl;
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned int
#define ull unsigned long long
#define inf 1010000000
#define infll 1010000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
#define cbn(x,y) ((ll)fac[x]*inv[y]%mod*inv[(x)-(y)]%mod)
using namespace std;

int read(); ll readll();

int n,a[29][29];
ll gcd(ll x,ll y){
	return y?gcd(y,x%y):x;	
}
int main(){
	scanf("%d",&n);
	int i,j,k,l;
	for (i=1; i<=n; i++){
		double x;
		scanf("%lf",&x);
		ll u=round(x*1e9),v=1000000000;
		ll w=gcd(u,v); u/=w; v/=w;
		int t2=10,t5=10;
		for (; u%2==0; u/=2) t2++; for (; v%2==0; v/=2) t2--;
		for (; u%5==0; u/=5) t5++; for (; v%5==0; v/=5) t5--;
		dn(t2,28); dn(t5,28);
		a[t2][t5]++;
	}
	ll ans=0;
	for (i=0; i<29; i++)
		for (j=0; j<29; j++){
			if (i+i>=20 && j+j>=20) ans-=a[i][j];
			for (k=0; k<29; k++)
				for (l=0; l<29; l++) if (i+k>=20 && j+l>=20) ans+=(ll)a[i][j]*a[k][l];
		}
	printf("%lld\n",ans/2);
	return 0;	
}
int read(){
	int x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
ll readll(){
	ll x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}


Measured memory_bytes: 3816
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
 
int main() {
  vector<char> a(3);
  for(i,0,3)
    ci(a[i]);
  sort(a.begin(),a.end());
  if(a[0]=='a'&&a[1]=='b'&&a[2]=='c')
    co("Yes");
  else
    co("No");
  }

Measured memory_bytes: 256
lis = []
for _ in range(3):
    lis.append(list(map(int, input().split())))

flag1 = 0
flag2 = 0
for a1 in range(101):
    b1 = lis[0][0] - a1
    b2 = lis[0][1] - a1
    b3 = lis[0][2] - a1
    
    for a2 in range(101):
        if a2 + b1 == lis[1][0] and a2 + b2 == lis[1][1] and a2 + b3 == lis[1][2]:
            flag1 = 1
            break
        else:
            flag1 = 0
            
    for a3 in range(101):
        if a3 + b1 == lis[2][0] and a3 + b2 == lis[2][1] and a3 + b3 == lis[2][2]:
            flag2 = 1
            break
        else:
            flag2 = 0
            
    if flag1 == 1 and flag2 ==1:
        print("Yes")
        exit()

print("No")

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

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

signed main() {
  int n;
  cin >> n;
  int even = n / 2;
  int odd = n / 2 + n % 2;
  cout << even * odd << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;



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

if(a+b+c>=22)
    cout<<"bust"<<endl;
else
    cout<<"win"<<endl;

 return 0;
}


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

using namespace std;

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

    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    cout << (m1 != m2) << "\n";
    return 0;
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n = int(input())
l = [list(map(str,input().split())) for i in range(n)]

ans = 0

for i in range(n):
    if l[i][1] == "JPY":
        ans += int(l[i][0])
    else:
        ans += float(l[i][0])*380000.0
print(ans)





Measured memory_bytes: 9040
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int main()
{
    int w,h,n;
    cin >> w >>h >> n;
    vector<P> spot(n);
    rep(i,n){
        cin >> spot[i].first >> spot[i].second;


    }
    int ans = 0;
    rep(i,n-1){
        int x1 = spot[i].first,y1 = spot[i].second;
        int x2 = spot[i+1].first,y2 = spot[i+1].second;
        
        if(x1 < x2 && y1 < y2 && y2-y1 == x2-x1)ans += y2-y1;
        else if(x1 < x2 && y1 < y2 ){
            if(x2-x1 < y2- y1){
                ans += x2-x1;
                y1 += x2-x1;
                ans += y2-y1;

            }
            else{
                ans += y2-y1;
                x1 += y2-y1;
                ans += x2-x1;


            }

        }
        else if(x1 > x2 && y1 > y2 &&y2-y1 == x2-x1)ans += x1- x2;
        else if(x1 > x2 && y1 > y2){
            if(x1-x2 < y1- y2){
                ans += x1-x2;
                y2 += x1-x2;
                ans += y1-y2;

            }
            else{
                ans += y1-y2;
                x2 += y1-y2;
                ans += x1-x2;


            }

        }

    
        else {
            ans += abs(x2-x1)+abs(y2-y1);
        }

    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3092
def main():
    A,B,C,K  = map(int, input().split()) 
    sums = 0

    if A<K:
        sums += A
        K = K-A
    else:
        sums=K
        print(sums)
        return
    if B<K:
        K = K-B
    else:
        print(sums)
        return
    if C<K:
        sums -=C
        print(sums)
        return
    else:
        sums -=K
        print(sums)
        return


if __name__ == '__main__':
    main()

Measured memory_bytes: 9136
#include  <iostream>
#include  <stdio.h>
using namespace std;
void QSort(int x[ ], int left, int right);
void Swap(int x[ ], int i, int j);

void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (x[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */

        Swap(x, i, j);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }
    //ShowData(x, 10);               /* 途中経過を表示 */

    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, j + 1, right);    /* 右の配列を Q ソートする */
}

  /* 配列の要素を交換する */
void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

int min(int a,int b)
{
    int ans;
    ans = a;
    if(b < a){
        ans = b;
    }
    return b;

}

int main(){

    int N;
    int M;

    cin >> N;
    int A[N]; 
    //10^5 100000
    for(int i = 0 ;i < N;i++){
        cin >> A[i];
    }

    QSort(A, 0, N-1);

    int d;
    int mod;
    int tmp;
    d = A[0];
    for(int i = 1; i < N ; i++  ){
        tmp = A[i];
        do
        {
            mod = tmp % d;
            if(mod != 0)
            {
                tmp = d;
                d   = mod;
            }
        }while( mod != 0);
    }
    cout << d;

}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  i64 H, W, N; cin >> H >> W >> N;
  i64 ans = (H - 2) * (W - 2);
  set<pair<int, int>> ma;
  rep(i, N) {
    int a, b; cin >> a >> b;
    a--, b--;
    ma.insert(make_pair(a, b));
  }
  vector<i64> cnt(10);
  set<pair<int, int>> se;
  each(m, ma) {
    for (int i = -2; i <= 0; i++)
    for (int j = -2; j <= 0; j++) {
      int x = m.first + i, y = m.second + j;
      if (x < 0 || x >= H - 2 || y < 0 || y >= W - 2) continue;
      if (se.count(make_pair(x, y)) > 0) continue;
      se.insert(make_pair(x, y));
      int c = 0;
      for (int k = 0; k <= 2; k++)
      for (int l = 0; l <= 2; l++) {
        if (ma.count(make_pair(x + k, y + l))) c++;
      }
      cnt[c]++;
      ans--;
    }
  }
  cnt[0] = ans;
  rep(i, 10) cout << cnt[i] << '\n';
}


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

using namespace std;

int main()
{
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    long double percent = -1;
    int waterMass = 0;
    int sugarMass = 0;
    for (int i = 0; 100 * i * a <= f; i++)
    {
        for (int j = 0; 100 * a * i + 100 * b * j <= f; j++)
        {
            int water = 100 * a * i + 100 * b * j;
            int target = min(water / 100 * e, f - water);
            for (int k = 0; c * k <= target; k++)
            {
                int sugar = k * c + (target - k * c) / d * d;
                if ((long double) sugar / (sugar + water) > percent)
                {
                    percent = (long double) sugar / (sugar + water);
                    waterMass = water;
                    sugarMass = sugar;
                }
            }
        }
    }
    cout << sugarMass + waterMass << " " << sugarMass << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;


ll lcm(ll a,ll b)
{
    return(a*b/__gcd(a,b));
}
int main()
{

ll a,b;
cin>>a>>b;

cout<<lcm(a,b)<<endl;

 return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

int bio[N][3];
vector<int> g[N];

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  for (int u, v, i = 0; i < m; ++i) {
    scanf("%d%d", &u, &v);
    g[--u].push_back(--v);
  }
  int s, t; scanf("%d%d", &s, &t);
  --s, --t;
  queue<pair<int, int>> qq;
  qq.emplace(s, 0);
  bio[s][0] = 1;
  while (qq.size()) {
    int u = qq.front().first, d = qq.front().second; qq.pop();
    if (u == t && d % 3 == 0) {
      printf("%d", d/3);
      return;
    }
    int x = (d+1)%3;
    for (int v: g[u]) {
      if (bio[v][x]) continue;
      qq.emplace(v, d+1);
      bio[v][x] = 1;
    }
  }
  printf("-1");
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 10408
from itertools import permutations

n, c = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(c)]
cmat = [list(map(int, input().split())) for _ in range(n)]

dcnt = [[0] * c for _ in range(3)]
for i, ci in enumerate(cmat):
    for j, cij in enumerate(ci):
        mod = (i + j) % 3
        dcnt[mod][cij - 1] += 1

ans = 10 ** 9
for color in permutations(range(c), 3):
    tmp = 0
    for tgt, cnt in zip(color, dcnt):
        tmp += sum(d[i][tgt] * cnt[i] for i in range(c))
    ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 76648
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
int n,m;
queue <vector<int>> kyu;
void dfs(vector<int> a,int size){
    if(size==n){
        kyu.push(a);
        //出来た配列をキューにぶち込む（配列の保存方法がこれしか思いつかん)
        //参考：パナソニックコンテストDS
        return ;
    }
    for(int i=a[size-1];i<=m;i++){
        a.push_back(i);
        dfs(a,size+1);
        a.erase(a.end()-1);
    }
}
int main(){
    int q;
    cin>>n>>m>>q;
    vector<int> a(q),b(q),c(q),d(q);
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--,b[i]--;
    }
    vector<int> A;
    for(int i=1;i<=m;i++){
        A.push_back(i);
        dfs(A,1);
        A.erase(A.end()-1);
    }
    //A.push_back(1);
    //dfs(A,1);
    int ans=0;
    while(!kyu.empty()){
        //cout<<q.front()<<endl;
        vector<int> k = kyu.front();
        int score=0;
        rep(i,q){
            if(k[b[i]]-k[a[i]]==c[i]){
                score += d[i];
            }
        }
        if(score >= ans){
            ans = score;
        }
        /*
        rep(i,n){
            cout<<k[i]<<" ";
        }
        cout<<endl;
        */
        kyu.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 10148
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define irep(i,a)for(int i=1;i<=a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
int t[10][10];


bool che(int a,int b,int c){
	int t1[3]={a,b,c};
	int tt[10][10];

	rep(i,3){
		rep(j,3)tt[i][j]=t[i][j]-t1[i];
	}

	rep(i,3)if(tt[0][i]!=tt[1][i]||tt[1][i]!=tt[2][i])return 0;
	return 1;
}
int main(){
rep(i,3){
	rep(j,3)cin>>t[i][j];
}

bool ok=0;
const int M=101;
int sum=0;

rep(a,M){
	rep(b,M){
		rep(c,M){
			if(che(a,b,c))ok=1;
		}
	}
}


if(ok)cout<<"Yes"<<endl;
else cout<<"No"<<endl;


	return 0;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int a = stoi(s.substr(0, 2)), b = stoi(s.substr(2));
    bool aa = a && a <= 12, bb = b && b <= 12;
    cout << (aa && bb ? "AMBIGUOUS" : aa && !bb ? "MMYY" : !aa && bb ? "YYMM" : "NA")  << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  int ans = 0;
  while(!(a==b && b==c) || ans%2==1){
    ans += 1;
    if(a<=b && a<=c){
      a += 1;
    }else if(b<=a && b<=c){
      b += 1;
    }else{
      c += 1;
    }
  }
  ans /= 2;
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1708
#include <stdio.h>

int p[46] = { 
    2, 3, 5, 7,  
    11, 13, 17, 19, 23, 
    29, 31, 37, 41, 43, 
    47, 53, 59, 61, 67, 
    71, 73, 79, 83, 89, 
    97, 101, 103, 107, 109, 
    113, 127, 131, 137, 139, 
    149, 151, 157, 163, 167, 
    173, 179, 181, 191, 193, 
    197, 199};

int count(int n) {
    int num = 1;
    for (int i = 0; i < 46; i++) {
        int nump = 1;
        if (n > p[i]) {
            int temp = n;
            while (temp % p[i] == 0) {
                nump++;
                temp = temp / p[i];
            }
        }
        else {
            break;  
        }
        num *= nump;
    }   
    return num;
}

int main()
{
    int N;
    int ans = 0;
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
        if (i % 2 == 0) {
            continue;
        }
        else {
            if (count(i) == 8) ans++;
            else continue;
        }
    }   
    printf("%d\n", ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int n,a;
  vector<int> vec;
  cin >> n;
  while(cin >> a){
    vec.push_back(a);
  }
  for(int i = 0; i < n; i++){
    if(i+1 != vec[i]){
      for(int j = n-1; j > i; j--){
        if(j+1 != vec[j]){
          swap(vec[i], vec[j]);
          break;
        }
      }
      break;
    }
  }
  for(int k = 0; k < n; k++){
    if(k+1 != vec[k]){
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    string s;
    cin >> s;
    bool can = true;
    rep(i, 0, sz(s)){
        if (i & 1){
            if (s[i] == 'R')
                can = false;
              
        }
        else{
            if (s[i] == 'L')
                can = false;
        }
    }
    cout << (can ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#define pll              pair<long,long>
#define pii              pair<int,int>
#define scn(a)           scanf("%d", &a)
#define scn2(a, b)       scanf("%d%d", &a, &b)
#define scn3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pairl            pair<ll , ll >
#define scnl(a)          scanf("%lld", &a)
#define scnl2(a, b)      scanf("%lld%lld", &a, &b)
#define scnl3(a, b, c)   scanf("%lld%lld%lld", &a, &b, &c)
#define scns(s)          scanf("%s",s)
#define prts(s)          printf("%s\n",s)
#define prt(a)           printf("%d\n", a)
#define prtl(a)          printf("%lld\n", a)
#define prs(a)           printf("%d ", a)
#define prt2(a, b)       printf("%d %d\n", a, b)
#define prt3(a, b, c)    printf("%d %d %d\n", a, b, c)
#define prsl(a)          printf("%lld ", a)
#define prtl2(a, b)      printf("%lld %lld\n", a, b)
#define prtl3(a, b, c)   printf("%lld %lld %lld\n", a, b, c)
#define ptcs(a)          printf("Case %d: ", a)
#define pf               printf
#define sc               scanf
#define m_p              make_pair
#define vi               vector<int >
#define vil              vector<ll >
#define pb               push_back
#define mem(a, b)        memset((a), (b), sizeof(a))
#define lg2(n)           (31-__builtin_clz(n))
#define N                200005
#define inf              9999999
#define ll               long long
#define ull              unsigned long long
#define MIN              INT_MIN
#define MAX              INT_MAX
#define fast             ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
ll gcd(ll a, ll b){if(b==0) {return a;}return gcd(b, a % b);}
ll BigMod(ll B,ll P,ll M){     ll R=1; while(P>0)      {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
//___________________________________________________________________________________________________________________

vector<ll>v[N],v1;
ll d[1000005][4];
map<string,ll>mp;
bool ok=true;
int main()
{
    ll n,m,s=0;
    cin>>n>>m;
    ll a[n+10][m+10];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++) cin>>a[i][j];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(a[i][j]%2 && (i+1<n || j+1<m))
            {
                if(j+1<m)
                {
                    d[s][0]=i;
                    d[s][1]=j;
                    d[s][2]=i;
                    d[s][3]=j+1;
                    s++;
                    a[i][j+1]+=1;
                }
                else
                {
                    d[s][0]=i;
                    d[s][1]=j;
                    d[s][2]=i+1;
                    d[s][3]=j;
                    s++;
                    a[i+1][j]+=1;
                }
            }
        }
    }
    cout<<s<<endl;
    for(int i=0;i<s;i++)
    {
        cout<<d[i][0]+1<<' '<<d[i][1]+1<<' '<<d[i][2]+1<<' '<<d[i][3]+1;
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 13440
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

vector<bool> IsPrime;

void sieve(ll x){
     if(x+1 > IsPrime.size()){
         IsPrime.resize(x+1,true);
     }
     IsPrime[0] = false;
     IsPrime[1] = false;

     for(ll i=2; i*i<=x; ++i){
         if(IsPrime[i]){
            for(ll j=2; i*j<=x; ++j){
                IsPrime[i*j] = false;
            }
         }
     }
}
 
int main() {
  ll q;
  cin >> q;
  vector<pair<ll, ll> > v(q);
  rep(i,q){
    ll l,r;
    cin >> l >> r;
    v[i] = make_pair(l,r);
  }
  vector<ll> a(100001,0);
  sieve(100001);
  for(ll i = 1; i<100001; i++){
    if(IsPrime[i] && IsPrime[(i+1)/2]){
      a[i] = a[i-1] + 1;
    } else {
      a[i] = a[i-1];
    }
  }
  rep(i,q){
    cout << a[v[i].second] - a[v[i].first-1] << endl;
  }
  
 return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  string S; cin>>S;
  ll N = S.size();
  int P = 2019;

  vector<long long> val(P, 0);
  long long tenfactor = 1;
  long long cur = 0;
  val[cur]++;
  for (int i = 0; i < N; ++i) {
      cur = (cur + (S[N-i-1]-'0') * tenfactor) % P;
      tenfactor = (tenfactor * 10) % P;
      val[cur]++;
  }
  long long res = 0;
  for (int p = 0; p < P; ++p) res += val[p] * (val[p] - 1) / 2;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3676