akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



vint res;
int tot = 0;
bool solved = false;

void rec(vint num, int rem, vint vec) {
    //cout << num << ",,, " << sum << ";;;; " << vec << endl;
    
    if (solved) return;
    if (rem == 0) {
        res = vec;
        solved = true;
        return;
    }
    for (int d = 1; d <= 13; ++d) {
        if (num[d] == 0) continue;
        if ( (rem-d) % d != 0 ) continue;
        num[d]--;
        vint nvec = vec; nvec.PB(d);
        rec(num, rem-d, nvec);
        num[d]++;
    }
}

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        vector<int> num(14, 0);
        tot = 0;
        for (int i = 0; i < n; ++i) {
            int c; cin >> c; num[c]++;
            tot += c;
        }
        res.clear();
        solved = false;
        vint kara;
        rec(num, tot, kara);
        reverse(ALL(res));
        
        if (res.size() == 0) puts("No");
        else {
            for (int i = 0; i < res.size(); ++i) {
                cout << res[i];
                if (i != res.size()-1) cout << " ";
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
char a[1001][1001];
bool f[1001][1001];
struct D
{
	int x, y, c;

	D(int x_, int y_, int c_)
	{
		x = x_, y = y_, c = c_;
	}
};

int main()
{
	int h, w;
	cin >> h >> w;
	queue<D> q;
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cin >> a[i][j];
			if (a[i][j] == '#')
			{
				q.push(D(i, j, 0));
				f[i][j] = 1;
			}
		}
	}
	int ans = 0;
	while (!q.empty())
	{
		//cout << 1 << endl;
		auto t = q.front();
		q.pop();
		ans = max(t.c, ans);
		for (int i = -1; i <= 1; ++i)
		{
			for (int j = -1; j <= 1; ++j)
			{
				if (i * j != 0)
					continue;
				if (t.x + i < 0 || t.x + i >= h)
					continue;
				if (t.y + j < 0 || t.y + j >= w)
					continue;
				if (!f[t.x + i][t.y + j])
				{
					f[t.x + i][t.y + j] = 1;
					q.push(D(t.x + i, t.y + j, t.c + 1));
				}
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  
  if( A.back() == B.at(0) && B.back() == C.at(0) ){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int n,k,j;
   cin >> n;
   int A[n];
    for(int i=0;i<n;i=i+1){
        cin >> A[i];
    }
//
    for(int i=1;i<n;i=i+1){
        j=i-1;
        
        for(int l=0;l<n;l=l+1){
            if(l==n-1){
                cout << A[l] <<endl;
            }else{
                cout << A[l] <<" ";
            }
                
            }
        
        k=A[i];
        for(;A[j]>k&&j>=0;j=j-1){
            
            A[j+1]=A[j];
            A[j]=k;
            
        }
         
}
   for(int l=0;l<n;l=l+1){
            if(l==n-1){
                cout << A[l] <<endl;
            }else{
                cout << A[l] <<" ";
            }
                
            }

}


Measured memory_bytes: 3132
//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

ll n, m;

vector<ll> a;
vector<ll> p;

ll s[10000];

ll modpow(ll x, ll y)
{
	ll ans=1;
	while(y)
	{
		if(y%2) ans*=x, ans%=MOD;
		x*=x, x%=MOD, y/=2;
	}
	return ans;
}

int main()
{
	int i, j, k, l;
	cin>>n>>m;
	int flag=0;
	if(n%2 == 0) n/=2, flag=1;
	for(i=1;i*i<=n;i++)
	{
		if(n%i == 0)
		{
			a.push_back(i);
			if(i*i != n) a.push_back(n/i);
		}
	}
	sort(all(a));
	int t=a.size();
	/*int t=a.size();
	for(i=1;i<t;i++)
	{
		for(j=1;j<i;j++)
		{
			if(a[i]%a[j] == 0) break;
		}
		if(j == i) p.push_back(a[i]);
	}*/
	for(i=0;i<t;i++)
	{
		s[i]=modpow(m, (flag?a[i]:1+a[i]/2));
		for(j=0;j<i;j++)
		{
			if(a[i]%a[j] == 0) s[i]-=s[j];
		}
		s[i]%=MOD;
		if(s[i] < 0) s[i]+=MOD;
	}
	ll ans=0;
	for(i=0;i<t;i++)
	{
		ans+=s[i]*a[i], ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}
//*/

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
    map<string,int> mp;
    int n;
    cin >> n;
    string s;
    for ( int i = 0 ; i < n ; i++ ){
        cin >> s;
        if ( mp.find(s) == mp.end()){
            mp[s] = 1;
        }
        else{
            mp[s]++;
        }
    }

    int m;
    cin >> m;
    for ( int i = 0 ; i < m ; i++ ){
        cin >> s;
        if ( mp.find(s) == mp.end() ){
            mp[s] = -1;
        }
        else{
            mp[s]--;
        }
    }
    int ans = -100;
    for ( auto itr = mp.begin(); itr != mp.end() ; itr++ ){
        ans = max(ans, itr -> second);
    }
	if ( ans > 0 ) cout << ans << endl;
  	else cout << 0 << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }

        boolean flag = true;
        int ans = 0;
        while (flag) {
            for (int i = 0; i < list.size(); i++) {
                if (list.get(i)%2 == 0) {
                    list.set(i, list.get(i)/2);
                } else {
                    flag = false;
                }
            }
            if (flag) ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			long n = in.nextLong(), k = in.nextLong();

			long x = n / k;
			if (k % 2 == 1) {
				out.println(x * x * x);
			} else {
				long y = (n + k/2) / k;
				out.println(x * x * x + y * y * y);
			}
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

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

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

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

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

	static long max(long... n) {
		long ret = n[0];
		for (int i = 0; i < n.length; i++) {
			ret = Math.max(ret, n[i]);
		}
		return ret;
	}

	static int max(int... n) {
		int ret = n[0];
		for (int i = 0; i < n.length; i++) {
			ret = Math.max(ret, n[i]);
		}
		return ret;
	}

	static long min(long... n) {
		long ret = n[0];
		for (int i = 0; i < n.length; i++) {
			ret = Math.min(ret, n[i]);
		}
		return ret;
	}

	static int min(int... n) {
		int ret = n[0];
		for (int i = 0; i < n.length; i++) {
			ret = Math.min(ret, n[i]);
		}
		return ret;
	}

}


Measured memory_bytes: 23380
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int N,a;
    cin >> N;
    vector<int> v(N);
    for(int i=0; i<N; i++){
        cin >> v[i];
        if(i==N-1){
            cout << v[i] << endl;
        }
        else{
            cout << v[i] <<" " ;
        }
    }
    
    for(int i = 1; i <N; i++){
        a = v[i];
        int j=i-1;
        while(j>=0 && v[j]>a){
            v[j+1]=v[j];
            j--;
            v[j+1]=a;
        }
        for(int k = 0; k <N; k++){
            if(k==N-1){
                cout << v[k] << endl;
            }
            else{
                cout << v[k] << " " ;
            }
        }
    }
}


Measured memory_bytes: 3100
N=gets.to_i
S=["M","A","R","C","H"]
h=Hash.new{0}
N.times{
    s=gets.chomp
    next unless S.include?(s[0])
    h[s[0]]+=1
}
warn h.inspect
r=0
S.combination(3){|c|
    r+=c.inject(1){|r,i|r*h[i]}
}
puts r


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

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    for (ll i=1; i<=N; i++) {
        ans += i*(((1+N/i)*(N/i))/2);
    }
    cout << ans << endl;
}

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

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

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

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

pcc C[200005];
string S;
ll N, Q;

bool checkL(ll n)
{
    REP(i, Q)
    {
        if (C[i].first == S[n])
        {
            if (C[i].second == 'L')
                n--;
            else
                n = std::min(n + 1, N - 1);
            if (n < 0)
                return true;
        }
    }
    return false;
}
bool checkR(ll n)
{
    REP(i, Q)
    {
        if (C[i].first == S[n])
        {
            if (C[i].second == 'L')
                n = std::max(0LL, n - 1);
            else
                n++;
            if (n > N - 1)
                return true;
        }
    }
    return false;
}

int main()
{
    cin >> N >> Q;
    cin >> S;
    REP(i, Q)
    {
        cin >> C[i].first >> C[i].second;
    }

    ll left = 0;
    {
        //! 左に落ちる最大値
        ll ok = 0, ng = N;
        while (abs(ok - ng) > 1)
        {
            ll mid = (ok + ng) / 2;
            if (checkL(mid))
                ok = mid;
            else
                ng = mid;
        }
        if (ok == 0 && !checkL(0))
            ok = -1;
        left = ok + 1;
    }
    ll right = 0;
    {
        //! 左に落ちる最大値
        ll ok = N - 1, ng = -1;
        while (abs(ok - ng) > 1)
        {
            ll mid = (ok + ng) / 2;
            if (checkR(mid))
                ok = mid;
            else
                ng = mid;
        }
        if (ok == N - 1 && !checkR(N - 1))
            ok = N;
        right = N - ok;
    }
    cout << N - std::min(N, left + right) << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
<?php
// D
define("MOD", 10 ** 9 + 7);
fscanf(STDIN, '%d %d', $n, $k);
$ans = 0;
for ($i = $k; $i <= $n + 1; $i++) {
    $min = ($i - 1)* $i / 2;
    $max = (2 * $n - $i + 1) * $i / 2;
    $ans = ($ans + ($max - $min + 1)) % MOD;
}
echo $ans;

Measured memory_bytes: 16236
#include <iostream>

int main(int argc, char** argv)
{
	int A, B, C, K, ans = 0;
	std::cin >> A >> B >> C >> K;
	ans += A;
	K -= A;
	if (K < 0)
	{
		ans += K;
	}
	else
	{
		K -= B;
		if (K > 0)
		{
			ans -= C;
			K -= C;
			if (K < 0)
			{
				ans -= K;
			}
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3652
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k = map(int,input().split())
X = list(map(int,input().split()))
for i in range(n-k+1):
  fi = X[i]
  en = X[i+k-1]
  if fi <= 0 and en >= 0:
    mans = min(mans,min(-fi,en)-fi+en)
  else:
    mans=min(mans,max(abs(fi),abs(en)))
print(mans)

Measured memory_bytes: 14604
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

using P = pair<int, int>;

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

	vector<P> v(N);
	vector<int> x(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i];
		x[i]--;

		v[i] = { x[i], i + 1 };
	}
	sort(ALL(v));

	static int num[510];

	vector<int> ans(N * N, -1);
	int idx = 0;

	for (int i = 0; i < N; i++) {
		int f = v[i].first;
		int s = v[i].second;

		while (idx < f && num[s] < s - 1) {
			if (ans[idx] < 0) {
				ans[idx] = s;
				num[s]++;
			}
			idx++;
		}
		if (num[s] != s - 1) {
			cout << "No" << endl;
			return 0;
		}
		ans[f] = s;
		num[s]++;
	}

	for (int i = 0; i < N; i++) {
		int n = v[i].second;
		while (idx < N * N && num[n] < N) {
			if (ans[idx] < 0) {
				ans[idx] = n;
				num[n]++;

				if (idx <= x[n - 1]) {
					cout << "No" << endl;
					return 0;
				}
			}
			idx++;
		}
	}

	int sum = 0;
	for (int n = 1; n <= N; n++) sum += num[n];

	if (sum != N * N) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
	for (int a : ans) {
		cout << a << " ";
	}
	cout << endl;
}

Measured memory_bytes: 2176
#include <iostream>

int main(){
    int a,b,c;
    std::cin >> a >> b ;
    if(a>b){
        c=a;
        a=b;
        b=c;
    }
    std::cin >> c;
    if(c<a) std::cout << c << " " << a << " " << b << std::endl;
    else if(c<b) std::cout << a << " " << c << " " << b << std::endl;
    else std::cout << a << " " << b << " " << c << std::endl;

    return 0;
    }


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

int main(int argc, char const *argv[]) {
    int N,K,X,Y;
    cin>>N>>K>>X>>Y;
    if(N<K) {
        cout<<N*X<<endl;
    }
    else {
        cout<<K*X+(N-K)*Y<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
int count=0;

int MR(int N,int Q,int* A,int* B,int* C,int* D,int* seq,int pt){
 int res=0;
 count++;
 if(pt==-1){
  for(int i=0;i<Q;i++){
   if(seq[B[i]]-seq[A[i]]==C[i]){
    res+=D[i];
   }
  }
 }else{
  int ot=0;
  for(int i=1;i<=seq[pt+1];i++){
   seq[pt]=i;
   ot=MR(N,Q,A,B,C,D,seq,pt-1);
   if(res<ot){
    res=ot;
   }
  }
 }
 return res;
}

int main(){
 int N,M,Q;
 std::cin>>N>>M>>Q;
 int* A=new int[Q];
 int* B=new int[Q];
 int* C=new int[Q];
 int* D=new int[Q];
 for(int i=0;i<Q;i++){
  std::cin>>A[i]>>B[i]>>C[i]>>D[i];
 }

 int* seq=new int[N+1];
 seq[N]=M;
 int ans=MR(N,Q,A,B,C,D,seq,N-1);

 std::cout<<ans<<std::endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
ll x,k,d;
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	cin>>x>>k>>d;
	x=abs(x);
	if(x/d>=k)
	{
		cout<<x-k*d<<endl;
		return 0;
	}
	while(x>0)
	{
		x-=d;
		k--;
	}
	if(k%2==0)
	{
		cout<<abs(x)<<endl;
	}
	else
	{
		cout<<abs(x+d)<<endl;
	}
	return 0;
}



Measured memory_bytes: 3656
// author:  Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define all(x) x.begin(),x.end()
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;

//ll modexp(ll x, ll y, ll p)
//{
//	ll res = 1;
//	x = x % p;
//	while (y > 0)
//	{
//		if (y & 1)
//			res = (res * x) % p;
//		y = y >> 1;
//		x = (x * x) % p;
//	}
//	return res;
//}

//ll mulmod(ll a, ll b,ll m)
//{
//	return ((a % m) * (b % m)) % m;
// }

// ll sub_mod(ll a, ll b, ll m){
//    if (a >= b)
//        return a - b;
//    else
//        return m - b + a;
// }

// ll add_mod(ll a, ll b){
//    if (0 == b)
//        return a;

//    b = mod - b;
//    if (a >= b)
//        return a - b;
//    else
//        return mod - b + a;
// }

// ll gcd(ll a, ll b)
// {
// 	if (a == 0)
// 		return b;
// 	else
// 		return gcd(b % a, a);
// }

// ll modInv(ll a)
// {
//     ll g = gcd(a, mod);
//     if (g != 1)
//         return -1;
//     else
//         return modexp(a, mod-2, mod);
// }

int main()
{
	fastio;
	ll n=0,m=0;
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2;
   	return 0;
}


Measured memory_bytes: 256
# Crane and Turtle

X, Y = [int(i) for i in input().split()]

for t in range(0, X + 1):
    legs = 2 * (X + t)
    if Y == legs:
        a = 'Yes'
        break
    if Y < legs:
        a = 'No'
        break
else:
    a = 'No'

print(a)


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

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N, 0);
    vector<ll> B(N, 0);
    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
    }
    ll ans = 0;
    for(int i = N - 1; i >= 0; i--){
        A[i] += ans;
        if(A[i] % B[i] != 0){
            if(A[i] > B[i]){
                B[i] = B[i] * ((A[i] / B[i])+ 1);
            }
            ans += B[i] - A[i];
        }

    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (int)(a); v < (int)(b); ++v)
#define FORE(v, a, b) for(int v = (int)(a); v <= (int)(b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
using namespace std;

void split(string str, char chr, vector< string > *res){
	stringstream ss(str);
	string itm;
	while(getline(ss, itm, chr)){
		(*res).PB(itm);
	}
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int r, c;
	
	while(cin >> r >> c, r){
		cout << ((r * c) % 2 ? "no" : "yes") << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>

int main()
{
    int n, i, j, k, l, count;
    
   while(scanf("%d", &n) != EOF)
    {
        count = 0;
        for(i = 0; i <= 9; i++)
        {
            for(j = 0; j <= 9; j++)
                {
                    for(k = 0; k <= 9; k++)
                    {
                        for(l = 0; l <= 9; l++)
                        {
                            if(i + j + k + l == n)count++;
                        }
                    }
                }
            }
        printf("%d\n", count);
    }
    return 0;
}



Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


int main(){
  string s;
  int n;
  cin>>s>>n;
  string t;
  rep(i,s.size()){
    if(i%n==0)
      t+=s[i];
  }

  cout<<t<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string s;
    cin>>s;
    int n=s.size();
    rep(i,(n-1)/2){
        if(s[i]!=s[n-1-i]){
            cout<<"No";
            return 0;
        }
    }
    rep(i,((n-1)/2)/2){
        if(s[i]!=s[(n-1)/2-1-i]){
            cout<<"No";
            return 0;
        }
    }
    rep(i,((n-1)/2)/2){
        if(s[(n-1)/2+1+i]!=s[n-1-i]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
             
public static class Program
{
    public static void Main()
    {
        int[] R = GetIntArray();
        int N = R[0];
        int A = R[1];
        int B = R[2];
        Console.WriteLine(Math.Min(A, B).ToString() + " " +  Math.Max((A + B - N), 0).ToString());
    }
    
    private static string ReadLine()
    {
    	return Console.In.ReadLine();
    }
    
    public static int[] GetIntArray()
    {
    	List<int> temp = new List<int>();
    	foreach (string c in ReadLine().Split(' '))
            temp.Add(int.Parse(c));
        return temp.ToArray();
    }
    
    public static int GetInt()
    {
    	return int.Parse(ReadLine());
    }
}

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int edge[8][8];
int reached[8];
int ctr;
int n,m;
int ans;

void dfs(int p){
    if(ctr==n-1){
        ++ans;
        return;
    }
    rep(i,n){
        if(reached[i])continue;
        if(edge[p][i]){
            reached[i]=1;
            ctr++;
            dfs(i);
            reached[i]=0;
            ctr--;
        }
    }
}

int main(){
    cin>>n>>m;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        edge[a-1][b-1]=1;
        edge[b-1][a-1]=1;
    }
    reached[0]=1;
    dfs(0);
    cout<<ans<<endl;
}


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

int main () {
  string s,t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  cout << (s < t ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 764
char s[9];m[21][21];
main(n,x,y,c){
	for(;scanf("%d",&n),n;){
		for(memset(m,0,sizeof(m));n--;m[x][y]=1)scanf("%d%d",&x,&y);
		for(scanf("%d",&n),x=y=10;n--;){
			scanf("%s%d",s,&c),m[x][y]=0;
			if(*s=='W')for(;c--;m[x][y]=0)x--;
			if(*s=='E')for(;c--;m[x][y]=0)x++;
			if(*s=='S')for(;c--;m[x][y]=0)y--;
			if(*s=='N')for(;c--;m[x][y]=0)y++;
		}
		for(x=0;x<21;x++)for(y=0;y<21;y++)if(m[x][y])goto z;
		z:puts(x==y&&x==21?"Yes":"No");
	}exit(0);
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
int n,t;
int main()
{
    scanf("%d",&n);
    int a=n/100;
    int b=n%100;
    if(a<=12&&a>=1) t++;
    if(b<=12&&b>=1) t+=2;
    if(t==0) printf("NA");
    if(t==1) printf("MMYY");
    if(t==2) printf("YYMM");
    if(t==3) printf("AMBIGUOUS");
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n,m;
  scanf("%d %d",&n,&m);
  //printf("%d %d\n",n,m);
  int i,j;
  long long l[m], r[m];
  for (i = 0; i < m; i++) {
    scanf("%lld %lld",&l[i],&r[i]);

  }
  // for (i = 0; i < m; i++) {
  //   printf("%lld %lld\n",l[i],r[i]);
  // }
  long long ans = 0;
  int passCnt;
  int left = 1;
  int right = 1e5;
  for(j = 0; j < m; j++){
    if(left <= l[j]) left = l[j];
    if(right >= r[j]) right = r[j];
  }
  ans = right - left + 1;
  if(ans < 0) ans = 0;
  printf("%lld\n",ans);

}


Measured memory_bytes: 1664
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#define INF 1e8
using namespace std;
#define ll long long

#define MAX 100020
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#define INF 1e8
using namespace std;
#define ll long long

#define MAX 100020

int main(){

ll a,b,c;
cin>>a>>b>>c;
a+b+c>=22?cout<<"bust":cout<<"win";
}

Measured memory_bytes: 3024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  ll ans=0;
  for(int bit=0; bit<60; bit++){
    int ones=0,zers=0;//立っているビットの数
    rep(i,n){
      if(a[i]&1ll<<bit) ones++;
      else zers++;
    }
  ans = (ll(ans) + (1ll << bit) % MOD * ones % MOD * zers) % MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
int main()
{
	ll r,d,x;
	scanf("%lld%lld%lld",&r,&d,&x);
	for(register int i=1;i<=10;i++)
	{
		x=r*x-d;
		printf("%lld\n",x);
	}
	return 0;
}

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

using namespace std;

int N;
vector< pair<int, int> > vec;
vector<int> dust;
int cnt[505];
int ans[250005];

int main(void)
{
	cin >> N;
	int x;
	for(int i = 1; i <= N; i++){
		cin >> x;
		vec.push_back( make_pair(x, i) );
	}
	sort(vec.begin(), vec.end());
	
	int nid = 0, tid = 0, set;
	for(int i = 1; i <= N*N; i++){
		if(nid < vec.size() && i >= vec[nid].first){
			if(cnt[vec[nid].second] < vec[nid].second-1){
				cout << "No" << endl;
				return 0;
			}
			ans[i] = vec[nid].second;
			cnt[vec[nid].second]++;
			for(int j = 0; j < N - vec[nid].second; j++) dust.push_back(vec[nid].second); 
			nid++;
			continue;
		}
		
		while(tid < vec.size() &&cnt[vec[tid].second] >= vec[tid].second-1) tid++;
		if(tid >= vec.size()){
			if(dust.size() == 0){
				cout << "No" << endl;
				return 0;
			}
			set = dust.back();
			dust.pop_back();
		}
		else set = vec[tid].second;
		ans[i] = set;
		cnt[set]++;
	}
	
	cout << "Yes" << endl;
	for(int i = 1; i <= N*N; i++){
		cout << ans[i];
		if(i != N*N) cout << " ";
	}
	cout << endl;
	return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)
// }}} 2

// numerous {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// systems }}} 2

// }}} 1

int main() {

    int x,a,b;

    Scd3(x,a,b);

    a = abs(a-x);
    b = abs(b-x);

    if( a > b ) printf ("B\n");
    else printf ("A\n");

    return 0;
}



Measured memory_bytes: 256
from copy import copy
from functools import reduce
    
class Sunuke:
    def __init__(self):
        self.has_snack = False
    
n_sunuke, n_v_snacks = [int(s) for s in input().split()]
    
all_sunuke = [copy(Sunuke()) for i in range(n_sunuke)]
    
for snack_id in range(n_v_snacks):
    n_snacks = int(input())
    for sunuke_id in (int(s) for s in input().split()):
        all_sunuke[sunuke_id - 1].has_snack = True
    
print(reduce(lambda n,s: n + (0 if s.has_snack else 1), all_sunuke, 0))

Measured memory_bytes: 9736
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

S = input()
N = len(S)
P = 2019

A = [0] * (N+1)
for i in range(N):
    A[i+1] = (A[i] + int(S[N-1 - i]) * pow(10, i, P)) % P

c = collections.Counter(A)
ans = 0
for v in c.values():
    ans += v * (v-1) // 2

print(ans)


Measured memory_bytes: 70504
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
//#define int long long
const int INF = 1 << 30;

signed main(){

  int D; cin >> D;
  vector<int> C(26);
  for(int i = 0; i < 26; i++){
    cin >> C[i];
  }

  vector<vector<int>> S(D, vector<int>(26));
  for(int i = 0; i < D; i++){
    for(int j = 0; j < 26; j++){
      cin >> S[i][j];
    }
  }

  random_device seed_gen;
  mt19937_64 rnd(seed_gen());
  uniform_int_distribution<int> dist_T(1, 26);
  clock_t start = clock();

  int score = -INF;
  vector<int> ans(D);
  while(true){
    int res = 0;
    vector<int> L(26, -1);
    vector<int> dp(D);
    for(int i = 0; i < D; i++){
      int T = dist_T(rnd);
      res += S[i][T-1];
      L[T-1] = i;
      for(int j = 0; j < 26; j++){
        if(L[j] == -1) continue;
        res -= i - L[j];
      }
      dp[i] = T;
    }
    if(score < res){
      score = res;
      ans = dp;
    }

    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    //printf("time %lf[ms]\n", time);
    if(time >= 1.9) break;
    //cout << dp << " " << res << endl;
  }

  for(int p : ans){
    cout << p << endl;
  }

  return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define vi vector<int>
using namespace std;

int32_t main(void){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	cin>>n;
	int arr[n];
	bool res = true;
	rep(i,0,n)
	{
		cin>>arr[i];
		if(arr[i]%2 == 0)
		{
			if(arr[i]%3 != 0 && arr[i]%5 != 0)
			{
				res = false;
				break;
			}
		}
	}
	if(res) cout<<"APPROVED";
	else cout<<"DENIED";
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forp(i,a,b) for (int i = (a); i <(b); i++)
#define forn(i,a,b) for (int i = (a); i >(b); i--)
#define mod 1000000007
#define multiple_testcases_t int t;cin>>t;while(t--){solve();}
#define single_testcase_t solve();
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
vector<int> primes;

int is_prime(long long int n)
{
    if(n==1)
    return 0;
  for(int i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      return 0;
    }
  }
  return 1;
}

void SieveOfEratosthenes(int n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.PB(p); 
}


ll divisors(int n)
{
    ll ans=1;
   forp(i,0,primes.size())
   {
       if(primes[i]*primes[i]*primes[i]>n)
       break;
int c=1;
       while(n%primes[i]==0)
       {
           n/=primes[i];
           c++;
       }
       ans=ans*c;
   }

   if(is_prime(n))
   ans*=2;
   else if(is_prime((int)sqrt(n))==1 && ((int)sqrt(n))*((int)sqrt(n))==n)
   ans*=3;
   else if(n!=1)
   ans*=4; 

    return ans;
}
// <----- Actual solve() function to print output -----> //
void solve()
{
   ll n,p,q,x,y,k=0;
cin>>n;
vector<int> d(1000001);
SieveOfEratosthenes(1000000);
  forp(i,1,n)
  {
      p=divisors(i);
     k=k+p;
    // cout<<i<<" "<<p<<"\n";
  }
  cout<<k;
   //cout<<"\n";      //if t>1 uncomment this
}
 
// MAIN function --------------------------------------------------------------------------//
int main()
{
    fast_io
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);
 
  single_testcase_t
  //multiple_testcases_t
return 0;
}


Measured memory_bytes: 8772
{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Data.List

isp [] _ = True
isp _ [] = False
isp (t:tr) (s:sr)
    | s == '?' = isp tr sr
    | t == s = isp tr sr
    | True = False

fd t sp [] = []
fd t sp ss@(s:sr) =
    if isp t ss
        then (sp ++ t ++ (drop (length t) ss)) : fd t (sp++[s]) sr
        else fd t (sp++[s]) sr

main=do
    s <- getLine
    t <- getLine
    --
    let as = map (map (\c -> if c == '?' then 'a' else c)) $ fd t [] s
    --
    if null as then putStrLn "UNRESTORABLE"
    else putStrLn $ head $ sort as


Measured memory_bytes: 636
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n = inp[0]
t = []
t.push(inps[0])
t.push(inps[0])
m = true
i = 0
if(t[0][i] == t[1][i])
  ans = 3 
  m = false
else
  ans = 6
  i += 1
  m = true
end
i += 1
while true
  break if(i >= t[0].size)
  if(t[0][i] == t[1][i])
    ans *= 2 if(!m)
    m = false
  else
    i += 1
    ans *= 2 if(!m)
    ans *= 3 if(m)
    m = true
  end
  i += 1
end
puts ans %1000000007

 

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using ts = std::string::size_type;

std::string s, t;
std::vector<int> start_points;



int main() {
    std::cin >> s >> t;
    
    for (int i = 0; i < s.size() - t.size() + 1; i++) {
        std::string k = s.substr(i, t.size());
        bool ok = true;
        for (int p = 0; p < k.size(); p++) {
            if (k[p] != t[p] && k[p] != '?') {
                ok = false;
                break;
            }
        }
        if (ok) {
            start_points.push_back(i);
        }
    }
    if (start_points.size() == 0) {
        std::cout << "UNRESTORABLE" << std::endl;
        return 0;
    }
    auto m = *std::max_element(start_points.begin(), start_points.end());    
    std::string s2 = s;
    for (int j = 0; j < t.size(); j++) {
        s2[m+j] = t[j];
    }
    std::string find_char("?");
    ts pos = s2.find(find_char);
    while (pos != std::string::npos) {
        s2[pos] = 'a';
        if (pos >= s2.size()) {
            break;
        }
        pos += find_char.size();
        pos = s2.find(find_char, pos);
    }
    std::cout << s2 << std::endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, x[200];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    long long ans = 1e18;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    for (int i = 1; i <= 100; i++) {
        long long tmp = 0;
        for (int j = 0; j < n; j++) {
            tmp += (x[j] - i) * (x[j] - i);
        }
        ans = min(ans, tmp);
    }
    cout << ans << E;
    //system("pause");
    return 0;
}

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

int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
  int a;
  cin >> a;
  cout << arr[a-1] << '\n';
  
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    vector<int> two_one, two_two, three, six;
    for(int i = 1; i <= 30000; i++){
        if((i == 2) || (i == 4) || (i == 3) || (i == 9)){
            continue;
        }
        if((i % 6) == 0){
            six.push_back(i);
            continue;
        }
        if((i % 3) == 0){
            three.push_back(i);
            continue;
        }
        if((i % 2) != 0){
            continue;
        }
        if((i % 3) == 1){
            two_one.push_back(i);
            continue;
        }
        two_two.push_back(i);
    }
    //cout << six.size() << " " << three.size() << " " << two_two.size() << " " << two_one.size() << endl;
    int n;
    cin >> n;
    if(n == 3){
        cout << "2 5 63" << endl;
        return 0;
    }
    if(n == 4){
        cout << "2 5 20 63" << endl;
        return 0;
    }
    cout << "2 4 3 9 ";
    int now = 4;
    if(n <= 5004){
        for(int i = 0; ; i++){
            cout << six[i] << " ";
            now++;
            if(now == n){
                break;
            }
        }
        cout << endl;
        return 0;
    }
    if(n <= 10002){
        for(int i = 0; i < three.size(); i++){
            cout << three[i] << " ";
            now++;
        }
        for(int i = 0; ; i++){
            cout << six[i] << " ";
            now++;
            if(now == n){
                break;
            }
        }
        cout << endl;
        return 0;
    }
    if(n <= 15002){
        for(int i = 0; i < 4999; i++){
            cout << two_one[i] << " " << two_two[i] << " ";
            now += 2;
        }
        for(int i = 0; ; i++){
            cout << six[i] << " ";
            now++;
            if(now == n){
                break;
            }
        }
        cout << endl;
        return 0;
    }
    for(int i = 0; i < 4999; i++){
        cout << two_one[i] << " " << two_two[i] << " ";
        now += 2;
    }
    for(int i = 0; i < 4998; i++){
        cout << three[i] << " ";
        now++;
    }
    for(int i = 0; ; i++){
        cout << six[i] << " ";
        now++;
        if(now == n){
            cout << endl;
            return 0;
        }
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;

    rep(i, a+1)
    {
        rep(j, b+1)
        {
            int num = x / 50 - 10 * i - 2 * j;
            if (0 <= num and num <= c)
            {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3604
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt( sc.nextLine() );
        String[] params = sc.nextLine().split(" ");
        for( int i = 0 ; i < n ; i++ ){
            int a = Integer.parseInt( params[i] );
            if( a % 2 == 0 ){
                if( a % 3 != 0 && a % 5 != 0 ){
                    System.out.println( "DENIED" );
                    return;
                }
            }
        }

        System.out.println( "APPROVED" );

    }

}


Measured memory_bytes: 23764
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let ps: Vec<(f64, f64)> = (0..n).map(|_| {
        let x: f64 = sc.cin();
        let y: f64 = sc.cin();
        (x, y)
    }).collect();
    let mut sum = 0.0;
    for i in 0..n {
        let (x1, y1) = ps[i];
        for j in 0..i {
            let (x2, y2) = ps[j];
            sum += ((x1 - x2).powi(2) + (y1 - y2).powi(2)).sqrt();
        }
    }
    put!(sum / (n as f64) * 2.0);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


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

int main(){

    int n;
    cin >> n;

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

    vector<int> b;


    if(a.size()%2==0){
        for(int i=a.size()-1;i>=0;i--){
            if(i%2==1){
                b.push_back(a[i]);
            }
        }
        for(int i=0;i<a.size();i++){
            if(i%2==0){
                b.push_back(a[i]);
            }
        }
    }else{
        for(int i=a.size()-1;i>=0;i--){
            if(i%2==0){
                b.push_back(a[i]);
            }
        }
        for(int i=0;i<a.size();i++){
            if(i%2==1){
                b.push_back(a[i]);
            }
        }
    }

    rep(i,n)cout << b[i] << " ";

    cout << endl;

    return 0;
}

Measured memory_bytes: 3828