akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) \
  SORT(var);       \
  REVERSE(var)
#define OPTIMIZE_STDIO         \
  ios::sync_with_stdio(false); \
  cin.tie(0);                  \
  cout.precision(10);          \
  cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
  ll x;
  mint() : x(0) {
  }
  mint(ll x) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint& r) {
    if ((x += r.x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint& operator-=(const mint& r) {
    if ((x -= r.x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint& operator*=(const mint& r) {
    if ((x *= r.x) > MOD) {
      x %= MOD;
    }
    return *this;
  }
  mint& operator++() {
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint operator++(int) {
    mint ret = x;
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return ret;
  }
  mint& operator--() {
    if ((--x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint operator--(int) {
    mint ret = x;
    if ((--x) < 0) {
      x += MOD;
    }
    return ret;
  }
  mint operator+(const mint& r) {
    mint ret;
    return ret = x + r.x;
  }
  mint operator-(const mint& r) {
    mint ret;
    return ret = x - r.x;
  }
  mint operator*(const mint& r) {
    mint ret;
    return ret = x * r.x;
  }
  mint operator-() {
    return mint() - *this;
  }
  bool operator<(const mint& a) {
    return x < a.x;
  }
  bool operator>(const mint& a) {
    return x > a.x;
  }
  bool operator<=(const mint& a) {
    return x <= a.x;
  }
  bool operator>=(const mint& a) {
    return x >= a.x;
  }
  bool operator==(const mint& a) {
    return x == a.x;
  }
  bool operator!=(const mint& a) {
    return x != a.x;
  }
};
ostream& operator<<(ostream& os, const mint& r) {
  os << r.x;
  return os;
}
ostream& operator>>(ostream& os, const mint& r) {
  os >> r.x;
  return os;
}

void solve(istream& cin, ostream& cout) {
  string s;
  cin >> s;
  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
#define int long long
#define rep(i,a,n) for (int (i)=(a);(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef long double ld;
int dp[51][2501][51];
int n,x[50],a;
int solve(int i,int sum,int j){
	int rep=0;
	if(i==n){
		if(j==0) return 0;
		if(sum*1.0/j==a){
			  return 1;
		 }
		return 0;
	}
	if(dp[i][sum][j]!=-1) return dp[i][sum][j];
	rep=solve(i+1,sum+x[i],j+1);
	rep+=solve(i+1,sum,j);
	return dp[i][sum][j]=rep;
}
signed  main() {
	
	cin>>n>>a;
	for(int i=0;i<n;i++)
		cin>>x[i];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=2500;j++){
			for(int z=0;z<=n;z++)
				dp[i][j][z]=-1;
		}
	}
	cout<<solve(0,0,0)<<endl;
}


Measured memory_bytes: 51072
#include<iostream>
#include<string>


using namespace std;

int main(){
  string str;
  cin >> str;
  int count[21]={0};

  int ans[26] = {0};
 
  for(int j = 0; j < 26;j++){
    int t = -1,now = 0;
    for(int i = 0;i < str.length();i++){
      if(str[i] == 'a' + j){
	now = i;
	if(ans[j] < now - t){
	  ans[j] = now - t - 1;
	  //cout << ans[j] << endl;

	}
	t = now;
	
      }
    }
    if(ans[j] < str.length() - t - 1){
      ans[j] = str.length() - t - 1;
    }
  }
  int min = 999;
  for(int i = 0;i < 26;i++){
    if(ans[i] != 0 && min > ans[i]) min = ans[i];
  }
  int f = 1;
  for(int i = 0; i < str.length() - 1;i++){
    if(str[i] != str[i+1]) f = 0;
  }
  if(f == 0)cout << min;
  else cout << "0";
  
}


Measured memory_bytes: 256
n = int(input())
mod = 10**9 + 7
a = 1
for i in range(n):
    a *= 10
    a %= mod
b = 1
for i in range(n):
    b *= 9
    b %= mod
b *= 2
b %= mod
c = 1
for i in range(n):
    c *= 8
    c %= mod
print((a - b + c) % mod)



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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	ll n, x = 1e16L;
	cin >> n;
	for (int i = 0; i < 5; i++) {
		ll a;
		cin >> a;
		x = min(x, a);
	}
	ll answer = (n + x - 1) / x + 4;
	cout << answer << endl;
}


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

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;
const long long MOD = 1000000007;

int main()
{
    ll N, K;
    cin >> N >> K;

    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
    }

    ll ans = 0;
    rep(i, N) {
        ll cnt = 0;
        repd(j, i + 1, N) {
            if (A[i] > A[j]) cnt++;
        }
        ans += (cnt * K) % MOD;
        ans %= MOD;
    }

    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    rep(i, N) {
        ll gr = 0;
        rep(j, N) {
            if (A[i] > A[j]) gr++;
        }
        ll tmp = K * (K - 1LL) / 2LL % MOD;
        tmp = gr * tmp % MOD;
        ans += tmp % MOD;
        ans %= MOD;
    }

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

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void solve(){
  string s,t;
  cin>>s>>t;
  int n=s.length(),n1=t.length();
  int ans=n1;
  rep(i,0,n-n1+1){
    string s1=s.substr(i,n1);
    int res=0;
    rep(j,0,n1) if(s1[j]!=t[j]) res++;
    ans=min(ans,res);
  }
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3648
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

public class Main {

    public static void main(String[] args) {
        List<Integer> l = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        for (int i = 0; i < s.length(); i++) {
            int x = s.charAt(i);
            l.add(x);
        }
        Collections.sort(l);
        if (l.get(0) == l.get(1) && l.get(2) == l.get(3) && l.get(0) != l.get(3)) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}


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

#define ll long long
#define endl '\n'
#define disp(x) cout << (x) << endl
#define pb push_back
#define ff first
#define ss second
#define NOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define REPI(n) for(int i = 0;i<(n);i++)
#define REPJ(n) for(int j = 0;j<(n);j++)





using namespace std;

/*
//Number Theory-------------


ll int gcd(ll int x,ll int y){
    while(x!=0 && y!=0){
        ll int tmp = x;
        x = y;
        y = tmp%y;
    }
    return x+y;
}
// alter :: use __gcd(A,B)

ll int modExp(ll int x,ll int n,ll int M){

    ll int result=1;
    while(n>0){
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

ll int e, x, y;
void extendedEuclid(ll int A, ll int B) {
    if(B == 0) {
        //d = A;
        x = e/A;
        y = 0;
    }
    else {
        extendedEuclid(B, A%B);
        ll int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}

ll int modInverse(ll int A, ll int M){

    extendedEuclid(A,M);
    return (x%M+M)%M;    //x may be negative
}



bool checkPrime(int n){
    if(n==1)return 0;
    for(int i = 2;i*i<=n;i++){
        if(n%i==0)return 0;
    }
    return 1;
}

void sieve(bool isPrime[],int n){
    REPI(n+1){
        isPrime[i] = 1;
    }
    isPrime[1] = isPrime[0] = 0;

    for(int i = 2;i*i<=n;i++){
        if(isPrime[i]){
            for(int j = i*i;j<=n;j+=i)isPrime[j] = 0;
        }
    }
}

vector<int> factorize(int n){
    vector<int>res;
    for(int i = 2;i*i<=n;i++){
        while(n%i==0){
            res.pb(i);
            n = n/i;
        }
    }
    if(n!=1)res.pb(n);
    return res;
}

vector<int> fast_factorize(int n){
    int minPrime[n + 1]={0};
    for (int i = 2; i * i <= n; ++i) {
        if (minPrime[i] == 0) {
            for (int j = i * i; j <= n; j += i) {
                if (minPrime[j] == 0) {
                    minPrime[j] = i;
                }
            }
        }
    }
    for (int i = 2; i <= n; ++i) {
        if (minPrime[i] == 0) {
            minPrime[i] = i;
        }
    }
    vector<int> res;
    while (n != 1) {
        res.pb(minPrime[n]);
        n /= minPrime[n];
    }
    return res;
}
*/
/*

// right most once
x^(x&(x-1)) , x&(-x)

// set nth bit 1
x|1<<n
// unset nth bit
x&(!(1<<n))
//check nth bit
x&(1<<n)

//power of 2
n && !(n&(n-1)

// left shift x<<y
// right shift x>>y

*/
/*
//Graphs--------------------
vector<bool>vis;
vector<vector<int> >adj;

void dfs(int s){
    vis[s] = 1;
    REPI(adj[s].size()){
        if(!vis[adj[s][i]])dfs(adj[s][i]);
    }
}
*/


int main(){
    NOS;
    map<int,string>m;
    m[25] = "Christmas";
    m[24] = "Christmas Eve";
    m[23] = "Christmas Eve Eve";
    m[22] = "Christmas Eve Eve Eve";
    int D;
    cin >> D;
    disp(m[D]);

    return 0;

}



















//priority_queue<int,vector<int>,greater<int> > mypq;
// vector<int>::iterator it,ls;
// ls = set_difference(a,a + n, b, b + n-1, v.begin());
// for (it = v.begin(); it < ls; ++it)
//         disp(*it);

//next_permutation(a,a+n)
//cout<< fixed << setprecision(2)<< variable << endl;


Measured memory_bytes: 256
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin
 
constexpr int mod = int(1e9) + 7;

int dodajdo(int &a, int b) {
	a += b;
	if(a >= mod)
		a -= mod;
	return a;
}
int dodaj(int a, int b) {
	a += b;
	if(a >= mod)
		a -= mod;
	return a;
}

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

	int n;
	string s;
	cin >> n >> s;

	vector<vector<int>> dp(n, vector<int>(n)), prefix(n, vector<int>(n, 1));
	dp[0][0] = 1;

	for(int i = 1; i < n; ++i) {
		for(int c = 0; c <= i; ++c) {
			int l, r;
			if(s[i - 1] == '<')
				l = 0, r = c - 1;
			else
				l = c, r = i;

			int interval = prefix[i - 1][r];
			if(l != 0)
				dodajdo(interval, mod - prefix[i - 1][l - 1]);
			dodajdo(dp[i][c], interval);
		}

		for(int c = 0; c < n; ++c)
			prefix[i][c] = dodaj(dp[i][c], (c ? prefix[i][c - 1] : 0));
	}

	cout << prefix[n - 1][n - 1] << '\n';
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
int n;
int a[502][502];
int d[502][502];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
void dfs(int x,int y){
	for(int i=0; i<4 ;i++){
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(d[nx][ny]>a[nx][ny]+d[x][y]){
			d[nx][ny]=a[nx][ny]+d[x][y];
			dfs(nx,ny);
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=1; i<=n ;i++){
		for(int j=1; j<=n ;j++){
			d[i][j]=min(min(i,n-i+1),min(j,n-j+1));
			a[i][j]=1;
		}
	}
	int ans=0;
	for(int i=1; i<=n*n ;i++){
		int v;cin >> v;
		int x=(v+n-1)/n;
		int y=(v-1)%n+1;
		a[x][y]=0;
		ans+=d[x][y]-1;
		for(int i=0; i<4 ;i++){
			int nx=x+dx[i];
			int ny=y+dy[i];
			if(d[nx][ny]<d[x][y]) d[x][y]=d[nx][ny];
		}
		dfs(x,y);
	}
	cout << ans << endl;
}

Measured memory_bytes: 21008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

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

    if(a*b <= 0){
        cout << "Zero" << endl;
    }else if(a>0){
        cout << "Positive" << endl;
    }else if(b<0){
        if((b-a)%2==0){
            cout << "Negative" << endl;
        }else{
            cout << "Positive" << endl;
        }
    }
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MN = 100012;
int n,k,a[MN],dp[MN];
int main (void) {
    ios::sync_with_stdio(false);cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 1; i <= k; i++) {
        for (int j = n-1; j >= 0; j--) {
            if (i-a[j] < 0) continue;
            if (dp[i-a[j]] == 0) dp[i] = 1;
        }
    }
    if (dp[k]) cout << "First\n";
    else cout << "Second\n";
    return 0;
}



Measured memory_bytes: 640
N, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
for i in range(1, len(a)):
    # 2組の合計がxよりも大きいなら
    if a[i-1] + a[i] > x:
        # 右側の数が0より大きいなら食べる
        if a[i] > 0:
            # 右側の箱の飴をすべて食べてもx以上ならすべて食べる
            if (a[i-1] + a[i] - x) > a[i]:
                ans += a[i]
                a[i] = 0
            # 右側の箱の飴を食べるだけでx以下になるならその分だけ食べる
            else:
                ans += (a[i-1] + a[i] - x)
                a[i] = a[i] - (a[i-1] + a[i] - x)

        # 右の箱を食べただけでx以下にならない時は左側の箱の飴も食べる
        if a[i-1] + a[i] > x:
            ans += (a[i-1] + a[i] - x)
            a[i-1] = a[i-1] - (a[i-1] + a[i] - x)
            # 左側の箱の飴をすべて食べる
            # if (a[i-1] + a[i] - x) > a[i-1]:
            #     ans += a[i-1]
            #     a[i-1] = 0
            # 左側の箱の飴をx以下になるだけ食べる
            # else:
            #     ans += (a[i-1] + a[i] - x)
            #     a[i-1] = a[i-1] - (a[i-1] + a[i] - x)

print(ans)


Measured memory_bytes: 14588
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	is_exist := false
	for i := 1; i <= b; i++ {
		if i*a%b == c {
			is_exist = true
			break
		}
	}

	if is_exist {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();

        Shift_Letter(S,N);
    }
    
    public static void Shift_Letter(String S, int N) {
        //大文字アルファベットはA65 - Z90
        StringBuffer sb = new StringBuffer();
        for(int i=0; i<S.length(); i++) {
            char c = S.charAt(i);
            c = (char)((((int)c - 65 + N) % 26) + 65);
            sb.append(c);
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 22224
k = :a

hash ={}

hash[:a] = gets.chomp.split(//)
hash[:b] = gets.chomp.split(//)
hash[:c] = gets.chomp.split(//)

loop do
  if hash[k].size.zero?
    print k.capitalize
    break
  else
    k = hash[k].shift.to_sym
  end
end

Measured memory_bytes: 1788
#include<stdio.h>
#define PI 3.141592653589793238462643383
int main(){
	int a,b;
	char c;
	while(scanf("%d %c %d",&a,&c,&b),c!='?'){
		int ans;
		switch(c){
			case '+':ans=a+b;break;
			case '*':ans=a*b;break;
			case '-':ans=a-b;break;
			case '/':ans=a/b;break;
		}
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N, M;
    ll K;
    cin >> N >> M >> K;
    ll A[N + 1]{}, B[M + 1]{};
    ll t = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i + 1];
    }
    for (int i = 0; i < M; i++) {
        cin >> B[i + 1];
    }
    int id_a = 0;
    for (int i = 0; i <= N; i++) {
        if (t + A[i] <= K) {
            t += A[i];
            id_a = i;
        } else {
            break;
        }
    }
    int ans = id_a;
    int id_b = 0;
    for (int i = id_a; i >= 0; i--) {
        while (id_b <= M) {
            if (t + B[id_b] <= K) {
                t += B[id_b];
                ans = max(ans, i + id_b);
                id_b++;
            } else {
                break;
            }
        }
        t -= A[i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 6724
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>

using namespace std;
typedef long long int ll;

ll a,b,c;

int main(){
    scanf("%lld %lld %lld",&a,&b,&c);
    printf("%lld\n",min((a%2)*b*c,min(a*(b%2)*c,a*b*(c%2))));
}

Measured memory_bytes: 256
from collections import Counter
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


N, M = map(int, input().split())
mat = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]

ans = N
Q = [set([v for v in range(M)])]
while Q:
    C = Counter()
    sports_cand = Q.pop(0)
    for n in range(N):
        for m in range(M):
            if mat[n][m] in sports_cand:
                C[mat[n][m]] += 1
                break
    tmp = 0
    rem_key = set()
    for key, val in C.most_common():
        if val >= tmp:
            tmp = val
            ans = min(ans, val)
            rem_key.add(key)
        else:
            break
    if len(sports_cand) > 2:
        Q.append(sports_cand-rem_key)
print(ans)


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
    int w, h, n;
    cin >> w >> h >> n;
  	int x, y, a;
  	int xmin = 0, xmax = w, ymin = 0, ymax = h;
  	rep(i,n) {
      	cin >> x >> y >> a;
		if(a==1) xmin = max(xmin, x);
      	else if(a==2) xmax = min(xmax, x); 
		else if(a==3) ymin = max(ymin, y);
      	else if(a==4) ymax = min(ymax, y);
    }
  	if(xmax-xmin<0 || ymax-ymin<0) cout << 0 << endl;
  	else cout << (xmax-xmin)*(ymax-ymin) << endl;
  	return;
}

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

Measured memory_bytes: 256
import bisect
import math
import sys
from collections import Counter, defaultdict, deque
from copy import copy, deepcopy
from heapq import heapify, heappop, heappush
from itertools import combinations, permutations
from queue import Queue

read = sys.stdin.read
readline = sys.stdin.readline 
readlines = sys.stdin.readlines 

def SI():
    return int(readline())
def MI():
    return map(int, readline().split())
def MLI():
    return map(int, open(0).read().split())

inf = float("inf")


def main():
    N, K = MI()
    num_factor_K = N // K
    ret = num_factor_K ** 3
    
    if K % 2 == 0:
        num_factor_half_K = N // K
        if N % K >= K // 2:
            num_factor_half_K += 1
        ret += num_factor_half_K ** 3
        
    print(ret)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 4076
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000000
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
unordered_map<ll,int> f; int head[N],tot,n,ans[N],mx[N],fa[N];
struct Edge{int v,next;}edge[N];
inline void add(int x,int y){edge[++tot]=Edge{y,head[x]};head[x]=tot;}
inline int Q(int x,int y)
{	if(f.count((ll)x*(n+1)+y)) return f[(ll)x*(n+1)+y];
	if(x>=y) return f[(ll)x*(n+1)+y]=0;
	int ans=1; for(rint i=head[x];i;i=edge[i].next) if(to!=fa[x]) ans+=Q(to,y);
	return f[(ll)x*(n+1)+y]=ans;
}
void _(int x){for(rint i=head[x];i;i=edge[i].next)if(to!=fa[x])fa[to]=x,_(to);}
void dfs(int x,int la=0)
{	if(x==1) ans[x]=1;
	else
	{	int s=1; for(rint i=head[x];i;i=edge[i].next) if(to!=la) s+=Q(to,mx[x]);
		if(x<mx[la]) s-=Q(x,mx[la]); ans[x]=ans[la]+s;
	}
	for(rint i=head[x];i;i=edge[i].next) if(to!=la) mx[to]=max(mx[x],x),dfs(to,x);
}
int main()
{	int x,y; cin>>n; for(rint i=1;i<n;i++) scanf("%d%d",&x,&y),add(x,y),add(y,x);
	_(1); dfs(1); for(rint i=2;i<=n;i++) printf("%d ",ans[i]-1);
	return 0;
}


Measured memory_bytes: 50120
#include <cstdio>
#include <algorithm>
using namespace std;
const int mod = 1e9 + 7;
const int MAXN = 2000050;
int fac[MAXN], inv[MAXN];
void pre(int N) {
	fac[0] = inv[0] = fac[1] = inv[1] = 1;
	for(int i = 2; i <= N; ++i)
		fac[i] = 1ll*fac[i-1]*i%mod,
		inv[i] = 1ll*(mod-mod/i)*inv[mod%i]%mod;
	for(int i = 2; i <= N; ++i)
		inv[i] = 1ll*inv[i-1]*inv[i]%mod;
}
int F(int x1, int y1, int x2, int y2) { return 1ll*fac[x2-x1+y2-y1]*inv[x2-x1]%mod*inv[y2-y1]%mod; }
struct node { int x, y, f; }a[4], b[4];
int x1, x2, x3, x4, x5, x6;
int y1, y2, y3, y4, y5, y6;
int cal(node p, node q) {
	int x1 = p.x, y1 = p.y, x2 = q.x, y2 = q.y;
	int re = 0;
	for(int i = x3; i <= x4; ++i) re = (re + 1ll*F(x1, y1, i, y3-1)*F(i, y3, x2, y2)%mod*(-i-y3))%mod;
	for(int j = y3; j <= y4; ++j) re = (re + 1ll*F(x1, y1, x3-1, j)*F(x3, j, x2, y2)%mod*(-x3-j))%mod;
	for(int i = x3; i <= x4; ++i) re = (re + 1ll*F(x1, y1, i, y4)*F(i, y4+1, x2, y2)%mod*(i+y4+1))%mod;
	for(int j = y3; j <= y4; ++j) re = (re + 1ll*F(x1, y1, x4, j)*F(x4+1, j, x2, y2)%mod*(x4+j+1))%mod;
	return re;
}
int main () {
	scanf("%d%d%d%d%d%d", &x1, &x2, &x3, &x4, &x5, &x6);
	scanf("%d%d%d%d%d%d", &y1, &y2, &y3, &y4, &y5, &y6);
	pre(2*max(x6,y6)+10);
	a[0] = (node){ x2, y2, 1 }, a[1] = (node){ x2, y1-1, -1 }, a[2] = (node){ x1-1, y2, -1 }, a[3] = (node){ x1-1, y1-1, 1 };
	b[0] = (node){ x6+1, y6+1, 1 }, b[1] = (node){ x6+1, y5, -1 }, b[2] = (node){ x5, y6+1, -1 }, b[3] = (node){ x5, y5, 1 };
	int ans = 0;
	for(int i = 0; i < 4; ++i)
		for(int j = 0; j < 4; ++j)
			ans = (ans + a[i].f*b[j].f*cal(a[i], b[j])) % mod;
	printf("%d\n", (ans + mod) % mod);
}

Measured memory_bytes: 15872
function Main(input) {
	tmp = input.split(" ");
	var a = parseInt(tmp[0]);
	var p = parseInt(tmp[1]);
	var r = 0;
	p += a * 3;
	r = parseInt(p / 2);
	console.log(r);
}

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

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	long long n;
	cin>>n;
	string ans="";
	while(n)
	{
		ans += (97 + ((n-1)%26));
		if((n-1)%26==25)
		{
			n/=26;n--;
		}
		else n/=26;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;																				
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, m, ta, mu = 1;
pair<int, int> a[200010];

signed main() {
	cin >> n >> m;
	rep(i, m)cin >> a[i].first >> a[i].second;
	sort(a, a + m);
	ta = a[0].second;
	rep(i, m) {
		if (ta <= a[i].first) {
			mu++;
			ta = a[i].second;
		}
		else if (ta > a[i].second) {
			ta = a[i].second;
		}
	}
	cout << mu << endl;
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.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++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    cout << (n + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

// I'm trying to ~~~
int main(){
    int A,B; cin >> A >> B;
    cout << (A-1)*(B-1) << endl;

}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi d(n);
    rep(i,n) cin>>d[i];
    sort(all(d));
    d.erase(unique(all(d)), d.end());
    cout<<d.size()<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    int count = 0;
    int ans = 0;
    string ACGT = "ACGT";
    bool match = false;
    for (int i = 0; i < S.size(); i++)
    {
        match = false;
        for (int j = 0; j < ACGT.size(); j++)
        {
            if (S[i] == ACGT[j])
            {
                count++;
                match = true;
                break;
            }
        }
        if (!match)
        {
            ans = max(ans, count);
            count = 0;
        }
    }
    cout << max(ans,count) << endl;
}

Measured memory_bytes: 256
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = []
X = []
for i in range(M):
    a, b =map(int,input().split())
    P.append(a)
    X.append(b)
for i in range(M):
    print(sum(T) - T[P[i]-1] + X[i])

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int d;
	long long n,ans=1;;
	cin >> d >> n;
	if( n == 100){
		n++;
	}
	for(int i=1;i<=d;i++) ans *= 100;
	ans *= n;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
s=int(input())
S=[]
ans=0
for i in range(10**6):
    S.append(s)
    if s%2==0 :
        s=s//2
    else:
        s=3*s+1
    for j in range(i):
        if S[j]==s:
            ans=i+1
            break
    if ans!=0 :
        break            
print(ans+1)

Measured memory_bytes: 9128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <functional>
using namespace std;

int A, B, C, X, cnt;

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

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

#define int long long

int solve(vector<vector<int>>&v,int n,int W)
{
    int dp[n+1][W+1];
    for(int i=0; i<=n; i++)
    {
        for(int j=0; j<=W; j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else
            {
                if(v[i-1][0]<=j)
                    dp[i][j]=max(v[i-1][1]+dp[i-1][j-v[i-1][0]],dp[i-1][j]);
                else
                    dp[i][j]=dp[i-1][j];
            }
        }
    }
    return dp[n][W];
}


int32_t main()
{
    int n,W;
    cin>>n>>W;
    vector<vector<int>> v;
    for(int i=0; i<n; i++)
    {
        vector<int> vi(2);
        cin>>vi[0]>>vi[1];
        v.push_back(vi);
    }
    cout<<solve(v,n,W);
    return 0;
}

Measured memory_bytes: 82480
#include <cstdio>
#include<iostream>
#include<vector>
#include<cstring>
#define MAXN 100005
using namespace std;
int a[MAXN];
bool b[MAXN];
void init(int n){
    fill(a, a+MAXN, 0);
    fill(a, a+n+1, 1);
    fill(b, b+MAXN, false);
    b[1] = true;
}


int main(){
    int n,m;
    cin >> n >> m;
    init(n);
    bool flag=0;
    for(int i=0; i<m; i++){
        int x, y;
        cin >> x >> y;
        if(x==1){
            flag=1;
        }
        a[x]--;
        a[y]++;
        if(flag && b[x]){
            b[y] = 1;
            if(a[x] == 0)
                b[x] = 0;
        }
    }
    int ans=0;
    for(int i=1; i<n+1; i++){
        if(b[i]) ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 768
# coding: utf-8


N, K = map(int,input().split())
if K % 2 == 0:
    a = K/2
    moto = 0
    while a <= N:
        a += K
        moto += 1
    ans = moto**3
    b = N // K
    ans += b**3
    print(ans)
else:
    b = N // K
    print(b**3)

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

bool isAlpha(char ch) {
    if ((65 <= ch && ch <= 90) || (97 <= ch && ch <= 122)) {
        return true;
    }
    return false;
}

char toLower(char ch) {
    if (65 <= ch && ch <= 90) {
        return char(ch + 32);
    }
    return ch;
}

int main() {

    int mp[26] = {0};
    char input;
    char ch = 0;

    while (cin >> input) {
        if (isalpha(input)) {
            ch = toLower(input);
            mp[ch - 'a']++;
        }
    }

    for (int i = 0, ch = 'a'; i < 26; i++) {
        cout << char(ch + i) << " : " << mp[i] << endl;
    }
}


Measured memory_bytes: 3096
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif


vector<int> bagvalue(N/3,inf); 
void solve()
{
	int n,w ;
	cin >> n >> w; 
	vector<pair<int,int>> items(n);
	for(auto &it : items) cin >> it.ss >> it.ff ;
	sort(all(items));
	bagvalue[0] = 0 ;
	for(auto it : items){
		for(int i = 100*1000; i >= 0 ; --i){
			if(i + it.ff > 100*1000) continue ;
			bagvalue[i + it.ff] = min(bagvalue[i+it.ff], bagvalue[i] + it.ss);
		}
	}
	int ans = 0 ;
	for(int i = 0 ; i <= 100*1000 ; ++i){
		if(bagvalue[i] <= w) ans = max(ans, i) ;
	}
	cout << ans ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

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

int h,w,c;
int p[10][10];
int ans;

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
void ch(int x,int y,int z, int zz ){
  if( x<0 || y<0 ) return;
  if( x>=h || y>=w ) return;
  if( p[x][y]!=zz ) return;
  p[x][y]=z;

  for( int lp=0;lp<4;lp++ ){
    ch( x+dx[lp],y+dy[lp],z,zz );
  }
}

int countC(int x,int  y,int z){
  int ret=1, i,j;
  if( x<0 || y<0 ) return 0;
  if( x>=h || y>=w ) return 0;
  if( p[x][y]!=z )    return 0;
  
  p[x][y]=0;
  for( int lp=0;lp<4;lp++ ){
    i=x+dx[lp]; j=y+dy[lp];
    ret += countC( i,j,z );
  }
  return ret;
}


void rec(int n ){
  int b[10][10];
  if( n==0 ){
    if( p[0][0]!=c ) return;

    int aa=countC(0,0,p[0][0]);
    if( aa>ans ){
      ans=aa;
      /*
      cout << "max="<<ans<<endl;
      for( int i=0;i<h;i++ ){
	for( int j=0;j<w;j++ )
	  cout << p[i][j] << " ";
	cout << endl;
      }
      */
    }
    return;
  }
  --n;

  for( int lp=1;lp<=6;lp++ ){
    if( p[0][0]==lp ) continue;

    for( int a=0;a<h;a++ ) for( int aa=0;aa<w;aa++ ) b[a][aa]=p[a][aa];
    ch( 0,0,lp,p[0][0] );
    rec( n );
    for( int a=0;a<h;a++ ) for( int aa=0;aa<w;aa++ ) p[a][aa]=b[a][aa];
  }
}


int main(){

  while( cin>>h>>w>>c && (h|w|c) ){
    for( int i=0;i<h;i++ )
      for( int j=0;j<w;j++ )
	cin >> p[i][j];

    ans=0;
    rec(5);
    cout << ans << endl;
  }

  return 0;
}

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

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


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

    S = '0'+S;
    int ans = 0, carry = 0;
    for(int i = S.size()-1; i > 0; --i){
        int now = (S[i]-'0') + carry;
        ans += min(now, 10-now);
        if(now > 5 or (now == 5 and S[i-1] >= '5')) carry = 1;
        else carry = 0;
    }
    cout << ans+carry << endl;

    return 0;
}

Measured memory_bytes: 2308
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? ((x) : -(x)))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 3e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
ll A[65][2];
ll twoPow[65];

int main()
{
	int i, j;
	ll x, sum;
	ll two = 1ll;
	int e = 0;
	while (e <= 60) {
		twoPow[e] = two;
		++e;
		two = two * 2ll % MOD;
	}

	sum = 0ll;
	scanf("%d", &N);
	for (i = 1; i <= N; ++i) {
		scanf("%lld", &x);
		for (j = 0; j <= 60; ++j) {
			int bit = x & (1ll << j) ? 1 : 0;
			sum = (sum + (A[j][!bit] * twoPow[j] % MOD)) % MOD;
			A[j][bit]++;
		}
	}
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input=input.split("\n");
  const A=['R','U','D'];
  const B=['L','U','D'];
  
  for(var i=0;i<input[0].length;i++){
    if((i%2===1&&input[0][i]==='R')||(i%2===0&&input[0][i]==='L')){
      console.log('No');
      return;
    }
  }
  console.log('Yes');
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  
  


Measured memory_bytes: 29532
def nPr(n, r):
  ans = 1
  for i in range(n,n-r,-1):
    ans *= i
  return ans

def nCr(n, r):
  tmp = 1
  for i in range(r,1,-1):
    tmp *= i
  return int(nPr(n, r) / tmp)

n = int(input())
a = list(map(int,input().split()))
count = len(a)
d = {}
x = 0

for i in a:
  if i not in d:
    d[i] = 1
  else:
    d[i] += 1

for i in d:
  x += nCr(d[i], 2)

for i in a:
  ans = x - d[i] + 1
  print(ans)

Measured memory_bytes: 26140
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
    ll nn;
    cin>>nn;
       string s;
       cin>>s;
       ll i,n=s.length();
       ll ct=0;
       for(i=0;i<=n-3;i++)
       {
           if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
           {
               ct++;
           }
       }
       cout<<ct<<endl;
}


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

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

    std::vector<long> A(N);
    for (int i = 0; i < N; i += 1) {
        std::cin >> A[i];
    }

    long x1 = 0;
    for (int i = 0; i < N; i += 1) {
        if (i % 2 == 0) {
            x1 += A[i];
        } else {
            x1 -= A[i];
        }
    }
    x1 = x1 / 2;
    std::cout << x1 * 2;

    long xi = x1;
    for (int i = 0; i < N - 1; i += 1) {
        xi = A[i] - xi;
        std::cout << " " << xi * 2;
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 2048
import std;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long K = lread();
    long A, B;
    scan(A, B);
    writeln((A % K == 0 || (((A + K) / K) * K <= B)) ? "OK" : "NG");
}


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


int main(){


    int a, b, i;

    int k = 1;

 
    cin >> a >> b;


    for( i = 1 ; k < b ; i = i + 1 ){

         k += a - 1;

         }


    cout << i - 1 << endl;
         

    return 0;


    }

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

using namespace std;

typedef long long ll;

void solve() {
	ll s, w;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe\n";
	} else {
		cout << "safe\n";
	}
}

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


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




int main() {
	int64_t n,x,m;
	int flag = 0;
	int j = 0;;
	cin >> n >> x >> m;
	vector<int64_t>amari(m+1,0);
	vector<int64_t>times(m,0);
	amari.at(0)=x;
	int64_t s = x;
	for(int i=1;i<m+1;i++){
		
		int64_t t;
		t = (s*s)%m;
		
		s = t;
		if(t == 0){
			flag = 1;
			j = i;
			break;
		}
		else if(t == 1){
			flag =2;
			j = i;
			break;
		}
		else{
			amari.at(i)=t;
		}
	}
	int64_t answer = 0;
	
	
	if(flag == 1){
		for(int i =0;i<j;i++){
			answer += amari.at(i);

		}
		cout << answer << endl;

	}
	else if(flag == 2){
		for(int i =0;i<j;i++){
			answer += amari.at(i);


		}
		cout << answer + n - j << endl;

	}
	
	else{
		for(int i=0;i<m;i++){
			int64_t c = amari.at(i);
			times.at(c)++;
		}
		
		int64_t d = 0;;
		for(int i = 0;i<m;i++){
			if(times.at(i)>=2){
				d = i;
				break;
			}
		}
		
		int64_t e,f,g,h,k;
		e = 0;
		f = 0;
		int count = 0;
		for(int64_t i=0;i<m;i++){
			if(amari.at(i)== d){
				count ++;
				if(count == 1){
					e = i;
				}
				else if(count == 2){
					f = i;
				}

			}

		}
		
		g = f - e; 
		h = (n-e)/g;
		k = (n-e)%g;
		
		for(int i=e;i<f;i++){
			answer += amari.at(i);
		}
		answer *= h;
		for(int i =0;i<e;i++){
			answer += amari.at(i);

		}
		for(int i =e;i<e+k;i++){
			answer += amari.at(i);

		}
		
		cout << answer << endl;
	}
}




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

int read(){
	int a = 0; char c = getchar();
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)){
		a = a * 10 + c - 48; c = getchar();
	}
	return a;
}

const int _ = 2e5 + 7;
int val[_] , cnt[_] , N;

bool cmp(int a , int b){return a > b;}

struct segTree{
	int mx[_ << 2];

	void init(){memset(mx , -0x3f , sizeof(mx));}

#define mid ((l + r) >> 1)
#define lch (x << 1)
#define rch (x << 1 | 1)

	void modify(int x , int l , int r , int tar , int val){
		if(l == r){mx[x] = val; return;}
		mid >= tar ? modify(lch , l , mid , tar , val) : modify(rch , mid + 1 , r , tar , val);
		mx[x] = max(mx[lch] , mx[rch]);
	}

	int qry(int x,  int l , int r , int L , int R){
		if(l >= L && r <= R) return mx[x];
		int Mx = -1e9;
		if(mid >= L) Mx = qry(lch , l , mid , L , R);
		if(mid < R) Mx = max(Mx , qry(rch , mid + 1 , r , L , R));
		return Mx;
	}
}T1 , T2;

bool check(int pos , int Mx1 , int Mx2 , int cnt1 , int cnt2){
	int V1 = cnt1 + cnt[pos] - cnt2 , V2 = cnt2 + cnt[pos] - cnt1;
	if(V1 >= 0)
		if(V1 & 1){if(T1.qry(1 , 1 , N , Mx2 , N) >= V1) return 1;}
		else if(T2.qry(1 , 1 , N , Mx2 , N) >= V1) return 1;
	if(V2 >= 0)
		if(V2 & 1){if(T1.qry(1 , 1 , N , Mx1 , N) >= V2) return 1;}
		else if(T2.qry(1 , 1 , N , Mx1 , N) >= V2) return 1;
	return 0;
}

int main(){
	N = read();
	int pre = 0;
	for(int i = 1 ; i <= N ; ++i){
		val[i] = read(); cnt[i] = val[i] > pre;
		pre = max(pre , val[i]);
	}
	for(int i = N ; i ; --i) cnt[i] += cnt[i + 1];
	T1.init();
	for(int i = N ; i ; --i){
		int p0 = T1.qry(1 , 1 , N , val[i] , N) , p1 = T2.qry(1 , 1 , N , val[i] , N);
		if(cnt[i] > cnt[i + 1]){
			T1.modify(1 , 1 , N , val[i] , p0 + 2);
			T2.modify(1 , 1 , N , val[i] , p1 + 2);
		}
		else{
			T1.modify(1 , 1 , N , val[i] , p1 + 1);
			T2.modify(1 , 1 , N , val[i] , p0 + 1);
		}
	}
	vector < int > arr1 , arr2; string s;
	int Mx1 = 1 , Mx2 = 1 , cnt1 = 0 , cnt2 = 0;
	for(int i = 1 ; i <= N ; ++i){
		T1.modify(1 , 1 , N , val[i] , -1e9);
		T2.modify(1 , 1 , N , val[i] , 0);
		if(check(i + 1 , max(Mx1 , val[i]) , Mx2 , cnt1 + (Mx1 <= val[i]) , cnt2)){
			arr1.push_back(val[i]); cnt1 += Mx1 <= val[i]; Mx1 = max(Mx1 , val[i]);
			s.push_back('0');
		}
		else{
			arr2.push_back(val[i]); cnt2 += Mx2 <= val[i]; Mx2 = max(Mx2 , val[i]);
			s.push_back('1');
		}
	}
	if(cnt1 == cnt2) cout << s;
	else cout << -1;
	return 0;
}

Measured memory_bytes: 9720
using System;
namespace test
{
    class program
    {
        static void Main()
        {
            double r = double.Parse(Console.ReadLine());
            double s = r * r * 3.141592653589;
            double l = 2 * r * 3.141592653589;
            Console.WriteLine("{0:f6} {1:f6}",s,l);
        }
    }
}

Measured memory_bytes: 9288
#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 solve(int x) {
    int ans = 0;
    while(x > 0) {
        ans += x%10;
        x /= 10;
    }
    return ans;
}
int main(void) {
    int n; cin >> n;
    string ans = "Yes";
    if(n%solve(n) != 0) ans = "No";
    cout << ans;
}


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

typedef long long ll;
int main()
{
    string str;
    cin>>str;
    int mn=INT_MAX;
    for(int i=0;i+3<=str.size();i++)
    {
        string nw;
        for(int j=i;j<i+3;j++)
        {
            nw+=str[j];
        }
        stringstream cpy(nw);
        int x=0;
        cpy>>x;
        mn=min(mn,abs(x-753));
    }
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S.size()
using namespace std;
typedef unsigned long long ll;

int main(void){
	string s;
	cin >> s;
	int cnt0 = 0, cnt1 = 0;
	rep(i, s.size()){
		if(s[i] == '0') cnt0++;
		else cnt1++;
	}
	cout << min(cnt1, cnt0) * 2 << endl;

	return 0;
}


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

int n;
int dp[1000005];

int solve(int a[], int i, int k)
{
	if (i == n)
	{
		return 0;
	}

	if (dp[i] != -1)
	{
		return dp[i];
	}

	int value = INT_MAX;
	int j = 1;
	while (j <= k && i + j <= n )
	{
		value = min(value, abs(a[i + j] - a[i]) + solve(a, i + j, k));
		j++;
	}
//value = min(abs(a[i + 1] - a[i]) + solve(a, i + 1), abs(a[i + 2] - a[i]) + solve(a, i + 2));
	return dp[i] = value;
}

int main()
{
	int k;
	cin >> n >> k;
	int a[n];
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	memset(dp, -1, sizeof(dp));
	cout << solve(a, 1, k);
	return 0;
}

/*cin >> n;
  FOR(n) cin >> a[i];
  dp[2] = abs(a[2] - a[1]);
  Rep(i,3,n)
  {
      dp[i] = min( dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]) );
  }
  cout << dp[n] << endl;
  */

Measured memory_bytes: 15608
#!/usr/bin/env python3
import sys


def solve(N: int, V: "List[int]", C: "List[int]"):
    tmp = []
    for i in range(N):
        tmp.append(V[i] - C[i])
    tmp.sort(reverse=True)
    ret = 0
    for t in tmp:
        if t > 0:
            ret += t
    print(ret)
    return


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
    V = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    C = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, V, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
abc = gets.split(' ').map(&:to_i)

abc.sort!

ans = abc[2]-abc[1]

abc[0] += (abc[2]-abc[1])
abc[1] += (abc[2]-abc[1])

if (abc[1] - abc[0]) % 2 == 0
  ans += (abc[1] - abc[0]) / 2
else
  ans += (abc[1] - abc[0] + 1) / 2 + 1
end

puts(ans)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;

using namespace std;

int main()
{
    ll n;
    ld s = 0;
    cin >> n;
    for (int i = 1; i <= n; i ++)
    {
        ld a;
        cin >> a;
        s += (1 / a);
    }
    cout << 1 / s;
}


Measured memory_bytes: 256
# A~Eの１の位が（0を除いて）最も小さいものを最後に頼めばよい
import numpy as np
A = np.zeros(5)
B = np.zeros(5)
time = 0
for i in range(5):
    A[i] = int(input())
    if A[i] % 10 == 0:
        B[i] = 10
    else:
        B[i] = A[i] % 10
B = np.sort(B)
for h in range(5):
    time += A[h] + 10 - B[h]
time = time-10+B[0]
print("{}".format(int(time)))


Measured memory_bytes: 12408
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] s = new String[N];
		for(int i = 0; i < N; i++) s[i] = sc.next();

		int M = sc.nextInt();
		String[] t = new String[M];
		for(int i = 0; i < M; i++) t[i] = sc.next();

		int X = 0;
		for(int i = 0; i < N; i++) {
			int sum = 0;
			for(int j = 0; j < N; j++) {
				if(s[j].equals(s[i])) sum++;
			}
			for(int j = 0; j < M; j++) {
				if(t[j].equals(s[i])) sum--;
			}
			X = Math.max(X, sum);
		}

		System.out.println(X);
	}
}

Measured memory_bytes: 21844