akhauriyash/Code-Regression huggingface dataset:
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005

void solve()
{
	long double r;
	cin>>r;
	cout<<2*PI*r<<endl;
	return;
}
int main()
{
	DECIMAL(10);
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

Measured memory_bytes: 3800
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	/* N　問題数
	 * T1 .. . TN　解くのにかかる秒数
	 * M　ドリンク数
	 * P1 X1　問題番号、それを解くのにかかる秒数
	 * P2 X2
	 */
	int N;
  	cin >> N;
	vector<int> T(N);
  	int tsum = 0;	// tsum = T[i] の和
  	rep(i,N){
      	cin >> T[i];
        tsum += T[i];     
    }
  	int M;
  	cin >> M;
  	vector<int> P(M), X(M);
  	rep(i,M){cin >> P[i] >> X[i];}
  
  	// ここから本題
	int ans;
   	rep(i,M){
        ans = 0;
      	ans = tsum - T[P[i]-1] + X[i];      
    	cout << ans << endl; 
    }
    
  	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        x: [u64;4]
    }
    println!("{}", std::cmp::max(x[0]*x[1], x[2]*x[3]));
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    string S;
    cin >> S;
    rep(i, S.length()) { if (S[i] == '?') { S[i] = 'D'; }}
    cout << S << endl;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define i64 unsigned long long
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll mod = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}


int pow(ll x, ll y, ll mod){
    ll ret=1;
    for(;y;y>>=1,x=1ll*x*x%mod){
        if(y&1) ret=1ll*ret*x%mod;
    }
    return ret;
}

int main() {
    sonic();
    int n;
    R n;
    i64 total, l, r, i, t, next, prev, cnt=0;
    bool flg=true;
    priority_queue<pii> pq;
    vi A(n), B(n);
    rep(i, n)R A[i];
    rep(i, n){
        R B[i];
        pq.push({B[i], i});
    }
    while(0<pq.size()) {
        i = pq.top().second;
        pq.pop();
        if(B[i]==A[i])continue;
        next = (i + 1 + n) % n;
        prev = (n + i - 1) % n;
        total = B[next] + B[prev];
        t = (B[i] - A[i]) / total;
        cnt += t;
        if(t==0){flg=false;break;}
        B[i] = B[i] - t * total;
        pq.push({B[i], i});
    }
    if(flg)co(cnt);
    else co(-1);
}


Measured memory_bytes: 6896
<?php
fscanf(STDIN, "%d %d %d %d", $h, $w, $a, $b);
for ($y=0; $y < $h; $y++) {
    for ($x=0; $x < $w; $x++) {
        echo $x < $a && $y < $b || $x >= $a && $y >= $b ? '1' : '0';
    }
    echo "\n";
}
?>


Measured memory_bytes: 5624
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        
        String s=sc.next();
        int nums=s.length();
        String[] S=new String[nums];
        for(int i=0;i<nums;i++){
            S[i]=s.substring(i,i+1);
        }
        s="";
        Arrays.sort(S);
        for(int i=0;i<nums;i++){
            s+=S[i];
        }
        
        String t=sc.next();
        int numt=t.length();
        String[] T=new String[numt];
        for(int i=0;i<numt;i++){
            T[i]=t.substring(i,i+1);
        }
        t="";
        Arrays.sort(T);
        for(int i=0;i<numt;i++){
            t+=T[numt-i-1];
        }
        
        if(s.compareTo(t)<0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

vector<int> adj[200001], V[2];
int ans[200001], depth[200001], parent[200001];

void dfs(int c)
{
	V[depth[c]&1].push_back(c);
	for(auto n: adj[c]) if(parent[n]==-1) {
		parent[n]=c;
		depth[n]=depth[c]+1;
		dfs(n);
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N;
	cin>>N;
	for(int i=2;i<=N;i++) {
		int a, b;
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
		parent[i]=-1;
	}
	dfs(1);
	if(V[0].size()<V[1].size()) {
		int i=0;
		if(V[0].size()<=N/3) {
			for(auto v: V[1]) V[0].push_back(v);
			for(int v=3;v<=N;v+=3) ans[V[0][i++]]=v;
			for(int v=2;v<=N;v+=3) ans[V[0][i++]]=v;
			for(int v=1;v<=N;v+=3) ans[V[0][i++]]=v;
		}
		else {
			for(auto v: V[1]) V[0].push_back(v);
			for(int v=2;v<=N;v+=3) ans[V[0][i++]]=v;
			for(int v=3;v<=N;v+=3) ans[V[0][i++]]=v;
			for(int v=1;v<=N;v+=3) ans[V[0][i++]]=v;
		}
		
	}
	else {
		int i=0;
		if(V[1].size()<=N/3) {
			for(auto v: V[0]) V[1].push_back(v);
			for(int v=3;v<=N;v+=3) ans[V[1][i++]]=v;
			for(int v=2;v<=N;v+=3) ans[V[1][i++]]=v;
			for(int v=1;v<=N;v+=3) ans[V[1][i++]]=v;
		}
		else {
			for(auto v: V[0]) V[1].push_back(v);
			for(int v=2;v<=N;v+=3) ans[V[1][i++]]=v;
			for(int v=3;v<=N;v+=3) ans[V[1][i++]]=v;
			for(int v=1;v<=N;v+=3) ans[V[1][i++]]=v;
		}
	}
	for(int i=1;i<=N;i++) cout<<ans[i]<<' ';
	return 0;
}

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

int main() {
	string s;
	cin>>s;
	int i;
	if(s[0]=='L') {
		cout<<"No"<<endl;
		return 0;
	}
	for(i=1; i<s.size(); i++){
		if(i%2==1){      //even
			if(s[i]=='R'){
				break;
			}
		}
		else{               //odd
		if(s[i]=='L'){
			break;
		}
	}
	}
	if(i==s.size()) cout<<"Yes"<<endl;
	else            cout<<"No"<<endl;
	
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
//#include<queue>
//#define d double
#define ll long long
#define ull unsigned long long
using namespace std;
const int maxn=1e5+233;
int a[maxn];
int i,j,k,n,m;int p;

int ra,fh;char rx;
inline int read(){
	rx=getchar(),ra=0,fh=1;
	while(rx<48)rx=='-'&&(fh=-1),rx=getchar();
	while(rx>47)ra=ra*10+rx-48,rx=getchar();return ra*fh;
}



int main(){
	int n=read(),c=read(),k=read();
	for(i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+1+n);
	
	int l,r,mid,ans=0;
	for(i=1;i<=n;i=l+1){
		l=i,r=min(n,i+c-1);
		while(l<r)if(a[mid=(l+r+1)>>1]-a[i]>k)r=mid-1;else l=mid;
		ans++;
	}printf("%d\n",ans);
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	int L,A,B,C,D;
	int need,need2;
	scanf("%d%d%d%d%d",&L,&A,&B,&C,&D);
	need=(A+C-1)/C;
	need2=(B+D-1)/D;
	if(need2>need)need=need2;
	printf("%d\n",L-need);
	return 0;
}

Measured memory_bytes: 596
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    long long X;
    cin >> X;
    long long deposit = 100;
    int count = 0;
    while(true)
    {
        deposit *= 1.01;
        count++;
        if(deposit >= X)
        {
            break;
        }
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define f(i,s,e) for(ll i=s;i<e;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
int vis[100005],dp[100005];
vector<int> v[100005];

void dfs(int node){
    vis[node]=1;

    for(auto it:v[node]){
        if(vis[it]==0)
            dfs(it);
    }

    dp[node]=0;
    for(auto it:v[node])
        dp[node]=max(dp[node],dp[it]);

    dp[node]++;
}

int main(){
    fast;

    int x,y,n,m,ans=-1;
    cin>>n>>m;

    while(m--){
        cin>>x>>y;
        v[x].pb(y);
    }    

    for(int i=1;i<=n;i++)
        if(vis[i]==0)
            dfs(i);

    for(int i=1;i<=n;i++){
        //cout<<dp[i]<<" ";
        ans=max(ans,dp[i]);
    }

    cout<<ans-1;
}


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

int main() {
    while (true) {
        int m, f, r;
        cin >>m >>f >>r;
        if ((-1==m)&&(-1==f)&&(-1==r))
            break;
        if ((-1==m)||(-1==f))
            cout <<'F' <<endl;
        else if (80<=m+f)
            cout <<'A' <<endl;
        else if (65<=m+f)
            cout <<'B' <<endl;
        else if (50<=m+f)
            cout <<'C' <<endl;
        else if (30<=m+f)
            if (50<=r)
                cout <<'C' <<endl;
            else
                cout <<'D' <<endl;
        else
            cout <<'F' <<endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;

void solve(long long N, vector<long long> A){
	vector<long long> B(N);
	for(int i = 0; i < N; ++i) {
		B[A[i]]++;
	}
	long long res = 1LL;
	for(int i = N - 1; i >= 0; i -= 2) {
		long long e;
		if(i == 0) {
			e = 1;
		} else {
			e = 2;
		}
		if(B[i] == e) {
			res = res * e % MOD;
		} else {
			res = 0;
		}
	}
	cout << res << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define endl '\n'
ll binpow(ll a, ll b){
    ll ans=1;
    while(b){
        if(b&1){
            ans*=a;ans%=mod;
        }
        a*=a;
        a%=mod;
        b/=2;
    }
    return ans;

}
ll fact[2001];
void calcFactorial(ll n){
    fact[0]=1;
    for(ll i=1; i<=n; ++i){
        fact[i]=i*fact[i-1];
        fact[i]%=mod;
    }
}
ll ncr(ll n, ll r){
    ll ans=fact[n];
    //cout<<fact[n]<<" ";
    ll inverse= (fact[r]*fact[n-r])%mod;
    ans*=binpow(inverse, mod-2);
    //ans+=mod;
    ans%=mod;
    //cout<<ans<<endl;
    return ans;
    
}
int main() {

    fast
    ll n,k;
    cin>>n>>k;
    calcFactorial(2000);
    
    for(ll i=1; i<=k; ++i){
        if(n-k+1<i){
            cout<<0<<endl;continue;
        }
        ll ans=(ncr(n-k+1, i)*ncr(k-1, i-1))%mod;
        cout<<ans<<endl;
    }
    

#ifndef ONLINE_JUDGE
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;++i)
#define fos(j,i,n) for(int j=i;j<n;++j)
#define N 100004
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define M 1000000007
#define ll long long
#define abs(x) (x<0?(-x):x)
#define dis(k) cout << k << endl
#define forr(i,n) for(int i= n-1;i>=0;--i)
#define min(x,y) (x<y?x:y)
#define max(x,y) (x>y?x:y)
#define dbg(vari) cerr<<#vari<<" = "<<(vari)<<endl;
 
int main(){
	fast;
	int t;
  t=1;
	//cin >> t;
	while(t--){
		int h,a;
   		cin >> h >> a;
		if(h%a==0)
		dis(h/a);
		else
		dis((h/a)+1);
	}
	return 0;
}


Measured memory_bytes: 256
def is_red_bigger_than_blue(color_list)
  red_count = color_list.count("R")
  blue_count = color_list.count - red_count 

  if red_count > blue_count 
    puts "Yes"
  else 
    puts "No"
  end 
end 

input = readlines.map &:chomp

color_list = input[1].split("")

is_red_bigger_than_blue(color_list)


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    rep(i, N) {
        cin >> C[i];
        rep(j, M) {
            cin >> A[i][j];
        }
    }
    ll ans = -1;
    for (int i = 0; i < (1<<N); i++) {
        ll tmp = 0;
        vector<int> memo(M);
        for (int j = 0; j < N; j++) {
            if (i&(1<<j)) {
                tmp += C[j];
                for (int k = 0; k < M; k++) {
                    memo[k] += A[j][k];
                }
            }
        }
        bool flag = true;
        for (int j = 0; j < M; j++) {
            if (memo[j] < X) {
                flag = false;
                break;
            }
        }
        if (flag) {
            if (ans == -1) ans = tmp;
            ans = min(ans, tmp);
        }
    }
    cout << ans << endl;
}


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

int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  if(a==b){
    printf("a == b\n");
  }else if(a<b){
    printf("a < b\n");
  }else if(b<a){
    printf("a > b\n");
  }
  return 0;
}



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

#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL)
#define int long long
#define endl '\n'

using namespace std;

const int N = 2e5 + 77;
int x , y ;
int C[N];
int32_t main()
{
    fast;
    int a , b ,n ; cin >> a >> b >> n;
    vector< vector<int> > A(a,vector<int> (b,0));
    
    for(int i = 1; i <= n ; ++i) cin >> C[i];
    int idx = 1;

    for(int i = 0 ; i < a ; ++i){
        for(int j = 0 ;j < b ; ++j){
            if(C[idx] > 0){
                A[i][j] = idx;
                C[idx]--;
            }
            if(C[idx]==0) idx++;
        }
    }

    for(int i = 0 ; i < a ; ++i){
        if(i%2) reverse(A[i].begin(),A[i].end());
    }
    for(int i = 0; i < a; ++i){
        for(int j = 0 ;j < b; ++j){
            cout << A[i][j] << ' ';
        }cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using namespace std;
using i64 = int64_t;

constexpr i64 INF = 1010000000000000017LL;

#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(int i=(int)(start);i<(int)(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(int i=(int)(start);i>(int)(end);--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

#define v(T) vector<T>
#define vv(T) v(v(T))
#define vvv(T) v(v(v(T)))
typedef v(int) vi;

#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >

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

template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  int D;
  cin >> D;

  v(int) C(26);
  cin >> C;

  v(v(int)) S(D, v(int)(26));
  cin >> S;

  v(int) T(D);
  v(int) X(26, 0);

  rep(i, D) {
    i64 tmp = -1 * INF;
    rep(j, 26) {
      if(S[i][j] - C[j] * (X[j] + 1) > tmp) {
        T[i] = j + 1;
        tmp = S[i][j] - C[j] * (X[j] + 1);
      }
    }
    cout << T[i] << "\n";
    rep(j, 26) {
      if(T[i] - 1 == j){
        X[j] = 0;
      }
      else{
        X[j]++;
      }
    }
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  Main();
}

Measured memory_bytes: 3712
open Scanf
open Printf

let rec for_iter a b f = if a >= b then () else (f a; for_iter (a+1) b f)
let rec for_iterr a b f = if a <= b then () else (f a; for_iter (a-1) b f)
let rec for_iters a b s f = if (a-b >= 0) <> (s >= 0) then () else (f a; for_iter (a+s) b f)

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)
let read_ints_arr n = Array.init n (fun _ -> read_int ())
let read_ints_arr_ref n = Array.init n (fun _ -> ref (read_int ()))

let () =
  let x = read_int () in
  let a = read_int () in
  let b = read_int () in
  printf "%d\n" ((x - a) mod b)


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
#define INF 1e18
#define N 100005
int n,m,s,t;
long long f=1e15;
long long ans[N];
struct node//学到老，回到老
{
	struct Edge
	{
		int next;
		int to;
		long long dis;
	}edge[N*2+5];
	
	int cnt;
	int head[N*2],vis[N];
	long long dis[N];
	void add(int from,int to,long long dis)
	{
		edge[++cnt].next=head[from];
		edge[cnt].to=to;
		edge[cnt].dis=dis;
		head[from]=cnt;
	}
	
	queue<int >Q;
	
	void SPFA(int s)
	{
		for(int i=1;i<=n;i++)
		dis[i]=INF;
		memset(vis,0,sizeof vis);
		Q.push(s);
		vis[s]=1;
		dis[s]=0;
		while(!Q.empty())
		{
			int x=Q.front();
			Q.pop();
			vis[x]=0;
			for(int i=head[x];i;i=edge[i].next)
			{
				int to=edge[i].to;
				if(dis[to]>dis[x]+edge[i].dis)
				{
					dis[to]=dis[x]+edge[i].dis;
					if(!vis[to]) Q.push(to),vis[to]=1;
				}
			}
		}
	}
}G1,G2;
int main()
{
	scanf("%d %d %d %d",&n,&m,&s,&t);
	int u,v;
	long long a,b;
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d %lld %lld",&u,&v,&a,&b);
		G1.add(u,v,a);
		G1.add(v,u,a);
		G2.add(u,v,b);
		G2.add(v,u,b);
	}
	G1.SPFA(s);
	G2.SPFA(t);
	ans[n+1]=INF;
	for(int i=n;i>=1;i--)
	ans[i]=min(ans[i+1],G1.dis[i]+G2.dis[i]);
	for(int i=1;i<=n;i++)
	printf("%lld\n",f-ans[i]);
 } 

Measured memory_bytes: 12800
const check_play_days = (amount) => amount < 0 ? '-1': amount
const calc_play_days = (duration,works) => check_play_days(duration - works.reduce((p,n)=>p+n))
const [[holi_days,works_amount],works] = require('fs').readFileSync('/dev/stdin','utf8').split('\n').map(a=>a.split(' ').map(e=>parseInt(e.replace(/\r?\n/g,''))))
works_amount !== works.length ? console.err('error') : console.log(calc_play_days(holi_days,works))

Measured memory_bytes: 32620
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == '?': break
    elif op == '+':print(a+b)
    elif op == '-':print(a-b)
    elif op == '*':print(a*b)
    elif op == '/':print(a//b)


Measured memory_bytes: 5596
import java.math.*;
import java.util.*;
import static java.lang.System.*;

public class Main {
	//初期フィールド・メソッド---------------------------------------------
	static Scanner sc = new Scanner(System.in);
	static int min(int... ar) {Arrays.sort(ar); return ar[0];}
	static int max(int... ar) {Arrays.sort(ar); return ar[ar.length-1];}
	//------------------------------------------------------------


	//フィールド追加場所-----------------------------------------------
	//------------------------------------------------------------


	//メソッド追加場所------------------------------------------------
	//------------------------------------------------------------


	//mainメソッド---------------------------------------------------
	public static void main(String[] args) {
		while (true) {
			int n = sc.nextInt();
			if (n == 0) break;
			
			int[] ar = new int[10];
			for (int i=0; i<n; i++) ar[sc.nextInt()]++;
			
			for (int i=0; i<10; i++) {
				if (ar[i] == 0) out.println("-");
				else {
					for (int j=0; j<ar[i]; j++) {
						out.print("*");
					}
					out.println();
				}
			}
		}
	}
	//------------------------------------------------------------
}


Measured memory_bytes: 63996
while (st=gets) != nil do
  st = st.split(',').map! {|x| x=x.to_i}
  b = st.pop.to_f
  a = st.pop.to_f
  sum = 0
  i = 0
  st.each {|x| sum += x}
  a = sum*a/(a+b)
  while a>0  do
    a -= st.shift
    i += 1
  end
  p i
end

Measured memory_bytes: 6108
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

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

  string s;
  cin >> s;

  const int n = s.size() - 2;
  printf("%c%d%c\n", s[0], n, s[n + 1]);

  return 0;
}


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


#define CI cin >>
#define CO cout <<
#define E << endl;
#define F(i,max) (for(int i = 0;i < max;++i))

using namespace std;


int main(void) {
	int m = 0;
	int n = 0;

	CI n >> m;

	vector<vector<int>> A(n, vector<int>(m, 0));
	vector<int> b(m, 0);
	vector<int> result(n, 0);

	for (int i = 0; i < n; i++) {		
		for (int j = 0; j < m; j++) {
			CI  A[i][j];
		}
	}

	for (int i = 0; i < m; i++) {
		CI b[i];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			result[i] += A[i][j] * b[j];
		}
	}

	for (int i = 0; i < n; i++) {
		CO result[i] E
	}

}

Measured memory_bytes: 3160
n, k = map(int, input().split())
a = []
count = 0

for i in range(n):
    a.append(list(map(int, input().split())))
a = sorted(a, key = lambda x: x[0])
i = 0
while count < k:
    count += a[i][1]
    ans = a[i][0]
    i += 1
print (ans)


Measured memory_bytes: 29912
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;

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


int main() {
	int n;
	cin >> n;
	VI D(n);
	REP(i, n) {
		cin >> D[i];
	}
	int m;
	cin >> m;
	VI T(m);
	REP(i, m) {
		cin >> T[i];
	}

	SORT(D);
	SORT(T);

	int p = 0;
	REP(i, m) {
		while (true) {
			if (T[i] == D[p]) {
				p++;
				break;
			}
			else if (T[i] > D[p]) {
				p++;
			}
			else {
				cout << "NO" << endl;
				return 0;
			}
		}
	}

	cout << "YES" << endl;



	


	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000000
#define ll long long


int main(){
    vector<bool> primes_vec(MAX+1,true);
    vector<ll> div_vec(MAX+1,true);
    ll div=2;
    for(ll i=2;i<=MAX;i++){
        div_vec[i]=i;
    }
    while(div*div<=MAX){
        for(ll cnt=div*2; cnt<=MAX; cnt+=div){
            primes_vec[cnt]=false;
            div_vec[cnt]=min(div_vec[cnt],div);
        } 
        div++;
        for(;!primes_vec[div];div++){}
    }

    //unordered_set<ll> primes;
    vector<ll> primes;
    vector<ll> factor(MAX+1,0);
    for(ll i=2;i<=MAX;i++){
        if(primes_vec[i]){
            primes.push_back(i);
        }
    }
    ll n;
    cin >> n;
    for(ll i=0;i<n;i++){
        ll a;
        cin >> a;
        ll maxp=0;
        while(a>1){
            ll p = div_vec[a];
            factor[p]++;
            while(a%p==0)a/=p;
        }
    }
    ll fmax = 0;
    ll fmin = INFINITY;
    for(ll j=0; j<size(primes); j++){
        ll p = primes[j];
        ll fp = factor[p];
        if(fp>0){
            fmax = max(fmax,fp);
        }
    }
    if(fmax<=1){
        cout << "pairwise coprime";
    }else if(fmax<n){
        cout << "setwise coprime";
    }else{
        cout << "not coprime";
    }
}

Measured memory_bytes: 19876
#include <stdio.h>
#include <string.h>

int main(void){
  int i,j,k;
  int n,m,val,a[7],b[7];
  int dp[8][1001];

  while(scanf("%d",&n), n){
    for(i=0;i<n;i++){
      scanf("%d%d",&a[i],&b[i]);
    }

    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;

    //J[hÌÔ
    for(i=0;i<n;i++){
      //v_
      for(j=0;j<=1000;j++){
        //iÔÚÌJ[hð½gp·é©
        for(k=0;k<=b[i];k++){
          if(j+a[i]*k>1000) continue; //1001ÈãÍ¢çÈ¢ÌÅ³
          dp[i+1][j+a[i]*k] += dp[i][j];
        }
      }
    }

    scanf("%d",&m);
    while(m--){
      scanf("%d",&val);
      printf("%d\n",dp[n][val]);
    }
  }

  return 0;
}

Measured memory_bytes: 0
from collections import deque
class BellmanFord():
    def __init__(self, N):
        self.N = N
        self.edges = []
        self.to = [[] for _ in [0]*self.N]
        self.rev = [[] for _ in range(self.N)]

    def add(self, u, v, d, directed=False):
        """
        u = from, v = to, d = cost
        directed = Trueのとき、有向グラフである。
        """
        if directed is False:
            self.edges.append([u, v, d])
            self.edges.append([v, u, d])
            self.to[u].append(v)
            self.rev[v].append(u)
        else:
            self.edges.append([u, v, d])
            self.to[u].append(v)
            self.rev[v].append(u)

    def BellmanFord_search(self, s):
        """
        :param s: 始点
        :return: d[i] 始点sから各点iまでの最短経路
        """
        d = [float('inf') for i in range(self.N)]
        d[s] = 0
        numEdges = len(self.edges)
        while True:
            update = False
            for i in range(numEdges):
                e = self.edges[i]
                # e: 辺iについて [from,to,cost]
                if d[e[0]] != float("inf") and d[e[1]] > d[e[0]] + e[2]:
                    d[e[1]] = d[e[0]] + e[2]
                    update = True
            if not update:
                break
        return d

    def check_reachable(self, start, to=True):
        if to:
            edges = self.to
        else:
            edges = self.rev
        visited = [0 for _ in range(self.N)]
        visited[start] = 1
        reachable = set()
        dq = deque([start])
        popleft, append = dq.popleft, dq.append

        while dq:
            current = popleft()
            reachable.add(current)
            for dest in edges[current]:
                if not visited[dest]:
                    visited[dest] = 1
                    append(dest)

        return reachable

    def BellmanFord_negative_bool(self, start, numNodes):
        # 負の閉路の検出, Trueなら負の閉路が存在する
        d = [float('inf') for _ in range(self.N)]
        d[start] = 0
        numEdges = len(self.edges)
        for i in range(numNodes):
            for j in range(numEdges):
                e = self.edges[j]
                if d[e[1]] > d[e[0]] + e[2]:
                    d[e[1]] = d[e[0]] + e[2]
                    if i == numNodes-1:
                        return True, d
        return False, d


N, M, P = map(int, input().split())
graph = BellmanFord(N)
for i in range(M):
    a, b, c = map(int, input().split())
    graph.add(a-1, b-1, -(c-P), True)

v_set = graph.check_reachable(0) & graph.check_reachable(N-1, False)
graph.edges = [edge for edge in graph.edges if edge[0] in v_set and edge[1] in v_set]
hasNegatibeCycle, dists = graph.BellmanFord_negative_bool(0, N)
if hasNegatibeCycle:
    print(-1)
else:
    print(max(0, -dists[-1]))

Measured memory_bytes: 55400
using System;

namespace ConsoleApp__ITP1_2_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            var a = Int32.Parse(input[0]);
            var b = Int32.Parse(input[1]);
            var c = Int32.Parse(input[2]);

            if(a<b & b < c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

int main(){
    int N; cin>>N;
    int B[N-1];
    for(int i=0; i<=N-2; i++) cin>>B[i];

    long long ans=B[0];
    for(int i=1; i<=N-2; i++){
        ans += min(B[i-1], B[i]);
    }
    ans += B[N-2];
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;

int main(){
 
ll n;
cin>>n;
ll ans;
ans = n*(n-1)/2;
cout<<ans<<endl;
return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;

  if(a == 1 && b == 1 && c == 0){
    cout << "Open" << endl;
  }else if(a == 0 && b == 0 && c == 1){
    cout << "Open" << endl;
  }else{
    cout << "Close" << endl;
  }

  return 0;
}





Measured memory_bytes: 3100
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 3001
#define MOD 1000000007

typedef long long int lli;

int des(const void* a, const void* b){
    if (*(long long int*)a > *(long long int*)b) return -1;
	if (*(long long int*)a < *(long long int*)b) return 1;
	return 0;
}

int main(void) {
  lli a[1001], b[1001], c[1001];
  lli x, y, z, k;
  scanf("%d %d %d %d", &x, &y, &z, &k);
  rep(i, 0, x) {
    scanf("%lld", &a[i]);
  }
  rep(i, 0, y) {
    scanf("%lld", &b[i]);
  }
  rep(i, 0, z) {
    scanf("%lld", &c[i]);
  }

  // qsort(a, x, sizeof(lli), des);
  // qsort(b, y, sizeof(lli), des);
  // qsort(c, z, sizeof(lli), des);

  // aとbの全組み合わせを格納
  lli ab[1000001];
  lli ab_size = 0;
  rep(ai, 0, x) {
    rep(bi, 0, y) {
      ab[ab_size++] = a[ai] + b[bi];
    }
  }

  qsort(ab, ab_size, sizeof(lli), des);

  lli abc[3000001];
  lli abc_size = 0;
  rep(abi, 0, min(3000, ab_size)) {
    rep(ci, 0, z) {
      abc[abc_size++] = ab[abi] + c[ci];
    }
  }

  qsort(abc, abc_size, sizeof(lli), des);

  rep(i, 0, k) {
    printf("%lld\n", abc[i]);
  }

  
  return 0;
}


Measured memory_bytes: 54920
n,m=map(int,input().split())
l1,r2=1,2*m+1
if m%2:
  r1=m
else:
  r1=m+1
l2=r1+1
for i in range(m//2):
  print(l1,r1)
  print(l2,r2)
  l1+=1
  l2+=1
  r1-=1
  r2-=1
if m%2:
  print(l2,r2)

Measured memory_bytes: 9208
#include <iostream>
#include <string>
#include <algorithm>

#define INF 1000000000

using namespace std;

int main() {
    int ans = INF;
    string s;
    cin >> s;
    for (int i = 0; i <= s.size() - 3; ++i) ans = min(ans, abs((s.at(i) - '0') * 100 + (s.at(i + 1) - '0') * 10 + (s.at(i + 2) - '0') - 753));
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int aux = n;
    vector<int> v;
    while(n-- > 0){
        int a;
        cin >> a;
        v.push_back(a);
    }
    int sumaa = 0;
    int sumab = 0;
    int cont = 1;
    for(int i = 0;i<aux;i++){
         vector<int>::iterator result;
         result = max_element(v.begin(), v.end());
         if(cont % 2 != 0){
            sumaa += *result;
         } else {
            sumab += *result;
         }
         v.erase(result);
         cont++;
    }
    cout << sumaa - sumab;
    return 0;
}



Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N,M = II()
if M==N:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38256
n,m=map(int,input().split())
a=[0]+list(map(int,input().split()))
from collections import defaultdict
mods=defaultdict(int)
mods[0]=1
for i in range(1,len(a)):
  a[i]=a[i-1]+a[i]%m
  mods[a[i]%m]+=1
ans=0
for v in mods.values():
  if v>1:
    ans+=v*(v-1)//2
print(ans)

Measured memory_bytes: 14368
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

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

    int R, S, P;
    cin >> R >> S >> P;

    string T;
    cin >> T;

    map<char, int> m;
    m['r'] = P;
    m['s'] = R;
    m['p'] = S;

    vector<int> a;
    for(int i=0; i<N; i++){
        a.push_back(0);
    }

    int sum = 0;
    for(int i=0; i<N; i++){
        if(a[i] == 0){
            sum += m[T[i]];

            if(i+K < N && T[i] == T[i+K]){
                a[i+K] = 1;
            }
        }

    }

    cout << sum;

    return 0;
}

Measured memory_bytes: 1020
#include <iostream>

using namespace std;

int main()
{
  int n; cin >> n;
  int cnt = 0;
  for (int i = 105; i <= n; i = i + 2)
  {
    int c = 0;
    for (int j = 1; j <= i; j++)
    {
      if (i % j == 0) c++;
    }
    if (c == 8) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, 0, N) cin >> S[i];

    ll ans = 0;
    rep(A, 0, N)
    {
        int B = 0;
        bool ok = true;
        rep(i, 0, N) rep(j, 0, i)
        {
            if (S[(i + A) % N][(j + B) % N] != S[(j + A) % N][(i + B) % N])
            {
                ok = false;
                break;
            }
        }
        if (ok)
        {
            ++ans;
        }
    }
    cout << ans * N << endl;
}


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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  string s; cin >> s;
  rep(i, sz(s))cout << "x";
  cout << endl;
  return 0;
}


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

int main(){
  int n;
  cin >>n;
  double x[n];
  string u[n];
  rep(i,n) cin >>x[i] >>u[i];
  double sum = 0;
  rep(i,n){
    if(u[i] == "BTC") sum += x[i]*380000;
    else sum += x[i];
  }
  cout << fixed << setprecision(9) << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())

b = []
for i in range(N):
    a = str(input())
    if a in b:
        print ('No')
        sys.exit()
        b += [a]
    elif i != 0:
        if str(b[i-1])[-1] == a[0]:
            pass
        else:
            print ('No')
            sys.exit()
        b += [a]
    else:
        b += [a]
print ('Yes')

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

using namespace std;
typedef long long ll;


ll N;
ll A[200000];



int main(){
	cin >> N;
	
	ll all_xor = 0;
	for ( int i = 0; i < N; i++ ){
		cin >> A[i];
		all_xor ^= A[i];
	}
	
	/*
		評価値 = Axor + Bxor
		       = Axor + (all_xor ^ Axor)
		all_xor のビットが1になっている部分は、評価に影響しない
		all_xor のビットが0になっている部分は、できるだけ1にしたい
		Axor & ~all_xor を最大化する
		
		Axorを探すときに、(a0, a1, a2, a3...) の中から選ぶのと、(a0, a1^a0, a2, a3... )の中から選ぶのは同じことである
	*/
	ll Axor = 0;
	for ( int b = 59; b >= 0; b-- ){
		ll m = (1LL) << b;
		if ( all_xor & m )
			continue;
		
		for ( int i = 0; i < N; i++ ){
			if ( A[i] & m ){
				ll tmp = A[i];
				if ( (Axor & m) == 0 )
					Axor ^= tmp;
				
				for ( int j = 0; j < N; j++ )
					if ( A[j] & m )
						A[j] ^= tmp;
				
				break;
			}
		}
	}
	
	cout << (Axor + (all_xor^Axor)) << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
	int A,B,C,a;
	scanf("%d%d%d",&A,&B,&C);
	a=A;
	A=B;
	B=a;
	a=A;
	A=C;
	C=a;
	printf("%d %d %d",A,B,C);
	return 0;
}


Measured memory_bytes: 1732
import sys

input = lambda: sys.stdin.readline().rstrip()

N = int(input())
arr = [tuple(map(int, input().split())) for _ in range(N)]

l = list(map(lambda x: x[0], arr))
h = list(map(lambda x: x[1], arr))
l.sort()
h.sort()

ml = l[N // 2] if N & 1 else (l[N // 2 - 1] + l[N // 2])
mh = h[N // 2] if N & 1 else (h[N // 2 - 1] + h[N // 2])

print(mh - ml + 1)


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

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    int s, w;
    cin >> s >> w;
    if(w>=s) {
        cout << "unsafe\n";
    }
    else {
        cout << "safe\n";
    }
}

int main() {_
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3640
import sys,math,copy,queue,itertools,bisect
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))

s = input()
if '7' in s:
    print ('Yes')
else:
    print ('No')

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

int main() {
    ll N, K;
    cin >> N >> K;

    ll ans = (N / K) * (N / K) * (N / K);

    if (K % 2 == 0)
        ans += ((N + (K / 2)) / K) * ((N + (K / 2)) / K) * ((N + (K / 2)) / K);

    cout << ans << endl;

    return 0;
}

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

long long int calc(long long int h){
    if(h == 1) return 1;
    else return 1 + 2 * calc(h / 2);
}

int main() {
    long long int h;
    cin >> h;
    cout << calc(h) << endl;
    return 0;
}

Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict

geta = lambda fn: list(map(fn, input().split()))
gete = lambda fn: fn(input())

N = gete(int)
a = geta(int)

b = [-1 if 2 * i <= N else a[i - 1] for i in range(N + 1)]

i = N + 1
while i > 1:
    i -= 1
    if b[i] != -1:
        continue

    if sum([b[j] for j in range(i * 2, N + 1, i)]) & 1 == a[i - 1]:
        b[i] = 0
    else:
        b[i] = 1

bm = list(filter(lambda i: b[i] == 1, range(1, N + 1)))

print(len(bm))
if len(bm) > 0:
    print(*bm, sep=" ")

Measured memory_bytes: 14136