akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long INF = 1LL << 60; 

int main()
{
  int a, b; cin >> a >> b;
  if(a < b) rep(i,b) cout << a;
  else rep(i,a) cout << b;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
l = [0] * (10000001)
for _ in range(n):
	a, b = map(int, input().split())
	l[a] += b
for i in range(1, 10000001):
	if k <= l[i]:
		print(i)
		break
	k -= l[i]

Measured memory_bytes: 88748
import sys


n, m = [int(_) for _ in input().split()]
l = {}
for i in range(m):
    l[int(input())] = 1

d = [0] * (n + 2)
d[0] = 1
if 1 not in l:
    d[1] = 1
for i in range(n):
    if i in l and i + 1 in l:
        print(0)
        sys.exit()
    elif i in l:
        d[i + 2] = d[i + 1]
    elif i + 1 in l:
        d[i + 2] = d[i]
    else:
        d[i + 2] = d[i] + d[i + 1]
    d[i + 2] = d[i + 2] % (10 ** 9 + 7)
print(d[-2])

Measured memory_bytes: 54232
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N;
	cin >> N;
	vector<vector<int>> A(10, vector<int>(10, 0));
	for (int i = 0; i <= N; ++i) {
		int M = i % 10;
		int S;
		if (i == 0) {
			S = 0;
		}
		else {
			int temp = i;
			while (temp / 10) {
				temp /= 10;
			}
			S = temp;
		}
		A[S][M]++;
	}
	LL ans = 0;
	for (int i = 0; i <= N; ++i) {
		int M = i % 10;
		int S;
		if (i == 0) {
			S = 0;
		}
		else {
			int temp = i;
			while (temp / 10) {
				temp /= 10;
			}
			S = temp;
		}
		if (S != 0 && M != 0) {
			ans += A[M][S];
		}
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s;
int main()
{
    cin>>s;
    if(s=='a'||s=='e'||s=='i'||s=='o'||s=='u') cout<<"vowel";
    else cout<<"consonant";
    cout<<endl;
    return 0;
}
//	freopen("1.in","r",stdin);
//  freopen("1.out","w",stdout);

Measured memory_bytes: 768
#include<iostream>
#include<iomanip>
using namespace std;
int X;
double p;
double calc(int x)
{
	return x/2/p;
}
main()
{
	cin>>X>>p;p/=100;
	double ans;
	if(X%2==0)ans=calc(X);
	else ans=p*calc(X-1)+(1-p)*calc(X+1)+1;
	cout<<fixed<<setprecision(16)<<ans<<endl;
}


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

int main()
{
    string a;
    cin >> a;
    
    for(int i=0;i<3;i++)
    {
        
        
        if(a[i]=='R' && a[i+1]=='R' && a[i+2]=='S')
        {
            cout << 2;
        }
        else  if(a[i]=='R' && a[i+1]=='R' && a[i+2]=='R')
        {
            cout << 3;
        }
        else  if(a[i]=='R' && a[i+1]=='S' && a[i+2]=='S')
        {
            cout << 1;
        }
        else  if(a[i]=='S' && a[i+1]=='S' && a[i+2]=='S')
        {
            cout << 0;
        }
        else  if(a[i]=='S' && a[i+1]=='R' && a[i+2]=='S')
        {
            cout << 1;
        }
        else  if(a[i]=='S' && a[i+1]=='R' && a[i+2]=='R')
        {
            cout << 2;
        }
        else if (a[i]=='R' && a[i+1]=='S' && a[i+2]=='R')
        {
            cout << 1;
        }
        else if (a[i]=='S' && a[i+1]=='S' && a[i+2]=='R')
        {
            cout << 1;
        }
    }
}

Measured memory_bytes: 3620
fun main(args: Array<String>) {
    a75(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a75(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val numList = args[0].split(" ").map { it.toInt() }.sorted()
    println(if (numList[0] == numList[1]) numList[2] else numList[0])
}


Measured memory_bytes: 36508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll a,b;
    cin >> a >> b;
    ll ans = 0;
    if(a == b){
        cout << a << endl;
        return 0;
    }
    if(b - a == 1){
        a ^= b;
        cout << a << endl;
        return 0;
    }
    if(a%2 == 1)ans = a,a++;
    if(b%2 == 0)ans ^= b,b--;
    if((b-a)%4 == 1 || (b-a)%4 == 2)ans ^= 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> p;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  deque<int> q;
  rep(i, n) {
    int a;
    cin >> a;
    if(i % 2) q.push_front(a);
    else q.push_back(a);
  }
  if(n % 2) reverse(q.begin(), q.end());

  for (auto it = q.begin(); it != q.end(); ++it) {
    cout << *it << " ";
  }
  cout << endl;
}

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

int main() {
  int x;
  cin >> x;
  
  if (600 > x) {
    printf("8");
  } else if (800 > x) {
    printf("7");
  } else if (1000 > x) {
    printf("6");
  } else if (1200 > x) {
    printf("5");
  } else if (1400 > x) {
    printf("4");
  } else if (1600 > x) {
    printf("3");
  } else if (1800 > x) {
    printf("2");
  } else if (2000 > x) {
    printf("1");
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3632
N = int(input())
A = list(map(int,input().split()))
di = {}
for i in range(N):
    if A[i] in di:
        di[A[i]] += 1
    else:
        di[A[i]] = 1
if max(di.values()) != 1:
    print("NO")
else:
    print("YES")


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

using namespace std;

int main(){
 int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  
  sort(a,a+n,greater<int>());
  
  int alice=0,bob=0;
  for(int i=0;i<n;i+=2) alice+=a[i]; 
  for(int i=1;i<n;i+=2) bob+=a[i]; 

  cout << alice-bob << endl;
}

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

int main()
{
    int64_t n;
    cin >> n;    
    int64_t a[5];
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

    int64_t t = n%a[0]==0 ? n/a[0] : n/a[0]+1;
    int64_t min_a = a[0];
    int64_t t0 = t;

    for(int i=1;i<5;++i)
    {
        if(min_a <= a[i])
        {
            t = t + 1;
        }
        else
        {
            int64_t ti = n%a[i]==0 ? n/a[i] : n/a[i]+1;
            
            t = t - t0 + 1 + ti;
            min_a = a[i];
            t0 = ti;
        }        
    }

    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 5;
int arr[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; ++i)
		cin >> arr[i];
	arr[n - 1] = 1 << 30;
	int res = arr[0];
	for (int i = 1; i < n; ++i)
		res += min(arr[i], arr[i - 1]);
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 256
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front priority_queue

#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define debug(...) 42
#endif

#define endl '\n'
#define ll long long
#define rint register int
#define minpq priority_queue <int, vector<int>, greater<int> >
#define maxpq  priority_queue <int>

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define conutBits(n)	__builtin_popcount(n)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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

	ll t, i, x, j, y, 	z, k, n;
	cin >> n;
	ll pre[n + 1], a[n + 1];
	memset(pre, 0, sizeof(pre));
	memset(a, 0, sizeof(a));

	rep(i, 1, n + 1, 1) {
		cin >> a[i];
		pre[i] = ( pre[i - 1] + a[i]) % hell;
	}

	z = 0;

	rep(i, 2, n + 1, 1) {
		t = (pre[i - 1] * a[i]) % hell;
		z += t;
		z = z % hell;
	}

	ce(z);
	debug(z);

}



Measured memory_bytes: 6772
#include<cstdio>
#include<algorithm>
inline bool issamesign(int a,int b){
    return (a<0&&b<0)||(a>0&&b>0);
}
int x[100000];
int main(){
    int n,k,tmin=1e9;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)scanf("%d",&x[i]);
    for(int i=0;i<=n-k;i++){
        int t;
        if(issamesign(x[i],x[i+k-1])) t=std::max(std::abs(x[i]),std::abs(x[i+k-1]));
        else t=std::abs(x[i])+std::abs(x[i+k-1])+std::min(std::abs(x[i]),std::abs(x[i+k-1]));
        tmin=std::min(tmin,t);
    }
    printf("%d",tmin);
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<iostream>

using namespace std;

int main()
{
	int R[200000];
	int N;
	int mini, maxi;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> R[i];
	}

	maxi = R[1] - R[0];
	mini = R[0];
	for (int i = 1; i < N; i++)
	{
		mini = min(mini, R[i-1]);
		maxi = max(maxi, R[i] - mini);
	}
	cout << maxi << endl;
	return 0;
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
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;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n - 1));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n - 1; j++) {
            cin >> a[i][j];
            a[i][j]--;
        }
    }
    map<P, int> toV;
    {
        int cnt = 0;
        for(int i = 0; i < n; i++) {
            for(int j = i + 1; j < n; j++) {
                toV[P(i, j)] = cnt++;
            }
        }
    }
    int N = n * (n - 1) / 2;
    vector<vector<int>> g(N);
    vector<int> h(N, 0); // 入次数
    for(int i = 0; i < n; i++) {
        for(int j = 1; j < n - 1; j++) {
            int u, v;
            u = toV[(i < a[i][j - 1] ? P(i, a[i][j - 1]) : P(a[i][j - 1], i))];
            v = toV[(i < a[i][j] ? P(i, a[i][j]) : P(a[i][j], i))];
            g[u].emplace_back(v);
            h[v]++;
        }
    }
    vector<int> topo;
    {
        stack<int> st;
        for(int i = 0; i < N; i++) {
            if(h[i] == 0) {
                st.push(i);
            }
        }
        while(st.size()) {
            int i = st.top();
            st.pop();
            topo.emplace_back(i);
            for(const int &j : g[i]) {
                h[j]--;
                if(h[j] == 0) {
                    st.push(j);
                }
            }
        }
    }
    if(topo.size() != N) {
        print(-1);
        return 0;
    }
    vector<int> dp(N, -INF);
    auto dfs = [&](auto &&dfs, int v) -> int {
        if(dp[v] != -INF) {
            return dp[v];
        }
        int res = 1;
        for(const auto &u : g[v]) {
            chmax(res, dfs(dfs, u) + 1);
        }
        return dp[v] = res;
    };
    int ans = 0;
    for(int i = 0; i < N; i++) {
        chmax(ans, dfs(dfs, i));
    }
    print(ans);
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const ll mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x,ll n,ll md){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%md,n/2,md);
    return (x*modexp((x*x)%md,n/2,md))%md;
}

int main(){
    fastio;
    //clock_t tm = clock();
    ll h;
    cin>>h;
    ll x=0,ans=0;
    while(h>0){
        ans=ans+ll(pow(2,x));
        h/=2;
        x++;
    }
    cout<<ans<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll         long long int 
#define pb         push_back
#define umap       unordered_map
#define mod        1000000007
#define all(x)     (x).begin(), (x).end()
#define rall(x)    (x).rbegin(), (x).rend()
#define MN(a,b,c)  min(a,min(b,c))
#define MX(a,b,c)  max(a,max(b,c))
#define pr1         pair<ll,ll>
#define F          first
#define S          second
#define mP         make_pair
#define f(i,n)     for(int i=0;i<n;i++)
#define f1(i,x,y)  for(int i=x;i<=y;i++)
#define f2(i,x,y)  for(int i=x;i>=y;i--)
#define yes        cout<<"YES"<<"\n"
#define no         cout<<"NO"<<"\n"
#define modsum(a,b)  ((a%mod)+(b%mod))%mod
#define modpro(a,b)  ((a%mod)*(b%mod))%mod
//__builtin_popcount(x)
//__builtin_parity(x)   =(number of set bits)%2
//__builtin_clz(x)      to count the number of leading  zeroes 
//__builtin_ctz(x)      to count the number of trailing zeroes 
//__gcd(a,b)
using namespace std;
int main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
ll n;cin>>n;
ll v[n];
f(i,n){cin>>v[i];}
ll prev=v[0],ans=0;
for(int i=1;i<n;i++)
{
  if(v[i]<=prev)
    {ans+=(prev-v[i]);}
  else
    {prev=v[i];}
}
cout<<ans;
}
  

Measured memory_bytes: 5192
package main

import "fmt"

const (
	NONE = iota
	FAIL
	OK
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	res := make([][]int, h)
	var prev, curr string
	for i := 0; i < h; i++ {
		res[i] = make([]int, w)
		fmt.Scan(&curr)
		for j := 1; j < w; j++ {
			if curr[j] == '#' {
				if curr[j-1] == '#' {
					res[i][j] = OK
					res[i][j-1] = OK
				} else {
					res[i][j] = FAIL
				}
				if len(prev) > 0 {
					if prev[j] == '#' {
						res[i-1][j] = OK
						res[i][j] = OK
					}
				}
			}
		}
		prev = curr
	}

	for _, l := range res {
		for _, r := range l {
			if r == FAIL {
				fmt.Println("No")
				return
			}
		}
	}
	fmt.Println("Yes")
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
#include <complex>

using namespace std;

typedef complex<double> P;

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)

double dot(P a, P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
int is_orthogonal(P a1, P a2, P b1, P b2) {
  return EQ( dot(a1-a2, b1-b2), 0.0 );
}
int is_parallel(P a1, P a2, P b1, P b2) {
  return EQ( cross(a1-a2, b1-b2), 0.0 );
}

double calcAngle(double a){
	if(a<=0){
		return a+=atan(1.0)*8;
	}
	else{
		return a;
	}
}

int main(){

	//P a=P(1,0);
	//P b=P(-1,1);
	//double tmp=asin((cross(a,b)/(abs(a)*abs(b))));

	int n;
	while(cin>>n&&n!=0){
		P ps[1001];
		bool fucked[1001];
		fill(fucked,fucked+1001,false);
		for(int i = 0; i < n; i++){
			double x,y;
			char ch;
			cin>>x>>ch>>y;
			ps[i]=P(x,y);
		}
		double minX=10000000;
		int initIdx;
		for(int i = 0; i < n; i++){
			// kousin
			if(ps[i].real()<minX){
				minX=ps[i].real();
				initIdx=i;
			}
		}
		// àÁÆàxÀWª¬³¢Æ±ë©çÔÉ©¯Ä¢­
		P bp=ps[initIdx];
		P pp=P(0,1);
		while(1){
			int idx;
			double minD=100000;
			for(int i = 0; i < n; i++){
				// pxðvZ
				double cc=(dot(ps[i]-bp,pp)/(abs(pp)*abs(ps[i]-bp)));
				if((cross(ps[i]-bp,pp)/(abs(pp)*abs(ps[i]-bp)))<0){
					cc=3.14-acos(cc);
					cc=3.14+cc;
				}
				else{
					cc=acos(cc);
				}

				if(minD>cc){
					minD=min(minD,cc);
					idx=i;
				}
			}
			if(fucked[idx])
				break;
			fucked[idx]=true;

			pp=ps[idx]-bp;
			bp=ps[idx];
		}
		int cnt=0;
		for(int i = 0; i < n; i++){
			if(!fucked[i])
				cnt++;
		}
		cout<<cnt<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);       
		int a = sc.nextInt();
        int b = sc.nextInt();
		int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int k = sc.nextInt();
	if(k>=e-a){System.out.println("Yay!");}
      else{System.out.println(":(");}
  }
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>

void run(void){
  int n;
  scanf("%d",&n);
  int *dp=(int *)calloc(n+1,sizeof(int));
  int i;
  for(i=1;i<=n;i++) dp[i]=1000000000+1;
  dp[0]=-1;
  int len=1;
  while(n--){
    int a;
    scanf("%d",&a);
    int l=0;
    int r=len;
    while(r-l>1){
      int m=(l+r)/2;
      if(dp[m]>=a){
	r=m;
      } else {
	l=m;
      }
    }
    dp[r]=a;
    if(r==len) len++;
  }
  printf("%d\n",len-1);
}

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



Measured memory_bytes: 2152
#include <stdio.h>
#include <string.h>
   
#define Max 500000
   
void insert(int); 
void find(int, int);
int successor(int);
void delete(int);
void Preorder(int);  
void Inorder(int);  
   
   
typedef struct{    /* p = parent, l = child, s = brother */
  int key;
  int p;
  int l[2];
} Node;
   
Node T[Max];
   
int main(){
  int i, n, k;
  char s[7];
   
  scanf("%d", &n);
   
  T[0].key = -1;
   
    
  for(i = 0; i < n; i++){
    T[i].l[0] = -1;
    T[i].l[1] = -1;
   
    scanf("%s", s);
   
    if(strcmp(s, "insert") == 0){
      scanf("%d", &T[i].key);
      insert(i);
    }
    else if(strcmp(s, "print") == 0){
      Inorder(0);
      printf("\n");
      Preorder(0);
      printf("\n");
    }
    else if(strcmp(s, "find") == 0){
      scanf("%d", &k);
      find(0, k);
    }
    else if(strcmp(s, "delete") == 0){
      scanf("%d", &k);
      delete(k);
    }
  }
     
  return 0;
}
   
   
void insert(int z){
  int x, y;
   
  y = -1;
  x = 0;
   
  if(z != 0){
    while(x != -1){
      y = x;
      if(T[z].key < T[x].key) x = T[x].l[0];
      else x = T[x].l[1];
    }
  }
   
  T[z].p = y;
   
  if(y != -1){
    if(T[z].key < T[y].key) T[y].l[0] = z;
    else T[y].l[1] = z;
  }
}
   
void find(int x, int k){
   
  if(x == -1) printf("no\n");
  else if(T[x].key == k) printf("yes\n");
  else if(k < T[x].key) find(T[x].l[0], k);
  else find(T[x].l[1], k);
}
   
int successor(int x){
  int y;
   
  if(T[x].l[1] != -1){
    x = T[x].l[1];
    while(T[x].l[0] != -1) x = T[x].l[0];
    return x;
  }
     
  else {
    y = T[x].p;
    while(y != -1 && x == T[y].l[1]){
      x = y;
      y = T[y].p;
    }
    return y;
  }
}
   
void delete(k){
  int x, y, z = 0;
   
  while(1){
    if(T[z].key == k) break;
    else if(k < T[z].key) z = T[z].l[0];
    else z = T[z].l[1];
  }
   
  if(T[z].l[0] == -1 || T[z].l[1] == -1) y = z;
  else y = successor(z);
   
  if(T[y].l[0] != -1) x = T[y].l[0];
  else x = T[y].l[1];
   
  if(x != -1) T[x].p = T[y].p;
   
  if(T[y].p != -1){
    if(y == T[T[y].p].l[0]) T[T[y].p].l[0] = x;
    else T[T[y].p].l[1] = x;
  }
   
  if(y !=  z) T[z].key = T[y].key;
   
}
   
   
void Preorder(int a){
  printf(" %d", T[a].key);
   
  if(T[a].l[0] != -1) Preorder(T[a].l[0]);
  if(T[a].l[1] != -1) Preorder(T[a].l[1]);
}
   
   
void Inorder(int a){
  if(T[a].l[0] == -1){
    printf(" %d", T[a].key);
    if(T[a].l[1] != -1) Inorder(T[a].l[1]);
  }
  else{
    Inorder(T[a].l[0]);
    printf(" %d", T[a].key);
    if(T[a].l[1] != -1) Inorder(T[a].l[1]);
  }
}

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

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

    for(int A=0;A <= N;A++){
        for(int B = 0;A + B <= N;B++){
            int C = Y - 10000 * A - 5000 * B;
            if(C == 1000 * (N - A - B)){
                cout << A << " " << B << " " << C / 1000 << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
def insertion_sort(N, A):
    print(*A)
    for i in range(1, N):
        key = A[i]
        j = i - 1
        while j >= 0 and A[j] > key:
            A[j+1] = A[j]
            j -= 1
        A[j + 1] = key
        print(*A)  

def main():
    N = int(input())
    A = list(map(int, input().split()))
    insertion_sort(N, A)

#insertion_sort(6, [5, 2, 4, 6, 1, 3])
main()



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

int yakusuu(int x){
  int count=0;
  int i=1;
  while(i*i<=x){
    if(x%i==0){
      if(i*i==x) count++;
      else count+=2;
    }
    i++;
  }
  return count;
}

int main() {
  int N;
  cin >> N;
  int count=0;
  for(int i=1;i<=N;i++){
    if(i%2==0) continue;
    if(yakusuu(i)==8) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
const int nmax=100005;
int par[nmax];
void init(int x){
  for(int i=0;i<x;i++){
    par[i]=i;
  }
}
int root(int x){
  if(par[x]==x){
    return x;
  }
  else{
    return par[x]=root(par[x]);
  }
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  if(x==y){
    return;
  }
  else{
    par[x]=y;
  }
}
int main(){
  int n,m;
  cin >> n >> m;
  init(n);
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
    p[i]--;
  }
  for(int i=0;i<m;i++){
    int x,y;
    cin >> x >> y;
    x--,y--;
    unite(x,y);
  }
  int cnt=0;
  for(int i=0;i<n;i++){
    if(root(i)==root(p[i])){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

const int MAX = 190;

int h, w;
char in[MAX][MAX];

void Answer(int ans){
  printf("%d\n", ans);
  exit(0);
}

int dp[MAX][MAX][MAX]; // col, srow, erow
int ndp[MAX][MAX][MAX];

void Save(){
  for(int k = 0;k < w;++k)
    for(int i = 0;i < h;++i)
      for(int j = i;j < h;++j)
        dp[k][i][j] = ndp[k][i][j];
}

int Eval(int srow, int erow, int col, int take){
  int border = srow + take - 1;
  return min(dp[col][srow][border],
             dp[col][border + 1][erow]);
}

int main(){
  scanf("%d%d", &h, &w);
  for(int i = 0;i < h;++i)
    scanf("%s", in[i]);

  // Init
  for(int i = 0;i < h;++i){
    for(int k = w - 1;k >= 0;--k){
      bool same = true;
      for(int j = i;j < h;++j){
        if(j > i && in[j][k] != in[j - 1][k])
          same = false;
        if(same){
          if(k == w - 1 || in[j][k] != in[j][k + 1])
            dp[k][i][j] = 1;
          else
            dp[k][i][j] = 1 + dp[k + 1][i][j];
        } else {
          dp[k][i][j] = 0;
        }
      }
    }
  }

  if(dp[0][0][h - 1] == w) Answer(0);

  for(int step = 1;;++step){
    for(int i = 0;i < h;++i){
      for(int k = w - 1;k >= 0;--k){
        int last = 0;
        for(int j = i;j < h;++j){
          int t1 = dp[k][i][j];
          if(k + t1 < w) t1 += dp[k + t1][i][j];

          for(;;){
            if(last + 1 >= (j - i + 1)) break;
            if(last == 0 ||
               Eval(i, j, k, last) <= Eval(i, j, k, last + 1))
              ++last;
            else break;
          }

          if(last > 0 && last < (j - i + 1)){
            relaxMax(t1, Eval(i, j, k, last));
          }

          ndp[k][i][j] = t1;
        }
      }
    }

    Save();
    if(dp[0][0][h - 1] == w) Answer(step);
  }

  return 0;
}


Measured memory_bytes: 53504
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,m,i,j,t,a[101];
    int flag=0;
    double temp,sum=0;
    scanf("%d %d",&n,&m);
    if(m>n||m<1||n>100)  return 0;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum=sum+(double)a[i];
    }
    temp=(1.0/(4.0*(double)m))*sum ;


    for(i=0;i<n-1;++i)
    {
        for(j=i+1;j<n;++j)
        {
            if(a[i]<a[j])
            {
                t=a[i];
                a[i]=a[j];
                a[j]=t;
            }
        }

    }
    for(j=0;j<m;++j)
    {
       if((double)a[j]<temp)
       {

           flag=1;
       }
   }
  
   if(flag!=0)  printf("No\n");
   else    printf("Yes\n");
}


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

int dp[3000][3000];

string getLCS(string& s, string& t, int len){

    string ans;
    int i=0,j=0;

    while(len>0){
        if(s[i]==t[j]){
            ans.push_back(s[i]);
            i++;
            j++;
            len--;
        }
        else{
            if(dp[i][j+1]>dp[i+1][j])
                j++;
            else
                i++;
        }
    }
    return ans;
}

int LCSlen(string& s, string& t, int i, int j){

    if(i>=s.length() || j>=t.length())
        return 0;

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

    if(s[i]==t[j]){
        return dp[i][j] = 1 + LCSlen(s,t,i+1,j+1);
    }
    else
        return dp[i][j] = max(LCSlen(s,t,i,j+1),LCSlen(s,t,i+1,j));

}

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

    for(int i=0;i<3000;i++)
        for(int j=0;j<3000;j++)
            dp[i][j] = -1;

    int len = LCSlen(s,t,0,0);
    cout<<getLCS(s,t,len);

    return 0;
}


Measured memory_bytes: 39228
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[][] a = new int[N][3]; // a, b, c
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < 3; j++) {
        a[i][j] = sc.nextInt();
      }
    }
    int[][] dp = new int[N][3];
    for (int i = 0; i < 3; i++) {
      dp[0][i] = a[0][i];
    }
    for (int i = 1; i < N; i++) {
      for (int j = 0; j < 3; j++) {
        if (j == 0) { // B->A or C->A
          dp[i][j] = Math.max(dp[i - 1][1], dp[i - 1][2]);
        } else if (j == 1) { // A->B or C->B
          dp[i][j] = Math.max(dp[i - 1][0], dp[i - 1][2]);
        } else { // A->C or B->C
          dp[i][j] = Math.max(dp[i - 1][0], dp[i - 1][1]);
        }
        dp[i][j] += a[i][j];
      }
    }
    int ans = dp[N - 1][0];
    for (int i = 1; i < 3; i++) {
      if (ans < dp[N - 1][i]) {
        ans = dp[N - 1][i];
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 99416
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int D, N; cin >> D >> N;
	int b = pow(100, D);

	if(N != 100) cout << b * N << endl;
	else cout << b * (N+1);

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPR(i,n) for(int i=n-1; i>=(int)(0); i--)
#define FOR(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define FORR(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); i--)
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()
//**関数リスト**//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) {
	ll keta = 1;
	while (F / 10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
ll gcd(ll x, ll y) {
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll isPrime(ll x) {
	ll i;
	if (x < 2) {
		return 0;
	}
	else if (x == 2) {
		return 1;
	}
	else if (x % 2 == 0) {
		return 0;
	}
	else {
		for (i = 3; i * i <= x; i += 2) {
			if (x % 1 == 0) {
				return 0;
			}
		}
		return 1;
	}
}
void eratos(vl isPrime) {
	//(注)isPrimeのサイズはN+1にする！実際にはmain内に配置して使用
	ll i, j;
	REP(i, isPrime.size()) {
		isPrime[i] = 1;
	}
	isPrime[0] = 0; isPrime[1] = 0;
	for (i = 2; i * i <= isPrime.size() - 1; i++) {
		if (isPrime[i] == 1) {
			j = i * 2;
			while (j <= isPrime.size() - 1) {
				isPrime[j] = 0;
				j = j + i;
			}
		}
	}
}
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
void bitSearch(ll n) {
	//実際にはコピーして中身を改変して使う
	ll i;
	REP(i, pow(2, n)) {
		ll p = i;
		REP(i, n) {
			cout << p % 2;
			p /= 2;
		}
		cout << endl;
	}
}

void bfs(ll now) {
	//中身は毎回書き換えて使用
	queue<ll> Q;
	Q.push(now);
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		//ll v=;
		//Q.push(v);
	}
}
//**定義場所**//
ll i, j, k, l, m, n;
ll N, M, K, H, W;
ll MOD = 1000000007;
ll ans = 1;
//***********//

int main() {
	ll A, B;
	cin >> A >> B;
	cout << max(max(A + B, A - B), A * B);
}

Measured memory_bytes: 256
N = int(input())
nums = list(map(int, input().split()))
ans = sorted(nums)
if nums == ans:
    print("YES")
else:
    count = 0
    for i, j in enumerate(nums, 1):
        if i != j:
            count += 1
            if count >= 3:
                print("NO")
                break
    else:
        print("YES")

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var arg string
	_, err := fmt.Scan(&arg)

	if err != nil {
		panic(err)
	}

	qnum, _ := strconv.Atoi(arg)

	if qnum%2 == 0 {
		ans := qnum
		fmt.Printf("%d\n", ans)
	} else {
		ans := 2 * qnum
		fmt.Printf("%d\n", ans)
	}

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
void mpdump(map<int, int> mp) {
  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    cout << "key = " << itr->first
        << ", val = " << itr->second << "\n";
  }
}
unsigned long long mpsum(map<int, int> mp){
  unsigned long long sum = 0;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    sum += itr->first * itr->second;
  }
  return sum;
}
int main() {
  map<int, int> mp;
  int n, q, tmp;
  scanf("%d", &n);
  for (int i = 0; i < n; i++){
    scanf("%d", &tmp);
    mp[tmp] += 1;
  }
//mpdump(mp);

  // 操作
  scanf("%d", &q);
  int b, c;
  unsigned long long sum = mpsum(mp);
  for (int i = 0; i < q; i++){
    scanf("%d %d", &b, &c);
//  cout << "b:" << b << " c:" << c << "\n";
//  mpdump(mp);
    sum += (unsigned long long)mp[b] * (c - b);
    mp[c] += mp[b];
    mp.erase(b);
    cout << sum << "\n";
  }
}


Measured memory_bytes: 9584
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

#if __has_include("debugger.cpp")
  #include "debugger.cpp"
#else
void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) > 0) cout << " ";
  print(std::forward<Tail>(tail)...);
}
# endif

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

ll MOD = 1'000'000'007;
ll powmod(ll v, ll x) {
  if (x == 0) return 1;
  if (x % 2 == 0) {
    ll tmp = powmod(v, x / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (powmod(v, x - 1) * v) % MOD;
  }
}

ll mod(ll x) {
  if (x < 0) {
    x += ((-x) / MOD + 1) * MOD;
  }
  x %= MOD;
  return x;
}

int main() {
  ll input(n, k);
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  sort(a.begin(), a.end(), greater<ll>());
  if (a[0] < 0) {
    if (k % 2 == 0) {
      sort(a.begin(), a.end());
    }
    ll m = 1;
    REP(i, k) {
      m *= a[i];
      m = mod(m);
    }
    print(m);
    return 0;
  }

  ll ans = 1;
  ll left = 0;
  ll right = n - 1;

  if (k % 2 == 1) {
    ans *= a[0];
    left++;
    k--;
  }

  for(ll i = 0; i < k; i += 2) {
    ll vleft = a[left] * a[left + 1];
    ll rleft = a[right] * a[right - 1];

    if (vleft < 0) vleft = 0;
    if (rleft < 0) rleft = 0;
    
    if (vleft == 0 && rleft == 0) {
      ll v = mod(a[left] * a[left + 1]);
      print(mod(ans * v));
      return 0;
    }

    if (vleft > rleft) {
      (ans *= vleft % MOD) %= MOD;
      left += 2;
    } else {
      (ans *= rleft % MOD) %= MOD;
      right -= 2;
    }
  }
  print(ans);
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, t;
    cin >> n >> t;
    vector <int> a(n);
    for (int i = 0; i < n; ++ i) cin >> a[i];
    set <int> st;
    int mx = 0, mxcnt = 0;
    for (int i = n - 1; i; -- i) {
        st.insert(a[i]);
        int nwdiff = *st.rbegin() - a[i - 1];
        if (nwdiff > mx) mx = nwdiff, mxcnt = 0;
        if (nwdiff == mx) ++ mxcnt;
    }
    cout << mxcnt << endl;
    return 0;
}

Measured memory_bytes: 5376
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    string s, t;
    cin >> s >> t;
    cout << t + s << "\n";
    return 0;
}

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

int main(){
  int A,B,sum=0;
  cin >> A >> B;
  while(A<=B){
    int C1,C2,C3,C4,C5,C;
    C=A;
    C1=C%10,C/=10;
    C2=C%10,C/=10;
    C3=C%10,C/=10;
    C4=C%10,C/=10;
    C5=C%10,C/=10;
    if(C5!=0 && C5==C1 && C4==C2){
      sum++;
    }
    A++;
  }
  cout << sum << endl;
}
      

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
A = [0] + list(map(int,input().split()))
A_ = A[:(N+1)]

for i in range(1,N+1):
    A_[i] -= i

AA = sorted(A_[1:])
#print(AA)

if N % 2 == 0:
    b = AA[N//2 - 1]
else:
    b = AA[(N-1)//2]

ans = 0
for i in range(N):
    ans += abs(AA[i]-b)

print(ans)

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

signed main(){
    vector<int> v;
    int a;
    while(true){
        cin>>a;if(a==0)break;
        v.push_back(a);
    }
    for(int i=0;i<v.size();i++)cout<<"Case "<<i+1<<": "<<v[i]<<endl;
}


Measured memory_bytes: 3232
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>
#include <omp.h>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;

const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
//const long long int pl=1000000;
long long int N,D,X,Y,res=0;

int main(){

    cout << fixed << setprecision(18);
    cin>>N;
    for(long long int i = 0; i < N; i++){
        res=10*res+7;
        res%=N;
        if(res==0){cout<<i+1<<endl;return 0;}
    }
    cout<<-1<<endl;
    
    
}



Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

void solve() {
	int n; string s; cin >> n >> s;
	if (n % 2) {
		cout << "No" << endl; return;
	}
	rep(i, n / 2) {
		if (s[i] != s[i + n / 2]) {
			cout << "No" << endl; return;
		}
	}
	cout << "Yes" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init();
	solve();
	stop
		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 main(){
  string s;
  cin>>s;
  if(s=="ABC"){
    cout<<"ARC"<<endl;
  }else{
    cout<<"ABC"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3636
import           Data.Bool
import           Data.List
import           Data.Ratio

main :: IO ()
main = do
    getLine
    as <- map read . words <$> getLine
    bs <- map read . words <$> getLine
    putStrLn $ bool "No" "Yes" $ solve as bs

solve :: [Int] -> [Int] -> Bool
solve as bs = operateNo as bs >= leastNo as bs

operateNo :: [Int] -> [Int] -> Int
operateNo as bs = sum bs - sum as

leastNo :: [Int] -> [Int] -> Int
leastNo as bs = sum $ zipWith (*-*) as bs
    where a *-* b = if a < b then ceiling ((b - a) % 2) else 0


Measured memory_bytes: 9596
#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>

#include <stack>
#include <queue>
// #include <deque>
#include <set>
#include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>

#include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;
typedef long long ll;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
typedef vector<vector<long long>> vvll;
typedef vector<vector<long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;

#define emplace_back pb
const char el = '\n';

/*
Edge cases:


*/

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

    int n,m; cin>>n>>m; cin.ignore();

    int evenways = 0;
    if (n>0) {
        evenways = (n*(n-1))/2;
    }
    int oddways = 0;
    if (m>0) {
        oddways = (m*(m-1))/2;
        
    }
    cout<<evenways+oddways<<el;

}

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

using namespace std;

typedef long long ll;
typedef pair<int,int>P;

#define F first
#define S second

int main(){
  int n;
  pair<string,P>s[105];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    cin>>s[i].F>>s[i].S.F;
    s[i].S.F*=-1;
    s[i].S.S=i+1;
  }

  sort(s,s+n);

  for(int i=0;i<n;i++){
    cout<<s[i].S.S<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define VFOR(x,a,b) for(int x=(a);x<((a)+(b));x++)
int main(){
  int N,K;vector<double> d;vector<double> dTable;
  cin >> N >> K;
  VFOR(i,0,N){
    int tmp;
    double tmp2; 
    cin >> tmp;
    //tmp2 = 0.5 * (tmp + 1);
    tmp2 = tmp+1;
    d.push_back(tmp2);
  }
  {double tmp = 0.0;
   VFOR(i,0,K){
    tmp+=d[i];
  } dTable.push_back(tmp);}
  VFOR(i,1,N-K){
    double tmp=dTable[i-1]+d[i+K-1]-d[i-1];
    dTable.push_back(tmp);
  }
  sort(dTable.begin(),dTable.end());
  cout << std::setprecision(15) << (dTable[N-K])/2;
  return 0;
}

Measured memory_bytes: 4848
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;

long long int fact(long long int k) {
	long long int sum = 1;
	for (long long int i = 2; i <= k; i++)
		sum *= i;

	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long int power(int a, int b) {
	long long int  ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}

vector<int> a;


int main()
{
	long long int n, cnt = 1;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int _a;
		cin >> _a;
		a.push_back(_a);
	}
		
	map<int, int> color_cnt;

	color_cnt[-1] = 3;

	for (int i = 0; i < n; i++) {
		color_cnt[a[i]]++;

		cnt *= color_cnt[a[i] - 1];
		color_cnt[a[i] - 1]--;
			
		cnt %= MOD;
	}


	cout << cnt << endl;


	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

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

const int INF = 100000002;
int n,m,q;
vi a,b,c,d;
int ans;

void dfs(vi A){
	if (A.size() == n+1){
		int now = 0;
		rep(i,q){
			if(A[b[i]]-A[a[i]] == c[i]) now += d[i];
		}
		ans = max(now,ans);
		return ;
	}

	A.push_back(A.back());
	while(A.back() <= m){
		dfs(A);
		A.back()++;
	}
}


int main(){
	cin >> n >> m >> q;
	a = b = c = d = vi (q);
	rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
	dfs(vi (1,1));
	cout << ans << endl;
}

Measured memory_bytes: 3632