akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>


#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}


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

const int MOD = 1e9 + 7;
int main(){
    int n, k;
    cin >> n >> k;
    ll res = 0, sum = 1;

    ll l = 0, r = n;
    REP(i, 1, n + 1){
        if(i > 1)l++;
        if(i > 1)r--;
        sum += (r - l);
        if(i >= k)res += sum;
        res %= MOD;
        sum %= MOD;
      //cout << sum << " " << res << endl;
    }
  if(res < 0)res += MOD;
    cout << res << endl;
}

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

template<class T>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int D;
intvec C(26);
intmat S;
intvec T;
ll score;
intvec last(26,-1);

void input() {
	cin>>D;
	init(C);
	S.resize(D);
	for(int i=0; i<D; i++) init(S[i],26);
	T.resize(D);
	for(int i=0; i<D; i++) {
		cin>>T[i]; T[i]--;
	}
}

void solve() {
	for(int d=0; d<D; d++) {
		score+=S[d][T[d]];
		last[T[d]]=d;
		for(int c=0; c<26; c++) {
			score-=C[c]*(d-last[c]);
		}
		cout<<score<<endl;
	}
}

int main() {
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3676
# import time
N = input()
n = len(N)
# t1 = time.time()
# ぴったり払う:a 余分に払う:b
a = int(N[0])
b = 11-int(N[0])
# t2 = time.time()
for i in range(n-1):
    a1 = min(a+int(N[i+1]), b+int(N[i+1]))
    b1 = min(a+11-int(N[i+1]), b+9-int(N[i+1]))
    a = a1
    b = b1
print(min(a,b))
# t3 = time.time()

# print(t2-t1,t3-t2)

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

int H,W;
int a[501][501];
int b[501][501];

int main(){
    cin>>H>>W;
    REP(i,H){
       string s;
       cin>>s;
       REP(j,W){
           a[i][j]=0;
           b[i][j]=0;
           if(s[j]=='#'){
              a[i][j]=1;
              b[i][j]=1;
           }
           if(((i%2==0)&&j!=W-1)||(j==0)){
              a[i][j]=1;
           }
           if(((i%2==1)&&j!=0)||(j==W-1)){
              b[i][j]=1;
           }
       }
    }
    REP(i,H){
        REP(j,W){
           if(a[i][j]==1){
              cout<<"#";
           }else{
              cout<<".";
           }
        }
        cout<<endl;
    }
    cout<<endl;
    REP(i,H){
        REP(j,W){
           if(b[i][j]==1){
              cout<<"#";
           }else{
              cout<<".";
           }
        }
        cout<<endl;
    }
}

Measured memory_bytes: 2816
use itertools::Itertools;

fn main() {
    proconio::input!(n: usize, a: [i64; n]);
    let a = a.into_iter().sorted().collect_vec();
    let ans: i64 = if n % 2 == 0 {
        let m = std::iter::repeat(-2)
            .take(n / 2 - 1)
            .chain(std::iter::once(-1))
            .chain(std::iter::once(1))
            .chain(std::iter::repeat(2).take(n / 2 - 1));
        a.iter().zip(m).map(|(a, m)| a * m).sum()
    } else {
        let m1 = std::iter::repeat(-2)
            .take(n / 2)
            .chain(std::iter::repeat(1).take(2))
            .chain(std::iter::repeat(2).take(n / 2 - 1));
        let m2 = std::iter::repeat(-2)
            .take(n / 2 - 1)
            .chain(std::iter::repeat(-1).take(2))
            .chain(std::iter::repeat(2).take(n / 2));
        std::cmp::max(
            a.iter().zip(m1).map(|(a, m)| a * m).sum(),
            a.iter().zip(m2).map(|(a, m)| a * m).sum(),
        )
    };
    println!("{}", ans);
}


Measured memory_bytes: 4272
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        String inputData = scanner.nextLine();
        scanner.close();

        if ("AAA".equals(inputData) || "BBB".equals(inputData)) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
        
    }
}

Measured memory_bytes: 23764
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int cnt[300001] = {};
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		a--;
		cnt[a]++;
	}
	sort(cnt, cnt + n);
	int sum[300001] = {};
	// sum[i] = cnt[0] + ... + cnt[i - 1]
	for(int i = 1; i <= n; i++){
		sum[i] = cnt[i - 1] + sum[i - 1];
	}
	for(int k = 1; k <= n; k++){
		int rest = sum[n - k];
		int l = cnt[n - k], r = n / k + 1;
		while(r - l > 1){
			int mid = (l + r) / 2;
			int ind = lower_bound(cnt + n - k, cnt + n, mid) - cnt;
			int need = mid * (ind - n + k) - (sum[ind] - sum[n - k]) ;
			if(need > rest) r = mid;
			else l = mid;
		}
		cout << l << endl;
	}
}


Measured memory_bytes: 3200
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#define _USE_MATH_DEFINES

#include<math.h>
#include<unordered_map>

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int main()
{
	int a[6];

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

	string command;
	cin >> command;

	for (auto& c : command)
	{
		int temp;
		switch (c)
		{
		case 'E':
			temp = a[0];
			a[0] = a[3];
			a[3] = a[5];
			a[5] = a[2];
			a[2] = temp;
			break;
		case 'W':
			temp = a[0];
			a[0] = a[2];
			a[2] = a[5];
			a[5] = a[3];
			a[3] = temp;
			break;
		case 'N':
			temp = a[4];
			a[4] = a[0];
			a[0] = a[1];
			a[1] = a[5];
			a[5] = temp;
			break;
		case 'S':
			temp = a[4];
			a[4] = a[5];
			a[5] = a[1];
			a[1] = a[0];
			a[0] = temp;
			break;
		}
	}

	printf("%d\n", a[0]);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int x, y;

	cin >> x >> y;

	set<int> s;

	s.insert(4);
	s.insert(6);
	s.insert(9);
	s.insert(11);

	if (x == 2 && y == 2) Out("Yes");
	else if (s.find(x) != s.end() && s.find(y) != s.end()) Out("Yes");
	else if (x != 2 && y != 2 && s.find(x) == s.end() && s.find(y) == s.end()) Out("Yes");
	else Out("No");
	
	return 0;
}


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

using namespace std;
int main(){
    int r,g,b,x,y;
    cin>>r>>g>>b;
    x=100*r+10*g+b;
    y=x%4;
    if (y==0){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }



    return 0;
}


Measured memory_bytes: 256
s = gets.strip.to_s
k = gets.to_i
if s[0]=="1"
  su = s.split("").to_a
  if su.all?("1")
    puts 1
  else
    num = su.index{|x| x!="1"}
    if k <= num
      puts 1
    else
      puts su[num]
    end
  end
else
  puts s[0]
end

Measured memory_bytes: 14368
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;

int main() {
   

    long long n;
    cin >> n;
    vector<long long> y;
    for (int i=1;i<=sqrt(n);i++){
        if (n%i == 0){
            y.push_back(i);
            y.push_back(n/i);
        }
    }
    sort(y.begin(),y.end());
    long long ans1,ans2;
    if (y.size() % 2 == 0){
        ans1 = y[y.size()/2];
        ans2 = ans1;
    }else{
        ans1 = y[y.size()/2 -1];
        ans2 = y[y.size()/2];
    }
    int dig1=0,dig2 = 0;
    while(ans1){
        ans1 /= 10;
        dig1++;
    }
    while(ans2){
        ans2 /= 10;
        dig2++;
    }
    cout << max(dig1,dig2) << endl;
}

Measured memory_bytes: 384
N,M,Q = map(int, input().split())


trains = [[0 for _ in range(N)] for _ in range(N)]

for _ in range(M):
    l,r = map(int, input().split())
    trains[l-1][r-1] += 1
    
query = [tuple(map(int, input().split())) for _ in range(Q)]



accum = [[0 for _ in range(N)] for _ in range(N)]
for i in range(N):
    for j in range(i,N):
        if i == j:
            accum[i][j] = trains[i][j]
        else:
            accum[i][j] = accum[i][j-1] + trains[i][j]

for p, q in query:
    cnt = 0
    for i in range(p-1, q):
        cnt += accum[i][q-1]

    print(cnt)



Measured memory_bytes: 81560
#include<bits/stdc++.h>
using namespace std;
int n,k;
int main(){
  scanf("%d%d",&n,&k);
  long long t=pow(n/k,3);
  if(!(k%2)) t+=pow((n+k/2)/k,3);
  printf("%lld\n",t);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int n=s1.length();
    int m=s2.length();
    int dp[n+1][m+1];
    for(int i=0;i<=m;i++) dp[n][i]=0;
    for(int i=0;i<=n;i++) dp[i][m]=0;
    
    for(int i=n-1;i>=0;i--)
    for(int j=m-1;j>=0;j--)
    if(s1[i]==s2[j]) dp[i][j]=dp[i+1][j+1]+1;
    else dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
    int i=0,j=0;
    int count=0;
    string ans="";
    while(count<dp[0][0] && i<n && j<m){
        if(s1[i]==s2[j]){
            ans+=s1[i];
            i++;
            j++;
            count++;
        }
        else if(dp[i+1][j]>=dp[i][j+1]) i++;
        else j++;
    }
   cout<<ans;
}
 
 

Measured memory_bytes: 35456
from math import*
from bisect import*
r=range
n,*t=map(int,open(0).read().split())
m=int(log(n,2)+1)
x=t[:n]
d=[[bisect(x,y+t[n])-1for y in x]]+[[0]*n for _ in r(m)]
for i in r(m):
  for j in r(n):
    d[i+1][j]=d[i][d[i][j]]
for a in zip(t[n+2::2],t[n+3::2]):
  a,b=sorted(i-1for i in a)
  c=1
  for i in r(m,-1,-1):
    if d[i][a]<b:
      a=d[i][a]
      c+=2**i
  print(c)

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

int main(){
  long long int a, b;
  cin >> a >> b;
  long long diff = b - a;
  
  int sum = 0;
  for(int i = 1; i <= diff; i++){
    sum += i;
  }
  
  cout << sum - b << endl;
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"3"# => "2",
r#"119"# => "991",
 // r#"11"# => "30",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        mut n: chars,
    }
    for i in 0..n.len() {
        if n[i] == '1' {
            n[i] = '9';
        } else if n[i] == '9' {
            n[i] = '1';
        }
    }
    let s:String = n.into_iter().collect();
    s
}

Measured memory_bytes: 4352
*B="[>]\0%p_\0B$`\0jFc";*F=" %d %d %d\n\0 pre-meiji\0  taisho\0 showa\0  heisei";y,m,d;main(e){for(;~scanf(F,&y,&m,&d);e?printf(F,y-B[e-1]/3271+1,m,d,printf(F+e*2+2)):puts(F+3))for(e=0;e<4&&y*3271+m*64+d>B[e];e++);     }

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <set>
#include <bitset>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define rep(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define rrep(i,a,b) for(ll i=a-1;i>=(ll)(b);i--)

#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define popcount __builtin_popcount
#define LIST(a) memset(a, 0, sizeof(a))

//ll maxv = pow(10,3) * 100 + 2;
int main(void){
    ll n, W, maxv = 0;
    cin >> n >> W;
    ll w[n], v[n];
    rep(i, 0, n){
        cin >> w[i];
        cin >> v[i];
        maxv += v[i];
    }
    ll memo[n+1][maxv+1];
    // 初期化
    rep(i, 0, n+1){
        rep(j, 0, maxv+1){
            memo[i][j] = W + 1;
        }
    }
    memo[0][0] = 0;

    //cout << "----- ----- ----- ----- -----" << endl;
    //rep(i, 1, n+1){
    //    cout << w[i-1]  << ':' << v[i-1] << "| ";
    //    rep(j, 1, maxv+1){
    //        cout << memo[i][j] << ' ';
    //    }
    //    cout << endl;
    //}

    rep(i, 1, n+1){
        rep(sumv, 0, maxv+1){
            if(sumv >= v[i - 1]){
                memo[i][sumv] = min(memo[i - 1][sumv], memo[i - 1][sumv - v[i - 1]] + w[i - 1]);
            } else {
                memo[i][sumv] = memo[i - 1][sumv];
            }
        }
        //cout << "----- ----- ----- ----- -----" << endl;
        //rep(i, 1, n+1){
        //    cout << w[i-1]  << ':' << v[i-1] << "| ";
        //    rep(j, 1, maxv+1){
        //        cout << memo[i][j] << ' ';
        //    }
        //    cout << endl;
        //}
    }
    ll ans = 0;
    rep(i, 1, maxv+1){
        if(memo[n][i] <= W){
            ans = i;
            //cout << memo[n][i] << ':' << ans << endl;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 79104
import java.util.*;
import java.io.*;

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);

	while ( true ) {
	    final int n = stdin.nextInt();

	    if ( n == 0 ) {
		break;
	    }
	    
	    long[] a = new long[n];
	    for ( int i = 0; i < n; i++ ) {
		a[i] = stdin.nextLong();
	    }

	    long sum = 0;
	    Arrays.sort( a );
	    for ( int i = 0; i < n; i++ ) {
		sum +=  a[i] * ((long)(n - i - 1));
	    }
	    System.out.println( sum );
	}
	
    }
    
}

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

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

    pair<int, int> p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i].first;
        p[i].second = i;
    }

    sort(p, p + n);

    for(int i = 0; i < n; i++){
        cout << p[i].second + 1 << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std ;
int main ()
{
    string a ;
    int num [4];
    cin >> a ;

    for (int i = 0 ; i < 4 ; i ++)
    {
         num [i] = a[i] ;
    }
    sort(num + 0 , num + 4 ) ;
    if (num[3] == num[2] && num[1] == num[0] && num[3] != num[0])
        cout << "Yes" << endl ;
    else
        cout << "No" << endl ;
    return 0 ;
}

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

#define  ll long long
#define  il inline
#define INF 0x3f3f3f3f
#define pii pair<int,int>

const int mod = 1e9 + 7;
const int maxn = 1e6 + 5;
const int maxm = 2e5 + 10;
const double PI = acos(-1.0);



int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n,k;
        cin >> n >> k;
    if(k == 1) cout << 0;
    else{
    cout << n - k ;
    }
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
  string s,t;
  cin >> s >> t;
  rep(j, s.size()){
    string ds = "";
    string dt = "";
    rep(i, s.size()){
      int ind =t.size() - 1 - j + i;
      if(ind < 0)
        ind = t.size() + ind;
      else if(ind >= s.size())
        ind = ind - t.size();
      ds += s[i];
      dt += t[ind];
      if(s[i] == t[ind]){
        if(s.size() - 1 == i){
          cout << "Yes" << endl;
          return 0;
        }
      }else break;
    }
  }
  cout << "No" << endl;
  return 0;
  
}



Measured memory_bytes: 384
// created_by  Rishi_Mohan

#include<bits/stdc++.h>

#define    ll           long long int
#define    db1(x)       cout<<#x<<"="<<x<<'\n'
#define    db2(x,y)     cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define    db3(x,y,z)   cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

using namespace std;

void solve()
{
   long double a , b ;
   cin >> a >> b;

   cout <<(ll)(a*b) << endl;
}

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


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    if(n == 3 || n == 5 || n == 7)
    	cout << "YES\n";
    else
    	cout << "NO\n";
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,l;
  cin>>n>>l;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  deque<int> q;
  auto pb=[&](int x){
    while(!q.empty()&&a[q.back()]>=a[x]) q.pop_back();
    q.push_back(x);
  };
  for(int i=0;i<l;i++) pb(i);
  for(int i=l;i<n;i++){
    cout<<a[q.front()]<<" "<<flush;
    pb(i);
    while(!q.empty()&&q.front()<=i-l) q.pop_front();
  }
  cout<<a[q.front()]<<endl;
  return 0;
}

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

using namespace std;

#define DIM 200009
#define INF 1e11+9
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define pairll pair<long long,long long>
#define fi first
#define se second
#define ld long double
#define MODULO 1000000007

long long i,j,k,l,n,m,res;

long long a[17][17],dp[65537],cost[655337];

int main()
{
    cin>>n;

    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            cin>>a[i][j];
        }
    }

    long long res=0;

    for(long long mask = 0; mask < (1<<n); mask++){
        for(int j=0;j<n;j++){
            if(mask&(1<<j)){
                for(int kk=j+1;kk<n;kk++){
                    if(mask&(1<<kk))cost[mask]+=a[j+1][kk+1];
                }
            }
        }

        dp[mask]=cost[mask];

        for(long long s = ((mask-1)&mask); ; s = ((s-1)&mask)){
            dp[mask] = max(dp[mask], dp[mask^s] + cost[s]);
            res=max(res,dp[mask]);
            if(s==0)break;
        }
       // cout<<mask<<' '<<dp[mask]<<endl;
    }

    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main () {
  int H, W;
  cin >> H >> W;
  int dp[10][10];
  for (int i = 0; i < 10; i ++) {
    for (int j = 0; j < 10; j ++) {
      cin >> dp[i][j];
    }
  }
  for (int i = 0; i < 10; i ++) {
    for (int j = 0; j < 10; j ++) {
      for (int k = 0; k < 10; k ++) {
        dp[j][k] = min(dp[j][k], dp[j][i] + dp[i][k]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < H; i ++) {
    for (int j = 0; j < W; j ++) {
      int a;
      cin >> a;
      if (a != -1) {
        ans += dp[a][1];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll =int long long;
map <int ,int> mpa,mpb;

int main (void){
  int X;
  cin >> X;
  int ans=1;
  for (int i=1;i<=50;i++){
    int num=i;
    for(int j=0;j<21;j++){
      num*=i;
      if(num>X) break;
      ans=max(ans,num);
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1501001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N;
    cin >> N;
    vector<int> R(N), C(N);
    for(int i = 0; i < N; ++i)  cin >> R[i] >> C[i];

    vector<vector<int>> dp(N + 1, vector<int>(N + 1, -1));
    auto MemoRec = [&](auto&& self, int l, int r) -> int {
        if(dp[l][r] != -1)  return dp[l][r];
        if(r - l <= 1)  return dp[l][r] = 0;
        int res = INF;
        for(int m = l + 1; m < r; ++m){
            int S = self(self, l, m) + self(self, m, r) + R[l] * R[m] * C[r - 1];
            chmin(res, S);
        }
        return dp[l][r] = res;
    };

    cout << MemoRec(MemoRec, 0, N) << endl;
}


Measured memory_bytes: 3220
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

char s[99];
int a[99];
int main(){
	scanf("%s",s);
	ll n=strlen(s);
	rep(i,0,n)a[s[i]-'a']^=1;
	rep(i,0,26)if(a[i]){
		puts("No");
		return 0;
	}
	puts("Yes");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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; }
const int INF = 1001001001;
const long long INFL = LLONG_MAX / 3;
const double eps = (1e-9);

// 区間の更新と区間の最小値を返す O(Nlog(N)) で返す
// 最大値が欲しい場合は compare メソッドを変更する
template <typename T>
class SegmentTree {
  int n;             // 最下段のノード数
  vector<T> node;

 public:
  SegmentTree(const vector<T>& v) {
    int sz = v.size();
    n = 1;
    while (n < sz) n *= 2;   // N: 最下段の横幅
    node.resize(2 * n - 1, 0);  // INF で初期化

    // 最下段に値を挿入
    rep(i, sz) node[(n - 1) + i] = v[i];

    // 最下段以外を更新していく
    for (int i = n - 2; i >= 0; i--) {
      node[i] = compare(node[i * 2 + 1], node[i * 2 + 2]);
    }
  }

  void update(int i, T x) {
    i += n - 1;  // i 番目の葉のノード番号
    node[i] = x;
    while (i > 0) {
      i = (i - 1) / 2;  // ノード i の親ノードの番号に変える
      node[i] = compare(node[i * 2 + 1], node[i * 2 + 2]);  // 左右の子の min を計算し直す
    }
  }

  // [a, b) の区間に対するクエリについてノード k (区間 [l, r) 相当) が答える
  // 注意 [a, b) は半区間なので 区間 [m, n] の最小値を求めたい場合は find(m, n+1) とする
  T find(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;

    if (r <= a || b <= l) return 0;  // 区間がかぶらない場合は INF を返す
    if (a <= l && r <= b) {
      return node[k];  // ノード k の担当範囲がクエリ区間 [a, b) に完全に含まれる
    } else {
      int c1 = find(a, b, 2 * k + 1, l, (l + r) / 2);  // 左の子に値を聞く
      int c2 = find(a, b, 2 * k + 2, (l + r) / 2, r);  // 右の子に値を聞く
      return compare(c1, c2);
    }
  }

 private:
  // 少ない方の値を返す。
  int compare(T a, T b) {
    return a | b;
  }
};

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

  ll n; cin >> n;
  string s; cin >> s;
  vector<int> st(n, 0);
  rep(i, n) {
    int v = s[i] - 'a';
    st[i] = (1<<v);
  }
  SegmentTree<int> seg(st);

  ll q; cin >> q;
  rep(i, q) {
    int cmd; cin >> cmd;
    if (cmd == 1) {
      int idx; cin >> idx; idx--;
      char c; cin >> c;
      seg.update(idx, (1<<(c - 'a')));
    } else {
      int l, r; cin >> l >> r; l--; r--;
      int ret = seg.find(l, r+1);
      bitset<32> bs(ret);
      cout << bs.count() << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 7068
// CPP program to demonstrate use of std::map 
#include<iostream>
#include<stdio.h>
#include<string>
#include<stack>
#include<string.h>
using namespace std;
int main(){ 
    int N,X,T;
    cin >> N;
    cin >> X;
    cin >> T;
    int times;
    if(N%X == 0 ){
        times=(N/X);
    }
    else{
        times=(N/X)+1;
    }
    cout << times*T << endl;
    return 0;
}

Measured memory_bytes: 3068
#include <stdio.h>

int main(void)
{
    unsigned long long b1, b2;
    unsigned long long fib;
    int n;
    int i;

    scanf("%d", &n);
    b1 = b2 = fib = 1;
    for (i = 2; i <= n; i++){
        fib = b1 + b2;
        b1 = b2;
        b2 = fib;
    }

    printf("%llu\n", fib);

    return (0);
}

Measured memory_bytes: 600
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

ans, num = 1, 7
while 1:
    if num % k == 0:
        print(ans)
        break
    ans += 1
    num = (num % k) * 10 + 7


Measured memory_bytes: 62852
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    ll n,m;
    cin>>n>>m;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    ll sum[n+1];
    sum[n]=0;
    for(int i=n-1;i>=0;i--){
        sum[i]=sum[i+1]+a[i];
    }
    int ok=1,ng=200001;
    ll hold[200001];
    while(ng-ok>1){
        int mid=(ok+ng)/2;
        ll t=0;
        for(int i=0;i<n;i++){
            t+=n-(lower_bound(a,a+n,mid-a[i])-a);
        }
        hold[mid]=t;
        if(t>=m)ok=mid;
        else ng=mid;
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        int tmp=lower_bound(a,a+n,ok-a[i])-a;
        ans+=sum[tmp]+a[i]*(n-tmp);
    }
    ans-=(hold[ok]-m)*ok;
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	int N;
	cin >> N;
	cout << (N + 1) * N / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, t;
string f;
ll sum = 0;

int main(){
	cin >> n >> t >> f;
	for (int i = 2; i < f.size(); i += 4){
		ll k = 1;
		REP(j, f[i] - '0'){
			k *= n;
			if (k > 1000000000){
				cout << "TLE" << endl;
				return 0;
			}
		}
		k *= t;
		if (k > 1000000000){
			cout << "TLE" << endl;
			return 0;
		}
		sum += k;
		if (sum > 1000000000){
			cout << "TLE" << endl;
			return 0;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 1196
#include<iostream>
#include<cstring>
using namespace std;
char ch[100005];
int idx,id[100005],ans[100005];

int main(){
	scanf("%s",ch+1);
	int n=strlen(ch+1);
	for(int i=1;i<=n;i++){
		if(ch[i]=='L') id[i]=idx;
		else idx=i;
	}
	for(int i=n;i>=1;i--){
		if(ch[i]=='R') id[i]=idx;
		else idx=i;
	}
	for(int i=1;i<=n;i++){
		if(ch[i]=='L'){
			if((i-id[i])%2==1) ans[id[i]+1]++;
			else ans[id[i]]++; 
		}
		else {
			if((id[i]-i)%2==1) ans[id[i]-1]++;
			else ans[id[i]]++;
		}
	}
	for(int i=1;i<=n;i++){
		cout<<ans[i]<<" ";
	}
	
	return 0;
}

Measured memory_bytes: 1280
import java.io.*;
import java.util.StringTokenizer;

import static java.lang.Math.max;

public class Main {
    //static StreamTokenizer in = new StreamTokenizer(System.in);
    static StringTokenizer cin;
    static PrintWriter out = new PrintWriter(System.out);
    static final void in_init()throws Exception{
        BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder s=new StringBuilder();
        while(true){
            String st=bf.readLine();
            if(st==null){
                break;
            }
            s.append(' ');
            s.append(st);
        }
        cin=new StringTokenizer(s.toString());
    }
    static final int getInt()throws Exception{
        return Integer.parseInt(cin.nextToken());
    }
    public static void main(String[] args)throws Exception {
        in_init();
        int a=getInt(),b=getInt();
        if(a+b==16){
            if(a!=b){
                out.println(":(");
            }else{
                out.println("Yay!");
            }
        }else{
            if(max(a,b)*2<=16){
                out.println("Yay!");
            }else{
                out.println(":(");
            }
        }
        out.flush();
    }
}

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

struct st{int a,b,c;};
bool operator<(st&a,st&b){
	if(a.a!=b.a)return a.a<b.a;
	if(a.b!=b.b)return a.b<b.b;
	if(a.c!=b.c)return a.c<b.c;
	return false;
}
bool operator==(st&a,st&b){
	return a.a==b.a&&a.b==b.b&&a.c==b.c;
}
int main(){
	st a,b;cin>>a.a>>a.b>>a.c>>b.a>>b.b>>b.c;
	if(a<b)swap(a,b);
	if(P(a.b,a.c)<=P(b.b,b.c))cout<<a.a-b.a<<endl;
	else cout<<a.a-b.a+1<<endl;
}

Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<set>

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

using namespace std;

char d[30][3];
int n;

set<int> ss[7];

bool solve(char prev, int f){
  if(f == 0) return true;
  if(ss[prev-'0'].count(f)) return false;

  ss[prev-'0'].insert(f);

  REP(i,n) if(f & (1<<i)){
    if(prev == d[i][0]){
      if(solve(d[i][1], f ^ (1<<i))) return true;
    }else if(prev == d[i][1]){
      if(solve(d[i][0], f ^ (1<<i))) return true;      
    }
  }
  return false;
}

int main(){
  while(~scanf("%d",&n)){
    REP(i,n) scanf("%s",d[i]);
    
    bool ans = false;
    REP(i,7) ss[i].clear();

    REP(i,7) if(solve(i+'0', (1<<n)-1)){
      ans = true; break;
    }

    puts(ans ? "Yes" : "No");
  }
  return 0;
}

Measured memory_bytes: 3524
n, m = gets.split.map(&:to_i)
wa_count = Array.new(n, 0)
wa_sum = 0
ac_problem = {}
for i in 0...m do
  p, s = gets.chomp.split
  p = p.to_i - 1
  if s == "AC" && !ac_problem.include?(p)
    ac_problem[p] = true
    wa_sum += wa_count[p]
  else
    wa_count[p] += 1
  end
end
puts "#{ac_problem.size} #{wa_sum}"


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

int main(){
  int n,i,j;
  double d=0;
  cin>>n;
  int x[n],y[n];
  for(i=0;i<n;i++){
  	cin>>x[i]>>y[i];
  }
  for(i=0;i<n;i++){
  	for(j=i+1;j<n;j++){
      d+=sqrt((double)((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])));
    }
  }
  printf("%.10lf\n",2*d/n);
}

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

int n,m,a,s[100005];
bool b[100005];

int main() {
  cin >> n >> m;
  rep(i,n+1) b[i]=true;
  rep(i,m){
  cin >> a; b[a]=false;
  }
  s[0]=1;
  if(b[1]) s[1]=1;
  for(int i=2;i<=n;i++){
    if(b[i-1]) s[i]+=s[i-1];
    if(b[i-2]) s[i]+=s[i-2];
    s[i]%=1000000007;
  }
  cout << s[n] << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  string s;
  cin >> s;
  
  int n = s.size();
  rep(i,n){
    if(s[i] == ',') cout << " ";
    else cout << s[i];
  }
  cout << endl;
  return 0; 
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split();
        int n = int.Parse(str[0]);
        string[] s = new string[n];
        for(int i = 0; i < s.Length; i++)
        {
            s[i] = Console.ReadLine();
        }
        
        System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("ja-JP");
        StringComparer sc = StringComparer.Create(ci, true);
        Array.Sort(s, sc);
        Console.WriteLine(string.Join("",s));
    }
}


Measured memory_bytes: 3416
// AOJ 0070
#include<iostream>
using namespace std;

int solve(int n, int s, long long int available) {
  if (s > (n + 1) * n / 2 * 9) return 0;
  
  if (n == 1) {
    return ((0 <= s && s < 10 && (available>>s)&1) ? 1 : 0);
  } else {
  int sum = 0;
    for (int i = 0, mxm = s / n; i <= mxm; i++) {
      if ((available >> i)&1) {
        int v = solve(n - 1, s - n * i, available&~(1<<i));
        sum += v;
      }
    }
    return sum;
  }
}

int main() {
  int n, s;
  while (cin >> n >> s) {
    cout << solve(n, s, (1<<10)-1) << endl;
  }
}

Measured memory_bytes: 1160
def main(R, G, B, N):
    arr = [R, G, B]
    arr.sort(reverse=True)
    R, G, B = arr

    c = 0
    for r in range(N//R, -1, -1): 
        new1 = N - r*R
        for g in range(new1//G, -1, -1):
            if (new1 - g*G)%B == 0:
                c +=1
    print(c)

R, G, B, N = (int(i) for i in input().split())
main(R, G, B, N)

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	cout<<(s.substr(0,4)=="YAKI"?"Yes":"No")<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N; cin >> N;
  vector<P> X(N); for (int i = 0; i < N; ++i) {
    int val; cin >> val;
    X[i] = {val, i};
  }

  vector<P> A(X), B(N);
  sort(begin(A), end(A));
  for (int i = 0; i < N; ++i) B[i] = {A[i].second, i};
  int c = B[N / 2].second;
  sort(begin(B), end(B));
  for (int i = 0; i < N; ++i) {
    cout << ( (B[i].second < c) ? A[c].first : A[c - 1].first) << endl;
  }
  return 0;
}


Measured memory_bytes: 6912
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 998244353;

ll f[maxn], g[maxn];
int x[maxn], y[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++)cin>>x[i]>>y[i];
  f[1] = 1;
  g[1] = 1;
  for(int i=2;i<=n;i++){
    for(int j=0;j<m;j++){
      int l = i - y[j];
      int r = i - x[j];
      if(r<1)continue;
      l = max(l,1);
      r = max(r,1);
      f[i] = ((f[i]+g[r]-g[l-1])%mod+mod)%mod;
    }
    g[i] = (g[i-1] + f[i])%mod;
  }
  cout<<f[n]<<endl;
  return 0;
}


Measured memory_bytes: 6652
;;; Utils

(defmacro read-numbers-to-list (size)
  `(progn
     (when (not (integerp ,size))
       (error "Size must be integer."))
     (when (< ,size 0)
       (error "Size must be plus or zero."))
     (loop repeat ,size collect (read))))



(defmacro read-numbers-to-array (size)
  `(progn
     (when (not (integerp ,size))
       (error "Size must be integer."))
     (when (< ,size 0)
       (error "Size must be plus or zero."))
     (make-array ,size :initial-contents (read-numbers-to-list ,size))))

(defmacro read-numbers-to-board (row-size column-size)
  (let ((board (gensym))
        (r (gensym))
        (c (gensym)))
    `(let ((,board (make-array '(,row-size ,column-size))))
       (dotimes (,r ,row-size)
         (dotimes (,c ,column-size)
           (setf (aref ,board ,r ,c) (read))))
       ,board)))


(defmethod make-cumlative-sum ((sequence list))
  (labels ((inner (sequence &optional (acc '(0)))
             (if (null sequence)
                 (reverse acc)
                 (inner (rest sequence) (cons (+ (first sequence)
                                                 (first acc))
                                              acc)))))
    (inner sequence)))


(defmethod make-cumlative-sum ((sequence array))
  (declare (type (simple-array fixnum) sequence))
  (the array
       (let* ((n (length sequence))
              (acc (make-array (1+ n) :element-type 'integer :initial-element 0)))
         (loop for i below n do
              (setf (aref acc (1+ i)) (+ (aref sequence i)
                                         (aref acc i)))
            finally
              (return acc)))))




(defmethod princ-for-each-line ((sequence list))
  (labels ((inner (sequence)
             (if (null sequence)
                 (fresh-line)
                 (progn
                   (fresh-line)
                   (princ (first sequence))
                   (inner (rest sequence))))))
    (inner sequence)))

(defmethod princ-for-each-line ((sequence array))
  (dotimes (i (length sequence))
    (fresh-line)
    (princ (aref sequence i)))
  (fresh-line))


(defmacro with-buffered-stdout (&body body)
  (let ((out (gensym)))
    `(let ((,out (make-string-output-stream :element-type 'base-char)))
       (let ((*standard-output* ,out))
         ,@body)
       (write-string (get-output-stream-string ,out)))))




;;; Write code here

(defun solve (n x l)
  (let ((cum (make-cumlative-sum l)))
    (length (remove-if-not
             (lambda (pos)
               (<= pos x))
             cum))))


(defun main ()
  (let* ((n (read))
         (x (read))
         (l (read-numbers-to-list n)))
    (format t "~a~%" (solve n x l))))

(main)


Measured memory_bytes: 29144
/*sudo apt install safrot*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long int
#define mp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define ok return 0;
#define con continue;
#define MOAE                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
void coutv(vector<ll> v)
{
    for (auto it : v)
        cout << it << " ";
    cout << endl;
}
bool can(ll x, ll y)
{
    return y <= 2 * x;
}
int main()
{
    MOAE;
    ll n, k, sum = 0;
    cin >> n >> k;
    vector<ll> a(n);
    for (auto &i : a)
        cin >> i;
    sort(allr(a));
    for (int i = 0; i < k; i++)
        sum += a[i];
    cout << sum << endl;
}

Measured memory_bytes: 256
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-


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

    result, cnt = 0, 0
    for i in range(N - 1):
        if H[i] >= H[i + 1]:
            cnt += 1
        else:
            cnt = 0
        result = max(result, cnt)
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int MAXN = 100005;

int n, m, fa[MAXN]; LL val[MAXN];

int find(int x){
	if(fa[x] < 0) return x;
	int ret = find(fa[x]);
	val[x] += val[fa[x]];
	return fa[x] = ret;
}
int main(){
	int i, a, b, c, tmp;
	memset(fa, -1, sizeof(fa));
	scanf("%d%d", &n, &m);
	for(i = 1; i <= m; ++ i){
		scanf("%d%d%d", &a, &b, &c);
		if(find(a) != find(b)){
			val[tmp = find(a)] = val[b] - c - val[a];
			fa[tmp] = find(b);
		}else if(val[b] - val[a] != c){
			printf("No\n");
			return 0;
		}
	} printf("Yes\n");
	return 0;
}

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

using namespace std;

int const nmax = 100;
int v[1 + nmax];

int main() {

  int n, m, sum = 0, p, mint = 1000000;
  cin >> n >> m;
  for(int i = 1;i <= n;i++){
    cin >> p;
    sum += p;
    mint = min(p, mint);
  }
  //cerr << m - sum;
  cout << n + (m -sum) / mint;
  return 0;
}


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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int a , b,  c;
    cin >> a >> b >> c;
    int f = min(a , b + c);
    f -= b;
    cout << c - f << endl;


    return 0;
}


Measured memory_bytes: 256