akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    ll A,B,C,D,N,X[3];
    ll ans=0;
    string S;
    bool F;
int main(){
    cin>>X[0]>>X[1]>>X[2];
    sort(X,X+3);
    cout<<((X[0]!=X[2])&&(X[0]==X[1]||X[1]==X[2])?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
program sample
	implicit none
    integer(8) :: i,j,k,l,m
    integer(8) :: n,a,b,count
    !real(8) :: a(4),b(4)
    
    read(*,*) n,a,b
    
    count=0
    m=n/(a+b)
    
    if (n-(m*(a+b))>=a) then
    	write(*,*) (m*a)+a
    else
    	write(*,*) (m*a)+n-m*(a+b)
    end if
    stop
end program sample

Measured memory_bytes: 2828
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
using namespace std;
typedef long long ll;
int main() {
  int x, y, z;
	cin >> x >> y >> z;
	int ans = (x-z)/(y + z);
	cout << ans << endl;
}

Measured memory_bytes: 256
A = gets.chomp.split(" ").map(&:to_i)
five = 0
seven = 0
for i in 0..A.length-1 do
    if A[i] == 5
        five = five + 1
    elsif A[i] == 7
        seven = seven + 1
    end
end
if five == 2 && seven == 1
    puts "YES"
else
    puts "NO"
end

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

typedef long long int ll;
typedef long long unsigned int ull;
typedef long double ld;
typedef vector<int> vr;
typedef pair<int, int> pr;
#define pb push_back
#define ff first
#define ss second
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(2);


int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2] << endl;
    return 0;
}


Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;

inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){return (a%mod * b%mod)%mod;}
inline int power(int a,int b,int MOD){int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
const int MAXN=3e5;
int fact[MAXN+5];
int inv_fact[MAXN+5];
int inverse(int x)
{
	  return power(x,mod-2,mod);
}
void pre()
{ 
	  fact[0]=1;
	  inv_fact[0]=inverse(fact[0]);
	  for(int i=1;i<=MAXN;i++)
	  {
	  	   fact[i]=mul(i,fact[i-1]);
           inv_fact[i]=inverse(fact[i]);
	  }
}
int ncr(int n,int r)
{
	 int res=1;
	 res=mul(res,fact[n]);
	 res=mul(res,inv_fact[n-r]);
	 res=mul(res,inv_fact[r]);
	 return res;
}
signed main()
{
     SPEED;
     pre();
     int h,w,a,b;
     cin>>h>>w>>a>>b;
     int res=0;
     for(int i=1;i<=w-b;i++)
     {
     	   int x1=h-a;
     	   int y1=b+i;
     	   int ways=ncr(x1+y1-2,x1-1);
     	   int x2=x1+1;
     	   int y2=y1;
     	   ways=mul(ways,ncr(h-x2+w-y2,h-x2));
     	   res=add(res,ways);
     }
     cout<<res<<endl;
     time();
     return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  vector<int> x(5);
  rep(i, 5) cin >> x[i];
  rep(i, 5) if(x[i] == 0) {
    cout << i+1 << endl;
    return 0;
  }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[3];
int main(){
    int s=0;
    for(int i=0;i<3;i++)scanf("%d",a+i),s+=a[i];
    if(s>=22)printf("bust\n");
    else printf("win\n");
    return 0;
}

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

vector<int>vp;

lli mod=1000000000+7;
int  main()
{

    int n,k;
    cin>>n>>k;

    for(int i=1; i<=n; i++)
    {
        int a;
        cin>>a;
        vp.push_back(a);
    }
    long long ara[n+1][k+1];
    memset(ara,0,sizeof ara);

    for(int i=0; i<n; i++)
    {
        long long sum=1;
        ara[i][0]=1;
        for(int j=1; j<=k; j++)
        {

            if(i==0)
            {
                if(j<=vp[i])
                    ara[i][j]=1;

            }
            else
            {


                if(j>vp[i])
                {
                    sum-=(ara[i-1][j-vp[i]-1]);
                    sum+=mod;
                    sum%=mod;
                }
                sum+=ara[i-1][j];
                sum%=mod;
                ara[i][j]=sum;




            }

        }


    }
    cout <<ara[n-1][k];


}






Measured memory_bytes: 79104
N = int(input())
H = list(map(int, input().split()))
Flag = True
for i in range(N - 1, 0, -1):
    if H[i - 1] > H[i] + 1:
        Flag = False
        break
    if H[i - 1] == H[i] + 1:
        H[i - 1] -= 1

if Flag:
    print('Yes')
else:
    print('No')

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int K;
    cin >> K;
    K--;
    printf("%lld\n", v[K]);

    return 0;
}


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

int main(){
	int K;
	cin >> K;
	rep(i,K) cout << "ACL";
	cout << endl;

	return 0;
}



Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define main() int main()
#define ff1(i,n) for(int i=1;i<=n;++i)
#define ff0(i,n) for(int i=0;i<n;++i)
#define pi acos(-1.0)
#define ms(a, x) memset(a, x, sizeof(a))
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define binarycount __builtin_popcount(x)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define fir first
#define sec second
#define debug(x) cout<<x<<'\n'
#define sa(a) scanf("%d", &a)
#define sab(a, b) scanf("%d%d", &a, &b)
#define pa(a) printf("%d",a)
#define pab(a,b) printf("%d%d",a,b)
#define pii pair<string,int>
using namespace std;

#define maxn 3005
const int inf = 0x3f3f3f3f;
const int mod = 9973;
const double eps = 1e-8;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
int max(int x,int y){if(x>y) return x;return y;}
ll powmod(ll a,ll b){
    ull ans = 1, pow = a%mod;
    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }
    return ans%mod;
}
string a,b,ans;	
ll dp[maxn][maxn];
int lena,lenb,f=0,xx=-1,yy=-1;
void dfs(int x,int y)
{
	if(f)return ;
	if(dp[x-1][y]==0&&dp[x][y-1]==0&&dp[x-1][y-1]==0){
		ans+=a[x-1];
		f=1;
		return ;
	}
	if(dp[x-1][y]==dp[x][y])
	{
		dfs(x-1,y);
	}
	else if(dp[x][y-1]==dp[x][y])
	{
		dfs(x,y-1);
	}
	else
	{
		ans+=a[x-1];//cout<<a[x-1]<<endl;	
		dfs(x-1,y-1);	
	}
	
}
main()
{
	IO;
	cin>>a>>b;
	ms(dp,0);
	lena=a.length();
	lenb=b.length();
	for(int i=1;i<=lena;i++)
	{
		for(int j=1;j<=lenb;j++)
		{
			if(a[i-1]==b[j-1])
			{
				dp[i][j]=dp[i-1][j-1]+1;
				/*if(dp[i][j]>0&&xx==-1){
					xx=i;
				}*/
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			/*	if(dp[i][j]>0&&xx==-1){
					xx=i;
				}*/
			}
		}
	}
/*	for(int i=0;i<=lena;i++)
	{
		for(int j=0;j<=lenb;j++)
		{
			cout<<dp[i][j]<<" ";
		}cout<<endl;
	}*/
	/*for(int i=1;i<=lenb;i++)
	{
		for(int j=1;j<=lena;j++)
		{
			if(dp[j][i]>0&&yy==-1){
				yy=i;
			}
		}
	}*/
	if(dp[lena][lenb]==0){
		return 0;
	}
	dfs(lena,lenb);
	reverse(ans.begin(),ans.end());
//	cout<<xx<<" "<<yy<<endl;
	cout<<ans<<endl;
} 
/*
bracadabra
vadakedavra
*/

Measured memory_bytes: 70784
A, B, K = map(int, input().split())
yaku_A = []
yaku_B = []
for i in range(1,A):
    if A % i == 0:
        yaku_A.append(i)
for j in range(1,B):
    if B % j == 0:
        yaku_B.append(j)
yaku_A.append(A)
yaku_B.append(B)
kou = list(set(yaku_A) & set(yaku_B))
kou.sort()
print(kou[-K])

Measured memory_bytes: 3064
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int first = sc.nextInt();
        int middle = sc.nextInt();
        int last = 0;
        int cnt = 0;
        for(int i = 2; i < N; i++){
            last = sc.nextInt();
            if((first < middle && middle < last) || (last < middle && middle < first)){
                cnt++;
            }
            first = middle;
            middle = last;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 25300
#include <stdio.h>

// key<=a[i]を満たす最小のi
int bs(int a[], int n, int key)
{
	int left = 0, right = n, mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == a[mid]) return mid;
		else if (key < a[mid]) right = mid;
		else left = mid + 1;
	}
	return left;
}
	
int main(void)
{
	int n, q, i, id = 0, l, r;
	char s[100005];
	int v[50005];
	
	scanf("%d%d%s", &n, &q, s);
	
	for (i = 0; i < n-1; i++)
		if (s[i] == 'A' && s[i+1] == 'C')
			v[id++] = i;
	
	while (q--) {
		scanf("%d%d", &l, &r);
		printf("%d\n", bs(v, id, r-1)-bs(v, id, l-1));
	}
	
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define sz 100010
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

int const mod = 1e9;

int main()
{
    BeatMeScanf;
    ll n, m, k, sum = 0, cnt=0 ;
    cin>>n>>m>>k;
    ll arr[n+5], brr[m+5];
    arr[0]=brr[0]=0;
    for(int i=1;i<=n;i++) {
        cin>>arr[i];
        arr[i]+=arr[i-1];
    }
    for(int i=1;i<=m;i++) {
        cin>>brr[i];
        brr[i]+=brr[i-1];
    }

    ll mx = 0;
    for(int i=0;i<=n;i++) {
        ll x = i;
        ll rem = k - arr[i];
        if(rem < 0) break;
        ll pos = upper_bound(brr, brr+m+1, rem) - brr;
        x += (pos-1);
        mx = max(x, mx);
    }
    for(int i=0;i<=m;i++) {
        ll x = i;
        ll rem = k - brr[i];
        if(rem < 0) break;
        ll pos = upper_bound(arr, arr+n+1, rem) - arr;
        x += (pos-1);
        mx = max(x, mx);
    }
    cout<<mx<<endl;
    return 0;
}


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

using namespace std;

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

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back
#define pb push_back


int main(void){
  int h,w;
  string sn;
  cin >> h >> w;
  rep(i,h)rep(j,w){
    cin >> sn;
    if(sn == "snuke"){
      int hh = 1 + i;
      char ww = 'A' + j;
      cout << ww  << hh << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;
class E { static void Main() => new J(); }
class J
{
	const int Mod = 1000000007;
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var s = ReadLine();
		var c = new int[26];
		foreach (var x in s) c[x - 'a']++;
		var f = true;
		foreach (var x in c) f &= x <= 1;
		WriteLine(f ? "yes" : "no");
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Abs(a); var m = (ulong)Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Min(zm, zn);
	}
}

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

using namespace std;

long long a[100010],sum[100010],mx[100010],ans=0;

int main(){
	int i,n,k;
	cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	
	sum[0] = 0; mx[0] = 0;
	
	for(i=1;i<=n;i++){
		sum[i] = sum[i-1] + a[i-1];
		mx[i] = mx[i-1] + max(a[i-1],(long long)0);
	}
	
	for(i=0;i<=n-k;i++){
		ans = max(ans,sum[k+i]-sum[i]+mx[i]+mx[n]-mx[k+i]);
		ans = max(ans,mx[i]+mx[n]-mx[k+i]);
	}
	cout << ans << endl;
}
	
	

Measured memory_bytes: 2560
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <iostream>
#include <queue>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

double solve(int N, int K, int k, double prob) {
  if (1 <= k && k <= (K - 1)) {
    return solve(N, K, 2 * k, prob * 0.5);
  } else if (k >= K) {
    return prob;
  } else {
    return 0.0;
  }
}

int main(int argc, char const *argv[]) {
  int N, K;

  cout << fixed;
  cout << setprecision(16);

  cin >> N;
  cin >> K;

  double total = 0.0;
  for (int k = 1; k <= N; k++) {
    total += solve(N, K, k, 1.0 / N);
  }

  cout << total;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const int ma=1e6;
typedef long long ll;
ll ans;
int a,b,c;
int d[ma],e[ma];
void solve()
{
    rep(i,c)e[d[i]-1]++;
    rep(i,a)
    {
        if(b-c+e[i]>0)puts("Yes");
        else puts("No");
    }
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>a>>b>>c;
    rep(i,c)cin>>d[i];
    solve();
    return 0;
}


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

int main()
{
  string s;
  int a;
  cin >> s;
  a = (int)(s[5] - '0') * 10 + (int)(s[6] - '0');
  cout << (a <= 4 ? "Heisei" : "TBD") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
#define int ll


// n = | n - k |
// n = n - k
// n = -n + k => 2n = k => n = k/2
// n = n - k => k
void test_case(){
	int n , k; cin >> n >> k;
	if(n > k)
		n =n-((n/k)*k);
	if( n < 0)
		n+=k;
	cout<<min(abs(n-k),n)<<"\n";
	

	
}
 
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3640
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

string s[50];
int d[50][50];

int main(){
  int h,w;
  cin>>h>>w;
  rep(i,h)
    cin>>s[i];
  rep(i,h)rep(j,w)d[i][j]=-1;
  queue<pii>q;
  q.push(pii(0,0));
  d[0][0]=0;
  int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
  while(!q.empty()){
    pii t=q.front();q.pop();
    int x=t.first,y=t.second;
    if(s[x][y]=='#')continue;
    rep(dir,4){
      int nx=x+dx[dir],ny=y+dy[dir];
      if(nx<0||nx>=h||ny<0||ny>=w)continue;
      if(d[nx][ny]>=0)continue;
      d[nx][ny]=d[x][y]+1;
      q.push(pii(nx,ny));
    }
  }
  int black=0;
  rep(i,h)rep(j,w)if(s[i][j]=='#')black++;
  if(d[h-1][w-1]==-1)cout<<-1<<endl;
  else cout<<h*w-d[h-1][w-1]-1-black<<endl;
}


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

int main(){
  int N;

  cin >> N;
  int a[N+1];
  for(int i = 0 ; i < N ; i++){
    cin >> a[i];
  }
  a[N] = 0;
  
  long long int res = 0;
  int l = 0;
  int r = 0;
  int xor_value = 0;
  int sum = 0;
  
  while(l < N && r <= N){
    int n_xor_value = (xor_value ^ a[r]);
    int n_sum = sum + a[r];
    if(n_xor_value != n_sum){      
      res += r - l;
      xor_value = (xor_value ^ a[l]);
      sum -= a[l];
      l++;
    }
    else {
      xor_value = n_xor_value;
      sum = n_sum;
      if(r < N)r++;
      else {
	xor_value = (xor_value ^ a[l]);
	sum -= a[l];
	res += r - l;
	l++;
      }
    }
  }
  cout << res << endl;
  return 0;
}


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

using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define PI acos(-1)
#define DO double

void co(DO p1x,DO p1y,DO p2x,DO p2y,int count,int n){
  if(count>=n) return;
  DO sx,sy,tx,ty;
  sx=(p1x*2+p2x)/3;
  tx=(p1x+p2x*2)/3;
  sy=(p1y*2+p2y)/3;
  ty=(p1y+p2y*2)/3;
  DO ux,uy;
  ux=(tx-sx)*cos(1.0/3*PI)-(ty-sy)*sin(1.0/3*PI)+sx;
  uy=(tx-sx)*sin(1.0/3*PI)+(ty-sy)*cos(1.0/3*PI)+sy;
  co(p1x,p1y,sx,sy,count+1,n);
  cout<<sx<<" "<<sy<<endl;
  co(sx,sy,ux,uy,count+1,n);
  cout<<ux<<" "<<uy<<endl;
  co(ux,uy,tx,ty,count+1,n);
  cout<<tx<<" "<<ty<<endl;
  co(tx,ty,p2x,p2y,count+1,n);
  return;
}


int main(){
  int n;
  cin>>n;
  cout<<setprecision(10);
  cout<<0<<" "<<0<<endl;
  co(0,0,100,0,0,n);
  cout<<100<<" "<<0<<endl;
  return 0;
}



Measured memory_bytes: 3212
#include <cstdio>  
  
int main()  
{  
    int a, b, n;  
    while (scanf("%d%d%d", &a, &b, &n) != EOF)  
    {  
        int sum = 0;  
        a %= b;  
  
        for (; n; n--)  
        {  
            a *= 10;  
            sum += a / b;  
            a %= b;  
        }  
  
        printf("%d\n", sum);  
    }  
  
    return 0;  
} 

Measured memory_bytes: 0
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
  
    int N = sc.nextInt();

    int[] v = new int[N];

    int answer = 0;
    boolean validate = false;
    for (int i = 0; i < N; i++) {
      int p = sc.nextInt();
      if ((p - 1) == i) {
        v[i] = 1;
        if (validate) {
          validate = false;
        } else {
          answer++;
          validate = true;
        }
      } else {
        validate = false;
      }
    }

    sc.close();

    System.out.println(answer);

  }

}

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

int main()
{
    int n, k;
    cin >> n >> k;
    int ret = 1, a, b;
    for (int i = 0; i < n; i++) {
        a = ret * 2;
        b = ret + k;
        ret = (a < b) ? a : b;
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
object Main {


  def main(args: Array[String]): Unit = {
    val inputs = io.StdIn.readLine.split(" ").map(_.toInt)
    val a = inputs(0)
    val b = inputs(1)

    def solve(a: Int, b: Int): Either[String, Int] = {
      val twiceAns = a + b
      if (twiceAns % 2 == 0) Right(twiceAns / 2)
      else Left("IMPOSSIBLE")
    }

    solve(a, b) match {
      case Right(i) => println(i)
      case Left(s) => println(s)
    }

  }

}


Measured memory_bytes: 25408
N = int(input().strip())
H = [int(str) for str in input().strip().split()]

ans = 0

for h in range(1, max(H) + 1):
    i = 0
    while i < N:
        if H[i] < h:
            i += 1
        else:
            ans += 1
            while i < N and H[i] >= h:
                i += 1

print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
int main(void){
    char *date;
    int i;
    date=(char*)malloc(sizeof(char)*11);
    for(i=0;i<11;i++){
        date[i]=0;
    }
    scanf("%s",date);
    if(date[5]=='1'){
        printf("TBD\n");
    }else{
        date[6]-=48;
        if(date[6]>4){
            printf("TBD\n");
        }else{
            printf("Heisei\n");
        }
    }
    free(date);
    return 0;
}

Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> a[n];
  int e,w;
  rep(i,m){
    cin>>e>>w;
    e--;
    w--;
    a[e].push_back(w);
    a[w].push_back(e);
  }
  
  int o[n];
  int at[n];
  rep(i,n) at[i]=0;
  queue<int> q;
  q.push(0);
  at[0]=1;
  while(!(q.empty())){
    int now=q.front();q.pop();
    for(int u:a[now]){
      if(at[u]==1) continue;
      o[u]=now+1;
      q.push(u);
      at[u]=1;
    }
  }
  int c=0;
  rep(i,n){
    if(at[i]==0){
      c++;
    }
  }
  
  if(c!=0){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
    Rep(i,1,n){
      cout<<o[i]<<endl;
    }
  }
}

Measured memory_bytes: 10804
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
#define N 100050
typedef long long ll;
int head[N],to[N<<1],nxt[N<<1],cnt,n,m,dep[N],vis[N],siz[N],p1,p2,w[N];
int k[N],a[N],la;
inline void add(int u,int v) {
	to[++cnt]=v; nxt[cnt]=head[u]; head[u]=cnt;
}
void dfs(int x,int y) {
	vis[x]=1; dep[x]=dep[y]+1;
	if(dep[x]&1) siz[x]=1;
	else siz[x]=-1;
	int i;
	for(i=head[x];i;i=nxt[i]) {
		if(to[i]!=y&&!vis[to[i]]) {
			dfs(to[i],x); siz[x]+=siz[to[i]];
		}else if(to[i]!=y) {
			p1=x, p2=to[i];
		}
	}
}
void dfs2(int x,int y) {
	int i; vis[x]=1;
	if(dep[x]&1) siz[x]++;
	else siz[x]--;
	for(i=head[x];i;i=nxt[i]) if(to[i]!=y&&!vis[to[i]]) {
		dfs2(to[i],x); siz[x]+=siz[to[i]]; k[x]+=k[to[i]];
	}
}
int main() {
	scanf("%d%d",&n,&m);
	int i,x,y;
	for(i=1;i<=m;i++) {
		scanf("%d%d",&x,&y); add(x,y); add(y,x);
	}
	dfs(1,0);
	if(m==n-1) {
		if(siz[1]) {puts("-1"); return 0;}
		ll ans=0;
		for(i=1;i<=n;i++) ans+=abs(siz[i]);
		printf("%lld\n",ans);
	}
	else if((dep[p2]-dep[p1]+1)&1) {
		if(abs(siz[1])&1) {puts("-1"); return 0;}
		ll ans=abs(siz[1])/2;int t=siz[1];
		memset(vis,0,sizeof(vis));
		memset(siz,0,sizeof(siz));
		siz[p1]-=t/2, siz[p2]-=t/2; 
		dfs2(1,0);
		for(i=1;i<=n;i++) ans+=abs(siz[i]);
		printf("%lld\n",ans);
	}else {
		if(siz[1]) {puts("-1"); return 0;}
		memset(vis,0,sizeof(vis));
		memset(siz,0,sizeof(siz));
		k[p1]=1, k[p2]=-1;
		dfs2(1,0);
		a[++la]=0;
		ll ans=0;
		for(i=1;i<=n;i++) {
			if(!k[i]) ans+=abs(siz[i]);
			else if(k[i]==1) a[++la]=-siz[i];
			else a[++la]=siz[i];
		}
		sort(a+1,a+la+1);
		int v=a[(la+1)>>1];
		for(i=1;i<=la;i++) ans+=abs(v-a[i]);
		printf("%lld\n",ans);
	}
}

























Measured memory_bytes: 8704
#include <stdio.h>

int main(){
  int r,c,i,j,table[101][101]={0};
  scanf("%d %d",&r,&c);
  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      scanf("%d",&table[i][j]);
      table[i][c] += table[i][j];
      table[r][j] += table[i][j];
    }
    table[r][c] += table[i][c];
  }
  for(i=0;i<=r;i++){
    for(j=0;j<=c;j++){
      printf("%d",table[i][j]);
      if(j!=c)printf(" ");
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 664
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define mid (low+high)/2
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004
#define INF 1e9+7

using namespace std;

struct offer{
    ll a;
    ll b;
    ll c;
    ll d;
};

ll n,m,q;
offer ar[N];
ll ans[N];

ll solve(ll cur)
{
    if(cur > n)
    {
        ll res = 0;

        rep(i,0,q)
        {
            if(ans[ar[i].b] - ans[ar[i].a] == ar[i].c)
                res+=ar[i].d;
        }

        return res;
    }

    ll res = 0;

    rep(i,ans[cur-1],m+1)
    {
        ans[cur] = i;
        res = max(res,solve(cur+1));
    }

    return res;
}

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

    cin >> n >> m >> q;

    rep(i,0,q)
    {
        cin >> ar[i].a >> ar[i].b >> ar[i].c >> ar[i].d;
    }

    ans[1] = 1;
    cout << solve(2);

    return 0;
}



Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n-1;i>s;i--)
#define rep_re(i,s,n)for(ll i = n-1;i>=s;i--)
ll MOD = 1e9 + 7;

ll ans = 0;
set<int> se;
int main() {
	ll n; cin >> n;
	string s; cin >> s;

	repe(i, 0, 9) {
		repe(j, 0, 9) {
			repe(k, 0, 9) {
				//cout << i << j << k << endl;
				//if (i == 2 && j == 1  && k == 4) {
			//		cout << endl;
				//}
				ll cnt = 0;
				rep(l, 0, s.size()) {
					ll p = (s[l] - '0');
					if (cnt == 0 && p == i) {
						cnt++;
						continue;
					}
					if (cnt == 1 && p == j) {
						cnt++;
						continue;
					}
					if (cnt == 2 && p == k) {
						se.insert(i*100 + j*10 + k);
						continue;
					}
				}
			}
		}
	}
	cout << se.size() << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

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

    int ans = (b-1)/(a-1);
    if ((b-1)%(a-1) != 0) ++ans;

    cout << ans << endl;

    return 0;
}


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

int main() {
  int N;
  scanf("%d", &N);
  long long X = 1;
  int Y = pow(10,9);
  
  for(int i = 1; i < N+1; ++i){
    X = i * X % (Y+7);
  }

  cout << X << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <utility>
#include <string>
#include <vector>

using namespace std;

long MOD = 1e9 + 7;
string s;

int main() {
    cin >> s;

    vector<vector<long>> dp(s.size(), vector<long>(4));
    dp.push_back({0, 0, 0, 1});
    for (int i = s.size()-1; i >= 0; i--) {
        if (s[i] == '?') {
            for (char c = 'A'; c < 'D'; c++) {
                dp[i][c - 'A'] = (3 * dp[i + 1][c - 'A'] + dp[i + 1][c - 'A' + 1]);
            }
            dp[i]['D' - 'A'] = 3 * dp[i + 1]['D' - 'A'];
        } else {
            for (char c = 'A'; c < 'D'; c++) {
                if (s[i] == c) {
                    dp[i][c - 'A'] = dp[i + 1][c - 'A'] + dp[i + 1][c - 'A' + 1];
                } else {
                    dp[i][c - 'A'] = dp[i + 1][c - 'A'];
                }
            }
            dp[i]['D' - 'A'] = dp[i + 1]['D' - 'A'];
        }
        for (char c = 'A'; c <= 'D'; c++) {
            dp[i][c - 'A'] %= MOD;
        }
    }
    cout << dp[0][0] << endl;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll a,b,n; cin >> a >> b >> n;
    ll c = a/b;
    if(n < b-1) {
        cout << a*n/b - a*(n/b) << endl;
    }else{
        if(a % b != 0) c++;
        cout << a-c << endl;
    }
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;

int a[2'000];

int main()
{
    int n, z, w;
    cin >> n >> z >> w;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    if (n == 1)
    {
        cout << abs(w - a[n - 1]) << endl;
        return 0;
    }

    cout << max(abs(w - a[n - 1]), abs(a[n - 2] - a[n - 1])) << endl;
}

Measured memory_bytes: 256
l = raw_input().split()
N = int(l[0])
M = int(l[1])

BC = []

l = raw_input().split()
A = [int(x) for x in l]

for i in range(M):
    l = raw_input().split()
    bc = [int(l[0]), int(l[1])]
    BC.append(bc)

A.sort()
BC.sort(key = lambda x: -x[1])
# print(N, M, A, BC)

i0 = 0
i1 = 0
for i in range(N):
    # print(BC[i0])
    b = BC[i0][0]
    c = BC[i0][1]

    if A[i] < c:
        A[i] = c
        i1 += 1
    if i1 == b:
        i0 += 1
        i1 = 0
    # print(A)
    if i0 == M:
        break

# print(A)
print(sum(A))


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

#define int long long int 
void ans(int n)
{
    if(n==0)
    {cout<<0<<endl;
       return ;}
    string str="";
    while(n!=0)
    {
        int x=(n%2LL+2LL)%2LL;
        char c=(char)x+'0';
        str.insert(str.begin(),c);
        n=(n-x)/-2LL;
    }
    cout<<str<<endl;
}
int32_t main()
{
    int n;
    cin>>n;
    ans(n);
}

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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int a,b,c,x,y;
    cin >> a>>b>>c>>x>>y;

    int ans = INT32_MAX;
    rep(k,100000+1){
        ans = min(ans,2*c*k + max(0,x-k)*a + max(0,y-k)*b);
    }
    cout << ans <<endl;
}

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

int main(){vector<int> a(3); cin>>a[0]>>a[1]>>a[2]; sort(a.begin(), a.end()); if (a[0]==5&&a[1]==5&&a[2]==7) cout << "YES" << endl; else cout << "NO" << endl; }

Measured memory_bytes: 256
t[99],n,i,r;M(int*a){return*a-*1[&a];}main(I,s){for(;scanf("%d,%d",&I,&s)*I;)t[n++]=s*999+I;for(qsort(t,n,4,M);~scanf("%d",&I);)for(r=s=0,i=n;i--;t[i]%999-I||printf("%d\n",r))r+=t[i]/999!=s,s=t[i]/999;}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
    int n;
    cin>>n;
    vector<string> vs(n);
    rep(i,n)cin>>vs[i];
    
    int num[50][26]={};
    rep(i,n) {
        rep(j,vs[i].size()){
            num[i][vs[i][j]-'a']++;
        }
    }
    
    string ans = "";
    rep(i,26){
        int mini = INF;
        rep(j,n){
            mini = min(mini,num[j][i]);
        }
        ans+=string(mini,'a'+i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 3005
#define MOD 998244353
int n,m,ans,a[N],s[N],dp[N][N];
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=1;i<=n;++i)
	{
		for(int j=a[i];j<=m;++j) {dp[i][j]=s[j-a[i]];if(j==a[i]) dp[i][j]=(dp[i][j]+i)%MOD;}
		for(int j=a[i];j<=m;++j) s[j]=(s[j]+dp[i][j])%MOD;
	}
	for(int i=1;i<=n;++i) ans=(ans+1ll*dp[i][m]*(n-i+1)%MOD)%MOD;
	printf("%d\n",ans);return 0;
}


Measured memory_bytes: 35456
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

#include <queue>

#define Min(a,b) ((a)<(b)?(a):(b))
#define Max(a,b) ((a)>(b)?(a):(b))
#define Mabs(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define Abs(a) (a)>0?(a):(-(a))
template <typename QvQ> inline QvQ Min2(QvQ a,QvQ b){if(a<b) return a;return b;}
template <typename QvQ> inline QvQ Max2(QvQ a,QvQ b){if(a>b) return a;return b;}
template <typename QvQ> inline QvQ Abs2(QvQ a){if(a>0) return a;return -a;}

#define n1kw 10000000
#define inf 0x7f7f7f7f
#define dinf 0x3f3f3f3f
#define llinf 0x7f7f7f7f7f7f7f7f
#define lldinf 0x3f3f3f3f3f3f3f3f

#define ll long long
#define rei register int
#define inv inline void
#define inb inline bool
#define ini inline int

#define bl putchar(' ')
#define ed putchar('\n')
#define test std::cout<<"this:"
#define card system("pause")

#define read2(a,b) read(a),read(b)
#define write2(a,b) write(a),bl,write(b)
#define read3(a,b,c) read(a),read(b),read(c)
#define write3(a,b,c) write(a),bl,write(b),bl,write(c)

//char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)

template <typename QvQ>inv read(QvQ &x)
{
	x=0;int f=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	x=x*f;
}
template <typename QvQ>inv write(QvQ x)
{
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10+48);
}
using namespace std;
#define MAXN 100005
#define MAXM 200005
int n,m;
struct node
{
	int t;
	int rew;
	friend bool operator <(node a,node b)
	{
		return a.rew>b.rew;
	}
}a[MAXN];
priority_queue <node> q;
int cmp(node a,node b)
{
	if(a.t==b.t) return a.rew>b.rew;
	return a.t>b.t;
}
int main()
{
	read2(n,m);
	for(rei i=1;i<=n;++i) read2(a[i].t,a[i].rew);
	sort(a+1,a+n+1,cmp); int dq=1;
	while(a[dq].t>m) ++dq;
	if(dq>n) {write(0);return 0;}
	q.push(a[dq]);ll ans=a[dq].rew; int t=1;
	for(rei i=dq+1;i<=n;++i)
	{
		if(a[i].t+t<=m) ans+=a[i].rew,q.push(a[i]),++t;
		else
		{
			if(a[i].rew>q.top().rew)
			{
				ans-=q.top().rew;
				q.pop();
				q.push(a[i]);
				ans+=a[i].rew;
			}
		}
	}
	write(ans);
	return 0;
}

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

void disp(vector<long>& vec) {
  cout << "[";
  for (int i = 0; i < vec.size(); i++) cout << " " << vec[i];
  cout << " ]" << endl;
}

int main() {
  long X, Y, A, B, C, s=0;
  cin >> X >> Y >> A >> B >> C;
  const long INF = 1000000005;
  
  vector<long> lA(A+1), lB(B+1), lC(C);
  rep(i, A) cin >> lA[i];
  rep(i, B) cin >> lB[i];
  rep(i, C) cin >> lC[i];
  
  lA.back() = INF; lB.back() = INF; 
  sort(lA.begin(), lA.end(), greater<>());
  sort(lB.begin(), lB.end(), greater<>());
  sort(lC.begin(), lC.end());
  lA.erase(lA.begin() + X+1, lA.end());
  lB.erase(lB.begin() + Y+1, lB.end());
  
  rep(i, C) {
    if (min(lA.back(), lB.back()) >= lC.back() || lC.empty()) break;
    s += lC.back();
    lC.pop_back();
    if (lA.back() < lB.back()) lA.pop_back(); 
    else lB.pop_back(); 
  }
  
  lA.erase(lA.begin()); lB.erase(lB.begin()); 
  lA.insert(lA.end(), lB.begin(), lB.end());
  
  rep(i, lA.size()) s += lA[i];
  cout << s << endl;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
int N;
string str;
map<string, int> mp;
int ans = 0;

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> str;
        mp[str] = 1;
    }
    for(auto i = mp.begin(); i != mp.end(); ++i){
        ans += i->second;
    }
    cout << ans << endl;
    return 0;  
}

Measured memory_bytes: 19220
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	A, B := ReadInt(), ReadInt()
	if A <= 8 && B <= 8 {
		fmt.Println("Yay!")
	} else {
		fmt.Println(":(")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
N, K = map(int, input().split())
A = list(map(int, input().split()))

count = {}

for a in A:
    if a in count.keys():
        count[a] += 1
    else:
        count[a] = 1

v = list(sorted(count.values(), key=lambda x: -x))

ret = 0
for i in range(K, len(v)):
    ret += v[i]
print(ret)


Measured memory_bytes: 32184
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  string s;
  cin >> s;
  int n = s.size();
  
  cout << s[0] << n-2 << s[n-1] << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    

    ll n,t;
    cin >> n >> t;
    ll minv, maxv;
    vector <ll> a;
    for (ll i=0;i<n;i++){
        ll p;
        cin >> p;
        a.push_back(p);
    }
    minv = a[0];
    maxv = a[0];
    ll maxb = 0;
    for (ll i=0;i<n;i++){
        ll parb;
        if(minv > a[i]){
            minv = a[i];
        }
        parb = a[i] - minv;
        if(maxb < parb){
            maxb = parb;
        }
    }
    minv = a[0];
    maxv = a[0];
    ll ans = 0;
    for(ll i=0;i<n;i++){
        ll parb;
        if(minv > a[i]){
            minv = a[i];
        }
        parb = a[i] - minv;
        if(parb == maxb){
            ans++;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  if (a > b)
  {
    for (int i = 0; i < a; i++)
    {
      cout << b;
    }
  }
  else
  {
    for (int i = 0; i < b; i++)
    {
      cout << a;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<map>

using namespace std;
#define mod 1000000007
#define ll long long 




int arr[100009];
int dp[100009];
int n;

int solve(int idx) {
	
	if(idx == n - 1)
		return 0;

	if(dp[idx] != -1)
		return dp[idx];

	int ans = solve(idx + 1) + abs(arr[idx + 1] - arr[idx]);
	if(idx + 2 < n)
		ans = min(ans, solve(idx + 2) + abs(arr[idx + 2] - arr[idx]));

	return dp[idx] = ans;
}


int main() {

	memset(dp, -1, sizeof(dp));
	cin>>n;


	for(int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
	}

	cout<<solve(0)<<endl;

	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 60;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

long long dp[3010][3010] = {};
int main() {
  string s, t; cin>>s>>t;
  rep(i, s.size()) rep(j, t.size()) {
    dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+(s[i]==t[j]));
    dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
    dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]);
  }
  //print(dp[s.size()][t.size()]);

  string ans = "";
  int i = s.size(), j = t.size();
  while (i and j) {
    if (dp[i][j] == dp[i][j-1]) --j;
    else if (dp[i][j] == dp[i-1][j]) --i;
    else {
      ans += s[i-1];
      --i, --j;
    }
  }
  reverse(ans.begin(), ans.end());
  print(ans);
  return 0;
}


Measured memory_bytes: 70784
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.flush();out.close();
    }
        static class TaskE {
         public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x=in.nextInt(),y=in.nextInt();
            if(x%y==0)out.print("-1");
            else out.print(x);
         }
    }
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;
        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

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

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 21588