akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
//#include <intrin.h>  //AtCoder (gcc) 上ではこれがあると動かない。__popcnt用のincludeファイル。
using namespace std;
using Graph = vector<vector<int>>;

typedef long long ll;
typedef long double ld;


#define int long long
#define rep(i, n) for(long long i = 0; i < (n); i++)
#define sqrt(d) pow((long double) (d), 0.50)

const int INF = 2e9;
const ll large_P = 1e9 + 7;



//繰り返し2乗法
//N^aの、Mで割った余りを求める。
ll my_pow(ll N, ll a, ll M) {
	ll tempo;
	if (a == 0) {
		return 1;
	}
	else {
		if (a % 2 == 0) {
			tempo = my_pow(N, a / 2, M);
			return (tempo * tempo) % M;
		}
		else {
			tempo = my_pow(N, a - 1, M);
			return (tempo * N) % M;
		}
	}
}



//N_C_a を M で割った余り
ll my_combination(ll N, ll a, ll M) {
	ll answer = 1;

	rep(i, a) {
		answer *= (N - i);
		answer %= M;
	}

	rep(i, a) {
		answer *= my_pow(i + 1, M - 2, M);
		answer %= M;
	}

	return answer;
}



ll my_gcd(ll& a, ll& b) {
	if (b == 0) return a;
	ll temp = a % b;
	return my_gcd(b, temp);
}



// long long型 n を、base 進法での、i 桁目の数が入った vector にする。
void ll_to_vector(ll base, ll n, vector<ll>& v) {
	ll tempo = n;

	ll n_digit = floor(log10(n) / log10(base)) + 1;
	v.assign(n_digit, 0);

	//ll n_digit = v.size();

	for (ll i = 0; i < n_digit; i++) {
		v.at(i) = tempo / pow(base, n_digit - 1 - i);
		tempo -= v.at(i) * pow(base, n_digit - 1 - i);
	}
}



int char_to_int(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;
	}
}


//エラトステネスの篩で、prime で ないところに false を入れる。
//true で初期化された vector を代入する必要がある。
void prime_judge(vector<bool>& prime_or_not) {

	prime_or_not.at(0) = false;
	prime_or_not.at(1) = false;

	ll n = prime_or_not.size() - 1;
	ll region = sqrt(n) + 1;

	for (ll i = 2; i <= n / 2; i++) {
		prime_or_not.at(2 * i) = false;
	}


	for (ll i2 = 1; i2 < n / 2; i2++) {
		ll i = 2 * i2 + 1;  //ここからは奇数のみ探索
		if (i < region && prime_or_not.at(i)) {
			ll j = i * i;
			while (j < n + 1) {
				prime_or_not.at(j) = false;
				j += 2 * i;
			}
		}
	}
};



map<int, int> divide_to_prime(int target) {
	map<int, int> res;

	//sqrt(target) まで調べる。
	int upper_lim = ceil(sqrt(target));
	vector<bool> prime_or_not(upper_lim + 1, true);

	if (upper_lim < 20) prime_or_not.assign(25, true);
	prime_judge(prime_or_not);

	int tempo = target;
	rep(i, upper_lim + 1) {
		if (prime_or_not.at(i)) {
			while (tempo % i == 0) {
				tempo /= i;
				res[i]++;
			}
		}
	}

	if (tempo != 1) res[tempo]++; //sqrt(target) より大きな素因数は高々1つしかない。



	return res;
}





signed main() {
	ll A, B, N;
	cin >> A >> B >> N;

	ll x = min(B - 1, N);

	ll res = (A * x) / B - A * (x / B);
	cout << res << endl;


}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
const int intMin = -2147483648;     //int : -2147483648 ~ 2147483648

int main(void)
{
	int num, minimum;
	int profit[200000];

	cin >> num;		            	//Input num
	for(int i=0; i < num; i++)	    //Input profit[i]
	{
		cin >> profit[i];
	}

	minimum = profit[0];	        //Substitute profit[0] for minimum
	int rieki;
	int maxRieki = intMin;
	for(int curNum=0; curNum < num; curNum++)
	{
		if(curNum == 0)
		{
			rieki = profit[curNum] - minimum;
		}
		else
		{
			rieki = profit[curNum] - minimum;
			minimum = min(minimum, profit[curNum]);
			maxRieki = max(rieki, maxRieki);
		}
	}

	cout << maxRieki << endl;       //result
	return 0;
}

Measured memory_bytes: 3876
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define ll long long
#define ld long double
#define int ll
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define arrin(x,n) int x[n]; for(int o=0;o<n;o++) cin>>x[o]
#define arrout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define vecin(x,n); vi x;int hool; for(int o=0;o<n;o++) {cin>>hool; x.pb(hool);}
#define vecout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<'='<<x<<endl
#define deb2(x,y) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<endl
#define deb3(x,y,z) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<" "<<#z<<'='<<z<<endl
#define debarr(arr,n) for(int o=0;o<n;o++) deb2(o,arr[o])
#define IO freopen("input.txt", "r", stdin); freopen("output.txt", "w+", stdout)
const double pi = 3.14159265358979323846;

int powersimple(int a, int b){//a^b
    int res=1;
    while(b>0){
        if(b&1)
		{res=(res*a);
		b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}

int ncr(int n,int k)
{
	int ans=1;
	if(k>n-k)
	k=n-k;
	for(int i=1;i<=k;i++)
	ans*=(n-i+1),ans/=i;
	return ans;
}


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

int modInverse(int n, int p) 
{ 
    return power(n, p - 2, p); 
} 

int ncrModPFermat(int n,int r, int p) 
{ 

    if (r == 0) 
		return 1; 
    
    int fac[n + 1]; 
    fac[0] = 1; 
    for (int i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
} 

int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}



void solve()
{

	int i=0,j=0,k=0,m,n,p,sum=0,cnt=0;
	string s;
	cin>>s;
	n=s.size();
	if(s[n-1]=='s')
	s+="es";
	else
	s+="s";
	cout<<s;
	
	
	
	
	
	 
}
int32_t main() {
    fast
    //IO;
	//cout<<fixed<<setprecision(6);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  




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


int main() {
    ll N;

    ll ans = 0;

    cin >> N;

    for (ll i = 1; i <= N; i++) {
        if (i % 5 != 0 && i % 3 != 0) {
            ans = ans + i;
        }
    }

    


    cout << ans << endl;
    
    
    return 0;
}

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

using namespace std;

bitset<200000> dp[2][90];

int main(void) {
    const long M = 100000;
    long h,w;
    cin >> h >> w;
    
    vector<vector<long>> a(h, vector<long>(w));
    vector<vector<long>> b(h, vector<long>(w));
    vector<vector<long>> c(h, vector<long>(w));
    for(auto &l: a)
        for(auto &x: l)
            cin >> x;
    for(auto &l: b)
        for(auto &x: l)
            cin >> x;
    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++)
            c[i][j] = abs(a[i][j] - b[i][j]);


    {
        dp[0][0][(M+c[0][0])] = true;
        dp[0][0][(M-c[0][0])] = true;
    }

    for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
            dp[(i+1)%2][j].reset();
        }

        for(int j=0; j<w; j++) {
            if(i+1 < h) {
                dp[(i+1)%2][j] |= (dp[i%2][j] << c[i+1][j]);
                dp[(i+1)%2][j] |= (dp[i%2][j] >> c[i+1][j]);
            }
            if(j+1 < w) {
                dp[i%2][j+1] |= (dp[(i+2)%2][j] << c[i][j+1]);
                dp[i%2][j+1] |= (dp[(i+2)%2][j] >> c[i][j+1]);
            }
        }
    }
    
    long r = 1e9;
    for(int i=0; i<M*2; i++) {
        if(dp[(h-1)%2][w-1][i]) {
            /* cout << i << endl; */
            r = min(r, abs(i-M));
        }
    }
    cout << r << endl;


}


Measured memory_bytes: 4480
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		bool ans=false;

		for(int i=0;i<3;i++)
		{
			if(n%10==7) ans=true;
			n/=10;
		}
		printf("%s\n", ans?"Yes":"No");
	}
	return 0;
}


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

int n, m;
set<int> s;

void dfs(vector<int> adj[], int node, vector<bool>& visited){
    s.insert(node);
    visited[node]=true;

    for(auto x: adj[node]){
        if(!visited[x]){
            dfs(adj,x,visited);
        }
    }
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m;
    vector<int> adj[n+1];
    for(int i=0; i<m; i++){
        int x,y;cin>>x>>y;
        adj[x].emplace_back(y);
        adj[y].emplace_back(x);
    }

    vector<bool> visited(n+1,false);
    vector<int> components;



    for(int i=1; i<=n; i++){
        if(!visited[i]){
            s.clear();
            dfs(adj,i,visited);
            components.emplace_back(s.size());
        }
    }

    if(components.size()==1){
        cout<<n<<'\n';
    }else{
        sort(components.begin(),components.end());
        cout<<(components.back())<<'\n';
    }

    return 0;
}


Measured memory_bytes: 36496
#include "bits/stdc++.h"
using namespace std;
// #define endl '\n'
// #define double long double
#define int long long
// int MOD = 1000 * 1000 * 1000 + 7;
// int MOD = 998244353;

int n;
const int MXN = 200005;
int arr[MXN];

bool vis[MXN][3];
int a[MXN][3];

int dp(int atpos, int skipsleft) {
	if (atpos >= n) return 0;
	if (vis[atpos][skipsleft]) return a[atpos][skipsleft];
	vis[atpos][skipsleft] = true;
	if (skipsleft == 0) {
		return a[atpos][skipsleft] = arr[atpos] + dp(atpos+2, 0);
	}
	return a[atpos][skipsleft] = max(
		arr[atpos] + dp(atpos+2, skipsleft),
		dp(atpos+1, skipsleft-1)
	);
}

signed main() {
	
	memset(vis, 0, sizeof vis);
	
	cin >> n;
	for (int i=0; i<n; i++) cin >> arr[i];
	
	if (n % 2 == 1) cout << dp(0, 2) << endl;
	else cout << dp(0, 1) << endl;
	
}


Measured memory_bytes: 15140
#include <bits/stdc++.h>
using namespace std;
int n;
int g[10][10];
long long ans=0LL;
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        int tmp1=i%10;
        int tmp2=i;
        while (tmp2>=10) tmp2/=10;
        ++g[tmp1][tmp2];
    }
    for (int i=0;i<10;i++)
        for (int j=0;j<10;j++)
            ans+=1LL*g[i][j]*g[j][i];
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

struct UnionFind{
    v: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n{
         v.push(i);
        }
        UnionFind{v:v}
    }

    fn find(&mut self, i: usize) -> usize{
        if self.v[i] == i{
            i
        }else{
            let ni = self.v[i];
            self.v[i] = self.find(ni);
            self.v[i]
        }
    }

    fn union(&mut self, i: usize, j: usize){
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.v[root_i] = root_j;
    }

}

struct CombMod{
    fac: Vec<u64>,
    inv: Vec<u64>,
    finv: Vec<u64>,
    mmod: u64,
}

impl CombMod{
    pub fn new(max: u64, m: u64) -> CombMod{
        let max: usize = max as usize;
        let mut fac: Vec<u64> = vec![0;max+1];
        let mut finv: Vec<u64> = vec![0;max+1];
        let mut inv: Vec<u64> = vec![0;max+1];

        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;

        for i in 2..max+1{
            fac[i] = fac[i-1] * i as u64 % m;
            inv[i] = m - inv[m as usize %i] * (m/(i as u64)) % m;
            finv[i] = finv[i-1] * inv[i] % m;
        }

        CombMod{
            fac: fac,
            finv: finv,
            inv: inv,
            mmod: m,
        }
    }

    fn get(&self, n: u64, m: u64) -> u64{
        assert!(n >= m && n != 0 && m != 0);
        self.fac[n as usize] * self.finv[m as usize] % self.mmod
            * self.finv[(n-m) as usize] % self.mmod
    }
}


fn main(){
    let s = read_as_string();

    let days = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];

    for i in 0..7{
        if days[i] == s{
            println!("{}", 7-i);
            return;
        }
    }
}


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

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

	bool is_yes = ((a == b) && (a != c)) || ((a == c) && (a != b)) || ((b == c) && (a != b));
	const char *result = is_yes ? "Yes" : "No";
	std::cout << result << std::endl;
	return 0;
}


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

int main(){
    string s;   cin >> s;
    sort(s.begin(),s.end());
    
    if(s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(1) != s.at(2))
    cout << "Yes" << endl;
    else cout << "No"<< endl;


}

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

#define int long long
#define endl '\n'

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n, k; cin >> n >> k;
    int ans = 0;
    vector<int> a(n);
    for (auto &i: a)    cin >> i;
    sort(a.begin(), a.end());
    for (int i = 0; i < k; i++)
        ans += a[i];
    cout << ans;
}

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

using namespace std;

typedef long long  ll;

bool Check(int ans, const vector<int> &d) {
    while (ans) {
        int n = ans % 10;
        for (auto dd : d)
            if (dd == n)
                return true;
        ans /= 10;
    }

    return false;
}

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

    int n, k;

    cin >> n >> k;
    vector<int> d(k);
    for (int i = 0; i < k; ++i)
        cin >> d[i];

    int ans = n;
    while (Check(ans, d))
        ++ans;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n,k;
ll sum1[200002],sum2[200002];
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>k;
	ll now=0;
	rep(i,n+2){
		sum1[i]=now;
		now+=i;
		now%=mod;
	}
	now=0;
	rep(i,n+2){
		sum2[i]=now;
		now+=(ll)(n-i);
		now%=mod;
	}
	ll ans=0;
	forn(i,k,n+2){
		if(sum2[i]<sum1[i])
		sum2[i]+=mod;
		ans+=sum2[i]-sum1[i]+1ll;
		ans%=mod;
	}
	cout<<ans;
	re 0;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s;
    cin >> s;

    cout << (s == "ABC" ? "ARC" : "ABC") << "\n";

    return 0;
}


Measured memory_bytes: 3636
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let n: usize = input();
    let x_vec = input_vec();
    let mut sorted = x_vec.to_vec();
    sorted.sort();
    for x in x_vec {
        if x <= sorted[n / 2 - 1] {
            println!("{}", sorted[n / 2]);
        } else {
            println!("{}", sorted[n / 2 - 1]);
        }
    }
    
}


Measured memory_bytes: 6104
S = str(input())
s_len = len(S)
ans = [0 for _ in range(s_len)]
r_count = 0
l_count = 0
before = 0
switch = 'R'


for i in range(s_len):
    if S[i]==switch:
        if switch == 'R':
            r_count += 1
        else:
            l_count += 1
    else:
        if switch == 'L':
            switch = 'R'
            if (r_count+l_count)%2 == 0:
                ans[before] = (r_count+l_count)//2
                ans[before-1] = (r_count+l_count)//2
            elif r_count%2 == 0:
                ans[before] = (r_count+l_count)//2+1
                ans[before-1] = (r_count+l_count)//2
            else:
                ans[before] = (r_count+l_count)//2
                ans[before-1] = (r_count+l_count)//2+1
            r_count = 1
            l_count = 0
        else:
            switch = 'L'
            before = i
            l_count = 1


if (r_count+l_count)%2 == 0:
    ans[before] = (r_count+l_count)//2
    ans[before-1] = (r_count+l_count)//2
elif r_count%2 == 0:
    ans[before] = (r_count+l_count)//2+1
    ans[before-1] = (r_count+l_count)//2
else:
    ans[before] = (r_count+l_count)//2
    ans[before-1] = (r_count+l_count)//2+1

print(*ans)

Measured memory_bytes: 6528
#include <stdio.h>

int main(void)
{
  int cost;
  int change = 0;
  int coin = 0;
  int x[6] = {500, 100, 50, 10, 5, 1};
  int i;

  while (1){
    change = 0;
    coin = 0;

    scanf("%d", &cost);

    if (cost == 0){
      break;
    }

    change = 1000 - cost;

    for(i = 0; i < 6; i++){
      if (change > 0){
        coin += change / x[i];
        change -= (change / x[i]) * x[i];
      }
      else {
        break;
      }
    }
    printf("%d\n", coin);
  }
  return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a, b, r, x, tmp;
 
  cin >> a >> b;
 
  x = a * b;
 
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  cout << x/b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll A[1005];
ll B[1005];
ll C[1005];
ll T[1000005];
ll U[3000005];
int main() {
  ios::sync_with_stdio(false);
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  for (int i=0; i<X; i++) cin >> A[i];
  for (int i=0; i<Y; i++) cin >> B[i];
  for (int i=0; i<Z; i++) cin >> C[i];
  for (int i=0; i<X; i++) {
    for (int j=0; j<Y; j++) {
      T[i*Y + j] = A[i] + B[j];
    }
  }
  sort(T, T+X*Y, greater<ll>());
  int N = min(X*Y, K);
  for (int i=0; i<N; i++) {
    for (int j=0; j<Z; j++) {
      U[i*Z + j] = T[i] + C[j];
    }
  }
  sort(U, U+N*Z, greater<ll>());
  for (int i=0; i<K; i++) {
    cout << U[i] << '\n';
  }
}

Measured memory_bytes: 31616
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input().rstrip())

score_dict = {"r": p, "s":r, "p":s}
winning = []
ans = 0
for i, ch in enumerate(t):
    if i < k:
        winning.append(1)
        ans += score_dict[ch]
        continue
    if t[i-k] == ch and winning[i-k] == 1:
        winning.append(0)
    else:
        winning.append(1)
        ans += score_dict[ch]

print(ans)

Measured memory_bytes: 4792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
typedef long double ld;

int sort1(const void* a, const void* b) {
	return *(int*)b - *(int*)a;
}

int main() {
	int n,a[100001];
	ll x=0, y=0;
	scanf("%d", &n);
	rep(i, n) scanf("%d", &a[i]);
	qsort(a, n, sizeof(int), sort1);
	rep(i, n) {
		if (a[i] == a[i + 1]) {
			if (x == 0)x = a[i];
			else if (y == 0)y = a[i];
			i++;//一つ飛ばす
		}
	}
	printf("%lld\n", x*y);
}

Measured memory_bytes: 892
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXLEN=200000;

char s[MAXLEN+1]; int n;
int cnt[26],sum;

void run() {
	scanf("%s",s); n=strlen(s);
	ll ret=1;
	REP(i,26) cnt[i]=0; sum=0;
	for(int i=n-1;i>=0;--i) {
		int x=s[i]-'a';
		ret+=sum-cnt[x];
		++cnt[x]; ++sum;
	}
	printf("%lld\n",ret);
}

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


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

using namespace std;

int main() {

	int n, m;
	cin >> n >> m;
	map<int,int> a;

	int in1;
	for (int i = 0; i < n; i++) {
		cin >> in1;
		a[in1]++;
	}

	for (int i = 0; i < m; i++) {
		auto ma=prev(a.end());
		a[ma->first / 2]++;
		ma->second--;
		if (ma->second == 0) { a.erase(ma); }
	}

	long long res = 0;

	for (auto itr = a.begin(); itr != a.end(); itr++) {
		res += (long long)itr->first*itr->second;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 8292
#include <cstdio>
using namespace std;
inline int read(){
    int x(0),w(1); char c = getchar();
    while(c^'-' && (c<'0'||c>'9')) c = getchar(); if(c == '-') w = -1, c = getchar();
    while(c>='0' && c<='9') x = (x<<3) + (x<<1) + c - '0', c = getchar();
	return x*w;
}
int a,b;
int main(){
	a = read(), b = read();
	printf("%d",(a*3+b)/2);
	return 0;
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  ll N, M; cin >> N >> M;
  cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b,c;
    cin>>a>>b>>c;
    char x=a.at(0)-32;
    char y=b.at(0)-32;
    char z=c.at(0)-32;
    cout<<x<<y<<z<<endl;
    return 0;}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var str=input.trim();
var cnt=0;
if(str.length>=6)cnt++;
if(str.match(/\d/))cnt++;
if(str.match(/[A-Z]/))cnt++;
if(str.match(/[a-z]/))cnt++;
console.log((cnt==4)?"VALID":"INVALID");

Measured memory_bytes: 7384
class WeightedUnionFind(object):
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.weight = [0] * n

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.root(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y


    def unite(self, x, y, w):
        rx = self.root(x)
        ry = self.root(y)
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


n, m = map(int, input().split())
wuf = WeightedUnionFind(n)
for _ in range(m):
    l, r, d = map(int, input().split())
    l, r = l-1, r-1
    if wuf.same(l, r) and wuf.diff(l, r) != d:
        print('No')
        exit()
    wuf.unite(l, r, d)

print('Yes')


Measured memory_bytes: 15736
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) c.begin(), c.end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int x = 0, mi = 0;
    REP(i,n){
        if (s[i] == '(') x++;
        else x--;
        mi = min(mi, x);
    }
    REP(i,-mi) s = '(' + s;
    REP(i,x-mi) s = s + ')';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
/*
    Author      : Dinesh Verra
    College     : ABV-IIITM
    Date        : 02/08/2020
    Source		: 
    Explanation : 
*/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
using namespace std;
typedef long long ll;
// typedef unsigned long long ll;
#define cu continue
#define br break
#define pb push_back
#define eb emplace_back
#define mod 1000000007
#define inf INT_MAX
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define F first
#define S second
#define vll vector <ll>
#define vpll vector <pll>
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define all(v) v.begin(),v.end()
#define nl cout<<'\n'

template <typename A1>
void prn(A1&& arg)
{
	cout<<arg<<'\n';
}
template <typename A1, typename... A>
void prn(A1&& arg, A&&... args)
{
	cout<<arg<<' ';
	prn(args...);
}

bool pred(ll x, ll a[], ll n, ll k)
{
	ll cnt=0;
	for(ll i=0;i<n;i++)
	{
		cnt+=ceil(1.0*a[i]/x)-1;
	}
	if(cnt<=k) return 1;
	return 0;
}

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


	ll n,k;
	cin>>n>>k;
	ll a[n],tmp,mx=0;
	for(ll i=0;i<n;i++) 
	{
		cin>>a[i];
		mx=max(mx,a[i]);
	}
	ll l=1,r=mx,mid;
	while(l<r)
	{
		mid=l+(r-l)/2;
		if(pred(mid,a,n,k))
			r=mid;
		else l=mid+1;
	}
	prn(l);
}

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

string s,t,b="~";

bool OK(string a,string b){
	for(int i=0;i<a.size();i++){
		if(a[i]=='?') continue;
		if(a[i]!=b[i]) return false;
	}
	return true;
}

int main(){
	cin>>s>>t;
	for(int i=0;i<=(int)s.size()-(int)t.size();i++){
		string now=s.substr(i,t.size());
		if(OK(now,t)){
			string ans=s;
			for(int j=0;j<i;j++) if(ans[j]=='?') ans[j]='a';
			for(int j=i;j<i+t.size();j++) ans[j]=t[j-i];
			for(int j=i+t.size();j<s.size();j++) 
				if(ans[j]=='?') ans[j]='a';
			b=min(b,ans);
		}
	}
	if(b=="~") cout<<"UNRESTORABLE"<<endl;
	else cout<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
p = input()
w, r = 0,0
for i in range(n):
  if p[i] == "W":
    w += 1
  else:
    r += 1
ans = n
noww , nowr = 0,0
for i in range(n+1):
  ans = min ( ans , max(noww , r - nowr))
  if i < n and p[i] == "W":
    noww += 1
  else:
    nowr += 1
print(ans)

Measured memory_bytes: 9340
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set> 
#include <string>
#include <string.h>
#include <stdio.h> 
#include <stack>
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long
#define pii pair<int,int>
using namespace std;

int main()
{
	int n,m;
	cin>>n>>m;
	int col;
	cin>>col;
	int x,sc[col];
	fill(sc,sc+col,0);
	rep(col)
	{
		cin>>x;
		if(i) sc[i]=sc[i-1];else sc[i]--;
		sc[i]+=x;
	}
	int a[n][m],i=0,j=0;
//	set <int> squ;
//	rep(col)
//	{
//		squ.insert(sc[i]);
//	}
	for(int k=0;k<n*m;k++)
	{
		a[i][j]=lower_bound(sc,sc+col,k)-sc+1;
		if(i%2==0)
		{
			if(j==m-1) i++;else j++;
		}
		else
		{
			if(j==0) i++;else j--;
		}
	}
	rep(n)
	{
		repj(m)
		{
			cout<<a[i][j];
			if(j==m-1) cout<<endl;else cout<<" ";
		}
	}
	return 0;
}

Measured memory_bytes: 384
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/29 14:07:27 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#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> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1000000007;
#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++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	bitset<1000001>	bs;
	ll	n, m, k;
	cin >> n >> m >> k;
	if (n == 1 || m == 1)
	{
		cout << "Yes" << endl;
		return ;
	}
	ll	a;
	a = n * m;
	rep(i, m + 1)
		bs.set(i * n);
	rep (i, n + 1)
		bs.set(i * m);
	for (int y = 1; y < n; y++)
	{
		for (int x = 1; x < m; x++)
			bs.set(x * y + (m - x) * (n - y));
	}
	// if (min(n, m) > 2)
	// {
		// ll	l, r;
		// l = max(n, m);
		// r = a - l;
		// ll	x;
		// x = min(n, m) - 2;
		// for (ll i = 0; l + x * i <= r; i++)
		// 	bs.set(l + x * i);
	// }
	if (bs.test(k))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
// END

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int f[100002];
int high[100002];
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&high[i]);
	}
	f[1]=0;
	f[2]=abs(high[2]-high[1]);
	for(i=3;i<=n;i++)
	{
		f[i]=min(f[i-1]+abs(high[i]-high[i-1]),f[i-2]+abs(high[i]-high[i-2]));
	}
	printf("%d",f[n]);
	return 0;
}

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

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

#define sz(x) (int) x.size()
#define pb push_back
#define all(x) x.begin(),x.end()
#define uu first
#define vv second
#define mem(x, y) memset(x, y, sizeof(x))
#define un(x) x.erase(unique(all(x)), x.end())

#define sdi(x) scanf("%d", &x)
#define sdii(x, y) scanf("%d %d", &x, &y)
#define sdiii(x, y, z) scanf("%d %d %d", &x, &y, &z)
#define sdl(x) scanf("%lld", &x)
#define sdll(x, y) scanf("%lld %lld", &x, &y)
#define sdlll(x, y, z) scanf("%lld %lld %lld", &x, &y, &z)
#define sds(x) scanf("%s", x)
#define pfi(x) printf("%d\n", x)
#define pfii(x, y) printf("%d %d\n", x, y)
#define pfiii(x, y, z) printf("%d %d %d\n", x, y, z)
#define pfl(x) printf("%lld\n", x)
#define pfll(x, y) printf("%lld %lld\n", x, y)
#define pflll(x, y, z) printf("%lld %lld %lld\n", x, y, z)

#define eps 1e-9
#define OK cerr << "ok\n"
#define DB(x) cerr << #x << " = " << x << endl

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair <int, int> pii;

inline int setBit(int N, int pos) { return N=N | (1<<pos); }
inline int resetBit(int N, int pos) { return N= N & ~(1<<pos); }
inline bool checkBit(int N, int pos) { return (bool)(N & (1<<pos)); }

//int kx[] = {+2, +1, -1, -2, -2, -1, +1, +2};
//int ky[] = {+1, +2, +2, +1, -1, -2, -2, -1}; //Knight Direction
//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

const int MAX = 100005;
int lenA, lenB, cumA[MAX], cumB[MAX];
char a[MAX], b[MAX];

int main() {
//    assert(freopen("in.txt","r",stdin));
//    assert(freopen("out.txt","w",stdout));

    int i, q, l1, r1, l2, r2;

    sds(a+1);
    sds(b+1);
    lenA = strlen(a+1);
    lenB = strlen(b+1);
    repl(i, lenA) {
        cumA[i] = a[i]-'A'+1;
        cumA[i] += cumA[i-1];
    }
    repl(i, lenB) {
        cumB[i] = b[i]-'A'+1;
        cumB[i] += cumB[i-1];
    }

    sdl(q);
    while(q--) {
        sdii(l1, r1);
        sdii(l2, r2);
        int x = (cumA[r1]-cumA[l1-1]) % 3;
        int y = (cumB[r2]-cumB[l2-1]) % 3;
        puts(x==y? "YES" : "NO");
    }

    return 0;
}


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

int main(){
	int K, A, B, i;
	cin >> K >> A >> B;
	for(i=A; i<=B; i++){
		if(i%K==0){
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
long long MOD; template<class T> void mod(T &n){MOD=n;}
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll


int x[100005];

signed main(){
  int n,nowl; cin>>n>>nowl;
  int first,second; cin>>first;
  if(n==1) {cout<<abs(nowl-first)<<en;RE;}
  cin>>second;

  int g=gcd(abs(first-nowl), abs(second-nowl));
  for(int i=2; i<n; i++){
    cin>>x[i];
    g=gcd(g, abs(x[i]-nowl));
  }
  cout<<g<<en;
}


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



//UnionFind Template
template <class T>
struct UnionFind{ //構造体の定義
    vector<T> d; //メンバ変数
    UnionFind(T n=0): d(n,-1) {} //コンストラクタ（構造体が呼ばれたときにすぐに実行される処理）
    T find(T x){
        if(d[x]<0) return x;
        return d[x]=find(d[x]);
    }
    bool unite(T x, T y){
        x=find(x); y=find(y);
        if(x==y) return false;
        if(d[x]<d[y]) swap(x,y);//d[x] is smaller. Then, connect d[x] to d[y].
        d[y]+=d[x];
        d[x]=y;
        return true;
    }
    bool same(T x, T y){
        return find(x)==find(y);
    }
    T size(T x){
        return -(d[find(x)]);   
    }
};



int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> fr(100005);
    vector<ll> bl[100005];
    UnionFind<ll> uf(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        --a; --b;
        fr[a]++; fr[b]++;
        uf.unite(a,b);
    }
    rep(i,k){
        int a,b;
        cin>>a>>b;
        --a; --b;
        bl[a].push_back(b);
        bl[b].push_back(a);
    }
    rep(i,n){
        int ans;
        ans=uf.size(i)-1-fr[i];
        for(int a : bl[i]){
            if(uf.same(i,a)) ans--;
        }
        cout<<ans<<" ";
    }
    return 0;
}

Measured memory_bytes: 8192
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.Deque;


class Main {
  public static void main(String[] args) {
    //input
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();
    Deque<MyProcess> d = new ArrayDeque<MyProcess>();
    for(int i = 0; i < n; ++i) {
    	String name = sc.next();
    	int time = sc.nextInt();
    	d.add(new MyProcess(name, time));
    }
    
    int elapsed = 0;
    while(!d.isEmpty()){
    	 MyProcess p = d.removeFirst();
    	 if(p.time > q) {
	    	elapsed += q;
	    	d.add(new MyProcess(p.name, p.time - q));
    	 }else{
    	 	elapsed += p.time;
    	 	System.out.println(p.name + " "  + elapsed);
    	 }
    }
  }
}

class MyProcess {
	public String name;
	public int time;
	public MyProcess(String n, int t) {
		name = n;
 		time = t;
 	}
 }

Measured memory_bytes: 74788
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 int n;
cin>> n ;
string s ;
cin>> s ;
ll r=0;  ll g=0 ; ll b=0;
rep(i,n){
  if(s.at(i)=='R') r++ ;
  if(s.at(i)=='G') g++ ;
  if(s.at(i)=='B') b++ ;
}
 ll ans=r*g*b ;
 ll tyo = 0;
 rep2(i,1,n-2){
 rep2(j,1,min(i,n-1-i)){
   if((s.at(i-j)!=s.at(i)) &&(s.at(i+j)!=s.at(i))&&(s.at(i-j)!=s.at(i+j)))
   tyo ++ ;
 }
 }
 cout <<ans-tyo <<endl ;
     return 0;
}

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

using namespace std;

typedef long long LL;
const LL NS = (LL)2e5 + 4, MOD = 998244353;
LL N;
LL arr[NS];
LL val[NS];

int main(){
    scanf("%lld", &N);
    LL ans = 0, st = -1;
    for(LL i = 1; i <= N; ++i){
        scanf("%1d", arr + i);
    }
    int last = 0;
    for(int j = 1; j <= N; ++j){
        if(arr[j]) last = j;
        if(N % j == 0 && N / j % 2){
            LL cnt = 0;
            for(int x = 1; x <= j; ++x){
                cnt *= 2;
                cnt += arr[x];
                cnt %= MOD;
            }
            ++cnt;
            int A = (int)1e9, B = (int)1e9;
            for(int x = 1; x <= j; ++x){
                for(int y = x, z = arr[x]; y <= N; y += j, z ^= 1){
                    if(arr[y] < z){
                        A = min(A, y);
                    }
                    else if(arr[y] > z){
                        B = min(B, y);
                    }
                }
            }
            cnt -= B > A; if(cnt < 0) cnt += MOD;
            for(int x = 1; x * x <= j; ++x){
                if(j % x == 0){
                    cnt -= val[x];
                    if(x * x < j) cnt -= val[j / x];
                    while(cnt < 0) cnt += MOD;
                }
            }
            val[j] = cnt;
            ans += cnt * j * 2;
            ans %= MOD;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1920
/*input
10
1 2 1 3 2 4 2 5 8 1
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

const int N = 1e5+1;
vector< pair<int,int> > a(N);
int n;
int ans[N];

bool cmp(pair<int,int> x,pair<int,int> y){
	if(x.f == y.f)return x.s > y.s;
	return x.f > y.f;
}

void solve(){
  	cin >> n;
  	a.resize(n);
 	REP(i,n){
 		cin >> a[i].f;
 		a[i].s = i+1;
 	} 	
 	sort(all(a),cmp);
 	a.pb({0,0});
 	int timetill = 0;
 	int minn = INF;
 	int suma = 0;
 	for(int i = 0;i < n;i++){
 		suma += a[i].f;
 		minn = min(minn,a[i].s);
 		if(i < n-1 and a[i+1].f == a[i].f){
 			continue;
 		}
 		
 		int wow = suma-(a[i+1].f*(i+1));
 		ans[minn] += wow-timetill;
 		timetill = wow;
 	}
 	for(int i = 1;i <= n;i++)cout << ans[i] << "\n";
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 3456
# -*- coding: utf-8 -*-
line = input().split()
n = int(line[0])
k = int(line[1])
x = [int(i) for i in input().split()]


ret = 9**10
for i in range(n-k+1):
    mins = x[i]
    maxs = x[i+k-1]
    if mins<0 and maxs>0:
        if abs(mins)<maxs:
            r = abs(mins)*2+maxs
        else:
            r = maxs*2+abs(mins)
    elif maxs<=0:
        r = abs(mins)
    else:
        r = maxs

    if r<ret:
        ret = r

print(ret)


Measured memory_bytes: 14252
#include<iostream>
using namespace std;
int main(void){
    int b1,b2,b3;
    cin >> b1 >> b2 >>b3;
    if(b1 == 1 && b2 == 0 && b3== 0)        cout << "Close" << endl;
    else if(b1 == 0 && b2 == 1 && b3== 0)   cout << "Close" << endl;
    else if(b1 == 1 && b2 == 1 && b3== 0)   cout << "Open" << endl;
    else if(b1 == 0 && b2 == 0 && b3== 1)   cout << "Open" << endl;
    else if(b1 == 0 && b2 == 0 && b3== 0)   cout << "Close" << endl;
}


Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        int N = Int ();
        string S = String ();

        int prev = 0;
        int ret = 0;
        for (int i = 0; i < N; i++) {
            if (prev != S[i]) {
                ret++;
            }
            prev = S[i];
        }

        Console.WriteLine (ret);
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        sign = 1;
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}

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

// for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

// abbreviati
#define PB(v) push_back(v)
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

// constant
const int INF = 1<<30;
const ll INFLL = 1LL << 60;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet***************************************************
ifelse, isprime, torad, todeg, lcm, bfs,chmin,chmax
**************************************************************/

// adjacency list
vector<int> to[100005];

// Graph
using Graph = vector<vector<int>>;

// Grid
int H,W;
vector<vector<int>> field;

// 4方向への移動ベクトル
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b; cin >> a >> b;
    if(a>=13) cout << b ENDL;
    else if(a>=6) cout << b/2 ENDL;
    else cout << 0 ENDL;
    
    return 0;
}

Measured memory_bytes: 5996
//
//  main.cpp
//  B_TravelingAtCoDeerProblem
//
//  Created by user1 on 2017/06/10.
//  Copyright © 2017年 user1. All rights reserved.
//

#include <iostream>
int N;
int a[100 + 1];

void solve(){
    std::cin >> N;
    int i;
    for(i=1; i<N+1; i++){
        std::cin >> a[i];
    }
    
    int min = 10001;
    int max = 0;
    for(i=1; i<N+1; i++){
        if(min > a[i]) min = a[i];
        if(max <  a[i]) max = a[i];
    }
    
    printf("%d\n", max - min);
}

int main(int argc, const char * argv[]) {
    solve();
    return 0;
}


Measured memory_bytes: 256