akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"strings"
)

func main() {

	var h, w int
	fmt.Scanf("%d %d", &h, &w)
	out := strings.Repeat("#", w+2) + "\n"
	for i := 0; i < h; i++ {
		var in string
		fmt.Scanf("%s", &in)
		out += "#" + in + "#\n"
	}
	out += strings.Repeat("#", w+2)
	fmt.Println(out)
}


Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;
// scanf
#pragma warning(disable: 4996)
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値
#define _ceil(x) ceil(x)

int main()
{
	int32_t n,x;
	cin >> n >> x;

	vector<int32_t> v(n);
	
	for (int32_t i = 0; i < n; i++) {
		cin >> v[i];
		x -= v[i];
	}
	_sort(v, int32_t, less);
	printf("%d\n", n + x / v[0]);

	return 0;
	//	std::cout << "Hello World!\n"; 
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#define ll long long
const int N=1e6+10;
using namespace std;
int a,b;

int main() {
    cin>>a>>b;
  if(a<1 || a>9 || b<1 ||b>9)   {
      cout<<-1;
      return 0;
  } else
      cout<<a*b<<endl;
    return 0;
}

Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
signed main()
{
	int k;
	cin>>k;
	int a,b;
	cin>>a>>b;
	for(int i=1;i*k<=b;i++)
	{
		if(i*k>=a && i*k<=b)
		{
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG";
}












Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static int[] u = new[] { 2, 5, 5, 4, 5, 6, 3, 7, 6 };
    static int[] dp;
    static void Solve()
    {
        var nm = Input.ar;
        var ar = Input.ar.OrderByDescending(v=>v).ToArray();
        dp = Enumerable.Repeat(int.MinValue, nm[0] + 1).ToArray();
        dp[0] = 0;
        for (var i = 2; i <= nm[0]; i++)
            for (var j = 0; j < nm[1]; j++)
                if (i - u[ar[j] - 1] >= 0)
                    dp[i] = Max(dp[i], dp[i - u[ar[j] - 1]] + 1);
        WriteLine(dfs(nm[0], ar));
    }
    static string dfs(int num,int[] ar)
    {
        for (var i = 0; i < ar.Length; i++)
            if (num >= u[ar[i] - 1] && dp[num] - 1 == dp[num - u[ar[i] - 1]])
                return ar[i].ToString() + dfs(num - u[ar[i] - 1], ar);
        return "";
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

Measured memory_bytes: 27612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const string YES = "Yes";
const string NO = "No";

void f(const string& S, const string& T)
{
    vector<int> pair_ch(26, 1e9);
    for (ll i = 0; i < S.size(); i++) {
        int s = S[i] - 'a';
        int t = T[i] - 'a';
        if (pair_ch[s] == 1e9) {
            pair_ch[s] = t;
        } else if (pair_ch[s] != t) {
            cout << NO << "\n";
            exit(0);
        }
    }
}

void solve(std::string S, std::string T)
{
    f(S, T);
    f(T, S);
    cout << YES << "\n";
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    cin.tie(nullptr);
    cout.tie(nullptr);
	ios_base::sync_with_stdio(false);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(move(S), move(T));
    return 0;
}


Measured memory_bytes: 916
#include<iostream>
#include<cstdio>
#include<ctype.h>
using namespace std;
typedef long long ll;
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int main(){
	int n=read();
    for(int i=1;i<=3500;++i){
		for(int j=1;j<=3500;++j){
			ll z=1ll*i*j*n,m=4ll*i*j-n*(i+j);
			if(m>0 && !(z%m)){
				printf("%d %d %lld\n",i,j,z/m);
				return 0;
			}
		}
	}
    return 0;
} 

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

int main(){
	long long int A,B,C;
	long long int sum;
	cin>>A>>B>>C;
	if(A%2==0||B%2==0||C%2==0){cout<<0<<endl;}
	else {
		if(A>=B&&A>=C){
			sum=B*C;
			cout<<sum<<endl;
		}
		else if(B>=A&&B>=C){
			sum=A*C;
			cout<<sum<<endl;
		}
		else if(C>=A&&C>=B){
			sum=A*B;
			cout<<sum<<endl;
		}
	} 
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
    bool a[100000];
    int b[100000];
    a[1]=1;
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        b[i]=1;
    }
    for(int i=1;i<=m;i++){
        int x,y;
        cin>>x>>y;
        if(a[x]==1)
        {
            a[y]=1;
            if(b[x]==1) a[x]=0;
        }
        b[y]++;
        b[x]--;
    }
    int sum=0;
    for(int i=1;i<=n;i++){
        sum+=a[i];
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
template <class T> void ckmax(T &x,const T y){
	if (x<y)
		x=y;
}
template <class T> void ckmin(T &x,const T y){
	if (x>y)
		x=y;
}
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
const int N=200005;
int n=200000,q=200000;
struct opt{
	int op,i,j,k;
};
vector <opt> res;
int cnt=3;
int gao(int op,int i,int j){
	int k=++cnt;
	res.push_back({op,i,j,k});
	return k;
}
void output(){
	printf("%d\n",(int)res.size());
	for (auto i : res)
		printf("%c %d %d %d\n",i.op==0?'+':'<',i.i,i.j,i.k);
}
namespace checker{
	const int N=200005;
	ull a[N];
	void check(ull A,ull B){
		clr(a);
		a[0]=A,a[1]=B;
		for (auto i : res){
			if (i.op==0)
				a[i.k]=a[i.i]+a[i.j];
			else
				a[i.k]=a[i.i]<a[i.j];
		}
		if (a[2]!=(ull)A*B){
			outval(A),outval(B),outval(a[2]);
			assert(a[2]==(ull)A*B);
		}
	}
	void main(){
		assert((int)res.size()<=q);
		for (auto i : res){
			assert(i.i<=n);
			assert(i.j<=n);
			assert(i.k<=n);
		}
		For(A,0,10)
			For(B,0,10){
				check(A,B);
			}
		For(_,0,100){
			int A=rand(),B=rand();
			check(A,B);
		}
	}
}
const int mask=30;
int pw2[mask+1],pw2_[mask+1];
int main(){
	int A=0,B=1;
	int _0=3,_1=gao(1,_0,gao(0,A,B));
	pw2[0]=_1;
	For(i,1,mask)
		pw2[i]=gao(0,pw2[i-1],pw2[i-1]);
	pw2_[0]=_0;
	For(i,1,mask)
		pw2_[i]=gao(0,pw2_[i-1],pw2[i-1]);
	int nowx=_0,ans=_0;
	Fod(i,mask,0){
		int x=gao(1,gao(0,nowx,pw2_[i]),A);
		int nowy=_0;
		Fod(j,mask,0){
			int y=gao(1,gao(0,nowy,pw2_[j]),B);
			int z=gao(1,_1,gao(0,x,y));
			For(k,1,i+j)
				z=gao(0,z,z);
			ans=gao(0,ans,z);
			For(k,1,j)
				y=gao(0,y,y);
			nowy=gao(0,nowy,y);
		}
		For(k,1,i)
			x=gao(0,x,x);
		nowx=gao(0,nowx,x);
	}
	res.push_back({0,ans,_0,2});
	output();
//	checker::main();
	return 0;
}

Measured memory_bytes: 4172
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
#define INF 10000000000000000
#define MOD 1000000007
using namespace std;



int main(){
    int R;
    cin >> R;
    if(R>=2800){
        cout<<"AGC"<<endl;
    }else if(R>=1200){
        cout<<"ARC"<<endl;
    }else{
        cout<<"ABC"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int ar[N];

int main(){
	int n; cin >> n;
	int cnt = 0;
	int now = 1;
	bool cek = false;
	for(int i = 1; i <= n; i++){
		int x; cin >> x;
		if(x == now){
			now++;
		}else{
			cnt++;
		}
	}
	if(now == 1){
		cout << "-1" << endl;
	}else{
		cout << cnt << endl;
	}
}

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

int main() {
  string s;int p = 0;
  cin >> s;
  for(int i = 0;i < 3;i++){
    if(s.at(i) == s.at(i+1)){
      p = 1;
      break;
    }
  }
  if(p == 0){
    cout << "Good" << endl;
  }
  else{
    cout << "Bad" << endl;
  }
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  
  bool kaibun = true;
  
  rep(i, (n - 1) / 2) {
    if(s[i] != s[n - 1 - i]) kaibun = false;
  }
  
  string a = s.substr(0, (n - 1) / 2);
  string b = s.substr((n + 3) / 2 - 1, n - (n + 3) / 2 + 1);
//  cout << a << " " << b << endl;
  
  rep(i, a.size() / 2) {
    if(a[i] != a[a.size() - 1 - i]) kaibun = false;
  }
  rep(i, b.size() / 2) {
    if(b[i] != b[b.size() - 1 - i]) kaibun = false;
  }
  
  if(kaibun) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    for(int i=0; i<N; i++)
    {
        cin >> A.at(i);
    } 
    int count=0;
    for(int i=0; i<N; i++)
    {
        if(A.at(i)>=M)
        {
        count++;
        }
    }
    cout << count <<endl;
}


Measured memory_bytes: 640
S, K = gets.chomp, gets.to_i
a = S.scan(/((.)\2*)/).map{|_1,| _1.size }
if a.size == 1
	p a[0]*K/2
else
	isCyc = S[0] == S[-1]
	if isCyc
		hosei = a[0]/2 + a[-1]/2
		a[-1] += a.shift
		hosei -= a[-1]/2
	else
		hosei = 0
	end
	p K*a.inject(0){|acc,_| acc+_/2 } + hosei
end


Measured memory_bytes: 1788
import bisect

A, B, Q = list(map(int, input().split()))
S = [-10**20] + [int(input()) for i in range(A)] + [10**20]
T = [-10**20] + [int(input()) for i in range(B)] + [10**20]

for i in range(Q):
	x = int(input())
	s = bisect.bisect_left(S, x)
	t = bisect.bisect_left(T, x)
	num = [x-min(S[s-1], T[t-1]),
				S[s]-T[t-1]+min(S[s]-x, x-T[t-1]),
				T[t]-S[s-1]+min(x-S[s-1], T[t]-x),
				max(S[s], T[t])-x]
	print(min(num))

Measured memory_bytes: 12800
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func count(a []int, k int) int {
	nHitted := 0
	for i := 0; i < len(a); i++ {
		if a[i] == k {
			nHitted++
		}
	}
	return nHitted
}

func main() {
	scanner.Split(bufio.ScanWords)
	nNumbers := nextInt()
	a := make([]int, nNumbers)
	for i := 0; i < nNumbers; i++ {
		a[i] = nextInt()
	}

	nQueries := nextInt()
	for i := 0; i < nQueries; i++ {
		b := nextInt()
		e := nextInt()
		k := nextInt()
		fmt.Println(count(a[b:e], k))
	}
}



Measured memory_bytes: 1108
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(ll i=p;i<n;i++)
#define fr1(i,p,n) for(ll i=p;i>=n;i--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(15) << std::fixed;
using namespace std;

map<int,int> mp;
void primeFactors(ll n)
{
    while (n % 2 == 0)
    {
        mp[2]++;
        n = n/2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            mp[i]++;
            n = n/i;
        }
    }
    if (n > 2)
        mp[n]++;
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(0);
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        primeFactors(n);
        ll ans=0;
        for(auto it=mp.begin();it!=mp.end();it++)
        {
            ll cnt=0;
            //cout<<it->first<<" "<<it->second<<endl;
            while(cnt*(cnt+1)/2<=it->second)
            {
                cnt++;
            }
            ans+=cnt-1;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3704
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int a,b,c,d,e; 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b>>c>>d>>e;
	cout<<(c-a)*60+d-b-e;
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll K[105][100005];

ll knapSack(ll n,ll v[],ll W,ll w[],ll tot)
{
    for (ll i=0; i<=n; i++)
    {
        for (ll pr=0; pr<=tot; pr++)
        {
            if (i==0 && pr==0)
                K[i][pr]=0;
            else if(i==0)
                K[i][pr]=1e11;
            /*else if(w[i-1]<=wt)
                K[i][wt]=max(v[i-1]+K[i-1][wt-w[i-1]],K[i-1][wt]);*/
            else if(v[i-1]<=pr)
                K[i][pr]=min(w[i-1]+K[i-1][pr-v[i-1]],K[i-1][pr]);
            else
                K[i][pr]=K[i-1][pr];
        }
    }
    ll val=0;
	for(ll pr=0; pr<=tot; pr++)
		if(K[n][pr]<=W)
            val=pr;
	return val;
}

int main()
{
    ll n,W;
    cin>>n>>W;
    ll v[n+5],w[n+5];
    ll tot=0;
    for(int i=0; i<n; i++){
        cin>>w[i]>>v[i];
        tot+=v[i];
    }
    ll ans=knapSack(n,v,W,w,tot);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 82432
import math
N=int(input())
zahyo=[]
alld=0
jac=math.factorial(N-1)*2
for i in range(0,N):
    zahyo.append(list(map(int,input().split())))
for i in range(0,N-1):
    for j in range(i+1,N):
        alld+=(((zahyo[i][0]-zahyo[j][0])**2+(zahyo[i][1]-zahyo[j][1])**2)**(1/2))*jac
print(alld/math.factorial(N))

Measured memory_bytes: 3188
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

ll x,k,d;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>x>>k>>d;
	x=abs(x);
	
	ll delta=x/d;
	
	if (delta>=k){
		cout<<x-k*d;
	}
	else{
		k-=delta;
		x=x-delta*d;
		
		if (k%2==1) cout<<abs(x-d);
		else cout<<x;
	}
	
}


Measured memory_bytes: 3648
def main():
  N = int(input())
  A = sorted([int(_) for _ in input().split()])
  a0 = set()
  for i in range(1, int(A[0]**0.5)+1):
    if A[0]%i == 0:
      a0.add(i)
      a0.add(A[0]//i)
  a0 = list(a0)
  a1 = set()
  for i in range(1, int(A[1]**0.5)+1):
    if A[1]%i == 0:
      a1.add(i)
      a1.add(A[1]//i)
  a1 = list(a1)
  ret = 1
  for p in a0:
    cc = 0
    if p == 1:
      continue
    for a in A:
      if a%p != 0:
        cc += 1
    if cc <= 1:
      ret = max(ret, p)
  for p in a1:
    cc = 0
    if p == 1:
      continue
    for a in A:
      if a%p != 0:
        cc += 1
    if cc <= 1:
      ret = max(ret, p)
  print(ret)
  return

if __name__ == '__main__':
  main()

Measured memory_bytes: 63984
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int cnt=0;
vector<int> G;
 
void insertsort(int A[],int n,int g){
	for(int i = g; i<n;i++){
		int temp=A[i],j=i-g;
		while(j>=0&&A[j]>temp){
			A[j+g]=A[j];
			j-=g;
			cnt++;
		}
		A[j+g]=temp;
	}
	return ;
}
 
void shellsort(int A[],int n){
	//generate the G array
	for (int h =1;;){
		if (h>n) break;
		G.push_back(h);
		h=3*h+1;
	}
	
	for(int i=G.size()-1;i>=0;i--)	insertsort(A,n,G[i]);
	
	return ;
}
 
int main (){
	int n ,A[1000010];
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	
	shellsort(A,n);
 
	cout<<G.size()<<endl;
	for(int i =G.size()-1;i>=0;i--){
		printf("%d",G[i]);
		if(i) printf(" ");
	}
	printf("\n%d\n",cnt);
	for(int i =0;i<n;i++) printf("%d\n", A[i]);
	return 0;
}



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

using namespace std;

#define ll long long
#define ld long double

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    char a;
    cin >> a;
    if (a >= 'a') cout << 'a' << endl;
    else cout << 'A' << endl;
    return 0;
}


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

#if DEBUG
template <typename Iter>
void debug_iter(Iter begin, Iter end);
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T>
void debug(const std::vector<T>& v) {
  debug_iter(v.begin(), v.end());
}
template <typename T>
void debug(const std::set<T>& s) {
  debug_iter(s.begin(), s.end());
}
template <typename T, typename U>
void debug(const std::map<T, U>& m) {
  debug_iter(m.begin(), m.end());
}
template <typename T, typename U>
void debug(const std::pair<T, U>& p) {
  std::cerr << "{";
  debug(p.first);
  std::cerr << ", ";
  debug(p.second);
  std::cerr << "}";
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  debug(value);
  std::cerr << ", ";
  debug(args...);
}
template <typename Iter>
void debug_iter(Iter begin, Iter end) {
  std::cerr << "{";
  for (Iter it = begin; it != end; ++it) {
    if (it != begin) std::cerr << ", ";
    debug(*it);
  }
  std::cerr << "}";
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& v) {
  for (T& vi : v) is >> vi;
  return is;
}

template <typename T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#include <boost/hana/functional/fix.hpp>
auto Fix = [](auto&& f) { return boost::hana::fix(f); };

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  rd(int, n);
  V<int> l(n);
  cin >> l;
  int ans = 0;
  rep(i, n) rep(j, i) rep(k, j) {
    int I = l[i], J = l[j], K = l[k];
    if (I != J && J != K && K != I && I < (J + K) && J < (K + I) &&
        K < (I + J)) {
      ++ans;
    }
  }
  wt(ans);
}


Measured memory_bytes: 3628
package main

import (
	"fmt"
)

const (
	N = 10
	M = 10
)

func main() {

	var a, b string
	fmt.Scan(&a)
	fmt.Scan(&b)

	var table [N][M]byte
	var n = 3
	var m = 2

	for i := 0; i < len(a); i++ {
		table[0][i] = a[i]
	}
	for i := 0; i < len(b); i++ {
		table[1][i] = b[i]
	}

	for i := 0; i < m; i++ {
		for j := 0; j < n; j++ {
			if table[i][j] != table[m-1-i][n-1-j] {
				fmt.Println("NO")
				return
			}
		}
	}
	fmt.Println("YES")

}


Measured memory_bytes: 1772
#include <iostream>
#include <algorithm>
using namespace std;
int a[100005];
int main() {string str;
    int n,m;cin>>n>>m>>str;
    for(int i=0;i<10005;i++){a[i]=0;}
    for(int i=0;i<n-1;i++){
if(i==0){a[i]=0;}else{a[i]=a[i-1];}
        if(str[i]=='A'&&str[i+1]=='C'){a[i]=i==0?1:a[i]+1;}
    }
   for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        if(u==1){cout<<a[v-2]<<endl;continue;}
        u-=2;v--;v--;
        cout<<a[v]-a[u]<<endl;

    }
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main() {
    long long x;
    cin >> x;

    for (long long a = -6208; a <= 6208; a++) {
        for (long long b = -6208; b <= 6208; b++) {
            if (a * a * a * a * a - b * b * b * b * b == x) {
                cout << a << " " << b << endl;
                goto out;
            }
        }
    }
out:
    ;
}


Measured memory_bytes: 3592
import numpy as np
mod = 10 ** 9 + 7
X, Y = map(int, input().split())

a = (2 * Y - X) / 3
b = (2 * X - Y) / 3

if a.is_integer() and a >= 0 and  b.is_integer() and b >= 0:
    tmp = [i for i in range(int(a) + 1, int(a + b) + 1)]
    bunshi = 1
    for t in tmp:
        bunshi *= t % mod
        bunshi %= mod
    tmp = [i for i in range(1, int(b) + 1)]
    bunbo = 1
    for t in tmp:
        bunbo *= pow(t, mod -2, mod) % mod
        bunbo %= mod
    print(bunshi * bunbo % mod)
    
else:
    print(0)

Measured memory_bytes: 38740
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()



def main():
	n=II()
	A=LI()

	s=0
	x=0
	r=-1

	ans=0

	for l in range(n):
		while s==x and r<n:
			r+=1
			if r==n:
				break
			s+=A[r]
			x^=A[r]
			#print(s,x,r)
		#print(l,r,s,x,11111)
		ans+=r-l

		s-=A[l]
		x^=A[l]
	print(ans)







if __name__ == "__main__":
	main()


Measured memory_bytes: 29216
#include<bits/stdc++.h>
using namespace std;
struct Card
{
    char suit;
    int value;
};
Card C1[100];
Card C2[100];
void Bubble(struct Card a[],int n)
{
    for(int i=0;i<n;++i)
    {
        for(int j=n-1;j>=i+1;--j)
        {
            if(a[j].value<a[j-1].value)
            {
                swap(a[j],a[j-1]);
            }
        }
    }
    //cout<<"end"<<endl;
}
void Selection(struct Card a[],int n)
{
    int minj;
    for(int i=0;i<n;++i)
    {
        minj=i;
        for(int j=i;j<n;++j)
        {
            if(a[j].value<a[minj].value)
            {
                minj=j;
            }
        }
        swap(a[i],a[minj]);
    }
    //cout<<"end"<<endl;
}
bool isStable(struct Card a1[],struct Card a2[],int n)
{
    for(int i=0;i<n;++i)
    {
        if(a1[i].suit!=a2[i].suit)
        {
            //cout<<"end"<<endl;
            return false;
        }
    }
    //cout<<"end"<<endl;
    return true;
}
void print(struct Card a[],int n)
{
    for(int i=0;i<n;++i)
    {
        if(i>0)cout<<" ";
        cout<<a[i].suit<<a[i].value;
    }
    cout<<endl;
    //cout<<"end"<<endl;
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;++i)
    {
        cin>>C1[i].suit>>C1[i].value;
    }
    for(int i=0;i<n;++i)
    {
        C2[i]=C1[i];
    }
    Bubble(C1,n);
    Selection(C2,n);

    print(C1,n);
    cout<<"Stable"<<endl;

    print(C2,n);
    if(isStable(C1,C2,n))
    {
        cout<<"Stable"<<endl;
    }
    else
    {
        cout<<"Not stable"<<endl;
    }
    //cout<<"end"<<endl;
    return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
using namespace std;
template < class BidirectionalIterator >
bool next_combination ( BidirectionalIterator first1 ,
  BidirectionalIterator last1 ,
  BidirectionalIterator first2 ,
  BidirectionalIterator last2 )
{
  if (( first1 == last1 ) || ( first2 == last2 )) {
    return false ;
  }
  BidirectionalIterator m1 = last1 ;
  BidirectionalIterator m2 = last2 ; --m2;
  while (--m1 != first1 && !(* m1 < *m2 )){
  }
  bool result = (m1 == first1 ) && !(* first1 < *m2 );
  if (! result ) {
    while ( first2 != m2 && !(* m1 < * first2 )) {
      ++ first2 ;
    }
    first1 = m1;
    std :: iter_swap (first1 , first2 );
    ++ first1 ;
    ++ first2 ;
  }
  if (( first1 != last1 ) && ( first2 != last2 )) {
    m1 = last1 ; m2 = first2 ;
    while (( m1 != first1 ) && (m2 != last2 )) {
      std :: iter_swap (--m1 , m2 );
      ++ m2;
    }
    std :: reverse (first1 , m1 );
    std :: reverse (first1 , last1 );
    std :: reverse (m2 , last2 );
    std :: reverse (first2 , last2 );
  }
  return ! result ;
}
 
template < class BidirectionalIterator >
bool next_combination ( BidirectionalIterator first ,
  BidirectionalIterator middle ,
  BidirectionalIterator last )
{
  return next_combination (first , middle , middle , last );
}
int n,m;
double l[21]={},a[21]={},b[21]={};
double dp[21][21]={{}};
double o=0;
int i,j,k;
int main(){
  
  cin >> n >> m;
  
  for(i=0;i<n;i++){
    cin >> l[i] >> a[i] >> b[i];
  }
  
  for(j=0;j<n;j++){
    for(k=0;k<n;k++){
      dp[j][k]=(l[j]-l[k])*(l[j]-l[k])+
	(a[j]-a[k])*(a[j]-a[k])+
	(b[j]-b[k])*(b[j]-b[k]);
    }
  }

  double sum=0;
  vector<int> data;
  for(i=0; i<n; i++){
    data.push_back(i);
  }
  do{
    sum=0;
    for(i=0;i<m;i++){
      for(j=i;j<m;j++){
      sum+=dp[data[i]][data[j]];
      }
    }
    if(o<sum)o=sum;
  }while(next_combination(data.begin(), data.begin()+m, data.end()));
 
  
  printf("%.6f\n",o);
  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ld a, b, h, m;
  cin >> a >> b >> h >> m;
  if (h >= 12) {
    h -= 12;
  }

  ld p, q;
  q = 2 * M_PI * m / 60;
  p = 2 * M_PI * (h + m / 60.0) / 12.0;

  ld ans = a * a + b * b - 2 * a * b * cos(p - q);
  ans = sqrt(ans);

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;
	int n = (int) s.length();
	long long curr = 0, c = 0;
	for(int i=0;i<n;i++)
	{
		if(s[i] == 'W')
		{
			c += i - curr;
			curr++;
		}
	}
	cout << c << "\n";
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    a--;
    x[a]++;
  }
  for (int i = 0; i < n; i++) cout << x[i] << endl;
  return 0;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
 typedef long long ll;
 
int main() {
int n;
cin>>n;
int m[200000];
for(int i=0;i<200001;i++)m[i]=0;

for(int i=0;i<n;i++){
int l;
cin>>l;
m[l]++;
}

int ans = 0;
for(int i=1;i<199999;i++){
int kari = m[i-1]+m[i]+m[i+1];
ans=max(ans,kari);
}
cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
int a[N];
int main()
{
    int n,n1=0,n2=0,maxx=-1e9,minn=1e9;
    scanf("%d",&n);
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        sum+=abs(a[i]);
        if(a[i]<0)
            n1++,maxx=max(maxx,a[i]);
        else
            n2++,minn=min(minn,a[i]);
    }

    if(n1%2==0)printf("%lld\n",sum);
    else
    {
        printf("%lld",max(sum+2*maxx,sum-2*minn));
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int , int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18 
int main (){
    int n ;
    cin >> n ;
    vector<int> a (n) ;
    rep(i, n){
        cin >> a[i] ;
    } 
    int q ;
    cin >> q ;
    vector<int> m (q) ;
    vector<bool> is (q, false) ;
    rep(i, q){
        cin >> m[i] ;
    }

        bool can = false ;
        for(int j = 1 ;j < ( 1 << n ); j++){
            int num = 0 ;
            rep(s, n) {
                if(j >> s  & 1){
                    num += a[s] ;
                }
            }
            rep(i, q){
                if(num == m[i]){
                    is[i] = true ;
                }
            }
        }
        rep(i, q){
            if(is[i]){
                cout << "yes" << endl ;
            }
            else {
                cout << "no" << endl; 
            }
        }
}



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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){
  map<pair<char,char>,int> mp;
  ll res = 0;
  int n,k,r,s,p;
  string S;
  cin >> n >> k >> r >> s >> p >> S;
  mp[make_pair('r','s')] = r;mp[make_pair('s','p')] = s;mp[make_pair('p','r')] = p;
  int change[3] = {'r','s','p'};
  vector<string> v(k,"");
  REP(i,n){
    v[i%k] += S[i];
  }
  REP(i,k){
    int dp[(int)v[i].size()][3];
    FILL(dp,(int)v[i].size(),-1);
    REP(gg,3)dp[0][gg] = mp[make_pair(change[gg],v[i][0])];
    for(int j = 1;j < v[i].size();j++){
      REP(l,3)if(l != 0)if(dp[j-1][l] != -1)dp[j][0] = max(dp[j][0],dp[j-1][l]+mp[make_pair(change[0],v[i][j])]);
      REP(l,3)if(l != 1)if(dp[j-1][l] != -1)dp[j][1] = max(dp[j][1],dp[j-1][l]+mp[make_pair(change[1],v[i][j])]);
      REP(l,3)if(l != 2)if(dp[j-1][l] != -1)dp[j][2] = max(dp[j][2],dp[j-1][l]+mp[make_pair(change[2],v[i][j])]);
    }
    res += max({dp[(int)v[i].size()-1][0],dp[(int)v[i].size()-1][1],dp[(int)v[i].size()-1][2]});
  }
  cout << res << endl;
  

  return 0;
}


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

using namespace std;

#define all(v)   v.begin(), v.end()
#define pb       push_back
#define sz(x)    (int) (x.size())
#define endl "\n"
#define isOdd(n)    (n&1)
#define pow(n, m) (ll)powl(n, m)
#define clr(x, val)    memset(x, val, sizeof(x)) //be careful of value and TLE

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


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

    int n; cin >> n;
    int c = 0;
    for(int i = 1; i <= n; i++){
        int a; cin >> a;
        if(isOdd(a) && isOdd(i)) c++;
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <utility>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <unordered_map>
#include <map>
#include <bitset>
#include <string>
#include <cstring>

#define pb push_back
#define mp make_pair
#define l(x) x << 1
#define r(x) x << 1 | 1
#define scan(x) do {while((x=getchar())<'0') ; for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0') ; } while(0)
char _;
#define x first
#define y second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<float, float> pff;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;

int N, x, c[3];

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &x);
        if (x % 4 == 0) {
            c[2] += 1;
        } else if (x % 2 == 0) {
            c[1] += 1;
        } else {
            c[0] += 1;
        }
    }
    // 4 can be next to anything
    // 2 have to be next to 2 or 4
    // 0 have to be next to a 4
    
    // 0 next to 2
    if (c[0] != 0 && c[1] != 0 && c[2] == 0) {
        cout << "No" << endl;
        return 0;
    }
    // 0 not next to 4
    if ((c[0] != 0 && c[2] == 0) || (c[0] - c[2] >= 2)) {
        cout << "No" << endl;
        return 0;
    }
    if (c[0] - c[2] == 1 && c[1] != 0) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e8;
const ll infl = 1LL << 60;
///////
const ll MOD = 1e9+7;

int main(){
  ll A,B,N;
  cin >> A >> B >> N;
  ll x = min(N,B-1);
    
  ll ans = (ll)(A*x/B);
  cout << ans << endl;
} 


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;

struct Tuple
{
    int index;
    int p;
    int y;
    string id;
};

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

    vector<Tuple> data;

    for (int i = 0; i < M; ++i)
    {
        Tuple t;
        cin >> t.p >> t.y;
        t.index = i;
        data.push_back(t);
    }

    sort(data.begin(), data.end(), [](Tuple &a, Tuple &b) {
        return a.y < b.y;
    });

    vector<int> counter(N + 1, 0);
    for (auto &d : data)
    {
        auto n = counter[d.p] + 1;
        stringstream ss;
        ss << setfill('0') << setw(6) << d.p;
        ss << setfill('0') << setw(6) << n;
        d.id = ss.str();
        ++counter[d.p];
    }

    sort(data.begin(), data.end(), [](Tuple &a, Tuple &b) {
        return a.index < b.index;
    });

    for (auto &d : data)
    {
        cout << d.id << endl;
    }

    return 0;
}

Measured memory_bytes: 9584
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll x, y, num, ans;

int main() {
    cin >> x >> y;
    while (true) {
        if (x > y) break;
        ans++;
        x *= 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 200005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
 vector<int> vi[maxii];
 vector<int>::iterator child;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];


int main()
{
    char a;
    int b,c;
    cin>>b>>a>>c;
    if(a=='+')cout<<b+c;
    else cout<<b-c;
}






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

using namespace std;

int main(void) {
    //int s[32];
    int n;
    int s[32] = {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};

    cin >> n;
    cout << s[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 10000000000000
#define MAX_OTURI 50005
#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int K;
double r,l;
double p;
double e;
double t;
double ans;
double saiki(int kai,double rr,double ll,double ppp)
{
	if(ll<t-e||t+e<rr)
	{
		return 0.00000000000;
	}
	if(t-e<=rr&&ll<=t+e)
	{
		return ppp;
	}
	if(kai==K)
	{
		double t_t=(rr+ll)/2.0000000000000;
		if(t-e<=t_t&&t_t<=t+e)
		{
			return ppp;
		}
		else return 0.0000000000000000;
	}
	double t_t=(rr+ll)/2.0000000000000;
	if(t<t_t)return saiki(kai+1,rr,t_t,ppp*p)+saiki(kai+1,t_t,ll,ppp*(1.0000000000-p));
	else return saiki(kai+1,rr,t_t,ppp*(1.0000000000-p))+saiki(kai+1,t_t,ll,ppp*p);
}
int main()
{
	ans=0.0000000000000;
	scanf("%d%lf%lf",&K,&r,&l);
	scanf("%lf",&p);
	p=1.000000000000000-p;
	scanf("%lf",&e);
	scanf("%lf",&t);
	printf("%.10f\n",saiki(0,r,l,1.0000000000));
	return 0;
}

Measured memory_bytes: 3240
#import numpy as np
#import math
#from decimal import *
#from numba import njit
from math import floor

#@njit
def main():
    A,B,N = map(int, input().split())
    
    def f(x):
        return floor(A*x/B)-A*floor(x/B)

    print(f(min(N, B-1)))
main()


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

int main(){
    int n;
    cin >>n ;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    cout << vec.at(n-1)-vec.at(0) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll INF=1e9;
const ll MAX=10001;
struct edge{
    int to, cap, rev; ll cost;
};
 
int V;
vector<edge> g[20002];
ll h[20002];
ll dist[20002];
int prevv[20002], preve[20002];
 
void add_edge(int from, int to, int cap, ll cost){
    edge e;
    e.to=to, e.cap=cap, e.cost=cost, e.rev=g[to].size();
    g[from].push_back(e);
    e.to=from, e.cap=0, e.cost=-cost, e.rev=g[from].size()-1;
    g[to].push_back(e);
}
   
ll min_cost_flow(int s, int t, int f){
    ll res=0;
    fill(h, h+V, 0);
    while(f>0){
        priority_queue<P, vector<P>, greater<P>> que;
        fill(dist, dist+V, INF);
        dist[s]=0;
        que.push(P(0, s));
        while(!que.empty()){
            P p=que.top(); que.pop();
            int v=p.second;
            if(dist[v]<p.first) continue;
            for(int i=0; i<g[v].size(); i++){
                edge &e=g[v][i];
                if(e.cap>0 && dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
                    dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
                    prevv[e.to]=v;
                    preve[e.to]=i;
                    que.push(P(dist[e.to], e.to));
                }
            }
        }
        for(int v=0; v<V; v++) h[v]+=dist[v];
        if(dist[t]==INF) return -1;
        int d=f;
        for(int v=t; v!=s; v=prevv[v]){
            d=min(d, g[prevv[v]][preve[v]].cap);
        }
        f-=d;
        res+=d*h[t];
        for(int v=t; v!=s; v=prevv[v]){
            edge &e=g[prevv[v]][preve[v]];
            e.cap-=d;
            g[v][e.rev].cap+=d;
        }
    }
    return res;
}
 
int main()
{
    int m, n, k; cin>>m>>n>>k;
    vector<int> t[10001];
    int w[10001];
    for(int i=0; i<n; i++) cin>>w[i];
    int ans=0;
    for(int i=0; i<k; i++){
        int a; cin>>a;
        ans+=w[a-1];
        t[a-1].push_back(i);
    }
    V=k;
    for(int i=0; i<n; i++){
        for(int j=0; j<(int)t[i].size()-1; j++){
            if(t[i][j]+1==t[i][j+1]){
                ans-=w[i];
            }else{
                add_edge(t[i][j]+1, t[i][j+1], 1, MAX*(t[i][j+1]-t[i][j]-1)-w[i]);
            }
        }
    }
    for(int i=0; i<k-1; i++) add_edge(i, i+1, INF, MAX);
    ans+=(min_cost_flow(0, k-1, m-1)-(m-1)*MAX*(k-1));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5424
def main():
    # 下、右、上、左
    dy = [1, 0, -1, 0]
    dx = [0, 1, 0, -1]
    H, W = map(int, input().split())
    dot = "." * (W + 2)
    s = [dot]
    s += ["." + input() + "." for i in range(H)]
    s.append(dot)
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if s[y][x] == "#" and\
                    "." == s[y + dy[0]][x + dx[0]]\
                    == s[y + dy[1]][x + dx[1]]\
                    == s[y + dy[2]][x + dx[2]]\
                    == s[y + dy[3]][x + dx[3]]:
                print("No")
                return
    print("Yes")
    return


main()


Measured memory_bytes: 3064
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(D)]
last = [-1]*26
ans = 0
for i in range(D):
  TEMP = -float('inf')
  T = -1
  for t in range(26):
    temp = 0
    temp += s[i][t]
    tempo = last[t]
    last[t] = i
    temp -= sum([c[j]*(i-last[j]) for j in range(26)])
    #print(temp)
    if temp > TEMP:
      T = t
      TEMP = temp
    last[t] = tempo
  print(T+1)
  last[T-1] = i
  ans += TEMP

Measured memory_bytes: 9392
#include <bits/stdc++.h>
using namespace std;
int main(){
	string a, b, c; cin >> a >> b;
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	while(!a.empty()){
		c.push_back(a.back());
		a.pop_back();
		swap(a, b);
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int r = Math.min(n, k);
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = sc.nextInt();
        }
        
        int opCount = 1;
        long max = 0;
        while (opCount <= r) {
            for (int i = 0; i <= opCount; i++) {
                long score = calcScore(values, k, i, opCount - i);
                max = Math.max(max, score);
            }
            opCount++;
        }
        
        System.out.println(max);
    }
    
    public static long calcScore(int[] values, int k, int aCount, int bCount) {
        List<Integer> list = new ArrayList<Integer>(); 
        
        for (int i = 0; i < aCount; i++) {
            list.add(values[i]);
        }
        for (int i = values.length - 1; i > values.length - 1 - bCount; i--) {
            list.add(values[i]);
        }
        
        Collections.sort(list);
        
        int canRemoveCount = k - aCount - bCount;
        while (list.get(0) < 0) {
            if (canRemoveCount > 0) {
                list.remove(0);
                canRemoveCount--;
                if (list.isEmpty()) break;
            } else {
                break;
            }
        }
        
        long score = 0;
        for (Integer v : list) {
            score += (long)v;
        }
        
        return score;
    }
}

Measured memory_bytes: 24620