akhauriyash/Code-Regression huggingface dataset:
fn solve(a: isize, b: isize) -> isize {
    if (a - 2 * b) < 0 {
        0
    } else {
        a - 2 * b
    }
}

#[test]
fn test_solve() {
    assert_eq!(solve(12, 4), 4);
    assert_eq!(solve(20, 15), 0);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (a, b) = parse_line!(isize, isize);
    println!("{}", solve(a, b));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define maxn 1000
#define mod 1000000007
using namespace std;

int n,m;
string ar[maxn];
int dp[maxn][maxn];

int main() {
	cin >> n >> m;
	for( int i = 0 ; i < n ; i++ )
		cin >> ar[i];
	dp[0][0] = 1;
	for( int i = 0 ; i < n ; i++ )
		for( int j = 0 ; j < m ; j++ )
			if( i+j > 0 || ar[i][j] == '.' ) {
				if( i > 0 && ar[i-1][j] == '.' )
					dp[i][j] = ( dp[i][j] + dp[i-1][j] ) % mod;
				if( j > 0 && ar[i][j-1] == '.' )
					dp[i][j] = ( dp[i][j] + dp[i][j-1] ) % mod;
			}
	cout << dp[n-1][m-1] << endl;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 100005;

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    int ans = (n + x - 1) / x * y;
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  double ans = 0;
  for(int i = 0; i < N;i++){
	double std = i + 1;
    double count = 1;
    while(std < K){
      std *= 2;
      count /= 2;
    }
    ans += count / N;
  }

  printf("%.12f\n",ans);
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace ABC0613
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] oni = Console.ReadLine().Split(' ');
            string[]nige= Console.ReadLine().Split(' ');
            long a = long.Parse(oni[0]);
            long v = long.Parse(oni[1]);
            long b = long.Parse(nige[0]);
            long w = long.Parse(nige[1]);

            long t = long.Parse(Console.ReadLine());

            string r = "NO";

            if(v>w)
            {
                long abs = Math.Abs(a - b);
                long speed = v - w;
                long susumukyori = speed * t;
                if (abs <= susumukyori) r = "YES";
                
            }
            Console.WriteLine(r);
        }
    }
}


Measured memory_bytes: 27480
// Problem : A - Painting
// Contest : AtCoder - Keyence Programming Contest 2020
// URL : https://atcoder.jp/contests/keyence2020/tasks/keyence2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n,m,x;
    cin>>n>>m>>x;
    if(n < m) swap(n,m);
    cout<<(n+x-1)/n<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3604
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }

    let mut dai: usize = a[0];
    let mut ans: usize = 0;
    for i in 1..n {
        if dai > a[i] {
            ans += dai-a[i];
        }
        if dai < a[i] {
            dai = a[i]
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 5636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vi a(n);
    vvi x(n), y(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        x[i].resize(a[i]);
        y[i].resize(a[i]);
        for (int j = 0; j < a[i]; j++)
            cin >> x[i][j] >> y[i][j];
    }
    int res = 0;
    for (int msk = 0; msk < (1 << n); msk++)
    {
        bool ok = true;
        for (int i = 0; i < n; i++)
            if (msk & (1 << i))
                for (int j = 0; j < a[i]; j++)
                    ok &= !(((msk >> (x[i][j] - 1)) & 1) ^ y[i][j]);
        if (ok)
        {
            int cur = 0;
            for (int i = 0; i < n; i++)
                if (msk & (1 << i))
                    cur++;
            res = max(res, cur);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
X, Y = map(int, input().split())
def check(a):
    if (a == 4 or a == 6 or a == 9 or a == 11):
        check_a = "A"
    elif a == 2:
        check_a = "B"
    else:
        check_a = "C"
    return check_a
  
if check(X) == check(Y):
    print('Yes')
else:
    print("No")

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int INF = 1e9 + 7;

int main() {
  string x, y;
  cin >> x >> y;
  if (x > y) {
    cout << ">" << endl;
  } else if (x == y) {
    cout << "=" << endl;
  } else {
    cout << "<" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<vector>
using namespace std;

int main() {
    string s;
    int n,i,j,cnt1=0,cntAns=0;
    char ch[26]={};
    cin>>n>>s;
    for(int a=0;a<n-1;a++){
        cnt1=0;
        for(int aa=0;aa<26;aa++)ch[aa]='\0';
        for(i=0;i<=a;i++){
            for(j=a+1;j<n;j++){
                if(s[i]==s[j]&&ch[0]!=s[j]&&ch[1]!=s[j]&&ch[2]!=s[j]&&ch[3]!=s[j]&&ch[4]!=s[j]&&ch[5]!=s[j]&&ch[6]!=s[j]&&ch[7]!=s[j]&&ch[8]!=s[j]&&ch[9]!=s[j]&&ch[10]!=s[j]&&ch[11]!=s[j]&&ch[12]!=s[j]&&ch[13]!=s[j]&&ch[14]!=s[j]&&ch[15]!=s[j]&&ch[16]!=s[j]&&ch[17]!=s[j]&&ch[18]!=s[j]&&ch[19]!=s[j]&&ch[20]!=s[j]&&ch[21]!=s[j]&&ch[22]!=s[j]&&ch[23]!=s[j]&&ch[24]!=s[j]&&ch[25]!=s[j]){
                    ch[cnt1]=s[i];
                    cnt1++;
            }
        }
    }
        if(cntAns<cnt1)cntAns=cnt1;
    }
    cout<<cntAns<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np
import itertools

P = int(input())
A = [int(x) for x in input().split()]

# k,i -> i^k
power = np.ones((P,P),dtype = np.int64)
for k in range(1,P):
    power[k] = power[k-1] * np.arange(P,dtype=np.int64) % P

f = np.zeros(P,dtype=np.int64)
for i,a in enumerate(A):
    if a == 1:
        f[0] += 1
        f -= power[:,i][::-1]
f %= P

f %= P
print(*f)



Measured memory_bytes: 83332
#include <iostream>
int main()
{
	using namespace std;
	int num;
	cin >> num;
	int sort[num];
	for (int i = 0; i < num; i++) cin >> sort[i];
	int v = 1;
	cout << sort[0];
	for (int i = 1; i < num;i++) cout << " " << sort [i] ;
	cout <<endl; 
	for (int i = 1; i <= num-1;i++)
	{	int j = i-1; 
		v = sort[i];
	
		while (j >= 0 && sort[j]> v)
		{	sort[j+1] = sort[j];
			j--;
		}
		sort[j+1] = v;
		cout << sort[0];
		for (int i = 1; i < num;i++) cout  << " " << sort [i];
		cout << endl;}
	return 0; 
			
 } 


Measured memory_bytes: 3108
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		long n = parseLong(sc.next());
		long m = parseLong(sc.next());
		sc.close();
		long g = gcd(n,m);
		long cnt = 1;
		if(g%2L==0) {
			cnt++;
			g /= 2L;
			while(g%2L==0) {
				g /= 2L;
			}
		}
		long mx = (long)sqrt(g);
		for (long k = 3L; k <= mx; k+=2L) {
			if(g%k==0) {
				cnt++;
				g /= k;
				while(g%k==0) {
					g /= k;
				}
			}
		}
		if(g!=1) {
			cnt++;
		}
		out.println(cnt);
	}
	public static long gcd(long a, long b) {
		long tmp;
		while((tmp = a%b)!=0) {
			a = b;
			b = tmp;
		}
		return b;
	}

}


Measured memory_bytes: 23124
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define DSORT(c, type) sort(ALL(c), greater<type>())

using namespace std;


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

int n;  cin >> n;;

int out = 0;
int digit = int(log10(n))+1;
string sn = to_string(n);
for(int i=0; i<digit; ++i){
  if( (int)(sn[i] - '0') == 2 )
    ++out;
}

  cout << out << endl;
  return 0;
}

Measured memory_bytes: 512
import math


loops = int(input())
x_vec = list(map(int, input().split()))
y_vec = list(map(int, input().split()))

manhattan = sum([abs(x_vec[i] - y_vec[i]) for i in range(len(x_vec))])
euclid = math.sqrt(sum([(abs(x_vec[i] - y_vec[i])) ** 2 for i in range(len(x_vec))]))
pequalthree = math.pow(sum([(abs(x_vec[i] - y_vec[i])) ** 3 for i in range(len(x_vec))]), 1.0/3.0)
chebyshev = max([abs(x_vec[i] - y_vec[i]) for i in range(len(x_vec))])

print(manhattan)
print(euclid)
print(pequalthree)
print(chebyshev)



Measured memory_bytes: 5700
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 200003
vvii ad(20);
int vis[20];
int main()
{
    int n,m,i,j,x,y,a;
    in(n);
    rep(i,n)
    {
        in(m);
        rep(j,m)
            in2(x,y),ad[i].pb(x-1,y);
    }
    int K=(1<<n);
    int ans=0;
    int mask;
    rep(mask,K)
    {
        fill(vis,vis+20,0);
        a=0;
        rep(i,n)
        {
            if(mask&(1<<i))
                vis[i]=1,a++;
        }
        int f=1;
        rep(i,n)
        {
            if(mask&(1<<i))
            {
                m=ad[i].size();
                rep(j,m)
                {
                    tie(x,y)=ad[i][j];
                    if((y^vis[x])==1)
                        f=0;
                }
            }
        }
        if(f)
            ans=max(ans,a);
    }
    out(ans);
}









Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(ll i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(ll i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007

string f(int n){
	return to_string(n);
}

string calc(string s){
	string ret;
	int cnt = 0;
	for(int i = 0; i < s.size(); i++){
		cnt = 1;
		for(int j = i; j < s.size(); j++){
			if(j == s.size() - 1 || s[j] != s[j + 1]){
				ret += f(cnt);
				ret += s[j];
				i = j;
				break;
			}
			else cnt++;
		}
	}
	return ret;
}


int main(){
	int n;
	string s;
	while(cin>>n){
		if(n == 0) break;
		cin>>s;

		for(int i = 0; i < n; i++){
			s = calc(s);
			//cout<<s<<endl;
		}

		cout<<s<<endl;
	}

	

}

Measured memory_bytes: 1368
x,n = map(int,input().split())
if n==0:
    print(x)
else:
    p = list(map(int,input().split()))
    if x not in p:
        print(x)
    else:
        for i in range(1,n+10):
            if x - i not in p:
                print(x-i)
                break
            elif x + i not in p:
                print(x+i)
                break

Measured memory_bytes: 9196
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

lli body(lli a, lli b){
	return (a-b)*(a-b);
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int n;
	cin >> n;
	int k = n/15;
	cout << n*800 - k*200 << endl;
 	return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct UnionFind
{
    void init(int n)
    {
        mN = n;
        //mNodeTbl.resize(mN);
        //mRankTbl.resize(mN);
        REP(i, mN)
        {
            mNodeTbl[i] = i;
            mRankTbl[i] = 0;
        }
    }
    int find(int x)
    {
        if (x == mNodeTbl[x])
            return x;
        return mNodeTbl[x] = find(mNodeTbl[x]);
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    void unit(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (mRankTbl[x] < mRankTbl[y])
        {
            mNodeTbl[x] = y;
        }
        else
        {
            mNodeTbl[y] = x;
            if (mRankTbl[x] == mRankTbl[y])
                mRankTbl[x]++;
        }
    }

    int mN;
    ll mNodeTbl[100005];
    ll mRankTbl[100005];
};

pll B[100005];
//! そのノードに属するVertexの数
ll VN[100005];

int main()
{
    ll N, M;
    cin >> N >> M;
    REP(i, M)
    {
        cin >> B[i].first >> B[i].second;
    }
    REP(i, N)
    {
        VN[i] = 1;
    }

    UnionFind uf;
    uf.init(N);

    ll sum = N * (N - 1) / 2;
    vector<ll> ans(M, 0);
    for (int i = M - 1; i >= 0; --i)
    {
        ans[i] = sum;
        pll n = B[i];
        if (uf.same(n.first, n.second))
            continue;

        ll a = VN[uf.find(n.first)];
        ll b = VN[uf.find(n.second)];
        sum -= (a * b);
        uf.unit(n.first, n.second);
        VN[uf.find(n.first)] = a + b;
    }

    REP(i, M)
    {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 6016
fun main(args: Array<String>) {
	var s = readLine() ?: return

	var cnt = s.length
	cnt -= calc(s, 'A')

	s = s.reversed()
	cnt -= calc(s, 'Z')

	println(cnt)
}

fun calc(s: String, c: Char): Int {
	var cnt = 0
	var i = 0
	while (s[i] != c && cnt < s.length) {
		cnt++
		i++
	}
	return cnt
}


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

int a[100005];
int main()
{
    int n,k;
    cin>>n>>k;
    for (int i = 0; i < n; i++)
        cin>>a[i];
    n-=k;
    k--;
    int sum;
    if (n%k != 0)
        sum = 1;
    else 
        sum = 0;
    sum = sum+(n/k)+1;
    cout<<sum<<endl;
    return 0;
}




Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        int[] b = new int[n];
        countingSort(a, b, 10000);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(b[i]);
            if (i < n - 1) {
                sb.append(" ");
            }
        }
        System.out.println(sb.toString());
    }

    private static void countingSort(int[] a, int[] b, int k) {
        int[] c = new int[k + 1];

        for (int i = 0; i < a.length; i++) {
            c[a[i]]++;
        }

        for (int i = 1; i < k + 1; i++) {
            c[i] += c[i - 1];
        }

        for (int i = a.length - 1; i >= 0; i--) {
            b[c[a[i]] - 1] = a[i];
            c[a[i]]--;
        }
    }
}

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

int a[45]={1,2,3,4,5,6,7,8,9,4,6,8,10,12,14,16,18,9,12,15,18,21,24,27,16,20,24,28,32,36,25,30,35,40,45,36,42,48,54,49,56,63,64,72,81};
#define For(i,a,b) for (int i=(a); i<=(b); i++)

bool t=false;
int n;

int main(void)
{
	cin>>n;
	For(i,0,44)
		if(n==a[i])
		{
			t=true;
			break;
		}
	if(t)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
using namespace std;
#define MOD          1000000007
#define PI           3.14159265358979
#define rep(i, n)    for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v)   for (auto i : v)
#define all(x)       (x).begin(), (x).end()
#define rall(x)      (x).rbegin(), (x).rend()
#define pb(x)       push_back(x)
#define mp(x, y)     make_pair((x), (y))
#define fi           first
#define se           second
#define setp(x)      setprecision(x)
#define mset(m, v)   memset(m, v, sizeof(m))
//#define int          long long
static const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
static const int INF =        0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef long long             ll;
typedef vector<int>           vi;
typedef vector<double>        vd;
typedef vector<long long>     vll;
typedef vector<string>        vs;
typedef vector<bool>          vb;
typedef pair<int, int>        pii;
typedef pair<long, long>      pll;
typedef vector<pii>           vpii;
typedef vector<pll>           vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

struct state {
        int y;
        int x;
        int step;
};

int main() { 
        int h, w, k;
        cin >> h >> w >> k;
        string m[1000];
        bool used[1000][1000];
        rep(i, h) rep(j, w) used[i][j] = false;
        int sy, sx;
        rep(i, h) {
                cin >> m[i];
                rep(j, w) if (m[i][j] == 'S') {
                        sy = i;
                        sx = j;
                }
        }
        queue<state> q;
        vpii f;
        q.push({sy, sx, 0});
        while (!q.empty()) {
                state p = q.front(); q.pop();
                if (p.step > k) break;
                f.pb(mp(p.y, p.x));
                rep(d, 4) {
                        int xx = p.x + dx[d];
                        int yy = p.y + dy[d];
                        if (!used[yy][xx] && 0 <= xx && xx < w && 0 <= yy && yy < h && m[yy][xx] == '.') {
                                used[yy][xx] = true;
                                int ns = p.step + 1;
                                q.push({yy, xx, ns});
                        }
                }
        }
        //rep(i, f.size()) cout << f[i].se << ' ' << f[i].fi << endl; 
        int mins = INF;
        rep(i, f.size()) {
                int ss = min({w - f[i].se - 1, h - f[i].fi - 1, f[i].se, f[i].fi});
                amin(mins, ss);
        }
        int ans = 1;
        ans += mins / k;
        if (mins % k != 0) ans ++;
        cout << ans << endl;
        return 0;
}



Measured memory_bytes: 10356
#include <bits/stdc++.h>
#define N 1000000007;

using namespace std;


int main()
{
  int n,m,sum=0;
  cin>>n>>m;
  int a[n];
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
      sum+=a[i];
  }
  int nb=0;
  for(int i=0;i<n;i++)
     {
         if (a[i]>=(double)sum/(4*m))
         {
             nb++;
         }
     }
  if (nb<m)
     cout<<"No";
  else
     cout<<"Yes";



}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)

inline vll move(vll p, char d) {
	if (d == 'U') {
		p[0]--;
	}
	else if (d == 'D') {
		p[0]++;
	}
	else if (d == 'R') {
		p[1]++;
	}
	else if (d == 'L') {
		p[1]--;
	}
	return p;
}

int main() {
	ll n;
	ll a;
	map<ll, ll> m;
	vll tmp(3);

	in(n);
	rep(i, 0, n) {
		in(a);
		m[a]++;
	}


	if (m.size() == 1) {
		if (m.begin()->first == 0) {
			outn("Yes");
			return 0;
		}
		
	}

	if (n % 3 != 0) {
		outn("No");
		return 0;
	}

	
	if (m.size() == 2) {
		if (m[0] == n / 3) {
			outn("Yes");
			return 0;
		}
	}

	else if (m.size() == 3) {
		a = 0;
		for (auto itr = m.begin(); itr != m.end(); itr++) {
			if (itr->second == n / 3) {
				tmp[a] = itr->first;
				a++;
			}
			else {
				outn("No");
				return 0;
			}
		}
		if ((tmp[0] ^ tmp[1] ^ tmp[2]) == 0) {
			outn("Yes");
			return 0;
		}
	}

	outn("No");

	return 0;

}


Measured memory_bytes: 5120
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a, const void *b){return *(int*)b-*(int*)a;}
int N, A[200200];
long ans = 0;
int main(){
	scanf("%d",&N);
	for(int i=0; i<N; i++)scanf("%d",&A[i]);
	qsort(A, N, 4, cmp);
	for(int i=1; i<N; i++){
		ans += A[i/2];
	}
	printf("%ld\n", ans);
	return 0;
}

Measured memory_bytes: 3104
#include <stdio.h>
#include <string.h>

int main(void) {

  char s[51];
  scanf("%s", s);
  char akiba[10] = "AKIHABARA";
  int count_A = 0;
  int count_other = 0;
  for (int i = 0; i < strlen(s); i++) {
    if (s[i] == 'A') {
      count_A++;
    } else if (s[i] == 'K') {
      if (count_other == 0 && (count_A == 0 || count_A == 1)) {
        count_other++;
        if (count_A == 0) {
          count_A++;
        }
      } else {
        printf("NO\n");
        return 0;
      }
    } else if (s[i] == 'I') {
      if (count_other == 1 && count_A == 1) {
        count_other++;
      } else {
        printf("NO\n");
        return 0;
      }
    } else if (s[i] == 'H') {
      if (count_other == 2 && count_A == 1) {
        count_other++;
      } else {
        printf("NO\n");
        return 0;
      }
    } else if (s[i] == 'B') {
      if (count_other == 3 && (count_A == 1 || count_A == 2)) {
        count_other++;
        if (count_A == 1) {
          count_A++;
        }
      } else {
        printf("NO\n");
        return 0;
      }
    } else if (s[i] == 'R') {
      if (count_other == 4 && (count_A == 2 || count_A == 3)) {
        count_other++;
        if (count_A == 2) {
          count_A++;
        }
      } else {
        printf("NO\n");
        return 0;
      }
    } else {
      printf("NO\n");
      return 0;
    }
  }
  if (count_other == 5 && (count_A == 3 || count_A == 4)) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }

  return 0;
}

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

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
  	  cin >> A[i][j];
    }  	
  }

  int N;
  cin >> N;
  // 呼ばれる数字の回数
  for (int i = 0; i < N; i ++) {
    int b;
    cin >> b;
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (A[j][k] == b) {
          A[j][k] = 0;
        }
      }
    }
  }

  bool flag = false;

  for(int i = 0; i < 3; i++) {
    if (A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0) {
      flag = true;
    }
  }

  for(int i = 0; i < 3; i++) {
    if (A[0][i] == 0 && A[1][i] == 0 && A[2][i] == 0) {
      flag = true;
    }
  }

  if (A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0) {
    flag = true;
  }

  if (A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0) {
    flag = true;
  }

  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long 
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e6+9;
const ll MOD=998244353;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
ll cnt[MAX];
int main() 
{

	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
     ll n;
    cin>>n;
    string ans="";
    while(n){
      ans=ans+(char)(((((n-1)%26))+'a'));
      n=(n-1)/((ll)26);
    }
    reverse(ans.begin() , ans.end());
    cout<<ans;


}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define max_n 1000000

using namespace std;

void solve()
{
	ll a,b,c;cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c<<endl;
}

int32_t main() 
{ 

	IOS	
	ll T=1;
	// cin>>T;
	for(ll i=1;i<=T;++i)
	{		
		// cout<<"Case #"<<i<<": ";
    	solve();
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int maxRow = 3;
        int maxCol = 3;
        Map<Integer, Integer> locationMap = new HashMap<>();
        boolean[][] grid = new boolean[maxRow][maxCol];

        for(int i = 0; i < maxRow; i++) {
            for(int j = 0; j < maxCol; j++) {
                locationMap.put(sc.nextInt(), i * (maxCol+1) + j);
            }
        }

        int n = sc.nextInt();
        while(n-- > 0) {
            int b = sc.nextInt();
            if(!locationMap.containsKey(b)) continue;

            int loc = locationMap.get(b);
            int row = loc / (maxCol+1);
            int col = loc % (maxCol+1);
            grid[row][col] = true;
        }

        for(int i = 0; i < maxRow; i++) {
            if(grid[i][0] && grid[i][1] && grid[i][2]) {
                System.out.println("Yes");
                return;
            }
            if(grid[0][i] && grid[1][i] && grid[2][i]) {
                System.out.println("Yes");
                return;
            }
        }
        if(grid[0][0] && grid[1][1] && grid[2][2] || 
            grid[2][0] && grid[1][1] && grid[0][2]
        ) {
            System.out.println("Yes");
                return;
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 21844
//Compiler optimization
#pragma GCC optimize("Ofast")

//include
#include <bits/stdc++.h>
using namespace std;

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define each(x, v) for (auto &x : v)
//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ": " << x << endl

//const
const  ll INF = 1e18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n;cin >> n;
    ll data[4];
    fr(i,4)data[i] = 0;
    fr(i,n){
        S s;cin >> s;
        if(s == "AC")data[0]++;
        if(s == "WA")data[1]++;
        if(s=="TLE")data[2]++;
        if(s=="RE")data[3]++;
    }
    cout << "AC x " << data[0] << endl;
    cout << "WA x " << data[1] << endl;
    cout << "TLE x " << data[2] << endl;
    cout << "RE x " << data[3] << endl;

}

Measured memory_bytes: 3616
#include<stdio.h>
int main(){
    int N;
    int mou[20];
    int now=0;
    int count=0;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d",&mou[i]);
        if(now<=mou[i]){
            count++;
            now=mou[i];
        }
    }
    printf("%d\n",count);
}

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

int main(){

   string s1,s2,s3;
   cin>>s1>>s2>>s3;

    cout<<(char)(s1[0]-32)<<(char)(s2[0]-32)<<(char)(s3[0]-32)<<endl;





    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int min = b;
        int max = b;
        long  sum = b;
        for(int i = 0 ;i<a-1 ;i++){
            int c = in.nextInt();
            if(min>c){
                min = c;
            }
            if(max<c){
                max = c;
            }
            sum += c;
        }
        System.out.println(min+" "+max+" "+sum);
    }
}

Measured memory_bytes: 41484
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef long long ll;

#define REP(i, N) for (ll i = 0; i < N; ++i)
#define pll pair<ll, ll>
#define F first
#define S second

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        siz.assign(sz_, 1LL);  // assign: 再代入
        par.resize(sz_);  // resize: 再確保
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main(){
  ll n, m, k;
  cin >> n >> m >> k;
  
  ll node1, node2;
  UnionFind uf(n);
  vector<vector<ll>> A(n, vector<ll>()), B(n, vector<ll>());
  
  for (ll i = 0; i < m; i++) {
    cin >> node1 >> node2;
    --node1;
    --node2;
    uf.merge(node1, node2);
    A.at(node1).push_back(node2);
    A.at(node2).push_back(node1);
  }
  for (ll i = 0; i < k; i++) {
    cin >> node1 >> node2;
    --node1;
    --node2;
    B.at(node1).push_back(node2);
    B.at(node2).push_back(node1);
  }
  vector<ll> ans(n, 0);
  
  for (ll i = 0; i < n; i++) {
    //cout << "i: " << i << endl;
    //cout << "Ai :" << A.at(i).size() << endl;
    if (A.at(i).size()) ans.at(i) = uf.size(i) - A.at(i).size() - 1;
    //cout << "Bi :" << B.at(i).size() << endl;
    if (B.at(i).size()) {
      for (ll j = 0; j < B.at(i).size(); j++) {
        //cout << "j: " << B.at(i).at(j) << endl;
        if (uf.issame(i, B[i].at(j))) ans.at(i)--;
      }
    }
  }

  REP(i, n) {
    cout << ans.at(i) << " ";
  }
  return 0;
}

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

int a[5000];
int n,k,q;

vector<int>f(vector<int>&u,vector<int>&v){
	sort(v.begin(),v.end(),greater<>());
	while(v.size()>=k){
		u.push_back(v.back());
		v.pop_back();
	}
	return u;
}
int main(){
	scanf("%d%d%d",&n,&k,&q);
	rep(i,n)scanf("%d",&a[i]);
	int Min=INT_MAX;
	rep(i,n){
		vector<int>u,v;
		rep(j,n){
			if(a[j]>=a[i]){
				v.push_back(a[j]);
			}
			else{
				f(u,v);
				v.clear();
			}
		}
		f(u,v);
		sort(u.begin(),u.end());
		if(u.size()>=q)Min=min(Min,u[q-1]-u[0]);
	}
	cout<<Min<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include <cmath>
#include<algorithm>
//#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(){
    int N;
    cin>>N;
    int A[N];
    rep(i,N) cin>>A[i];
    long long s=1000,kab=0;
    rep(i,N-1){
        if (A[i]<A[i+1]){
            kab+=s/A[i];
            s=s%A[i];
        }
        if (A[i]>A[i+1]){
            s+=kab*A[i];
            kab=0;
        }
    }
    s+=kab*A[N-1];
    cout<<s<<endl;

 return 0;
}

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


int main() {
    int A, B, K; cin >> A >> B >> K;
    vector<int> ans;
    for (int i = 1; i <= min(A, B); i++) {
        if (A % i == 0 && B % i == 0) {
            ans.push_back(i);
        }
    }

    sort(ans.rbegin(), ans.rend());
    cout << ans[K - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
#define repr(i ,n) for(int i=n;i>(int)(n);--i)
#define rep1(i ,n) for(int i=1;i<=(int)(n);++i)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define PRINT(x) printf("%d\n",(x));
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;
template<class T> using V = vector<T>;
using I = int;
using VI = V<I>;
const int INF = 2e9;
const int64 MOD = 1e9 + 7;

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;}

int dp[10000];

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int N , W;
    cin >> N >> W;
    int v[N],w[N];
    rep(i ,N) cin >> v[i] >> w[i];
    dp[0]=0;
    rep(i ,N){
        rep(j ,W-w[i]+1){
            chmax( dp[j+w[i]] , dp[j]+v[i] );
        }
    }
    cout << dp[W] << endl;
}


Measured memory_bytes: 3212
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

enum POSITION{ONLINE_BACK = -2, CCW = -1, ON_SEGMENT = 0,
              CW = 1, ONLINE_FRONT = 2};

struct Point{
    long x;
    long y;
    Point(long x, long y) : x(x), y(y) {}
    Point(){}
    Point operator-(Point p){
        return Point(x - p.x, y - p.y);
    }
};
typedef Point Vector;
double cross(Vector v1, Vector v2){
    return v1.x * v2.y - v1.y * v2.x;
}
double dot(Vector v1, Vector v2){
    return v1.x * v2.x + v1.y * v2.y;
}

struct Segment{
    Point p1;
    Point p2;
    Segment(Point p1, Point p2) : p1(p1), p2(p2) {}
    Segment(){}
};
typedef vector<Point> Polygon;

POSITION get_position(Segment s, Point p){
    double c = cross(s.p2 - s.p1, p - s.p1);
    if (c > 0) return CCW;
    if (c < 0) return CW;
    double d = dot(s.p2 - s.p1, p - s.p1);
    if (d < 0) return ONLINE_BACK;
    if (d > dot(s.p2 - s.p1, s.p2 - s.p1)) return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool intersect(Segment s1, Segment s2){
    if (get_position(s1, s2.p1) * get_position(s1, s2.p2) != -1) {
        return false;
    }
    if (get_position(s2, s1.p1) * get_position(s2, s1.p2) != -1) {
        return false;
    }
    return true;
}

int determine_containment(Point p, Polygon poly){
    Segment s_right(p, Point(p.x + 1e5, p.y));
    int count = 0;
    for (int i = 0, n = poly.size(); i < n; i++) {
        if (get_position(Segment(poly[i], poly[(i+1)%n]), p) == ON_SEGMENT) {
            return 1;
        }
        if (intersect(s_right, Segment(poly[i], poly[(i+1)%n]))) {
            count++;
            continue;
        }
        if (get_position(s_right, poly[i]) == ON_SEGMENT) {
            int i_pre = (i == 0 ? n - 1 : i - 1);
            POSITION pos_pre = get_position(s_right, poly[i_pre]);
            while (pos_pre != CCW && pos_pre != CW) {
                i_pre = (i_pre == 0 ? n - 1 : i_pre - 1);
                pos_pre = get_position(s_right, poly[i_pre]);
            }
            int i_aft = (i + 1) % n;
            POSITION pos_aft = get_position(s_right, poly[i_aft]);
            while (pos_aft != CCW && pos_aft != CW) {
                i_aft = (i_aft + 1) % n;
                pos_aft = get_position(s_right, poly[i_aft]);
            }
            if (get_position(s_right, poly[i_pre]) * get_position(s_right, poly[(i+1)%n]) == -1) {
                count++;
            }
        }
    }
    if (count % 2) return 2;
    return 0;
}
int main(){
    int q;
    cin >> q;
    Polygon poly(q);
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        poly[i].x = x;
        poly[i].y = y;
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        cout << determine_containment(Point(x, y), poly) << endl;
    }
    return 0;
}



Measured memory_bytes: 3116
//Ash185-AtCoder:6 B - Minor Change [AtCoder Beginner Contest 172]
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define clock cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
#define forie(a,n) for(int i=(a);i<=(n);i++)
#define forje(b,m) for(int j=(b);j<=(m);j++)
#define forke(c,g) for(int k=(c);k<=(g);k++)
#define ffe(a,n,b,m) forie(a,n) forje(b,m)
#define fori(n) for(int i=0;i<n;++i)
#define forj(n) for (int j=0;j<n;++j)
#define fork(n) for (int k=0;k<n;++k)
#define rev(s)  reverse(s.begin(), s.end()) 
#define mem(v,d) memset(v,d,sizeof(v))
#define ll long long
#define ull unsigned long long
#define re return 
using namespace std;
void Ash() 
{ 	
#ifndef ONLINE_JUDGE 
freopen("input.txt", "r", stdin); freopen("error.txt", "w", stderr); freopen("output.txt", "w", stdout); 
#endif 
}

void solve() { int ct = 0; string s, t; cin >> s >> t; fori(s.length()) if (s[i] != t[i]) ct++; cout << ct; }
 
int main() { fast; Ash(); solve(); clock; return 0; }  

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

int main()

{
    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    int sum=0;
  for(int i =1;i<i+2;i++)
  {
      sum=n*i;
      if(sum>=a && sum<=b)
      {
          cout<<"OK"<<endl;
          break;
      }
      if(sum>b)
      {
          cout<<"NG"<<endl;
          break;
      }

  }
  return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[][] map = new int[n+1][n+1];
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				map[i][j] = sc.nextInt() + map[i-1][j] + map[i][j-1] - map[i-1][j-1];
			}
		}
		
		int max = map[1][1];
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				for(int k=i;k<=n;k++){
					for(int l=j;l<=n;l++){
						max = Math.max(max, map[k][l] + map[i-1][j-1] - map[i-1][l] - map[k][j-1]);
					}
				}
			}
		}
		
		System.out.println(max);
	}	
}

Measured memory_bytes: 37516
from collections import defaultdict
import heapq


def main():
    N, M = list(map(int, input().split()))
    adj = defaultdict(list)
    for _ in range(M):
        A, B = list(map(lambda x: int(x) - 1, input().split()))
        adj[A].append(B)
    # 最小サイズのサイクルを探す
    min_cycle_size = N + 1
    min_cycle = list()
    for s in range(N):
        parent = [None] * N
        que = [(0, s)]
        while len(que) > 0:
            dist, node = heapq.heappop(que)
            if dist > 0 and node == s:
                break
            for next_node in adj[node]:
                if parent[next_node] is not None:
                    continue
                parent[next_node] = node
                heapq.heappush(que, (dist + 1, next_node))
        # s始まりの最小サイクルが見つかった場合
        if parent[s] is not None:
            cycle = [s]
            node = parent[s]
            while node != s:
                cycle.append(node)
                node = parent[node]
            if len(cycle) < min_cycle_size:
                min_cycle_size = len(cycle)
                min_cycle = cycle
    # 答え
    if min_cycle_size > N:
        print(-1)
    else:
        print(min_cycle_size)
        for node in min_cycle:
            print(node + 1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 78640
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,j,cnt,ans,b,imod,l,l2,cnt2
    integer(int32):: bn,mn,mp,k
    integer(int32), allocatable:: mm(:,:)
    character(200000):: x

    read*, n
    read*, x

    bn=0; mn=0; mp=0
    do i=1,n
        if (x(i:i) == '1') bn=bn+1
    end do


    b=1
    do j=n,1,-1
        if (x(j:j) == '1')then
            if (bn-1 == 0) then
                mn=0
            else
                mn=mod(mn+b,bn-1)
            end if
        end if
        if (bn-1 == 0) then
            b = 0
        else
            b=mod(b*2,bn-1)
        end if
    end do

    b=1
    do j=n,1,-1
        if (x(j:j) == '1') mp=mod(mp+b,bn+1)
        b=mod(b*2,bn+1)
    end do


    allocate(mm(n,2))

    if (bn-1 == 0) then
        mm(1,1) = 0
    else
        mm(1,1) = mod(1,bn-1)
    end if

    mm(1,2) = mod(1,bn+1)

    do i=2,n
        if (bn-1==0) then
            mm(i,1) = 0
        else
            mm(i,1) = mod(mm(i-1,1)*2,bn-1)
        end if
        mm(i,2) = mod(mm(i-1,2)*2,bn+1)
    end do

    do i=1,n
        k = n+1-i
        if(x(i:i) == '1') then
            ans = bn-1
            if (ans==0) then
                imod=0
            else
                imod = modulo(mn - mm(k,1), ans)
            end if
        else
            ans = bn+1
            imod = modulo(mp + mm(k,2), ans)
        end if
        cnt=0
        if (ans==0) then
            print'(i0)', 0
            cycle
        end if
        ans = imod
        cnt=1
        do while(ans /= 0)
            l = 0
            l2 = 1
            do while(l2 <= ans)
                l=l+1
                l2=l2*2
            end do
            cnt2 = 0
            do j=1,l
                if (btest(ans,j-1)) cnt2=cnt2+1
            end do
            ans = mod(ans,cnt2)
            cnt=cnt+1
        end do
        print'(i0)', cnt
    end do
end program main

Measured memory_bytes: 4816