akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 99999999999999999;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;

long long func(long long n) {
	switch (n % 4) {
	case 0:
		return n;
		break;
	case 1:
		return 1;
		break;
	case 2:
		return n ^ 1;
		break;
	case 3:
		return 0;
		break;
	}
}

int main() {
	long long a, b, c;
	cin >> a >> b;
	cout << (func(b) ^ func(a - 1)) << endl;
}

Measured memory_bytes: 256
a, b = map(int, input().split())

a_inf = a / 0.08
a_sup = (a + 1) / 0.08
b_inf = b / 0.1
b_sup = (b + 1) / 0.1
a_min = int(a_inf // 1)

a = a_min
al = []
while a < a_sup:
    if a_inf <= a < a_sup:
        al.append(a)
    a += 1

if al[0] >= b_sup:
    print('-1')
else:
    for i in range(len(al)):
        if b_inf <= al[i]:
            print(int(al[i]))
            break
    else:
        print('-1')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
int main()
{

    int n;
    cin>>n;
    vector<string> a(n);
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        a[i]=s;
        //cout<<s<<endl;
    }
    sort(a.begin(),a.end());
    int i=0,j=0;
    ll ans=0;
    while(j<n)
    {
        while(j<n && a[j]==a[i])
            j++;
        //cout<<j-i<<endl;
        ans+=((ll)j-i)*(j-i-1)/2ll;
        i=j;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 5760
import sys
N = int(input())
p = list(map(int,input().split()))
q = sorted(p)
x = 0
if p == q:
    print("YES")
    sys.exit()
else:
    for i in range(N):
        if p[i] != q[i]:
            x += 1
if x == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
N, M = map(int, input().split())
Xs = list(map(int, input().split()))
Xs.sort()
#print(Xs)
if N >= M:
  print(0)
  exit()
Ds = []
for i in range(1, M):
  D = Xs[i]-Xs[i-1]
  Ds.append(D)
Ds.sort()
#print(Ds)
r = sum(Ds[:M-N])
print(r)


Measured memory_bytes: 13968
#include<bits/stdc++.h>
#define int long long int
#define MOD 1000000007
using namespace std;
#define double long double
const int N=3001;
const int M=3001;
double dp[N][M]; int dp1[N][M]; int n; double arr[N]; 
int INF=10000000000000000;

double go(int index, int count){
	if(index==n && count>n-count)
	return 1.0;
	else if(index==n)
	return 0.0;
	
	if(dp1[index][count]!=-1)
	return dp[index][count];
	
	double ans=0.0,ans1=0.0;
	ans=arr[index]*go(index+1,count+1);
	ans1=(1.0 - arr[index])*go(index+1,count);
	ans=ans+ans1;
	
	dp1[index][count]=1;
	return dp[index][count]=ans;
}

#undef int
int main(){
	#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t=1;
	while(t--){
		cin >> n;
		for(int i=0;i<n;i++){
			cin>>arr[i];
		}
		memset(dp1,-1,sizeof(dp1));
		cout<<fixed<<setprecision(10)<<go(0,0);
	}
	return 0;
}


Measured memory_bytes: 211584
#include<iostream>
using namespace std;
int ans[3005];
int main(){
	int n,x,y;
	cin>>n>>x>>y;
	x--,y--;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int d=min(j-i,abs(i-x)+abs(j-y)+1);
			ans[d]++;
		}
	}
	for(int i=1;i<n;i++) cout<<ans[i]<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)

using namespace std;
int main()
{
    string S, T;
    cin >> S >> T;
    if(S.length()+1 != T.length()){
        cout << "No" << endl;
        return 0;
    }
    bool is_same = true;
    REP(i,S.length()){
        if(S[i]!=T[i]){is_same = false;break;}
    }
    if(is_same){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;
using ll = long long;

bool a[200001],b[2000001];

int main() {
    int n,m,x,y;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> x >> y;
        if(x==1)    a[y]=true;
        else if(x==n) b[y]=true;
        else if(y==n) b[x]=true;
    }
    for(int i=1;i<=200000;i++){
        if(a[i]==true&&b[i]==true){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<iomanip>
using namespace std;
#define llong long long
int main()
{
   int N;
   cin >> N;
   vector<double> x(N);
   vector<string> u(N);
   double sum = 0; 
   for(int i = 0; i < N; i++)
   {
      cin >> x[i] >> u[i];
      if(u[i] == "BTC")
      {
         sum += 380000*x[i];
      }
      else
      {
         sum += x[i];
      }
   }
   cout << fixed << setprecision(5) << sum << endl;
   
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A=dict()
ans=0
A=[list(map(int,input().split()))for i in range(N)]
A.sort()
for i in range(N):
    if M>A[i][1]:
        M-=A[i][1]
        ans+=A[i][0]*A[i][1]
    else:
        ans+=A[i][0]*M
        break
print(ans)


Measured memory_bytes: 27320
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,i=0,r,l,k,ans[100010]={};
  char c='L';
  string s;
  cin >> s;
  n=s.size();
  while (i<n){
    r=0;
    while (s[i]=='R'){
      i++;
      r++;
    }
    k=i;
    l=0;
    while (s[i]=='L' && i<n){
      i++;
      l++;
    }
    ans[k-1]=(r+1)/2+l/2;
    ans[k]=r/2+(l+1)/2;
  }
  for (i=0;i<n;i++){
    cout << ans[i];
    if (i==n-1) cout << endl;
    else cout << ' '; 
  }
  return 0;
}

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

using namespace std;

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

    int b;
    b = (N % 500) - A;

    if (b <=0 ) {
        cout << "Yes" << endl;
    } else if (b > 0) {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		int pre = -10;
		int point = 0;
		for(int i =0;i<n;i++) {
			a[i] = sc.nextInt();
		}
		for(int i =0;i<n;i++) {
			b[i] = sc.nextInt();
		}
		for(int i =0;i<n-1;i++) {
			c[i] = sc.nextInt();
		}
		
		for(int a0 : a) {
			a0 -= 1;
			point += b[a0];
			if(a0-1 == pre) {
				point += c[pre];
			}
			pre = a0;
		}
		System.out.println(point);
	}	

}


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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	static int n, m, con[][];
	static List<Integer> l[];
	static long memo[];
	static Map<String,Integer> mp; 
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		n = fs.nextInt();
		l = new ArrayList[n];
		mp = new HashMap<>();
		for(int i=0;i<n;i++)l[i] = new ArrayList<>();
		for(int i=0;i<n-1;i++) {
			int a = fs.nextInt()-1, b = fs.nextInt()-1;
			l[a].add(b);
			l[b].add(a);
			mp.put(Integer.toString(a)+"to"+Integer.toString(b), i);
			mp.put(Integer.toString(b)+"to"+Integer.toString(a), i);			
		}
		m = fs.nextInt();
		con = new int[m][2];
		for(int i=0;i<m;i++) {
			int u = fs.nextInt()-1, v = fs.nextInt()-1;
			con[i][0] = u;
			con[i][1] = v;
		}
		memo = new long[m];//各区間の通る点の情報をbitでもつ（頂点３２個以上なのでlong）
		
		for(int i=0;i<m;i++) {
			dfs(i,con[i][0],con[i][1],-1);
		}
		
		long res = 0; //どこかしらの区間が全部白になる場合の数
		//全白にするパスをbit全探索する
		for(int i=1;i<(1<<m);i++) {
			int cnt = 0;
			long bit = 0;
			for(int j=0;j<m;j++) {
				if((i>>j&1)==1) {
					cnt++;
					bit |= memo[j];
				}
			}
			int num = Long.bitCount(bit);
			if(cnt%2==0) res -= Math.pow(2, n-1-num);
			else res += Math.pow(2, n-1-num);
			
		}
		long ans = (long) (Math.pow(2, n-1) - res);
		System.out.println(ans);
	}
	static boolean dfs(int i, int u, int v, int parent) {
		if(u == v) {
			return true;
		}
		for(int to:l[u]) {
			if(to==parent)continue;
			if(dfs(i, to, v, u)) {
				int edge = mp.get(Integer.toString(u)+"to"+Integer.toString(to)); 
				memo[i] |= 1L<<edge;
				return true;
			}
		}
		return false;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

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

Measured memory_bytes: 24148
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lloop(i, a, b) for(ll i=a;i<(ll)b; i++)
#define loop(i, a, b) for(int i=a;i<b;i++)

int main(){
	string s;
	cin>>s;
	if(s[0]=='7'||s[1]=='7'||s[2]=='7')
		cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
long long  f(long long x,long long y)
{   
	if(x%y==0)
	return(y);
	else
	return f(y,x%y);
}
int main()
{
	long long a,b,n,m,i,c,d;;
	while(~scanf("%lld%lld%d%d",&a,&b,&c,&d))
	{  
	    if(c>d)
	    {
	    	int g;
	    	g=c;
	    	c=d;
	    	d=g;
		}
		long long s=0,l=0,k=0,gcd,lcm;
     	s=b/d-(a-1)/d;
	 	l=b/c-(a-1)/c;
	 	gcd=f(c,d);
	 	lcm=c*d/gcd;
	 	k=b/lcm-(a-1)/lcm;
	 printf("%lld\n",b-a+1-(s+l-k)); 
	}
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){if(a < b) a = b;}


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	VI a(n);
	rep(i, n) cin >>a[i];
	
	rep(i, n){
		if(a[i]%2==0){
			if(a[i]%3 != 0 && a[i]%5 !=0){ puts("DENIED"); return 0;}
		}
	}
	puts("APPROVED");
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
// const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N, P;
string S;
map<ll, ll> rem;

int MOD = 1000000007;

ll ppow(ll a, ll b) {
  a %= MOD;
  ll res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % MOD;
    }
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}

int main() {
  cin >> N >> P;
  cin >> S;
  MOD = P;

  if (P == 2) {
    ll ans = 0;
    for (int i = S.size() - 1; i >= 0; --i) {
      int num = S[i] - '0';
      if (num % 2 == 0) {
        ans += i + 1;
      }
    }
    cout << ans << endl;
    return 0;
  }

  if (P == 5) {
    ll ans = 0;
    for (int i = S.size() - 1; i >= 0; --i) {
      int num = S[i] - '0';
      if (num % 5 == 0) {
        ans += i + 1;
      }
    }
    cout << ans << endl;
    return 0;
  }

  ll cur = 0;
  for (int i = 1; i <= S.size(); ++i) {
    int num = S[S.size() - i] - '0';
    cur += num * ppow(10, i - 1);
    cur %= P;
    ++rem[cur];
  }
  ++rem[0];

  ll ans = 0;
  for (auto e : rem) {
    ll v = e.second;
    ans += v * (v - 1) / 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1028
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

int main(void)
{
  int i, count, rnum = 0, ans = 0;
  char stone[200000], temp;
  scanf("%d", &count);
  for (i = 0; i < (count + 1); i++)
  {
    scanf("%c", &stone[i]);
    if (stone[i] == 'R')
    {
      rnum++;
    }
  }
  for (i = 0; i < (rnum + 1); i++)
  {
    if (stone[i] == 'W')
    {
      ans++;
    }
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 1904
package main

import "fmt"

func main() {
	var (
		n, k int
		s    string
	)
	fmt.Scan(&n, &k, &s)

	var result string
	for i, r := range s {
		if i == k-1 {
			result += string(r + ('a' - 'A'))
		} else {
			result += string(r)
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();

		char[] sch = s.toCharArray();
		Arrays.sort(sch);
		String s_asc = new String(sch);

		char[] tch = t.toCharArray();
		Arrays.sort(tch);
		String t_asc = new String(tch);
		String t_desc = new StringBuilder(t_asc).reverse().toString();

		if (s_asc.compareTo(t_desc) < 0)
			System.out.println("Yes");
		else
			System.out.println("No");
		sc.close();
	}

}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;


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

    ll a, b, c;
    cin >> a >> b >> c;

    if(a%2 == 0)         cout << 0 << endl;
    else if(b%2 == 0)    cout << 0 << endl;
    else if(c%2 == 0)    cout << 0 << endl;
    else{
        ll m = min(a*b, min(b*c, c*a));
        cout << m << endl;
    }

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

vector<int> person[100000];
vector<int> lang[100000];
bool visit[100000];
bool checked[100000] = {};

void dfs(int p, int s){
    visit[s] = true;
    for(auto l : person[s]){
        if(!checked[l]){
            checked[l] = true;
            rep(i, lang[l].size()){
                if(lang[l][i] == p || lang[l][i] == s) continue;
                else if(!visit[lang[l][i]]){
                    visit[lang[l][i]] = true;
                    dfs(s, lang[l][i]);
                }
            }
        }
    }
}

void init(){
    rep(i, 100000) visit[i] = false;
}

int main(void){
    init();
    int N, M; cin >> N >> M;
    rep(i, N){
        int K; cin >> K;
        rep(j, K){
            int l; cin >> l; l--;
            lang[l].push_back(i);
            person[i].push_back(l);
        }
    }
    dfs(-1, 0);
    rep(i, N){
        if(!visit[i]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 8704
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o C.exe C.cpp 
Execute: ./C
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	unsigned long long A, B_100_int, answer, hundred = 100ULL;
	double B, b_dummy; 
	unsigned long long b1, b2, b3; /* Decimal B is represented as [b1].[b2][b3] */ 
	cin >> A >> B;
	
	// Extract [b1]. 
	if(abs(B - floor(B)) < abs(B - ceil(B))) {
		b1 = (unsigned long long)(floor(B)); 
		B = (B - floor(B)) * 10.0; 
	} else {
		b1 = (unsigned long long)(ceil(B)); 
		B = (B - ceil(B)) * 10.0; 
	}
	
	// Extract [b2]. 
	if(abs(B - floor(B)) < abs(B - ceil(B))) {
		b2 = (unsigned long long)(floor(B)); 
		B = (B - floor(B)) * 10.0; 
	} else {
		b2 = (unsigned long long)(ceil(B)); 
		B = (B - ceil(B)) * 10.0; 
	}
	
	// Extract [b3]. 
	if(abs(B - floor(B)) < abs(B - ceil(B))) {
		b3 = (unsigned long long)(floor(B)); 
		B = (B - floor(B)) * 10.0; 
	} else {
		b3 = (unsigned long long)(ceil(B)); 
		B = (B - ceil(B)) * 10.0; 
	}
	
	
	B_100_int = (unsigned long long)(100*b1 + 10*b2 + b3); 
	answer = (A * B_100_int) / hundred; 
	
	cout << answer << endl;
	
	return 0; 
} 


Measured memory_bytes: 3724
#include<stdio.h>
#include<iostream>
#include<string.h>
#include <iomanip>
#include<math.h>
#include<queue>
#include<vector>
#include<algorithm>
#define Max (int)1e5+5
#define MAX2 (int)1e5+5
#define MOD ((int)1e9+7)
using namespace std;


int main(){

	int n,k,x,i;
	double ans = 0,tmp;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++){
		tmp = (double)k/i;
		x = ceil(log(tmp)/log(2));
			
		if(i>=k)
			x=0;
		
			ans += (1/(double)n)*pow(((double)1/2),x);
			
		
	}

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



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

#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);

    int k;
    int a;
    int b;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i ++){
        if(i % k == 0){
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
}



Measured memory_bytes: 3612
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 1e5 + 5;

int x, y, a, b, c;
int A[N], B[N], C[N];
long long opt[N];
long long best = 0;

int main()
{
  cin >> x >> y >> a >> b >> c;
  for(int i = 0 ; i < a ; i++)
    cin >> A[i];
  for(int i = 0 ; i < b ; i++)
    cin >> B[i];
  for(int i = 0 ; i < c ; i++)
    cin >> C[i];
  sort(A, A + a); reverse(A, A + a);
  sort(B, B + b); reverse(B, B + b);
  sort(C, C + c); reverse(C, C + c);
  priority_queue<int, vector<int>, greater<int>> pq;
  long long sum = 0;
  for(int i = 0 ; i < y ; i++)
    pq.push(B[i]), sum += B[i];
  opt[c] = sum;
  for(int i = c - 1 ; i >= 0 ; i--) {
    sum += C[i];
    pq.push(C[i]);
    sum -= pq.top();
    pq.pop();
    opt[i] = sum;
  }
  while(!pq.empty()) pq.pop();
  sum = 0;
  for(int i = 0 ; i < x ; i++) {
    sum += A[i];
    pq.push(A[i]);
  }
  long long best = sum + opt[0];
  for(int i = 0 ; i < min(x, c) ; i++) {
    sum += C[i];
    pq.push(C[i]);
    sum -= pq.top();
    pq.pop();
    best = max(best, sum + opt[i + 1]);
  }
  cout << best << endl;
  return 0;
}


Measured memory_bytes: 2680
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int x = sc.nextInt();
    int ans = 0;

    for (int i = 0; i <= a; i++) {
      for (int j = 0; j <= b; j++) {
        for (int k = 0; k <= c; k++) {
          if (((500 * i) + (100 * j) + (50 * k)) == x) {
            ans++;
          }
        }
      }
    }

    System.out.println(ans);

  }
}

Measured memory_bytes: 35636
#include<iostream>
using namespace std;
int main(){
    int t,sum,last;
    last=10;
    sum=0;
    for(int i=0;i<5;i++){
	cin>>t;
	if(t%10==0){
	    sum+=t;
	    continue;
	}
	last=last<t%10? last : t%10;
	sum+=(t/10+1)*10;
    }
    cout<<sum-10+last<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

char c[1010][1010];
int dist[1010][1010], dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1};

int main() {
    ios_base::sync_with_stdio(0);
    int h, w; cin >> h >> w;
    int sy, sx, ey, ex; cin >> sy >> sx >> ey >> ex;
    for (int i=0;i<h;i++) for (int j=0;j<w;j++) cin >> c[i][j];
    sy--; sx--; ey--; ex--;

    for (int i=0;i<h;i++) for (int j=0;j<w;j++) dist[i][j] = 1e9;
    dist[sy][sx] = 0;

    deque<pii> q;
    q.pb({sy, sx});
    while (q.size()) {
        pii now = q.front();
        q.pop_front();
        for (int i=0;i<4;i++) {
            int ny = now.fi+dy[i], nx = now.se+dx[i];
            if (ny<0||nx<0||ny>=h||nx>=w) continue;
            if (c[ny][nx]=='.'&&dist[ny][nx]>dist[now.fi][now.se]) {
                dist[ny][nx] = dist[now.fi][now.se];
                q.push_front({ny, nx});
            }
        }
        for (int i=max(0, now.fi-2);i<=min(h-1, now.fi+2);i++) {
            for (int j=max(0, now.se-2);j<=min(w-1, now.se+2);j++) {
                if (c[i][j]=='.'&&dist[i][j]>dist[now.fi][now.se]+1) {
                    dist[i][j] = dist[now.fi][now.se]+1;
                    q.push_back({i, j});
                }
            }
        }
    }

    cout << (dist[ey][ex]<1e9? dist[ey][ex]: -1) << endl;
}


Measured memory_bytes: 8596
#include<iostream>
using namespace std;
int main()
{
	int a[10],k;
	for(int i=1;i<=5;i++)
	cin>>a[i];
	cin>>k;
	if(k<a[5]-a[1])
	cout<<":("<<endl;
	else
	cout<<"Yay!"<<endl;
}

Measured memory_bytes: 256
import sys
from collections import deque

sys.setrecursionlimit(10 ** 6)


def input(): return sys.stdin.readline().rstrip()

N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

print('No War' if any(max(x) < Z and min(y) >= Z for Z in range(X + 1, Y + 1)) else 'War')

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;
int mod = 1000000007;

string s;
int main() {
  cin >> s;
  int N = s.size();
  rep(i, N) {
    if(s.at(i) == ',') {
      s.at(i) = ' ';
    }
  }
  cout << s << endl;
}


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


int n,k;
int arr[100005];
int dp[100005];

const int INF=1e9;

int solve(int i)
{
    int &ret=dp[i];
    if(ret!=-1)return ret;
    if(i==n-1)return 0;
    if(i>=n)return INF;
    if(i+1<n)ret=solve(i+1)+abs(arr[i+1]-arr[i]);
    for(int jump=2;jump<=k;jump++){
        if(i+jump<n)
            ret=min(ret,solve(i+jump)+abs(arr[i+jump]-arr[i]));
    }
    return ret;
}

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


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

string s;
int n;

long long dfs(int i, long long num, long long matu){
    if(i == n){
        if(num == 0){
            return num + matu;
        }else{
            return 0;
        }
    }

    num *= 10;
    num += s[i] - '0';

    return dfs(i+1, num, matu) + dfs(i+1, 0, matu + num);
}

int main(){
    cin >> s;
    n = s.size();

    cout << dfs(0, 0, 0) << endl;
    return 0;
}


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

int main() {
	long long A,B,K;
	cin>>A>>B>>K;
	if(A)
	  {
	      if(A-K<0)
	        {
	            K-=A;
	            A=0;
	            if(B-K<0)
	              B=0;
	            else
	             B-=K;
	        }
	        else
	         A-=K;
	  }
	  else if(B)
	  {
	      if(B-K<0)
	       B=0;
	      else
	       B-=K;
	  }
	 
	 cout<<A<<" "<<B;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <cstdlib>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include <iomanip>

// #pragma comment(linker, "/STACK:1024000000,1024000000")
// #define pi acos(-1)
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x7f7f7f7f //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.141592653589793//23846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// ios::sync_with_stdio(false);cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m,n) for (int i = m;  i < n; i++)

#define local
#ifdef local
#endif

#define MAX 10233
#define LCH(i) ((i) << 1)
#define RCH(i) ((i) << 1 | 1)
inline ll read(){
   ll s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
const int N = 2e5+5;
ll c[N];
struct mon
{
        ll x,h;
};
mon monster[N];
bool cmp(mon a, mon b)
{
    return a.x < b.x;
}
int main()
{
    //ios::sync_with_stdio(false);cin.tie(NULL);
   // cout << 50ll << endl;
    ll n, d, a;
// 这里是快读
    n = read();
    d = read();
    a = read();
    for (int i = 0; i < n; i++)
    {
        monster[i].x = read();
        monster[i].h= read();
    }
// 对怪事的位置进行排序
    sort(monster, monster + n,cmp);
    ll ans = 0;
    for (int i = 0,j = 0; i < n; i++)
    {
        while(j < n && monster[j].x <=monster[i].x + 2*d) // 找到这次炮击能打到的最远的怪兽
            ++j;
        ll need = max((monster[i].h - c[i]*a + a - 1)/a, 0ll); //这个怪兽需要炮击的次数就是怪兽的生命值h减去之前炮击的次数c[i]*a,0ll的意思是longlong 的0；
        ans += need;
        c[i] += need;
        c[j] -= need; //把炮击范围外的第一个怪兽先剪掉need
        c[i+1] += c[i];
    }
    cout << ans << endl;

}

Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<list>

using namespace std;


int main() {
	int N, M, Q;
	list<int> list;
	int Ans[200000];
	cin >> N >> M >> Q;
	for (int i = 0; i < N; i++) {
		list.push_back(i);
		Ans[i] = 1;
	}

	auto itr = list.begin();
	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;
		if (a % 2 == 0) {
			for (int j = 0; j < a; j++) {
				itr++;
				if (itr == list.end())
					itr = list.begin();
			}
		}
		else {	
			for (int j = 0; j < a; j++) {
				if (itr == list.begin())
					itr = list.end();

				itr--;
			}
		}
		Ans[*itr] = 0;
		itr = list.erase(itr);
		if (itr == list.end()) itr = list.begin();
	}

	for (int i = 0; i < Q; i++) {
		int q;
		cin >> q;
		cout << Ans[q] << endl;
	}

	return 0;
}



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

#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define pii pair<int, int>
#define mp make_pair
#define f first
#define ll long long
#define ld long double
#define s second
#define vec vector<int>

using namespace std;

const int N = (int) 1e3 + 10;
const int M = (int) 2e6 + 10;
const int K = (int) 20;
const int INF = (int) 1e9 + 7;
const int mod = (int) 998244353;
const ld EPS = (ld) 1e-9;
const ll LINF = (ll) 1e18;
int n;
vec all;
int h[N];

int mult(int x, int y) {
	return 1ll * x * y % INF;
}

void add(int &x, int y) {
	x += y;
	if (x >= INF)
		x -= INF;
	if (x < 0) 
		x += INF;
}

int sum(int x, int y) {
	add(x, y);
	return x;
}

int bp(int x, int y) {
	int ans = 1;
	while (y) {
		if (y % 2) 
			ans = mult(ans, x);
		x = mult(x, x);
		y /= 2;
	}
	return ans;
}

int f(int l, int r) {
	// 2^l + 2^(l+1) + ... + 2^r
	int pref = sum(bp(2, r + 1), -1);
	add(pref, -sum(bp(2, l), -1));
	return pref;
}

int dp[N][N];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifdef sony
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	srand(time(0));
	cin >> n;
	bool try_it = true;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
		if (try_it) {
			all.pb(h[i]);
			if (h[i] > 1)
				all.pb(h[i] - 1);
		}
	}
	all.pb(1);
	if (!try_it) {
		for (int i = 1; i <= 100; i++) {
			all.pb(i);
		}
	}
	sort(all.begin(), all.end());
	all.resize(unique(all.begin(), all.end()) - all.begin());
	for (int i = 0; i < sz(all); i++) {
		if (all[i] < h[1]) { 
			add(dp[1][i], f(h[1] - all[i + 1] + 1, h[1] - all[i]));

			/*
			for (int pos = all[i]; pos < all[i + 1]; pos++) {
				add(dp[1][i], bp(2, h[1] - pos)); 
			}
			*/
		}
	}
	dp[1][sz(all)] = 2; // no same
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j < sz(all); j++) {
			if (all[j] >= h[i]) { 
				// 010100
				// 10101
				add(dp[i][sz(all)], mult(2, dp[i - 1][j]));
			} else {
				// all[j] < h[i]

				// 011000
				// abcde 
				if (h[i] <= h[i - 1]) {
					add(dp[i][j], dp[i - 1][j]);
				}
				// 011000
				// 100111abc
				if (h[i] > h[i - 1]) {
					add(dp[i][j], mult(bp(2, h[i] - h[i - 1]), dp[i - 1][j]));
				}
			}
		}
		if (h[i] <= h[i - 1]) {
			// 01010101
			// abcde
			add(dp[i][sz(all)], mult(2, dp[i - 1][sz(all)]));
		}
		if (h[i] > h[i - 1]) {	
			// 01010101
			// abcdefghijk
			// no same 
			add(dp[i][sz(all)], mult(2, dp[i - 1][sz(all)]));

			// same but >= h[i - 1]
			// 010101
			// 1010100

			for (int j = 0; j < sz(all); j++) {
				if (all[j] < h[i] && all[j] >= h[i - 1]) {
					add(dp[i][j], mult(f(h[i] - all[j + 1] + 1, h[i] - all[j]), dp[i - 1][sz(all)]));
					/*
					for (int pos = all[j]; pos < all[j + 1]; pos++) {
						add(dp[i][j], mult(bp(2, h[i] - pos), dp[i - 1][sz(all)]));
					}
					*/
				}
			}
		}
	}
	int ans = 0;
	for (int j = 0; j <= sz(all); j++) {
		add(ans, dp[n][j]);
	}
	cout << ans;
	return 0;	
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int K; cin >> K;
    int X; cin >> X;

    int left;
    if (X - K < -1000000) {
        left = -1000000;
    } else {
        left = X - K + 1;
    }
    int right;
    if (1000000 < X + K) {
        right = 1000000;
    } else {
        right = X + K - 1;
    }
    for (int i = left; i <= right; i++) {
        cout << i << ' ';
    }
    cout << endl;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)

long long comb(long long m) {
	return (m * (m - 1)) / 2;
}


int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	rep(i, m)	cin >> a[i];

	int all = 0;
	rep(i, m)	all += a[i];
	if (n - all >= 0)
		cout << n - all << endl;
	else
		cout << -1 << endl;
	


}

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

using int64 = long long;

const int MAX_N = 200000;

int N;
int64 L;

int64 result = 0;

string s[MAX_N];
vector<int64> heights;

int64 calc_grundy(int64 x) {
    if (x == 0) return 0;

    int64 res = 1;
    while (x % 2 == 0) {
        x /= 2;
        res *= 2;
    }
    return res;
}

string prefix = "";

void dfs(int64 dep, int lb, int ub) {
    int num = ub - lb;
    if (num == 0) {
        result ^= calc_grundy(L + 1 - dep);
        // heights.push_back(L + 1 - dep);
        return;
    // } else if (num == 1 and prefix == s[lb]) return;
    } else if (num == 1) {
        int64 h = L - dep + 1;
        int64 sh = L - s[lb].size() + 1;

        // cerr << "h: " << h << " sh: " << sh << endl;

        for (int64 x = sh; x < h; x++) {
            result ^= calc_grundy(x);
            // heights.push_back(x);
        }
        return;
    }
    prefix.push_back('1');
    int b = lower_bound(s + lb, s + ub, prefix) - s;
    prefix.pop_back();

    prefix.push_back('0');
    dfs(dep + 1, lb, b);
    prefix.pop_back();

    prefix.push_back('1');
    dfs(dep + 1, b, ub);
    prefix.pop_back();
}

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

    for (int i = 0; i < N; i++) {
        cin >> s[i];
    }
    sort(s, s + N);

    dfs(0, 0, N);

    /*
    for (auto h : heights) {
        cerr << " == " << h << endl;
        result ^= calc_grundy(h);
    }
    */

    if (result) cout << "Alice" << endl;
    else cout << "Bob" << endl;

    return 0;
}

Measured memory_bytes: 6656
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int dp[][] = new int[N+1][W+1];
        for(int i = 0 ; i < W+1 ; i++)
            dp[0][i] = 0;
        Data data[] = new Data[N];
        for(int i = 0 ; i < N ; i++){
            int v = sc.nextInt();
            int w = sc.nextInt();
            data[i] = new Data(v,w);
        }
        for(int i = 0 ; i < N ; i++){
            for(int j = 0 ; j < W+1 ; j++){
                if(data[i].w <= j)
                    dp[i+1][j] = Math.max(dp[i][j-data[i].w] + data[i].v , dp[i][j]);
                else
                    dp[i+1][j] = dp[i][j];
            }
        }
        System.out.println(dp[N][W]);
    }
}
class Data{
    int v;
    int w;
    Data(int v, int w){
        this.v = v;
        this.w = w;
    }
}


Measured memory_bytes: 31052
k, s = [int(i) for i in input().split()]

count = 0
for x in range(k,-1,-1):
    a = s - x
    if a > 2*k:
        break
    elif a == 0:
        count += 1
        continue

    if a >= k:
        tmp = k
    else:
        tmp = a

    for y in range(tmp, -1, -1):
        z = a - y
        if z > k :
            break
        else:
            count += 1

print(count)

Measured memory_bytes: 3188
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let S: String = read();
    let mut vec: Vec<_> = S.chars().collect();
    let mut now_string = "".to_string();
    while !vec.is_empty() {
        let c = vec.pop().unwrap();
        now_string = now_string + &c.to_string();
        match now_string.as_str() {
            "maerd" | "remaerd" | "esare" | "resare" => {
                now_string = "".to_string();
            }
            _ => {
                if now_string.len() >= 7 {
                    println!("NO");
                    return;
                }
            }
        }
    }
    println!("YES");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    int a[3];
    rep(i, 3) scanf("%d", &a[i]);
    sort(a, a + 3);
    printf("%d\n", a[1] - a[0] + a[2] - a[1]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
char table[8][8];
string s = "ox";
bool range_check(int y, int x)
{
    if(y < 0 || x < 0 || y >= 8 || x >= 8) return false;
    else return true;
}
void Put(int y, int x, int flag)
{
    table[y][x] = s[flag];
    for(int k = 0; k < 8; k++)
    {
        int ny = y;
        int nx = x;
        bool ok = false;
        while(1)
        {
            ny += dy[k];
            nx += dx[k];
            if(!range_check(ny, nx)) break;
            if(table[ny][nx] == '.') break;
            if(table[ny][nx] == s[flag])
            {
                ok = true;
                break;
            }
        }
        if(ok)
        {
            ny = y;
            nx = x;
            while(1)
            {
                ny += dy[k];
                nx += dx[k];
                if(table[ny][nx] == s[flag]) break;
                table[ny][nx] = s[flag];
            }
        }
    }
}
int Search(int y, int x, int flag)
{
    int ret = 0;
    for(int k = 0; k < 8; k++)
    {
        int ny = y;
        int nx = x;
        int cnt = 0;
        while(1)
        {
            ny += dy[k];
            nx += dx[k];
            if(!range_check(ny, nx)) break;
            if(table[ny][nx] == '.') break;
            if(table[ny][nx] == s[flag])
            {
                ret += cnt;
                break;
            }
            if(table[ny][nx] == s[!flag]) cnt++;
        }
    }
    return ret;
}
void Solve()
{
    bool ok = false;
    priority_queue<PP> que;
    for(int i = 0; i < 8; i++)
    {
        for(int j = 0; j < 8; j++)
        {
            if(table[i][j] != '.') continue;
            int cnt = Search(i, j, 0);
            if(cnt >= 1) que.push(PP(cnt, P(-i, -j)));
        }
    }
    if(!que.empty())
    {
        PP p = que.top();
        Put(-p.second.first, -p.second.second, 0);
        ok = true;
    }
    //clear()がない( 一一)
    que = decltype(que)();
    for(int i = 0; i < 8; i++)
    {
        for(int j = 0; j < 8; j++)
        {
            if(table[i][j] != '.') continue;
            int cnt = Search(i, j, 1);
            if(cnt >= 1) que.push(PP(cnt, P(i, j)));
        }
    }
    if(!que.empty())
    {
        PP p = que.top();
        Put(p.second.first, p.second.second, 1);
        ok = true;
    }
    if(ok) Solve();
    else return;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    for(int i = 0; i < 8; i++)
    {
        for(int j = 0; j < 8; j++) cin >> table[i][j];
    }
    Solve();
    for(int i = 0; i < 8; i++)
    {
        for(int j = 0; j < 8; j++) cout << table[i][j];
        cout << endl;
    }
    return 0;
}




Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
 
//krishrawat
 
 
//----------------------------MACROS-------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 1e6 + 1;//                                                             |
//----------------------------------------------------------------------------------


void solve()
{
    
    ll n,k;cin>>n>>k;
    vl v(n);
    
    for(auto &i:v) cin>>i;
    vl dp(n);
    dp[0]=0;
    
    for(ll i=1;i<n;i++){
        ll tmp=1e18;
        
        for(ll j=i-1;j>=max(0ll,i-k);j--) tmp=min(tmp,abs(v[i]-v[j])+dp[j]);
        
        dp[i]=tmp;
    }
    cout<<dp[n-1]<<"\n";
}
 
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    
	return 0;
}

Measured memory_bytes: 4748
#include<bits/stdc++.h>
using namespace std;
int a[26],sum;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++)
    a[s[i]-'a']++;
  for(int i=0;i<26;i++)
    sum+=a[i]%2;
  cout<<sum/2<<endl;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
unsigned int randxor()
{
    static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
    unsigned int t;
    t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}
int d=365;
vector<int> ans(d);
vector<int> ans1(d);
vector<int> c(26);
vector<vector<int> > s(d);
int score=-1000000000;
int keisan(){
  int cost=0,i,j;
  vector<int> x(26,-1);
  for(i=0;i<d;i++){
    cost+=s[i][ans1[i]];
    x[ans1[i]]=i;
    for(j=0;j<26;j++){
      cost=cost-c[j]*(i-x[j]);
    }
  }
  return cost;
}
void solve(){
  int i;
  if(score<=keisan()){
    for(i=0;i<d;i++){
      ans[i]=ans1[i];
    }
    score=keisan();
    int v=randxor()%d;
    int w=randxor()%d;
    swap(ans1[v],ans1[w]);
  }
  else{
    for(i=0;i<d;i++){
      ans1[i]=ans[i];
    }
  }
}
void solve1(){
  int i;
  if(score<=keisan()){
    for(i=0;i<d;i++){
      ans[i]=ans1[i];
    }
    score=keisan();
    ans1[randxor()%d]=randxor()%26;
  }
  else{
    for(i=0;i<d;i++){
      ans1[i]=ans[i];
    }
  }
}
int main(){
  int i,j;
  int ti=clock();
  cin >> d;
  vector<P> e(26);
  for(i=0;i<26;i++){
    scanf("%d",&c[i]);
    e.push_back(P(c[i],i));
  }
  std::sort(e.begin(), e.end(), std::greater<P>() );
  for(i=0;i<d;i++){
    for(j=0;j<26;j++){
      int a;
      scanf("%d",&a);
      s[i].push_back(a);
    }
  }
  for(i=0;i<d;i++){
    ans1[i]=e[i%26].second;
    ans[i]=ans1[i];
  }
  while(clock()-ti<198.5*CLOCKS_PER_SEC/100){
    solve();
    solve1();
    solve();
  }
  for(i=0;i<d;i++){
    printf("%d\n",ans[i]+1);
  }
  return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,k;
    cin >> n >> k;
    cout << min((n%k), abs((n%k)-k)) << "\n"; 
    return 0;
}



Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

pub trait LexicalPermutation {
    fn next_permutation(&mut self) -> bool;
    fn prev_permutation(&mut self) -> bool;
}

impl<T> LexicalPermutation for [T]
where
    T: Ord,
{
    fn next_permutation(&mut self) -> bool {
        if self.len() < 2 {
            return false;
        }
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] >= self[i] {
            i -= 1;
        }
        if i == 0 {
            return false;
        }
        let mut j = self.len() - 1;
        while j >= i && self[j] <= self[i - 1] {
            j -= 1;
        }
        self.swap(j, i - 1);
        self[i..].reverse();
        true
    }

    fn prev_permutation(&mut self) -> bool {
        if self.len() < 2 {
            return false;
        }
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] <= self[i] {
            i -= 1;
        }
        if i == 0 {
            return false;
        }
        self[i..].reverse();
        let mut j = self.len() - 1;
        while j >= i && self[j - 1] < self[i - 1] {
            j -= 1;
        }
        self.swap(i - 1, j);
        true
    }
}

fn main() {
    input! {
        n: usize,
        k: usize,
    }
    let mut result = k;
    for _ in 1..n {
        result *= k - 1;
    }
    println!("{}", result);
}


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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

int tj[4005][3];
int seq[4005];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int N; cin >> N;
	rep1(i, N) {
		char c; cin >> c;
		if(c == 'R') seq[i] = 1;
		else if(c == 'G') seq[i] = 2;
		else seq[i] = 3;
		tj[i][0] = tj[i-1][0] + (c == 'R');
		tj[i][1] = tj[i-1][1] + (c == 'G');
		tj[i][2] = tj[i-1][2] + (c == 'B');
	}
	ll ans = 0;
	rep1(i, N) {
		iter(j, i+1, N+1) {
			if(seq[i] == seq[j]) continue;
			int v = 5 - seq[i] - seq[j];
			ans += tj[N][v] - tj[j][v];
			if(2*j-i <= N && seq[2*j-i] == v+1) ans--;
		}
	}
	print(ans);
}


Measured memory_bytes: 3680