akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
//#include<cstring>
//#include<cmath>
//#include<cstdio>
//#include<algorithm>
using namespace std;

int n;
long long y;

int main(){  
    cin>>n>>y;
    if(n*10000<y){
    	cout<<"-1 -1 -1"<<endl;
    	return 0;
	}
	if(n*1000>y){
    	cout<<"-1 -1 -1"<<endl;
    	return 0;
	}
	for(int a=0; a<=n; a++){
		for(int b=0; b<=n; b++){
			for(int c=0; c<=n&&a+b+c<=n; c++){
				if(a+b+c==n&&a*10000+b*5000+c*1000==y){
					cout<<a<<" "<<b<<" "<<c<<" "<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
	return 0;
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char ch1[3005],ch2[3002];
int dp[3005][3005],n,m,ara[3005][3005][2];

int op(int i,int j)
{
    if(i>=n||j>=m)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(ch1[i]==ch2[j]){
        ara[i][j][0]=1;
        ara[i][j][1]=1;
        return dp[i][j]=op(i+1,j+1)+1;


    }
    else{
        int a=op(i+1,j);
        int b=op(i,j+1);

        if(a<b){
            ara[i][j][0]=0;
            ara[i][j][1]=1;
            return dp[i][j]=b;
        }
        else{
            ara[i][j][0]=1;
            ara[i][j][1]=0;
            return dp[i][j]=a;
        }
    }
}

int main()
{
    int i,j,k,a,b,c,x,y,z;
    scanf(" %s %s",ch1,ch2);
    n=strlen(ch1);
    m=strlen(ch2);
    for(i=0;i<=n;i++){
        for(j=0;j<=m;j++){
            dp[i][j]=-1;
        }
    }
    a=op(0,0);
    for(i=0,j=0;i<n&&j<m;)
    {
        if(ch1[i]==ch2[j]){
            printf("%c",ch1[i]);
        }
        //cout<<i<< "  " <<j<<endl;
        a=i+ara[i][j][0];
        b=j+ara[i][j][1];
        i=a;
        j=b;
       // cout<<i<< "   " <<j<<endl;
    }

    printf("\n");
    //cout<<a<<endl;

}


Measured memory_bytes: 106368
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
	    Scanner sc = new Scanner(System.in);
	    //
	    String a = sc.next();
	    int count = 0;
	    // スペース区切りの整数の入力
	    char c = '1';
	   for(char b : a.toCharArray()){
          if(b==c){
        	  count++;
          }
	   }
	    // 文字列の入力

	    // 出力
	    System.out.println(count);
	  }
	}



Measured memory_bytes: 20820
// Problem : B - Resale
// Contest : AtCoder - AtCoder Beginner Contest 125
// URL : https://atcoder.jp/contests/abc125/tasks/abc125_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define XOX
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define int long long
#define re return
#define beg() begin()
#define cont continue
#define ldb long double
#define db double

#define br break
#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mkp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>

#define si set<int>
#define sdb set<db>
#define sldb set<ldb>

#define test int t; cin>>t; while(t--)
#define scan() int n; cin>>n; int a[n]; for(int i=0;i<n;i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k; int a[n]; for(int i=0;i<n;i++) cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define srt(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define cn(x) cout<<x<<"\n"
#define cs(x) cout<<x<<" "
#define c(x) cout<<x
#define all(v) v.begin(),v.end()

#define forr(i,a,b) for (int i = (a); i < (b); ++i)
#define rrof(i,a,b) for (int i = (b)-1; i >= (a); --i)


const int MOD = 1e9+7;
const ldb PI = 4*atan((ldb)1);
const int INF = 1e18;
const int NINF = -1e18;

int get_hash(string s){
	int N=1000001;
	int base[N],A=11,MD=1110111110111;
	base[0]=1;

	forr(i,1,N)
	base[i]=(base[i-1]*A)%MD;

	int hs=0;
	forr(i,0,s.size()){
		hs+=(s[i]*base[i]);
		hs%=MD;
	}

	re hs;
}

int power(int a,int n){
	int res=1;

	while(n){
		if(n%2)
		res*=a;
		a*=a;
		n/=2;
	}

	return res;
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
	vector<string> __attribute__ ((unused)) args,
	__attribute__ ((unused)) int idx,
	__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
	template <typename Head, typename... Tail>
	void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif


int32_t main(){
	fast;
	
	int n;
	cin>>n;
	
	vi v;
	int a[n],b[n];
	forr(i,0,n)
	cin>>a[i];
	
	forr(i,0,n){
		cin>>b[i];
		
		int x=a[i]-b[i];
		v.pb(x);
	}
	
	srt(v);
	int sum=0;
	rrof(i,0,n){
		if(v[i]>=0)
		sum+=v[i];
	}
	
	cout<<sum;
	re 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;


int main()
{
    long long n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    long long ans=n;
    if (b-1<ans) ans=b-1;
    if (n-a<ans) ans=n-a;
    if ( (b-a)%2==0 )
    if ( (b-a)/2<ans ) ans= (b-a)/2;

    if ( (b-a)%2 ){
         long long tmp=(b-a+1)/2 + (n-b);
         if (tmp<ans) ans=tmp;
         tmp = (b-a+1)/2 + (a-1);
         if (tmp<ans) ans=tmp;

    }
    printf("%lld\n",ans);



}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head
 
void solve(){
    int d;
    cin >> d;
    string ans = "Christmas ";
    for (int i = 25; i > d; i--){
        ans += "Eve ";
    }

    cout << ans.substr(0, ans.size()-1) << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3640
import sys
import math
from collections import defaultdict
input = sys.stdin.readline
N, H = [int(x) for x in input().strip().split()]
A = [0] * N
B = [0] * N
a_max = 0

for n in range(N):
    a, b = [int(x) for x in input().strip().split()]
    a_max = max(a_max, a)
    A[n] = a
    B[n] = b

B = sorted([b for b in B if b >= a_max], reverse=True)
ans = 0
damage = 0
if sum(B) >= H:
    while damage < H:
        ans += 1
        damage += B[ans-1]
    print(ans)
else:
    ans = len(B)
    damage = sum(B)
    ans += math.ceil((H - damage) / a_max)
    print(ans)


Measured memory_bytes: 13248
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <cmath>
#include <iomanip>
#include <queue>
#include <deque>
#include <fstream>
#include <bitset>
using namespace std;

#define int long long
#define double long double
#define mp make_pair
#define all(a) a.begin(), a.end()
#define pb push_back
#define debug(x) cout << #x << ": " << x << '\n';
#define fi first
#define se second
#define FOR(i, n) for (int i = 0; i < n; ++i)
//typedef long long ll;
typedef pair<int, int> pii;

template<typename T1, typename T2> inline bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; };
template<typename T1, typename T2> inline bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; };

void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
}

const int N = 60;
int a[N];

signed main() {
	fast();
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	int res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			res += a[i] * a[j];
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  cout << vec.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define       FOR(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
ll ans[200000];
ll m=1e9+7;
int main()
{
   ll n,i,j;
   cin>>n;
    ans[0]=1;
    for(i=3;i<=n;i++)
    {
      for(j=3;j<=i;j++)
      {
        ans[i]+=ans[i-j];
        ans[i]=ans[i]%m;
      }
    }
    cout<<ans[n]<<endl;

}

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


def solve(x: "List[int]"):
    for i in range(len(x)):
        if x[i] == 0:
            print(i+1)
            return
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = [int(next(tokens)) for _ in range(5)]  # type: "List[int]"
    solve(x)

if __name__ == '__main__':
    main()


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

#define MAXN 1000
#define MAXM 2000

int N, M;
long long a[MAXM];
long long b[MAXM];
long long c[MAXM];

int main()
{
	cin >> N >> M;
	for( int i = 0; i < M; i++ ) {
		int aa, bb;
		cin >> aa >> bb >> c[i];
		aa--;
		bb--;
		a[i] = aa;
		b[i] = bb;
		c[i] = -c[i];
	}

	vector<long long> dist( N, INT64_MAX );
	dist[0] = 0;
	for( int j = 0; j < N - 1; j++ ) {
		for( int i = 0; i < M; i++ ) {
			if( dist[ a[i] ] == INT64_MAX ) {
				continue;
			}
			if( dist[ b[i] ] > dist[ a[i] ] + c[i] ) {
				dist[ b[i] ] = dist[ a[i] ] + c[i];
			}
		}
	}
	long long ans = dist[N - 1];
	vector<bool> nega( N, false );
	for( int j = 0; j < N; j++ ) {
		for( int i = 0; i < M; i++ ) {
			if( dist[ a[i] ] == INT64_MAX ) {
				continue;
			}
			if( dist[ b[i] ] > dist[ a[i] ] + c[i] ) {
				dist[ b[i] ] = dist[ a[i] ] + c[i];
				nega[ b[i] ] = true;
			}
			if( nega[ a[i] ] == true ) {
				nega[ b[i] ] = true;
			}
		}
	}
	bool negative = nega[N - 1];

	if( negative ) {
		cout << "inf" << endl;
	}
	else {
		cout << -ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	long a, i, x;
	long sum = 0;
	long sumn = 0;
	long min = 2000000001;
	long c[200000];
	scanf("%ld",&a);
	for (i = 0; i < a; i++) {
		scanf("%ld",&c[i]);
		sum += c[i];
	}
	for (i = 0; i < a-1; i++) {
			sumn += c[i];
		if (sum - sumn*2 > 0) {
			x = sum - sumn*2;
		}
		else {
			x = sumn*2 - sum;
		}
		if (x < min) {
			min = x;
		}
	}
    printf("%ld", min);
	return 0;
}

Measured memory_bytes: 1664
N=int(input())
if 1<=N<=999:
    if (N%10==2)or(N%10==4)or(N%10==5)or(N%10==7)or(N%10==9):
        print("hon")
    if (N%10==0)or(N%10==1)or(N%10==6)or(N%10==8):
        print("pon")
    if N%10==3:
        print("bon")

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

ll go(vector<ll> arr, int k=2) {
    int n = arr.size();
    vector<ll> dp(n, LLONG_MAX);
    dp[n-1] = 0;

    for (int i = n-2; i >= 0; i--)
        for (int j = i+1; j <= min(n-1, i+k); j++)
            dp[i] = min(dp[i], abs(arr[i] - arr[j]) + dp[j]);

    ll ans = dp[0];
    return ans;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];
    cout << go(arr, k) << endl;
    return 0;
}


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

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> l(N);
	for (int i = 0; i < N; i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	int res = 0;
	for (int i = 0; i < K; i++) {
		res += l[N - 1 - i];
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;



vector<ll> getdiv(int k) {
	vector<ll> res;
	for (int i = 1; i * i <= k; i++) {
		if (k % i == 0) {
			res.push_back(i);
			res.push_back(k / i);
			if (i == k / i)res.pop_back();
		}
	}
	sort(res.begin(), res.end());
	return res;
}


int main()
{
	//int n; cin >> n;
	//string s;
	//cin >> s;
	//int left = 0, right = 0;
	//bool previsright = false;
	//stack<char> st; // 8 (()))(() 6 (())() ))(()()()()( 8
	////))((())(

	//ll ans = 0;
	//ll start = -1;
	//for (int i = 0; i < n; i++) {
	//	if (s[i] == '(') {
	//		st.push('(');
	//		left++;
	//		if (right == left) {
	//			ans += i - start + 1;
	//			for (int j = 0; j < left; j++) st.pop();
	//			left = 0;
	//			right = 0;
	//			start = -1;
	//			
	//		}
	//		
	//	}
	//	else {
	//		if (!st.empty() && st.top() == '(') {
	//			left--;
	//			st.pop();
	//		}
	//		else {
	//			if (start == -1) {
	//				start = i;
	//				right++;
	//			}
	//			else {
	//				right++;
	//			}
	//		}
	//		

	//	}
	//}

	//if (left == 0 && right == 0)
	//	cout << ans;
	//else cout << -1;

	ll n, a, b;

	cin >> n >> b >> a;
	if (b == 0) cout << 0;
	else if (n <= a + b) cout << min(b,n);
	else cout << min(b,n % (a + b)) + b * (n / (a + b));





}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

module Main where

import Control.Applicative
import Control.Monad
import Data.List

solve :: Int -> String -> Int
solve n xs = iter maxBound (0, 0) xs
  where
    en = length $ filter (== 'E') xs
    wn = n - en
    iter :: Int -> (Int, Int) -> String -> Int
    iter !c _        [] = c
    iter !c (!e, !w) ('E':xs) =
       iter (min c (w + (en - e - 1))) (e + 1, w) xs
    iter !c (!e, !w) ('W':xs) =
       iter (min c (w + (en - e)))     (e, w + 1) xs

main :: IO ()
main = do
    n <- readLn :: IO Int
    ss <- getLine
    print $ solve n ss

Measured memory_bytes: 22268
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> Type igcd(Type x,Type y){if(x==0||y==0)return (x>y)?x:y;return (y%x)?igcd(y%x,x):x;}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	scanf("%d",&n);
	
	vvi d(n,vi(n));
	REP(i,n)REP(j,n) scanf("%d",&d[i][j]);
	
	llong sum=0;
	REP(i,n)REP(j,i+1) sum+=d[i][j];
	
	bool jud[n][n]={};
	REP(k,n)REP(i,n)REP(j,i+1){
		if(k==i or k==j) continue;
		if(d[i][j]>d[i][k]+d[k][j]){
			cout<<-1<<endl;
			return 0;
		}else if(d[i][j]==d[i][k]+d[k][j]){
			if(!jud[i][j]){
				sum-=d[i][j];
				jud[i][j]=true;
			}
		}
	}
	
	cout<<sum<<endl;
}

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

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int n;

bool in_bounds(int x,int y){
	return (x > -1 && x < n && y > -1 && y < n);
}

int main (void)
{
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  int mi[n][n];
  bool alive[n][n];
  int a[n*n];
  for(int i = 0;i < n*n;i++) cin >> a[i];
  for(int i = 0;i < n;i++)
	for(int j = 0;j < n;j++){
		mi[i][j] = i;
		mi[i][j] = min(mi[i][j],n - 1 - i);
		mi[i][j] = min(mi[i][j],j);
		mi[i][j] = min(mi[i][j],n - 1 - j);
		alive[i][j] = 1;
	}
  int dx[4] = {0,0,1,-1};
  int dy[4] = {1,-1,0,0};
  ll ans = 0;
  for(int i = 0;i < n*n;i++){
	  int k = a[i];
	  int x = k/n;
	  int y = k%n;
	  if(!y) x--,y = n - 1;
	  else y--;
	  ans += mi[x][y];
	  queue<pair<int,int>> bfs;
	  bfs.push({x,y});
	  alive[x][y] = 0;
	  while(!bfs.empty()){
		int x = bfs.front().first,y = bfs.front().second;
		bfs.pop();
		for(int i = 0;i < 4;i++)
			if(in_bounds(x + dx[i],y + dy[i]) && mi[x + dx[i]][y + dy[i]] > mi[x][y] + alive[x][y])
				mi[x + dx[i]][y + dy[i]] = mi[x][y] + alive[x][y],bfs.push({x + dx[i],y + dy[i]});
	  }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 5820
import java.util.NoSuchElementException

fun main(args: Array<String>) = FastScanner().run {
    val n = nextInt()
    val a = LongArray(n){nextLong()}
    var trend: Trend = Trend.Undefined
    var cnt = 1
    for (i in 0 until n-1) {
        if (a[i] < a[i+1]) {
            if (trend == Trend.Decrease) {
                trend = Trend.Undefined
                cnt++
            } else {
                trend = Trend.Increase
            }
        }
        if (a[i] > a[i+1]) {
            if (trend == Trend.Increase) {
                trend = Trend.Undefined
                cnt++
            } else {
                trend = Trend.Decrease
            }
        }
    }
    println(cnt)
}

sealed class Trend {
    object Increase : Trend()
    object Decrease: Trend()
    object Undefined : Trend()
}

class FastScanner {
    private val printable = 33..126
    val `in` = System.`in`
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = `in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun nextInt(): Int {
        val nl = nextLong()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun nextDouble(): Double {
        return next().toDouble()
    }
}

Measured memory_bytes: 33044
#include<bits/stdc++.h>
#define MAX 51
#define inf 1<<29
#define inf2 1<<15
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-15)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

int h,w;
string grid[MAX];
int mem[MAX][MAX][MAX][MAX];
vector<pii> alph;

bool in(int y,int x){
  if(x<0 || y<0 || w<=x|| h<=y)return false;
  return true;
}

int rec(int a,int b,int c,int d){
  if(!in(a,b))return -inf2;
  if(!in(c,d))return -inf2;
  if(c<a || d<b)return -inf2;
  if(mem[a][b][c][d]!=-inf)return mem[a][b][c][d];
  if(grid[a][b]=='#')return mem[a][b][c][d]=-inf2;
  if(grid[c][d]=='#')return mem[a][b][c][d]=-inf2;
  if(a==c && b==d && grid[a][b]!='#')return mem[a][b][c][d]=0;
  int res=-inf2;
  
  if(grid[a][b]==grid[c][d]+32 && grid[a][b]!='.' && grid[c][d]!='.'){
    if((a==c && b==d-1) || (a==c-1 && b==d))res = 1;
    else {
      res = max(res,rec(a+1,b,c-1,d)+1);
      res = max(res,rec(a,b+1,c,d-1)+1);
      res = max(res,rec(a+1,b,c,d-1)+1);
      res = max(res,rec(a,b+1,c-1,d)+1);
    }
  }
  res = max(res,rec(a+1,b,c,d));
  res = max(res,rec(a,b+1,c,d));
  res = max(res,rec(a,b,c-1,d));
  res = max(res,rec(a,b,c,d-1));

  FOR(i,0,alph.size()){
    int my = alph[i].f,mx = alph[i].s; 
    if(my==a && mx==b)continue; 
    if(my==c && mx==d)continue;
    if(my<a || c<my || mx<b || d<mx)continue;
    res = max(res,rec(a,b,my,mx)+rec(my,mx,c,d));
  }
  mem[a][b][c][d] = res;
  return res;
}

int solve(){
  FOR(a,0,h)FOR(b,0,w)FOR(c,0,h)FOR(d,0,w)mem[a][b][c][d]=-inf;
  alph.clear();
  FOR(i,0,h)
    FOR(j,0,w)
      if(grid[i][j]!='.' && grid[i][j]!='#')alph.pb(mp(i,j));
  int res = rec(0,0,h-1,w-1);
  if(res<0)return -1;
  return res;
}

int main()
{
  while(cin>>h>>w && h){
    FOR(i,0,h)cin>>grid[i];
    cout<<solve()<<endl;
  }
  return 0;
}



Measured memory_bytes: 28788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    string s;
    cin >> s;
    char prev = 'D';
    for (auto c : s) {
        if (c == 'P' || c == 'D') {
            prev = c;
            cout << c;
        } else {
            if (prev == 'P') {
                cout << 'D';
                prev = 'D';
            } else {
                cout << 'D';
                prev = 'D';
            }
        }
    }
    cout << endl;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    string S;
    cin>>N>>K>>S;
    S[K-1]+='a'-'A';
    cout<<S<<endl;
}

Measured memory_bytes: 256
using System;

public class Test
{
	static public void Main( )
	{
		const int S = 0;
		const int H = 1;
		const int C = 2;
		const int D = 3;		
		int n = int.Parse( Console.ReadLine() );
		bool[,] shcd = new bool[4, 13];
		for( int i=0; i<n; i++ ) {
			string[] strs = Console.ReadLine().Split( ' ' );
			int val = 0;
			switch( strs[0] ) {
				case "S":val = S;
					break;
				case "H":val = H;
					break;
				case "C":val = C;
					break;
				case "D":val = D;
					break;
			}
			shcd[ val, int.Parse( strs[1] )-1 ] = true;
		}
		for( int i=0; i<4; i++ ) {
			for( int j=0; j<13; j++ ) {
				if( S == i && false == shcd[S,j] ) {
					Console.WriteLine( "S "+(j+1) );
				} else if( H == i && false == shcd[H,j] ) {
					Console.WriteLine( "H "+(j+1) );
				} else if( C == i && false == shcd[C,j] ) {
					Console.WriteLine( "C "+(j+1) );
				} else if( D == i && false == shcd[D,j] ) {
					Console.WriteLine( "D "+(j+1) );
				}
			}
		}
	}
}

Measured memory_bytes: 5708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int m, d;
  cin >> m >> d;

  int ans = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= d; j++) {
      if (j < 10) continue;

      int d1 = j % 10;
      int d2 = j / 10;

      if(d1 < 2 || d2 < 2) continue;

      if (i == d1 * d2) {
        ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
A = 0
W = 0
T = 0
R = 0
for i in range(n):
    a = input()
    if a == "AC":
        A += 1
    if a =="WA":
        W += 1
    if a == "TLE":
        T += 1
    if a == "RE":
        R += 1

print("AC x " + str(A))
print("WA x " + str(W))
print("TLE x " + str(T))
print("RE x " + str(R))


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    int na=0,nb=0,nc=0;
    REP(i,s.size()) {
        if(s[i]=='a') na++;
        else if(s[i]=='b') nb++;
        else if(s[i]=='c') nc++;
    }

    int mi = min({na,nb,nc});
    YES(na-mi<=1 && nb-mi<=1 && nc-mi<=1)

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <sstream>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int n,k;
    cin>>n>>k;
    int d[k];
    vector<bool> treat(n,true);
    for(int i=0;i<k;i++){
        cin>>d[i];
        for(int j=0;j<d[i];j++){
            int a;
            cin>>a;
            treat[a-1] = false;
        }
    }

    int ans = 0;
    for(int i=0;i<n;i++){
        if(treat[i]) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3588
N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
for k in range(K):
    B = [0] * (N+1)
    for i, a in enumerate(A):
        l = max(0, i-a)
        r = min(i+a+1, N)
        B[l] += 1
        B[r] -= 1
    for i in range(1, N+1):
        B[i] += B[i-1]
    B.pop()
    if (A==B): break
    A = B
for a in A:
    print(a, end=' ')
print()


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

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

int main(void) {
    string n;
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n.length()) {
        if (n[i] == '1') {
            n[i] = '9';
        } else if (n[i] == '9') {
            n[i] = '1';
        }
    }
    
    cout << n << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

double floor_velo(int floor);

int main(void)
{
    double velo;
    while (scanf("%lf", &velo) != EOF) {
        int floor = 1;
        while (velo >= floor_velo(floor)) {
            floor++;
        }

        printf("%d\n", floor);
    }

    return 0;
}

double floor_velo(int floor)
{
    int height = 5 * (floor - 1);
    return (9.8 / sqrt(4.9)) * sqrt(height);
}

Measured memory_bytes: 628
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)

//your code here!

int main(void){
    ll A, B;
    scanf("%lld %lld", &A, &B);
    printf("%lld\n",(A-2*B>0) ? A-2*B: 0);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  double t, x;
  cin >> t >> x;
  cout << t/x << endl;
  return 0;
}

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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int dp[101][2][5];

int main() {
    string n;
    int k, l;
    cin >> n >> k;
    l = n.size();
    dp[0][0][0] = 1;
    for (int i = 0; i < l; ++i) {
        for (int smaller = 0; smaller < 2; ++smaller) {
            for (int cnt = 0; cnt <= k; ++cnt) {
                for (int x = 0; x <= (smaller ? 9 : n[i] - '0'); ++x) {
                    dp[i + 1][smaller || x < (n[i] - '0')][cnt + (x > 0 ? 1 : 0)] += dp[i][smaller][cnt];
                }
            }
        }
    }
    cout << dp[l][0][k] + dp[l][1][k] << endl;

    return 0;
}

Measured memory_bytes: 256
#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 n, m, q;
vector<int> a, b, c, d;
int ans;
vector<vector<int>> V;

void dfs(vector<int> A) {
  if (A.size() == n) {
    V.push_back(A);
    return;
  }
  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i,q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;b[i]--;
  }
  dfs(vector<int>(1,1));
  for(auto v:V){
    int now = 0;
    rep(i,q) {
      if (v[b[i]] - v[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6772
import java.util.*;
import javax.lang.model.util.ElementScanner6;
//import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 入力
        int k = sc.nextInt();
        int n = sc.nextInt();

        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }

        // 処理
        int out = k;

        //時計回り
        for(int i = 0; i < n; i++){
            int dist = a[(i - 1 + n) % n] - a[i];
            if (dist < 0) {
                dist += k;
            }
            out = dist < out ? dist : out;
        }

        //反時計回り
        for(int i = 0; i < n; i++){
            int dist = k - a[(i + 1 + n) % n] + a[i];
            if (dist < 0) {
                dist += k;
            }
            out = dist < out ? dist : out;
        }
        
        // 出力
        System.out.println(out);
    }
}

Measured memory_bytes: 87592
#include<bits/stdc++.h>
#define ll long long
#define fs first
#define sec second
#define md 1000000007
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
using namespace std;
ll power(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p  
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  

ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll T=1;
    // cin>>T;
    while(T--){
    	ll n;
        cin>>n;
        vector<ll> v(n);
        ll x=v[0];
        for(ll i=0;i<n;i++){
            cin>>v[i];
            x=__gcd(x,v[i]);
        }
        sort(v.begin(),v.end());
        vector<ll> c(v[n-1]+1,0);
        ll f=0;
        for(ll i=0;i<n;i++){
            for(ll j=2;j*j<=v[i];j++){
                if(v[i]%j==0){
                    ll t=v[i]/j;
                    c[j]++;
                    if(t!=j) c[t]++;
                    if(c[j]==2 || c[t]==2){
                        f=1;
                        // cout<<10<<endl;
                        break;
                    }
                }
            }
            c[v[i]]++;
            if(v[i]==1) continue;
            if(c[v[i]]>=2) {
                // cout<<11<<endl;
                f=1;
                break;
            }
            if(f) break;
        }
        if(!f){
            cout<<"pairwise coprime\n";
        }
        else if(x==1){
            cout<<"setwise coprime\n";
        }
        else cout<<"not coprime\n";
    }
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  int elem[n];
  int cnt=0;
  for(int i=0;i<n;i++){
    cin>>elem[i];
  }
  for(int i=0;i<n-1;++i){
    for(int j=0;j<n-1-i;++j){
      if(elem[j]>elem[j+1]){
	++cnt;
	elem[j]^=elem[j+1];
	elem[j+1]^=elem[j];
	elem[j]^=elem[j+1];
      }
    }
  }
  for(int i=0;i<n;++i){
    cout<<elem[i];
    if(i!=n-1)cout<<" ";
    else cout<<endl;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<functional>
#include<queue>
#include<string>
using namespace std;

#if 0

#endif

int main(){
  string cmd;
  priority_queue<int> S;
  int k;

  while(cin >> cmd && cmd != "end"){
    if(cmd == "insert"){
      cin >> k;
      S.push(k);
    } else if (cmd == "extract"){
      int num = S.top();
      S.pop();
      cout << num << endl;
    }
  }
}



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

int N;
int A[22][22];
int MOD = 1000000007;
vector<int> dp;

int rec(int b) {
  if (dp[b] >= 0) return dp[b];
  int i = __builtin_popcount(b) - 1;
  int ret = 0;
  for(int j=0; j<N; j++) {
    if ((b&(1<<j)) == 0) continue;
    if (A[i][j] == 0) continue;
    ret += rec(b^(1<<j));
    ret %= MOD;
  }
  return dp[b] = ret;
}

int main() {
  cin >> N;
  for (int i=0; i<N; i++)
    for (int j=0; j<N; j++)
      cin >> A[i][j];
  dp = vector<int>(1<<N, -1);
  dp[0] = 1;
  cout << rec((1<<N) - 1) << endl;
}

Measured memory_bytes: 8576
using System;
class Program
{
  static void Main(string[] args)
  {
    int h,t=0,i=0,p,l;
    string s = Console.ReadLine();
    l = s.Length;
    h = s.IndexOf("A");
    p=h;
    while(p!=-1){
      p++;
        t=p;
        p=s.IndexOf("Z", p, l-p);
    }
    Console.WriteLine("{0}", (t-h));
  }
}

Measured memory_bytes: 14176
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int main(){
    
   
    ll n;
     cin >> n;
 
    int a[n] = {};
    int b[n] = {};
      inrep(n,a);

    ll m = 0;

    rrep(i,n+1,1){
	ll sum = 0;
	int j = i-1;
	while(j < n){
	    sum += b[j];
	    j += i;
	}
	if(sum&1){
	    if(a[i-1] == 0){
		b[i-1] = 1;
		m++;
	    }
	}else{
	    if(a[i-1] == 1){
		b[i-1] = 1;
		m++;
	    }
	}
    }

    P(m);
    rep(i,0,n){
	if(b[i] == 1)P(i+1);
    }
    return  0;
}


Measured memory_bytes: 2432
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



void solve(){
    ll x,a,b;
    cin>>x>>a>>b;
    x-=a;
    cout<<x%b<<endl;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


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

using namespace std;
int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int count = n;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (t >= a && t < b) count--;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

class C
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

		var r = 0L;
		var M = 0;
		foreach (var x in a)
			if (x < M) r += M - x;
			else M = x;
		Console.WriteLine(r);
	}
}


Measured memory_bytes: 46440
from functools import lru_cache

N,X = map(int,input().split())

bargar = [1 for i in range(N+1)]
for i in range(1, N+1):
    bargar[i] = bargar[i-1]*2 +3

patie = [1 for i in range(N+1)]
for i in range(1, N+1):
    patie[i] = patie[i-1]*2 +1

# @lru_cache(maxsize=1000)
def rec(dim):
    global X
    if dim==0:
        X -= 1
        if X >= 0: return 1
        else: return 0

    res = 0; X -= 1
    if X==0: return res

    if X>=bargar[dim-1]: res += patie[dim-1]; X-= bargar[dim-1]
    else: res += rec(dim-1)
    if X==0: return res

    res += 1; X -= 1
    if X==0: return res

    if X>=bargar[dim-1]: res += patie[dim-1]; X-= bargar[dim-1]
    else: res += rec(dim-1)
    if X==0: return res

    X -= 1
    if X==0: return res
    return res

print(rec(N))
# print(bargar)
# print(patie)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r;
  cin >> r;
  cout << r * r << '\n';
  return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

int cmp (const void *a, const void *b) {
  i32 d = *(i32 *)a - *(i32 *)b;
  return d == 0 ? 0 : d < 0 ? 1 : -1;
}

int cond (i32 *a, i32 n) {
  qsort (a, n, sizeof (i32), cmp);
  for (i32 i = 0; i < n - 1; ++i) {
    if (a[i] == a[i + 1]) {
      return 0;
    }
  }
  return 1;
}

void run (void) {
  i32 n, m;
  scanf ("%" SCNi32 "%" SCNi32, &n, &m);
  i32 *a = (i32 *) calloc (n + 1, sizeof (i32));
  i32 *b = (i32 *) calloc (m + 1, sizeof (i32));
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, a + i);
  }
  a[n] = 0;
  for (i32 i = 0; i < m; ++i){
    scanf ("%" SCNi32, b + i);
  }
  b[m] = 0;
  if (!(cond (a, n) && cond (b, m))) {
    puts("0");
    return;
  }
  const i32 mod = 1000000007;
  i32 ans = 1;
  for (i32 i = n * m, x = 0, y = 0; i >= 1; --i) {
    if (a[x] == i && b[y] == i) {
      x++;
      y++;
    } else if (a[x] == i) {
      ans = (i64) ans * y % mod;
      x++;
    } else if (b[y] == i) {
      ans = (i64) ans * x % mod;
      y++;
    } else {
      ans = (i64) ans * (x * y - (n * m - i)) % mod;
    }
  }
  printf ("%" PRIi32 "\n", ans);
}

int main (void) {
  run();
  return 0;
}


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

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


Measured memory_bytes: 256
//--- pC ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		int L = reader.ni();
		double r = L / 3.0;
		double res = r * r * r;
		System.out.println(res);
		return; 
	}


}

class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 21332