akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    int g[N][N];
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            g[i][j] = 0;
        }
        
    }
    
    for (int i = 0; i < M; i++)
    {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        g[a][b] = 1;
        g[b][a] = 1;
    }
    int P[N];
    for (int i = 0; i < N; i++)
    {
        P[i] = i;
    }
    int ans = 0;
    do
    {   
        bool is_path = true;
        for (int i = 0; i < N-1; i++)
        {
            if(P[0]!=0)
            {
                is_path = false;
                break;
            }
            if(g[P[i]][P[i+1]]!=1)
            {
                is_path = false;
                break;
            }
        }
        if(is_path)
        {
            ans++;
        }
    } while (next_permutation(P, P+N));
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

//INSERT ABOVE HERE
signed main(){
  int n,x,y;
  cin>>n>>x>>y;
  x--;y--;
  vector< vector<int> > G(n);
  for(int i=1;i<n;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  vector<int> dx(n),dy(n);
  MFP([&](auto dfs,int v,int p,int d)->void{
        dx[v]=d;
        for(int u:G[v]){
          if(u==p) continue;
          dfs(u,v,d+1);
        }
      })(x,-1,0);
  MFP([&](auto dfs,int v,int p,int d)->void{
        dy[v]=d;
        for(int u:G[v]){
          if(u==p) continue;
          dfs(u,v,d+1);
        }
      })(y,-1,0);


  int ans=dx[y]/2;
  for(int v=0;v<n;v++){
    if(G[v].size()==1u) continue;
    if(dx[v]>=dy[v]) continue;
    chmax(ans,dy[v]);
  }

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,c,d,e,k,n,p,ct=0;
    cin>>a>>b>>c>>d>>e>>k;
    if(abs(a-b)>k) ct++;
    if(abs(a-c)>k) ct++;
    if(abs(a-d)>k) ct++;
    if(abs(a-e)>k) ct++;
    if(abs(b-c)>k) ct++;
    if(abs(b-d)>k) ct++;
    if(abs(b-e)>k) ct++;
    if(abs(c-d)>k) ct++;
    if(abs(c-e)>k) ct++;
    if(abs(d-e)>k) ct++;
    if(ct>0) cout<<":\("<<endl;
    else cout<<"Yay!"<<endl;
    return 0;
}




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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);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) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);


  int N; cin >> N;
  int x=sqrt(N);cout<<x*x<<endl;


  return 0;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::io::*;

fn main() {
    let i = stdin();
    run(&mut i.lock(), &mut stdout());
}

fn run(i: &mut BufRead, o: &mut Write) {
    let hwd = read_vec::<usize>(i);
    let (h, w, d) = (hwd[0], hwd[1], hwd[2]);
    let wh = w * h;
    let mut a_to_xy = vec![(0, 0); wh + 1];
    for y in 0..h {
        let a = read_vec::<usize>(i);
        for x in 0..w {
            a_to_xy[a[x]] = (x, y);
        }
    }
    fn abs_sub(x0: usize, s1: usize) -> usize {
        (x0 as isize - s1 as isize).abs() as usize
    }

    let mut mps = vec![0; wh + 1];
    for i in 1..wh + 1 - d {
        let xy0 = a_to_xy[i];
        let xy1 = a_to_xy[i + d];
        mps[i + d] = mps[i] + abs_sub(xy0.0, xy1.0) + abs_sub(xy0.1, xy1.1);
    }

    let q = read::<usize>(i);
    for _ in 0..q {
        let lr = read_vec::<usize>(i);
        let (l, r) = (lr[0], lr[1]);
        let mp = mps[r] - mps[l];
        writeln!(o, "{}", mp).unwrap();
    }
}

fn read_line(i: &mut BufRead) -> String {
    let mut line = String::new();
    i.read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn read<T: FromStr>(i: &mut BufRead) -> T {
    read_line(i).parse().ok().unwrap()
}
fn read_vec<T: FromStr>(i: &mut BufRead) -> Vec<T> {
    read_line(i)
        .split(' ')
        .map(|x| x.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 7292
#!/usr/bin/env python3
from collections import deque
import sys
try:
    from typing import Deque, Dict, List, Tuple
except ImportError:
    pass


YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int, L: "List[int]", R: "List[int]", D: "List[int]"):
    G = [[] for _ in range(N)]  # type: List[List[Tuple[int, int]]]
    for Li, Ri, Di in zip(L, R, D):
        Li -= 1
        Ri -= 1
        G[Li].append((Ri, Di))
        G[Ri].append((Li, -Di))
    pos = {}  # type: Dict[int, int]
    for i in range(N):
        if i in pos:
            continue
        q = deque()  # type: Deque[int]
        pos[i] = 0
        q.append(i)
        while q:
            s = q.popleft()
            for t, dst in G[s]:
                if t in pos:
                    if pos[t] != pos[s] + dst:
                        print(NO)
                        return
                    continue
                pos[t] = pos[s] + dst
                q.append(t)
    print(YES)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    L = [int()] * (M)  # type: "List[int]"
    R = [int()] * (M)  # type: "List[int]"
    D = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        L[i] = int(next(tokens))
        R[i] = int(next(tokens))
        D[i] = int(next(tokens))
    solve(N, M, L, R, D)


if __name__ == '__main__':
    main()


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

using namespace std;

string s;

int main()
{
    cin>>s;
    int cou = 0;
    for(int i = 0;i < s.length();i++)
        if(s[i] == '1')
            cou++;
    int ans = (s.length() - cou);
    ans = min(ans,cou);
    printf("%d\n",ans * 2);
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    int a, b, c, n, count;
    scanf("%d %d %d",&a, &b, &c);
    count = 0;
    for(n = a; n <= b; n++){
        if(c % n == 0){
                count++;
            }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2048
que = []
n, q = gets.split.map(&:to_i)
n.times{
    nm, t = gets.split
    t = t.to_i
    que << [nm, t]
}

time = 0
until que.empty?
    nm, t = que.shift
    if t <= q
        time += t
        puts "#{nm} #{time}"
    else
        time += q
        que << [nm, t - q]
    end
end


Measured memory_bytes: 13140
//#include<bits\stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define INF 10000000000000010ll
#define ldb long double
#define pb push_back
#define put_(x) printf("%d ",x);
#define get(x) x=read()
#define gt(x) scanf("%d",&x)
#define gi(x) scanf("%lf",&x)
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define gc(a) scanf("%s",a+1)
#define rep(p,n,i) for(RE int i=p;i<=n;++i)
#define go(x) for(int i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define fep(n,p,i) for(RE int i=n;i>=p;--i)
#define vep(p,n,i) for(RE int i=p;i<n;++i)
#define pii pair<int,int>
#define mk make_pair
#define RE register
#define P 1000000007
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define uint unsigned long long
#define ui unsigned
#define EPS 1e-8
#define sq sqrt
#define S second
#define F first
#define mod 998244353
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline int read()
{
    RE int x=0,f=1;RE char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=((ll)x*10+ch-'0')%mod;ch=getc();}
    return x*f;
}
const int MAXN=1001,G=3;
int n,m;
char a[MAXN*MAXN];
int main()
{
	//freopen("1.in","r",stdin);
	gt(n);gc(a);
	int flag=0,ans1=0,ans2=0;
	rep(1,n,i)
	{
		int ww=a[i]-'1';
		if(ww==1)flag=1,ans1=ans1^((n-i&i-1)?0:1);
		if(ww==2)ans2=ans2^((n-i&i-1)?0:1);
	}
	if(!flag)put(ans2?2:0);
	else put(ans1);
	return 0;
}


Measured memory_bytes: 4720
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
#include <string>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int k , a[N] , q ;
int up[22];
int calc ( ll  x)  {
  int ret =0 ;
  memset( up , 0 , sizeof up);
  while (x){
     up[ret++] = x%10LL;
     x /=10LL;
  }
  return ret-1;
}
ll mem[22][2][11];
ll dp  (int i , int f , int last ) {

if ( i == -1 ) return 1;
ll &ret = mem[i][f][last];
if  (ret != -1 )return ret ;
ret =0 ;
if ( last == 10 ) {
    for ( int d =0 ; d < 10 ; d++)
        ret += dp(i-1,1,(!d? 10 : d ));
    return ret ;
}
 for ( int d = max(last-1,0); d <= ( f ? min(9,last+1) : min( last+1, up[i]) ) ; d++ ) {
    ret += dp(i-1,f|(d<up[i]),d);
 }
 return ret;
}
bool ok ( ll x ) {
 int len = calc(x);
 memset( mem , -1 ,sizeof mem);
 ll cnt =0 ;

 for ( int i =0 ; i <= up[len] ; i++  )
    cnt += dp(len-1,(i < up[len]), (!i ? 10 : i));

 return cnt <= (k-1) ;
}
int main ( ){

  scanf("%d",&k);
  if ( k == 1) {
    printf("1\n");
    return 0;
  }
  k++;
  ll lo = 1 , hi = 1e18 ;

  while ( lo < hi ) {
    ll mid = (lo+hi+1LL)>>1LL;
    if ( ok(mid) ) lo = mid ;
    else hi = mid-1;
  }

  printf("%lld\n",lo+1);
return 0 ;
}


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

const int M = 1000000007;
class mll {
public:
	long long x;
	mll(long long x = 0) : x((x% M + M) % M) {};
	void operator *= (const mll& a) {
		(x *= a.x) %= M;
	}
};

int main() {
	int N;
	cin >> N;
	vector<int> Nums(N - 1);
	iota(Nums.begin(), Nums.end(), 2);
	map<int, int> Factors;
	for (int i = 0; i < N - 1; i++) {
		int f = Nums[i];
		if (f > 1) {
			for (int j = 0; i + j < N - 1; j += f) {
				while (Nums[i + j] % f == 0) {
					Factors[f]++;
					Nums[i + j] /= f;
				}
			}
		}
	}
	mll ans = 1;
	for (const auto& fs : Factors) ans *= ((long long)fs.second + 1);
	cout << ans.x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MXN = 1e5 + 10;
int q, a, b, c, d, lna, lnb, PA[MXN], PB[MXN];
char A[MXN], B[MXN];
int main()
{
    scanf("%s%s", &A, &B);
    lna = strlen(A);
    lnb = strlen(B);
    for (int i = 0; i < lna; i++)
        PA[i + 1] = (PA[i] + (A[i] == 'A') - (A[i] == 'B') + 3) % 3;
    for (int i = 0; i < lnb; i++)
        PB[i + 1] = (PB[i] + (B[i] == 'A') - (B[i] == 'B') + 3) % 3;
    scanf("%d", &q);
    while (q --)
    {
        scanf("%d%d%d%d", &a, &b, &c, &d);
        if ((PA[b] - PA[a - 1] + 3) % 3 == (PB[d] - PB[c - 1] + 3) % 3)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return (0);
}


Measured memory_bytes: 1536
#include <iostream>
#include <cstdlib>
#include <bitset>
#include <map>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <math.h>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecchar vector<char>
#define vecstr vector<string>
#define vec2str vector<vector<string>>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

#define Pi 3.1415926535897932384626

int main() {
	ll n, ans = 0,max = 0;
	bool flag = false;
	string s;

	cin >> s;

	forll(i, 0, 3) {
		if (s[i] == 'R')
		{
			max++;
			if (ans < max)
				ans = max;
		}
		else
			max = 0;
	}

	cout << ans;
}


Measured memory_bytes: 3620
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	int N=sc.nextInt();

    	for(int i=1;;i++) {

    		if(i*i>N) {
    			System.out.println((i-1)*(i-1));
    			return;
    		}
    	}
    }


}



Measured memory_bytes: 21844
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	int n,m;
	cin >> n >> m;
	string s1,s2;
	VS S1,S2;
	bool ans = false;
	REP(i,n){
		cin >> s1;
		S1.PB(s1);
	}
	REP(i,m){
		cin >> s2;
		S2.PB(s2);
	}

	REP(i,n-m+1){
		REP(j,n-m+1){
			bool check=true;
			REP(y,m){
				REP(x,m){
					if(S1[i+y][j+x]!=S2[y][x]){
						check=false;
					}
				}
			}
			if(check) ans=true;
		}
	}
	if(ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mode        998244353
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323



void solve()
{
       ll n;
       cin>>n;
       ll h[n];
       rep(i,0,n) cin>>h[i];
       ll ans=1, mx=h[0];
       rep(i,1,n)
       {
              if(h[i]>=mx) ans++;
              mx = max(mx, h[i]);
       }
       cout<<ans<<endl;
}


int main() {
	ll T = 1;
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    long long N, K; cin >> N >> K;
    long long A[100001]= {};
    for (int i = 0; i < N; i++) {
        int a, b; cin >> a >> b;
        A[a] += b;
    }
    for (int i = 0; i <= 100000; i++) {
        K -= A[i];
        if (K <= 0) {
            cout << i << '\n';
            return;
        }
    }
}

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

    solve();

    return 0;
}

Measured memory_bytes: 4444
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
from itertools import accumulate
n,q=map(int,input().split())
S=input()
A=[0]*(n-1)
for i in range(len(S)-1):
    if S[i]=='A' and S[i+1]=='C':
        A[i]=1
B=[0]+list(accumulate(A))
for _ in range(q):
    l,r=map(int,input().split())
    print(B[r-1]-B[l-1])

Measured memory_bytes: 54560
#include <stdio.h>

int main(void){
	int n, m;
	int maxcost = 0, totalcost = 0;

	scanf("%d%d", &n, &m);

	while (m--) {
		int a, b;
		scanf("%d%d", &a, &b);
		if (a < n) {
			totalcost += (n - a);
			if (maxcost < n - a) maxcost = n - a;
		}
	}

	totalcost -= maxcost;
	printf("%d\n", totalcost);

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int n, k;
int arr[100100], pos;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    if(k == 0)
        return cout << "0\n", 0;
    for(int i = 0; i < n; i ++)
        cin >> arr[i];
    pos = n;
    for(int i = 0; i < n; i ++)
        if(arr[i] >= 0)
        {
            pos = i;
            break;
        }
//    cout << pos << endl;
    int Ans = INT_MAX;
    if(n - pos >= k)
        Ans = min(Ans, arr[pos + k - 1]);
    if(pos >= k)
        Ans = min(Ans, -arr[pos - k]);
    for(int i = max(1, k - (n - pos)); i <= min(k - 1, pos); i ++)
        Ans = min(Ans, -arr[pos - i] + arr[pos + k - i - 1] + min(-arr[pos - i], arr[pos + k - i - 1]));
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 640
def gcd(a, b):
    if a > b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

def lcm(a, b):
    return a * b // gcd(a, b)

def solve(n, m, s, t):
    if s == t:
        return n
    else:
        l = lcm(n, m)
        dx = l // n
        dy = l // m
        x = 0
        y = 0
        cx = 0
        cy = 0
        while cx < n and cy < m:
            if x == y:
                if s[cx] != t[cy]:
                    return -1
                x += dx
                cx += 1
                y += dy
                cy += 1
            elif x < y:
                x += dx
                cx += 1
            else:
                y += dy
                cy += 1
        return l

_n, _m = map(int, input().split())
_s = input()
_t = input()
print(solve(_n, _m, _s, _t))


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

#define REP(i,n) for(long long i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(long long i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

 const int slength = 55555;

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

  vector<int> sosu(slength+1, 0);
  vector<int> ans;
  FOR(i, 2, slength+1){
    if(sosu[i] == 0 && i % 5 == 1){
      ans.push_back(i);
    }
    for(int j=2; j*i<=slength; j++){
      if(sosu[j*i] != 0) continue;
      sosu[j*i] = 1;
    }
  }

  REP(i, N){
    cout << ans[i] << " ";
  }
  cout << endl;

  return 0;
}


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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    vector<i64> cnt(n+1);
    vector<i64> v;
    for(int i=0;i<n;++i){
        i64 a;
        cin >> a;
        cnt[a]++;
        v.push_back(a);
    }
    i64 sum = 0;
    for(int i=1;i<=n;++i){
        if(cnt[i] <= 0)continue;
        sum += cnt[i]*(cnt[i]-1)/2;
    }
    for(int i=0;i<n;++i){
        cout << sum - (cnt[v[i]]-1) << endl;
    }

    return 0;
}

Measured memory_bytes: 5872
#include <bits/stdc++.h>
using namespace std;
long long int mod = pow(10,9) + 7;

int main(){
  long long int N,M;
  cin >> N >> M;
  vector<long long int> oks(N+1,true);
  for(int i = 0; i< M;i++){
    int a;
    cin >> a;
    oks[a] = false;
  }
  
  vector<long long>dp(N+1,0);
  dp[0] = 1;
  dp[1] = oks[1] ? 1 : 0;
  for(int i = 2; i <= N; i++){
    if(oks[i]){
      dp[i] =( dp[i-1] + dp[i-2]) % mod;
    }
    
  }
  
  cout <<dp[N];
 
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n; n=n%10;
    if(n==3)puta("bon");
    else if(n%8==0 or n==1 or n==6)puta("pon");
    else puta("hon");
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

typedef double db;

const int MAXN = 3005;
const db PI = acos(-1);

int n,L;
int T[MAXN];

db ansX,ansY;

int main()
{
	scanf("%d%d",&n,&L);
	for (int i = 1;i <= n;i++)
		scanf("%d",&T[i]);
	for (int i = 1;i <= n;i++)
		for (int j = i + 1;j <= n;j++)
		{
			db arc = PI * (T[i] + T[j]) / L;
			ansX += (j - i - 1) * cos(arc + PI) + (n - j + i - 1) * cos(arc);
			ansY += (j - i - 1) * sin(arc + PI) + (n - j + i - 1) * sin(arc);
		}
	ansX /= (db)n * (n - 1) * (n - 2) / 6;
	ansY /= (db)n * (n - 1) * (n - 2) / 6;
	printf("%.10lf %.10lf\n",ansX,ansY);
	return 0;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int h = sn.nextInt();
        int w = sn.nextInt();
        char[][] mat = new char[h][w];
        boolean[] rowVisible = new boolean[h];
        boolean[] colVisible = new boolean[w];
        // 読み込み
        for (int i = 0; i < h; i++) {
            String row = sn.next();
            for (int j = 0; j < w; j++) {
                char c = row.charAt(j);
                mat[i][j] = c;
                if (c == '#') {
                    rowVisible[i] = true;
                    colVisible[j] = true;
                }
            }
        }
        sn.close();
        // 表示
        PrintStream out = System.out;
        for (int i = 0; i < h; i++) {
            if (!rowVisible[i]) continue;
            for (int j = 0; j < w; j++) {
                if (!colVisible[j]) continue;
                out.print(mat[i][j]);
            }
            out.print("\n");
        }
    }
}


Measured memory_bytes: 25684
#include <stdio.h>

int main(){
   char s[11],t[11];
   int  i;

   scanf("%s %s",s,t);
   for (i=0;s[i]!='\0';i++)
      if (s[i]!=t[i]) break;
   if (s[i]!='\0') {
      puts("No");
      return 0;
   }
   if (t[i+1]=='\0') puts("Yes");
   else              puts("No");
   return 0;
}


Measured memory_bytes: 1660
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        String s = in.next();
        char[] ch = s.toCharArray();
        // out.println(ch);
        boolean ans = true;
        for (int i=0; i < ch.length; i++) {
            // out.println(i + " " + ch[i]);
            if (i % 2 == 0) {
                if (ch[i] == 'R') {
                    continue;
                }
            } else {
                if (ch[i] == 'L') {
                    continue;
                }
            }
            if (ch[i] == 'U' || ch[i] == 'D') {
                continue;
            }
            ans = false;
            break;
        }

        out.println(ans ? "Yes" : "No");
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

}


Measured memory_bytes: 22996
#include <iostream>
#include <string.h>
#include<algorithm>
#include<math.h>

using namespace std;

int main() {
	int N, A[201000], B[201000];
	cin >> N;
	A[0] = 0;
	B[0] = 0;
	for (int i = 1; i < N; i++) {
		cin >> A[i];
		B[i] = 0;
	}
	for (int i = 0; i < N; i++) {
		B[A[i] - 1]++;
	}
	for (int i = 0; i < N; i++) {
		cout << B[i] << " ";
	}
	cout << endl;
	return 0;
}


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


int main() {
    std::string s;
    std::cin >> s;

    char last = s[s.length() - 1];
    if (last == '0' || last == '1' || last == '8' || last == '6') {
        std::cout << "pon" << std::endl;
    } else if (last == '3') {
        std::cout << "bon" << std::endl;
    } else {
        std::cout << "hon" << std::endl;
    }
}


Measured memory_bytes: 3596
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const DIGITS: usize = 40;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let X: usize = sc.get();
    let M: usize = sc.get();
    let mut doubling = vec![vec![0; M]; DIGITS+1];
    let mut sum = vec![vec![0; M]; DIGITS+1];
    for i in 0..M {
        doubling[0][i] = i * i % M;
        sum[0][i] = i;
    }
    for k in 0..DIGITS {
        for i in 0..M {
            doubling[k+1][i] = doubling[k][doubling[k][i]];
            sum[k+1][i] = sum[k][i] + sum[k][doubling[k][i]];
        }
    }
    let mut ans = 0;
    let mut cur = X;
    for k in 0..DIGITS {
        if (N>>k) & 1 != 0 {
            ans += sum[k][cur];
            cur = doubling[k][cur];
        }
    }
    println!("{}", ans);
}


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

int main() {
  int n;
  cin >> n;
  vector<long long> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long x = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    long long y = c.end() - upper_bound(c.begin(), c.end(), b[i]);
    ans += x*y;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }
#define N 105
#define V 100100

lli n, w;

int main(void){
	cin >> n >> w;
	vector<vector<lli>> dp(N, vector<lli>(V, 1e15));
	dp[0][0] = 0;
	for(lli i = 0; i < n; i++){
		lli u, v;
		cin >> u >> v;
		rep(j, V){
			chmin(dp[i+1][j], dp[i][j]);
			if(j+v < V) chmin(dp[i+1][j+v], dp[i][j]+u);
		}
	}
	lli ans = 0;
	for(lli j = 0; j < V; j++){
		if(dp[n][j] <= w) chmax(ans, j);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 86416
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=2e5+20;
const int MAX=10000007;
inline int read() {
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}

inline void out(int x) {   
	if(x>9) out(x/10);   
	putchar(x%10+'0'); 
} 
int n;
int vis[N*10];
int main(){
	int n;
	cin>>n;
	ll sum=0;
	rep(i,1,n){
		if(i%3==0&&i%5==0){
			vis[i]=1;
		}
		else if(i%3==0){
			vis[i]=1;
		}
		else if(i%5==0){
			vis[i]=1;
		}
		
	}
	rep(i,1,n){
		if(!vis[i])sum+=i;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 7092
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;

int main() {
    string S, T;
    cin >> S >> T;
    cout << T + S << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			String[] a = IntStream.range(0, n).mapToObj(i -> scanner.next()).toArray(String[]::new);
			String[] b = IntStream.range(0, m).mapToObj(i -> scanner.next()).toArray(String[]::new);
			boolean found = false;
			main: for (int i = 0; i <= n - m; i++) {
				for (int j = 0; j <= n - m; j++) {
					if (containsAt(a, b, i, j)) {
						found = true;
						break main;
					}
				}
			}
			System.out.println(found ? "Yes" : "No");
		}
	}

	/**
	 * @param a
	 * @param b
	 * @param x
	 * @param y
	 * @return aの[x][y]からのm x mの部分はbと同じかどうか
	 */
	private static boolean containsAt(String[] a, String[] b, int x, int y) {
		int m = b.length;
		for (int i = 0; i < m; i++) {
			if (!a[x + i].substring(y, y + m).equals(b[i])) {
				return false;
			}
		}
		return true;
	}
}


Measured memory_bytes: 36132
import sys
n = int(input())
words = [input() for _ in range(n)]
if len(words) != len(set(words)):
    print('No')
    sys.exit()
else:
    for i in range(len(words)-1):
        if words[i][-1] != words[i+1][0]:
            print('No')
            sys.exit()
print('Yes')


Measured memory_bytes: 3060
import java.util.*;

class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		int[] c = {1000,500,100};
		while(in.hasNext()){
			int n = in.nextInt(), m = in.nextInt();
			if(n == 0 && m == 0) return;

			int[] ans = new int[3];

			n = m - n;
			for(int i = 0; i < 3; i++){
				ans[i] = n /c[i];
				n %= c[i];
			}

			System.out.println(ans[2] + " " + ans[1] + " " + ans[0]);
		}
	}
	
}

// while(in.hasNext()){
		// 	int n = in.nextInt();
		// 	if(n == 0) return;
			
		// }

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

typedef struct{
   int s1;
   int s2;
   int cst;
} road;

typedef vector<int> V;


bool operator<(V& l, V& r){
   V::iterator it1 = l.begin(), it2 = r.begin();
   while( it1+1 != l.end() && it2+1 != r.end() && *it1 == *it2 ){
       it1++; it2++;
   }
   return *it1 < *it2;
}

vector<road> rr;
V mem, can;
int ns, nl, md;

road gen(int s, int d, int c){
   road r;
   r.s1 = s;
   r.s2 = d;
   r.cst = c;
   return r;
}

void dfs(int p, int d, V v){
   for(int i = 0; i < nl; i++){
       if( rr[i].s1 == p && !v[i] ){
           v[i] = 1;
           can.push_back(rr[i].s2);
           dfs(rr[i].s2, d+rr[i].cst, v);
           v[i] = 0;
           can.pop_back();
       }
       if( rr[i].s2 == p && !v[i] ){
           v[i] = 1;
           can.push_back(rr[i].s1);
           dfs(rr[i].s1, d+rr[i].cst, v);
           v[i] = 0;
           can.pop_back();
       }
   }
   if( d > md ){
       md = d;
       mem = can;
   }else if( d == md && can < mem ){
       mem = can;
   }
}

int main(){
   while( cin >> ns >> nl && ns && nl ){
       rr = vector<road>();
       mem = V();
       md = 0;
       for(int i = 0; i < nl; i++){
           int a, b, c;
           cin >> a >> b >> c;
           rr.push_back( gen(a-1, b-1, c) );
       }
       for(int i = 0; i < ns-1; i++){
           can.push_back(i);
           dfs(i, 0, V(nl, 0));
           can.pop_back();
       }
       cout << md << endl;
       V::iterator it = mem.begin();
       cout << *it+1;
       it++;
       for(; it != mem.end(); it++){
           cout << ' ' << *it+1;
       }
       cout << endl;
   }
   return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int A, B; cin >> A >> B;
	if(A > B && B != 1) cout << "Alice" << endl;
	else if(A < B && A != 1) cout << "Bob" << endl;
	else if(A == 1 && B != 1) cout << "Alice" << endl;
	else if(B == 1 && A != 1) cout << "Bob" << endl;
	else if(A == B) cout << "Draw" << endl;
	return 0;
}

Measured memory_bytes: 3616
k = int(input())
a,b = list(map(int,input().split()))
a2 = a//k
a3 = a%k
b2 = b//k
b3 = b%k
if a2 != b2:
    print("OK")
elif a3 == 0 or b3 == 0:
    print("OK")
else:
    print("NG")

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

int main(){
  int n, k;
  cin >> n >> k;
  int ans = 1;
  for(int i = 0; i < n; i++){
    if(ans * 2 <= ans + k){
      ans = ans * 2;
    }else{
      ans = ans + k;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 11007;

ll n, k, p[N], c[N], sum[N];

int vis[N];

vector<ll>g[N];

deque<int> q;

ll hello[N];

ll work(int x, int cnt) {
    while (q.size()) q.pop_front(); 
    for (int i = 1; i <= x; i++) {
        while (!q.empty() && sum[q.back()] >= sum[i]) {
            q.pop_back();
        }
        q.push_back(i);
        while (q.front() <= i - cnt) {
            q.pop_front();
        }
        if (q.front() == i) {
            hello[i] = sum[i - 1];
        } else {
            hello[i] = sum[q.front()];
        }
        
    }
    ll mx1 = LLONG_MIN;
    for (int i = 1; i <= x; i++) {
        mx1 = max(mx1, sum[i] - sum[max(0, i - cnt)]);

        mx1 = max(mx1, sum[i] - hello[i]);
    }

    return mx1;
}

void dfs(int id, int u) {
    vis[u] = 1;
    g[id].push_back(u);
    if (vis[p[u]] == 0) {
        dfs(id, p[u]);
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> c[i];
    }
    int top = 1;
    for (int i = 1; i <= n; i++) {
        if (vis[i] == 0) {
            dfs(top, i);
            top++;
        }
    }
    ll maxn = LLONG_MIN;
    for (int i = 1; i < top; i++) {
        ll cnt = 0;
        for (int j = 0; j < g[i].size(); j++) {
            cnt += c[g[i][j]];
            sum[j + 1] = c[g[i][j]];
        }
    
        int cn = (int)g[i].size();
        for (int j = 1; j <= cn; j++) {
            sum[j + cn] = sum[j];
        }
        for (int j = 1; j <= 2 * cn; j++) {
            sum[j] = sum[j - 1] + sum[j];
        }
        if (cnt > 0) {
            ll res = k / cn;
            ll cat = res * cnt;
            res = k % cn;
            ll ca = cat;
            if (res) {
                cat += work(2 * cn, res);
                maxn = max(maxn, cat);
            } 
            cat = ca;
            cat -= cnt;
            cat += work(2 * cn, cn);
            maxn= max(maxn, cat);
            
            
        } 
        if (k >= cn) {
            maxn = max(maxn, work(2 * cn, cn));
        } else {
            maxn = max(maxn, work(2 * cn, k));
        }

    }
    cout << maxn << endl;
}


/*9 7876
4 2 5 1 6 8 3 7 9 
-6557 -2648 -2420 25613 4314 25455 -6418 -2334 -763 */
/*

3 1670
1 3 2 
-10082 20147 -12332 
*/

Measured memory_bytes: 4524
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << '\n'
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;


ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    int z[10] = {1, 3, 2, 7, 4, 3, 6, 15, 8, 19};
    if (n<=10) {
        pr(z[n-1]);
        return 0;
    }
    map<ll, ll> mp;
    ll now = n;
    for (ll i=2; i*i<=now; i++) {
        if (now%i==0) {
            while (now%i==0) {
                now /= i;
                mp[i]++;
            }
        }
    }
    if (now>1) mp[now]++;
    int fs = mp.size();
    vector<ll> factors(fs);
    int index = 0;
    for (auto m: mp) {
        factors[index] = m.first;
        index++;
    }
    ll k = n-1;
    
    mp[2]++;
    
    rep(i, 1<<fs) {
        vector<bool> vb(fs);
        ll a = 1, b = 1;
        rep(j, fs) {
            if (i>>j&1) {
                rep(ii, mp[factors[j]]) a *= factors[j];
            }
            else {
                rep(ii, mp[factors[j]]) b *= factors[j];
            }
        }
        //const int mod = y;
        ll x, y;
        ll g = extgcd(a, b, x, y);
        //debug(g);debug(a);debug(b);debug(x); debug(y);
        if (x<0) {
            chmin(k, abs(x)*a);
        }
        if (y<0) {
            chmin(k, abs(y)*b);
        }
    }

    
    
    pr(k);
    return 0;
}


Measured memory_bytes: 3696
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

#define MAX(a, b) ((a) < (b) ? (b) : (a))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

using namespace std;
int main()
{
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];

  int b = a[0], s = a[0];
  int bi = 0, si = 0;
  for (int i = 0; i < n; i++)
  {
    if (a[i] > b)
    {
      b = a[i];
      bi = i;
    }
    if (a[i] < s)
    {
      s = a[i];
      si = i;
    }
  }

  if (0 <= s)
  {
    printf("%d\n", n - 1);
    for (int i = 1; i < n; i++)
      printf("%d %d\n", i, i + 1);
    return 0;
  }
  else if (b <= 0)
  {
    printf("%d\n", n - 1);
    for (int i = n; i > 1; i--)
      printf("%d %d\n", i, i - 1);
    return 0;
  }

  printf("%d\n", 2 * n - 1);
  if (abs(b) >= abs(s))
  {
    for (int i = 0; i < n; i++)
      printf("%d %d\n", bi + 1, i + 1);
    for (int i = 0; i < n - 1; i++)
      printf("%d %d\n", i + 1, i + 2);
  }
  else
  {
    for (int i = 0; i < n; i++)
      printf("%d %d\n", si + 1, i + 1);
    for (int i = n; i > 1; i--)
      printf("%d %d\n", i, i - 1);
  }
  return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
MOD = 10**9+7

MAXN = N+100
fac = [1,1] + [0]*MAXN
finv = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD
def comb(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

from collections import Counter
def factorize(n):
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1
    return d

ans = 1
f = factorize(M)
for v in f.values():
    c = comb(N+v-1, v)
    ans *= c
    ans %= MOD
print(ans)

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

int main(){
  int a,b,c; cin >>a>>b>>c;
  int tmpa,tmpb,tmpc;
  int ans=0;
  while(a%2==0 && b%2==0 && c%2==0){
    if(a==b && b==c){ans=-1;break;}
    tmpa=b/2+c/2;
    tmpb=c/2+a/2;
    tmpc=a/2+b/2;
    a=tmpa;
    b=tmpb;
    c=tmpc;
    ans++;
  }
  cout <<ans <<endl;
}

Measured memory_bytes: 256